diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 0443fc530a5..0089f175458 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -570,3 +570,7 @@ jobs: retention-days: 7 if-no-files-found: ignore include-hidden-files: true + - name: Compare SimpleCov results with Undercover + env: + RAILS_ENV: test + run: bundle exec undercover --compare origin/master diff --git a/Gemfile b/Gemfile index 54a0affdc12..64010048de7 100644 --- a/Gemfile +++ b/Gemfile @@ -173,6 +173,8 @@ group :test do gem 'pdf-reader' gem 'rails-controller-testing' gem 'simplecov', require: false + gem 'simplecov-lcov', require: false + gem 'undercover', require: false gem 'vcr', require: false gem 'webmock', require: false # See spec/spec_helper.rb for instructions diff --git a/Gemfile.lock b/Gemfile.lock index 0d9d2b78a68..e1f14ff8230 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -354,6 +354,8 @@ GEM image_processing (1.12.2) mini_magick (>= 4.9.5, < 5) ruby-vips (>= 2.0.17, < 3) + imagen (0.2.0) + parser (>= 2.5, != 2.5.1.1) immigrant (0.3.6) activerecord (>= 3.0) invisible_captcha (2.3.0) @@ -704,6 +706,7 @@ GEM rubyzip (2.3.2) rufus-scheduler (3.8.2) fugit (~> 1.1, >= 1.1.6) + rugged (1.7.2) sanitize (6.1.0) crass (~> 1.0.2) nokogiri (>= 1.12.0) @@ -732,6 +735,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) spreadsheet_architect (5.0.0) caxlsx (>= 3.3.0, < 4) @@ -790,6 +794,11 @@ GEM turbo-rails (>= 1.3.0) tzinfo (2.0.6) concurrent-ruby (~> 1.0) + undercover (0.6.3) + bigdecimal + imagen (>= 0.2.0) + rainbow (>= 2.1, < 4.0) + rugged (>= 0.27, < 1.8) unicode-display_width (2.5.0) uniform_notifier (1.16.0) uri (0.13.0) @@ -965,6 +974,7 @@ DEPENDENCIES sidekiq sidekiq-scheduler simplecov + simplecov-lcov spreadsheet_architect spring spring-commands-rspec @@ -977,6 +987,7 @@ DEPENDENCIES timecop turbo-rails turbo_power + undercover valid_email2 validates_lengths_from_database vcr diff --git a/spec/base_spec_helper.rb b/spec/base_spec_helper.rb index c4cb929a7e6..755fe1e0394 100644 --- a/spec/base_spec_helper.rb +++ b/spec/base_spec_helper.rb @@ -6,6 +6,15 @@ # for full configuration, see .simplecov require 'simplecov' if ENV["COVERAGE"] +require 'simplecov-lcov' if ENV["COVERAGE"] +SimpleCov::Formatter::LcovFormatter.config.report_with_single_file = true +SimpleCov.formatter = SimpleCov::Formatter::LcovFormatter +SimpleCov.start do + add_filter(/^\/spec\//) # For RSpec + enable_coverage(:branch) # Report branch coverage to trigger branch-level undercover warnings +end + +require 'undercover' if ENV["COVERAGE"] require 'pry' unless ENV['CI'] require 'view_component/test_helpers'