diff --git a/.github/workflows/test-ruby.yml b/.github/workflows/test-ruby.yml index 07fd25fb1bf..101de66ac70 100644 --- a/.github/workflows/test-ruby.yml +++ b/.github/workflows/test-ruby.yml @@ -94,7 +94,7 @@ jobs: DB_HOST: localhost DB_USER: postgres DB_PASS: postgres - DISABLE_SIMPLECOV: true + DISABLE_SIMPLECOV: ${{ matrix.ruby-version != '.ruby-version' }} RAILS_ENV: test ALLOW_NOPAM: true PAM_ENABLED: true @@ -137,6 +137,12 @@ jobs: - run: bin/rspec + - name: Upload coverage reports to Codecov + if: matrix.ruby-version == '.ruby-version' + uses: codecov/codecov-action@v3 + with: + files: coverage/lcov/mastodon.lcov + test-e2e: name: End to End testing runs-on: ubuntu-latest diff --git a/Gemfile b/Gemfile index 039e1367548..add7b36066e 100644 --- a/Gemfile +++ b/Gemfile @@ -139,6 +139,7 @@ group :test do # Coverage formatter for RSpec test if DISABLE_SIMPLECOV is false gem 'simplecov', '~> 0.22', require: false + gem 'simplecov-lcov', '~> 0.8', require: false # Stub web requests for specs gem 'webmock', '~> 3.18' diff --git a/Gemfile.lock b/Gemfile.lock index 84ad19b8054..20c958e2e0f 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -725,6 +725,7 @@ GEM simplecov-html (~> 0.11) simplecov_json_formatter (~> 0.1) simplecov-html (0.12.3) + simplecov-lcov (0.8.0) simplecov_json_formatter (0.1.4) smart_properties (1.17.0) sprockets (3.7.2) @@ -936,6 +937,7 @@ DEPENDENCIES simple-navigation (~> 4.4) simple_form (~> 5.2) simplecov (~> 0.22) + simplecov-lcov (~> 0.8) sprockets (~> 3.7.2) sprockets-rails (~> 3.4) stackprof diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 7c97d85953e..f5dcefc789c 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -2,13 +2,21 @@ if ENV['DISABLE_SIMPLECOV'] != 'true' require 'simplecov' + require 'simplecov-lcov' + SimpleCov::Formatter::LcovFormatter.config.report_with_single_file = true + SimpleCov.formatter = SimpleCov::Formatter::LcovFormatter SimpleCov.start 'rails' do + enable_coverage :branch + enable_coverage_for_eval + add_filter 'lib/linter' add_group 'Policies', 'app/policies' add_group 'Presenters', 'app/presenters' add_group 'Serializers', 'app/serializers' add_group 'Services', 'app/services' add_group 'Validators', 'app/validators' + + add_group 'Libraries', 'lib' end end