How to integrate travis ci with codec testing coverage in Python?

I am trying to get my Travis CI to send trial coverage data to the Code Climate service, but the Code Climate and Travis CI documentation does not describe in detail how to do this using Python. However, its supported feature in Code Climate and Travis documents. I tried to find any working examples on this without any luck and can't get it to work on its own.

Code Climate documentation: Test coverage setup , Readme: codeclimate-test-reporter

Travis CI Documentation: Using the Code Click Using Travis CI

I set CODECLIMATE_REPO_TOKEN in Travis CI, as described in this answer: https://stackoverflow.com/a/167389/

My .travis.yml file is:

language: python python: - 2.7 install: - pip install -r requirements.txt - pip install coverage - pip install codeclimate-test-reporter #commands to run tests: script: - python mytests.py - coverage run mytests.py after_success: - codeclimate-test-reporter 

since the after_success line is excluded in Travis, it gives me this in log view mode:

 /home/travis/build.sh: line 45: codeclimate-test_reporter: command not found 
+8
python continuous-integration travis-ci code-climate
source share
1 answer

indeed, it seems that in the end it is only a problem of the type that Peter mentioned in the commentary. Your after_success should have codeclimate-test-reporter - it looks like you have one, but travis reports something else.

Now, why did I discover the generosity and why really I just don’t understand how codeclimate_test_reporter works. I wanted to report my coverage from py.test. The codeclimate_test_reporter code has a nice readme on GitHub showing how to generate a coverage report . However, from their example, this is similar to giving codeclimate-test-reporter as an argument to --cov automatically sends a report to codecliamte. This is not true.

Using py.test, you want:

 script: - py.test --cov=YourModuleYouWantToCover test_folder - codeclimate-test-reporter --file .coverage 

The magic happened, the first time I have a codeclimate coverage report!

edit: I sent a transfer request for codeclimate-test-reporter to update their readme, and it was merged, so there is less confusion for future people, I hope!

+4
source share

All Articles