From da436164a3366c6c16ab3fae5e8c0d5c65412a28 Mon Sep 17 00:00:00 2001 From: Alan Cruikshanks Date: Wed, 29 Jan 2020 18:31:46 +0000 Subject: [PATCH] Temp. fix for cc-test-reporter & SimpleCov 0.18 https://github.com/codeclimate/test-reporter/issues/418 On 28 Jan 2020 [SimpleCov 0.18.0](https://github.com/colszowka/simplecov/releases/tag/v0.18.0) was released. Though it's generating code coverage for us, its changed the JSON format of the `/coverage/.resultset.json` CodeClimate's [cc-test-reporter](https://github.com/codeclimate/test-reporter) appears to rely on.
Format before ```json { "RSpec": { "coverage": { "/path/to/my/file.rb": [ null, null, 1 ] }, "timestamp": 1580226312 } } ```
Format after ```json { "RSpec": { "coverage": { "/path/to/my/file.rb": { "lines": [ null, null, 1, null ], "branches": { } } }, "timestamp": 1580299988 } } ```
When **cc-test-reporter** is called in the `after_script` hook in Travis-CI we are seeing the following error ```bash if [ "$TRAVIS_PULL_REQUEST" == "false" ]; then ./cc-test-reporter after-build --exit-code $TRAVIS_TEST_RESULT; fi Error: json: cannot unmarshal object into Go struct field input.coverage of type []formatters.NullInt Usage: cc-test-reporter after-build [flags] Flags: -s, --batch-size int batch size for source files (default 500) -e, --coverage-endpoint string endpoint to upload coverage information to (default "https://api.codeclimate.com/v1/test_reports") -t, --coverage-input-type string type of input source to use [clover, cobertura, coverage.py, excoveralls, gcov, gocov, jacoco, lcov, simplecov, xccov] --exit-code int exit code of the test run -r, --id string reporter identifier (default "463a251defaae85271bff85ea8b1e58aa06cc9322157aa3ad7ee2a986aa13612") --insecure send coverage insecurely (without HTTPS) -p, --prefix string the root directory where the coverage analysis was performed (default "/home/travis/build/DEFRA/waste-carriers-front-office") Global Flags: -d, --debug run in debug mode ``` As the CodeClimate integration is important to our CI process, we have chosen to temporarily set the version of SimpleCov as 0.17.1 until the issue is resolved. --- Gemfile | 2 +- Gemfile.lock | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Gemfile b/Gemfile index fe0871afc..771b3d64f 100644 --- a/Gemfile +++ b/Gemfile @@ -59,7 +59,7 @@ end group :test do gem "database_cleaner" gem "factory_bot_rails", require: false - gem "simplecov", require: false + gem "simplecov", "~> 0.17.1", require: false gem "timecop" gem "vcr", "~> 4.0" gem "webmock", "~> 3.4" diff --git a/Gemfile.lock b/Gemfile.lock index 8b260c115..c3651a897 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -338,7 +338,7 @@ DEPENDENCIES rails_12factor rspec-rails (~> 3.6) secure_headers (~> 5.0) - simplecov + simplecov (~> 0.17.1) spring timecop turbolinks