From 765fe3054026d09cf68267a37fddf19e9f4ad8e2 Mon Sep 17 00:00:00 2001 From: Justin Howard Date: Thu, 11 Aug 2022 19:59:44 -0700 Subject: [PATCH] Setup codecov code coverage --- .github/workflows/ci.yml | 10 +++------- Gemfile | 6 ++---- spec/spec_helper.rb | 11 ++++------- 3 files changed, 9 insertions(+), 18 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 4b38eb0..e5a71f6 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -55,14 +55,10 @@ jobs: env: MYSQL_USER: root MYSQL_PASSWORD: root - - name: Run codacy-coverage-reporter - env: - CODACY_PROJECT_TOKEN: ${{ secrets.CODACY_PROJECT_TOKEN }} - if: matrix.ruby == '2.7' && env.CODACY_PROJECT_TOKEN - uses: codacy/codacy-coverage-reporter-action@master + - uses: codecov/codecov-action@v3 + if: matrix.ruby == '2.7' with: - project-token: ${{ secrets.CODACY_PROJECT_TOKEN }} - coverage-reports: coverage/lcov/faulty.lcov + files: coverage/coverage.xml release: needs: test diff --git a/Gemfile b/Gemfile index 8913709..1c22893 100644 --- a/Gemfile +++ b/Gemfile @@ -20,15 +20,13 @@ gem 'irb', '~> 1.0' gem 'mysql2', '>= 0.5.0', platforms: not_jruby gem 'redcarpet', '~> 3.5', platforms: not_jruby gem 'rspec_junit_formatter', '~> 0.4' -gem 'simplecov', '>= 0.17.1' -# 0.8 is incompatible with simplecov < 0.18 -# https://github.com/fortissimo1997/simplecov-lcov/pull/25 -gem 'simplecov-lcov', '~> 0.7', '< 0.8' gem 'yard', '~> 0.9.25', platforms: not_jruby if Gem::Version.new(RUBY_VERSION) >= Gem::Version.new('2.6') gem 'rubocop', '~> 1.32.0' gem 'rubocop-rspec', '~> 2.12' + gem 'simplecov', '>= 0.17.1' + gem 'simplecov-cobertura', '~> 2.1' end if ENV['REDIS_VERSION'] diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 41ff5f0..81ed7af 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -2,18 +2,15 @@ require 'byebug' if Gem.loaded_specs['byebug'] -if ENV['COVERAGE'] || ENV['CI'] +if Gem.loaded_specs['simplecov'] && (ENV.fetch('COVERAGE', nil) || ENV.fetch('CI', nil)) require 'simplecov' if ENV['CI'] - require 'simplecov-lcov' - SimpleCov::Formatter::LcovFormatter.config.report_with_single_file = true - SimpleCov.formatter = SimpleCov::Formatter::LcovFormatter + require 'simplecov-cobertura' + SimpleCov.formatter = SimpleCov::Formatter::CoberturaFormatter end SimpleCov.start do - if Gem::Version.new(SimpleCov::VERSION) >= Gem::Version.new('0.18.0') - enable_coverage :branch - end + enable_coverage :branch add_filter '/spec/' add_filter '/vendor/' end