From 95caa8bc4ea4b0abeedb953bdd74ef4131b3048c Mon Sep 17 00:00:00 2001 From: Matt Jankowski Date: Tue, 4 Feb 2025 06:14:45 -0500 Subject: [PATCH] Switch coverage generation default to false, allow opt in with `COVERAGE` env var (#33824) --- .github/workflows/test-migrations.yml | 1 - .github/workflows/test-ruby.yml | 6 ++---- Gemfile | 2 +- spec/flatware_helper.rb | 2 +- spec/rails_helper.rb | 2 +- 5 files changed, 5 insertions(+), 8 deletions(-) diff --git a/.github/workflows/test-migrations.yml b/.github/workflows/test-migrations.yml index 306191fb8..733664b75 100644 --- a/.github/workflows/test-migrations.yml +++ b/.github/workflows/test-migrations.yml @@ -64,7 +64,6 @@ jobs: DB_HOST: localhost DB_USER: postgres DB_PASS: postgres - DISABLE_SIMPLECOV: true RAILS_ENV: test BUNDLE_CLEAN: true BUNDLE_FROZEN: true diff --git a/.github/workflows/test-ruby.yml b/.github/workflows/test-ruby.yml index 4deb08d32..1f7f8f93a 100644 --- a/.github/workflows/test-ruby.yml +++ b/.github/workflows/test-ruby.yml @@ -107,7 +107,7 @@ jobs: DB_HOST: localhost DB_USER: postgres DB_PASS: postgres - DISABLE_SIMPLECOV: ${{ matrix.ruby-version != '.ruby-version' }} + COVERAGE: ${{ matrix.ruby-version == '.ruby-version' }} RAILS_ENV: test ALLOW_NOPAM: true PAM_ENABLED: true @@ -208,7 +208,7 @@ jobs: DB_HOST: localhost DB_USER: postgres DB_PASS: postgres - DISABLE_SIMPLECOV: ${{ matrix.ruby-version != '.ruby-version' }} + COVERAGE: ${{ matrix.ruby-version == '.ruby-version' }} RAILS_ENV: test ALLOW_NOPAM: true PAM_ENABLED: true @@ -295,7 +295,6 @@ jobs: DB_HOST: localhost DB_USER: postgres DB_PASS: postgres - DISABLE_SIMPLECOV: true RAILS_ENV: test BUNDLE_WITH: test LOCAL_DOMAIN: localhost:3000 @@ -411,7 +410,6 @@ jobs: DB_HOST: localhost DB_USER: postgres DB_PASS: postgres - DISABLE_SIMPLECOV: true RAILS_ENV: test BUNDLE_WITH: test ES_ENABLED: true diff --git a/Gemfile b/Gemfile index 89648e8ca..ebfee9d78 100644 --- a/Gemfile +++ b/Gemfile @@ -156,7 +156,7 @@ group :test do gem 'shoulda-matchers' - # Coverage formatter for RSpec test if DISABLE_SIMPLECOV is false + # Coverage formatter for RSpec gem 'simplecov', '~> 0.22', require: false gem 'simplecov-lcov', '~> 0.8', require: false diff --git a/spec/flatware_helper.rb b/spec/flatware_helper.rb index 57a7c1f56..a1bcb6234 100644 --- a/spec/flatware_helper.rb +++ b/spec/flatware_helper.rb @@ -3,7 +3,7 @@ if defined?(Flatware) Flatware.configure do |config| config.after_fork do |test_env_number| - unless ENV.fetch('DISABLE_SIMPLECOV', nil) == 'true' + if ENV.fetch('COVERAGE', false) require 'simplecov' SimpleCov.at_fork.call(test_env_number) # Combines parallel coverage results end diff --git a/spec/rails_helper.rb b/spec/rails_helper.rb index 6564f1737..7d63ea630 100644 --- a/spec/rails_helper.rb +++ b/spec/rails_helper.rb @@ -2,7 +2,7 @@ ENV['RAILS_ENV'] ||= 'test' -unless ENV['DISABLE_SIMPLECOV'] == 'true' +if ENV.fetch('COVERAGE', false) require 'simplecov' SimpleCov.start 'rails' do