使用TravisCI on Rails配置CodeClimate测试覆盖率

时间:2018-03-08 04:37:55

标签: ruby-on-rails travis-ci

我的.travis.yml文件的相关行,我从这里的示例中得到: https://docs.codeclimate.com/v1.0/docs/travis-ci-test-coverage

env:
  global:
    - CC_TEST_REPORTER_ID=MY_ACTUAL_ID

services:
  - postgresql

before_script:
  - curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-darwin-amd64 > ./cc-test-reporter
  - chmod +x ./cc-test-reporter
  - ./cc-test-reporter before-build
  - psql -c 'create database travis_ci_test;' -U postgres

script:
  - bundle exec rake db:migrate
  - bundle exec rspec

after_script:
- ./cc-test-reporter after-build --exit-code $TRAVIS_TEST_RESULT

错误:

$ ./cc-test-reporter before-build
/home/travis/.travis/job_stages: line 57: ./cc-test-reporter: cannot execute binary file: Exec format error
The command "./cc-test-reporter before-build" failed and exited with 126 during .

由于

解决:

我意识到虽然我的开发机器可能是MacOS,但TravisCI环境在Linux上。

将测试记者网址更改为https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64就可以了!

2 个答案:

答案 0 :(得分:4)

Linux 上的最新版本 0.9.0 抛出相同的格式错误。

The executable has been compiled incorrectly

作为一种解决方法,您可以使用以前的版本:

curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-0.7.0-linux-amd64 > ./cc-test-reporter

答案 1 :(得分:0)

我意识到虽然我的开发机器可能是MacOS,但TravisCI环境在Linux上。

将测试记者网址更改为https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64就可以了!