From 8ffa4fe866f25c5f3206b5bfc3ccf05436bc917f Mon Sep 17 00:00:00 2001 From: Duncan Stuart Date: Thu, 22 Aug 2019 11:16:15 +0200 Subject: [PATCH] Report test coverage to CodeClimate Coverage gets generated on every build, but we only need to send it for one build. Send it on the first one, otherwise we get eg: ./cc-test-reporter after-build --exit-code $TRAVIS_TEST_RESULT time="2019-08-22T12:37:01Z" level=warning msg="Conflict when uploading: A test report for commit 6dabaaa6cd7e4c5c51dc538e4fbb7861ca433d8e already exists, skipping upload" I guess this is because the test reporter assumes that if coverage exists, then it has been sent? Config from here: https://docs.codeclimate.com/docs/travis-ci-test-coverage#section-travis-ci-single-test-suite-non-parallel-builds --- .gitignore | 1 + .travis.yml | 6 ++++++ pundit.gemspec | 1 + spec/spec_helper.rb | 5 +++++ 4 files changed, 13 insertions(+) diff --git a/.gitignore b/.gitignore index 1b71c6b..f3dcde2 100644 --- a/.gitignore +++ b/.gitignore @@ -2,6 +2,7 @@ *.rbc .bundle .config +.coverage .yardoc Gemfile.lock InstalledFiles diff --git a/.travis.yml b/.travis.yml index 92bce14..8cf045d 100644 --- a/.travis.yml +++ b/.travis.yml @@ -8,6 +8,12 @@ matrix: - gem install bundler script: bundle exec rake rubocop # ONLY lint once, first - rvm: 2.3.5 + before_script: + - curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ./cc-test-reporter + - chmod +x ./cc-test-reporter + - ./cc-test-reporter before-build + after_script: + - ./cc-test-reporter after-build --exit-code $TRAVIS_TEST_RESULT - rvm: 2.4.6 - rvm: 2.5.5 - rvm: 2.6.3 diff --git a/pundit.gemspec b/pundit.gemspec index 677b9c4..41e68e0 100644 --- a/pundit.gemspec +++ b/pundit.gemspec @@ -27,5 +27,6 @@ Gem::Specification.new do |gem| gem.add_development_dependency "rake" gem.add_development_dependency "rspec", ">= 3.0.0" gem.add_development_dependency "rubocop", "0.74.0" + gem.add_development_dependency "simplecov", ">= 0.17.0" gem.add_development_dependency "yard" end diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 257796c..8fc39db 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -1,5 +1,10 @@ # frozen_string_literal: true +require "simplecov" +SimpleCov.start do + add_filter "/spec/" +end + require "pundit" require "pundit/rspec"