Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ziaulrehman40/b829d09e0c5c90693ad775c98d5308f4 to your computer and use it in GitHub Desktop.
Save ziaulrehman40/b829d09e0c5c90693ad775c98d5308f4 to your computer and use it in GitHub Desktop.
CircleCI 2.0 Parallel builds SimpleCov coverage report for CodeClimate reporting

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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment