如何将travis ci与Python中的codeclimate测试覆盖率集成?

Ton*_*rmi 9 python continuous-integration python-2.7 travis-ci code-climate

我正在尝试让我的Travis CI将测试覆盖率数据发送到Code Climate服务,但Code Climate和Travis CI的文档没有详细描述如何使用Python执行此操作.根据Code Climate和Travis文档,它仍然是其支持的功能.我试图在没有运气的情况下找到任何有关这方面的工作示例,并且无法使其自行运行.

代码气候文档: 设置测试覆盖率, 自述文件:codeclimate-test-reporter

Travis CI文档: 将Code Climate与Travis CI结合使用

我在Travis CI中设置了CODECLIMATE_REPO_TOKEN,如下所示:https://stackoverflow.com/a/31281481/1754089

我的.travis.yml文件:

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
Run Code Online (Sandbox Code Playgroud)

因为在Travis中,after_success行已经完成了,它在日志视图中给出了这个:

/home/travis/build.sh: line 45: codeclimate-test_reporter: command not found
Run Code Online (Sandbox Code Playgroud)

iSc*_*E4m 5

事实上,在你看来,它只是像彼得在评论中提到的一种类型的问题.你after_success应该拥有codeclimate-test-reporter- 看起来你拥有它,但travis正在报告别的东西.

现在为什么我开了一个赏金,为什么它实际上只是我不理解codeclimate_test_reporter是如何工作的.我想从py.test报告我的报道.codeclimate_test_reporter在GitHub上有一个很好的自述文件,展示了如何创建一个覆盖率报告.然而,从他们的例子来看,它似乎提供了codeclimate-test-reporter作为参数--cov会自动向codecliamte发送报告.事实并非如此

使用py.test,你想要做的是:

script:
- py.test --cov=YourModuleYouWantToCover test_folder
- codeclimate-test-reporter --file .coverage
Run Code Online (Sandbox Code Playgroud)

魔术发生了,我第一次有关于codeclimate的报道!

编辑:我向codeclimate-test-reporter提交了一个pull请求来更新他们的自述文件并将其合并,所以希望对未来的人们不要太混淆!