Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Coverage.py (python) #117

Closed
Maarten-vd-Sande opened this issue Feb 26, 2020 · 8 comments · Fixed by #118
Closed

Coverage.py (python) #117

Maarten-vd-Sande opened this issue Feb 26, 2020 · 8 comments · Fixed by #118
Assignees
Labels
bug Something isn't working

Comments

@Maarten-vd-Sande
Copy link

I am trying to get codeclimate-action to work with coverage.py. However I am having some issues. I switched from conda to pip which solved the issue that the command coverage isn't found. However now I have some issues with the action mangling paths it seems:

/home/runner/work/peaksql/peaksql/cc-reporter before-build
/opt/hostedtoolcache/Python/3.7.6/x64/bin/coverage xml
/home/runner/work/peaksql/peaksql/cc-reporter after-build --exit-code 0 --debug --prefix 
time="2020-02-26T08:17:55Z" level=debug msg="about to run format-coverage" 
time="2020-02-26T08:17:55Z" level=debug msg="searching for a formatter to use" 
time="2020-02-26T08:17:55Z" level=debug msg="checking cobertura formatter" 
time="2020-02-26T08:17:55Z" level=debug msg="checking search path cobertura.xml for cobertura formatter" 
time="2020-02-26T08:17:55Z" level=debug msg="checking coverage.py formatter" 
time="2020-02-26T08:17:55Z" level=debug msg="checking search path coverage.xml for coverage.py formatter" 
time="2020-02-26T08:17:55Z" level=debug msg="found file coverage.xml for coverage.py formatter" 
time="2020-02-26T08:17:56Z" level=debug msg="couldn't load committed at from ENV, trying git..." 
time="2020-02-26T08:17:56Z" level=debug msg="creating test file report for /home/runner/work/peaksql/peaksql/peaksql/__init__.py" 
time="2020-02-26T08:17:56Z" level=info msg="trimming with prefix /" 
time="2020-02-26T08:17:56Z" level=debug msg="getting fallback blob_id for source file home/runner/work/peaksql/peaksql/peaksql/__init__.py" 
time="2020-02-26T08:17:56Z" level=error msg="failed to read file home/runner/work/peaksql/peaksql/peaksql/__init__.py\nopen home/runner/work/peaksql/peaksql/peaksql/__init__.py: no such file or directory" 
Error: open home/runner/work/peaksql/peaksql/peaksql/__init__.py: no such file or directory
Usage:
  cc-test-reporter after-build [flags]

Flags:
  -s, --batch-size int               batch size for source files (default 500)
  -e, --coverage-endpoint string     endpoint to upload coverage information to (default "https://api.codeclimate.com/v1/test_reports")
  -t, --coverage-input-type string   type of input source to use [clover, cobertura, coverage.py, excoveralls, gcov, gocov, jacoco, lcov, simplecov, xccov]
      --exit-code int                exit code of the test run
  -r, --id string                    reporter identifier (default "***")
      --insecure                     send coverage insecurely (without HTTPS)
  -p, --prefix string                the root directory where the coverage analysis was performed (default "/home/runner/work/peaksql/peaksql")

Global Flags:
  -d, --debug   run in debug mode

(node:2854) UnhandledPromiseRejectionWarning: TypeError: (s || "").replace is not a function
    at escapeData (/home/runner/work/_actions/paambaati/codeclimate-action/v2.5.2/node_modules/@actions/core/lib/command.js:66:10)
    at Command.toString (/home/runner/work/_actions/paambaati/codeclimate-action/v2.5.2/node_modules/@actions/core/lib/command.js:60:35)
    at issueCommand (/home/runner/work/_actions/paambaati/codeclimate-action/v2.5.2/node_modules/@actions/core/lib/command.js:23:30)
    at Object.issue (/home/runner/work/_actions/paambaati/codeclimate-action/v2.5.2/node_modules/@actions/core/lib/command.js:27:5)
    at Object.error (/home/runner/work/_actions/paambaati/codeclimate-action/v2.5.2/node_modules/@actions/core/lib/core.js:120:15)
    at /home/runner/work/_actions/paambaati/codeclimate-action/v2.5.2/lib/main.js:163:20
    at Generator.throw (<anonymous>)
    at rejected (/home/runner/work/_actions/paambaati/codeclimate-action/v2.5.2/lib/main.js:6:65)
    at runMicrotasks (<anonymous>)
    at processTicksAndRejections (internal/process/task_queues.js:93:5)
(node:2854) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
(node:2854) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

It manages to find the coverage.xml file, but somehow something goes wrong with the paths. I am not sure what could be causing this. I am using the latest version (v2.5.2). This is how I call it:

    - name: Run tests
      run: |
        coverage run -m unittest discover -v test

    - uses: paambaati/codeclimate-action@v2.5.2
      env:
        CC_TEST_REPORTER_ID: ${{ secrets.CodeClimate }}
      with:
        coverageCommand: coverage xml
        debug: true
@Maarten-vd-Sande
Copy link
Author

The error looks a bit like #102. Should I revert to an older version of coverage.py?

@Maarten-vd-Sande
Copy link
Author

On my local machine this works:

curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ./cc-test-reporter
chmod +x ./cc-test-reporter
./cc-test-reporter before-build

coverage run -m unittest discover -v test
coverage xml

./cc-test-reporter after-build --exit-code $TRAVIS_TEST_RESULT --coverage-input-type coverage.py -r {my_secret_code}

@paambaati
Copy link
Owner

@Maarten-vd-Sande Can you link me to the action run log where debug is true?

@Maarten-vd-Sande
Copy link
Author

You mean this?
https://github.com/vanheeringen-lab/peaksql/runs/469251819?check_suite_focus=true

@Maarten-vd-Sande
Copy link
Author

I am not sure if you can see the log, but I think my first message gives it.

@paambaati
Copy link
Owner

@Maarten-vd-Sande I've pushed a fix for this. Can you try v2.5.3?

@Maarten-vd-Sande
Copy link
Author

Yes I saw it! It seems to work!
https://github.com/vanheeringen-lab/peaksql/runs/469306889?check_suite_focus=true

@Maarten-vd-Sande
Copy link
Author

Thanks a lot for the super fast fix!

@paambaati paambaati self-assigned this Mar 4, 2020
@paambaati paambaati added the bug Something isn't working label Mar 4, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants