First of all you have to follow my other gist here: https://gist.github.com/ziaulrehman40/1516c0bb940b6ee653b57387cee4e62d
In that gist, follow the second solution which is: Use deploy step in simple CircleCI 2.0 build
After that is done and everything seems working. Than there is very little needing to be done.
We will use CodeClimate's new way of reporting, which is cc-test-reporter
, this is a binary to work with any kind of projects.
Before this we had specific gem and other language specific solutions. Those are deprecated. And gem doesn't work with simplecov > 0.13
Ok, enough talk, now straight to action, following is the circleci config i used:
version: 2
jobs:
build:
parallelism: 1
environment:
CC_TEST_REPORTER_ID: codeclimatetokenhere
# OTHER ENV VARS AND OTHER CONFIGS
steps:
- checkout
- run:
name: Setup Code Climate test-reporter
command: |
curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ./cc-test-reporter
chmod +x ./cc-test-reporter
- run:
name: Code Climate before-build
command: |
./cc-test-reporter before-build
# HERE ADD OTHER CONFIGS AND TESTS RUNS ETC, ALSO INCLUDE CONFIGS FROM THE LINKED GIST HERE
# This is magic step, which actually will combine coverage reports of all parallel containers + WILL REPORT THAT TO CODECLIMATE
- deploy:
name: Merge and copy coverage data
command: |-
RUN_COVERAGE=true bundle exec spec/simplecov_merger.rb
mv coverage/.resultset.json coverage/.resultset_buk.json
mv coverage/.resultset.json.lock coverage/.resultset_buk.json.lock
cp coverage_results/.resultset.json coverage/.resultset.json
cp coverage_results/.resultset.json.lock coverage/.resultset.json.lock
./cc-test-reporter after-build -t simplecov
# rest of the config