diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index f4a97638a9..c6711bb01a 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -410,6 +410,6 @@ jobs: include-hidden-files: true - name: Compare SimpleCov results with Undercover run: | - git fetch --no-tags origin master:master + git fetch --no-tags origin ${{ github.event.pull_request.base.ref }}:master bundle exec undercover if: ${{ github.ref != 'refs/heads/master' }} # Does not run on master, as we can't fetch master in the master branch diff --git a/.rubocop_styleguide.yml b/.rubocop_styleguide.yml index b82dbada1e..91c745cdd9 100644 --- a/.rubocop_styleguide.yml +++ b/.rubocop_styleguide.yml @@ -16,6 +16,7 @@ AllCops: - node_modules/**/* # Excluding: inadequate Naming/FileName rule rejects GemFile name with camelcase - engines/web/Gemfile + - .undercover Bundler/DuplicatedGem: Enabled: false diff --git a/.simplecov b/.simplecov index 66573a094d..dd47f33e21 100755 --- a/.simplecov +++ b/.simplecov @@ -4,17 +4,11 @@ SimpleCov.start 'rails' do add_filter '/bin/' add_filter '/config/' - add_filter '/jobs/application_job.rb' - add_filter '/schemas/' - add_filter '/lib/generators' - add_filter '/spec/' - add_filter '/vendor/' - add_filter '/public' - add_filter '/swagger' add_filter '/script' - add_filter '/log' add_filter '/db' - add_filter '/lib/tasks/sample_data/' + + # We haven't managed to make simplecov recognise rake coverage accurately. + add_filter '/lib/tasks/' formatter SimpleCov::Formatter::SimpleFormatter end diff --git a/.undercover b/.undercover index 95a9fe08c9..9b7d04fdb9 100644 --- a/.undercover +++ b/.undercover @@ -1,5 +1,4 @@ #!/bin/env ruby # frozen_string_literal: true --l coverage/lcov/openfoodnetwork.lcov --c master \ No newline at end of file +-c master diff --git a/Gemfile b/Gemfile index a80dab5fe4..fd77f79d72 100644 --- a/Gemfile +++ b/Gemfile @@ -174,7 +174,6 @@ group :test do gem 'puffing-billy' 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 diff --git a/Gemfile.lock b/Gemfile.lock index b42743cb50..6c1600ba7d 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -769,7 +769,6 @@ 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) @@ -1016,7 +1015,6 @@ DEPENDENCIES sidekiq sidekiq-scheduler simplecov - simplecov-lcov spreadsheet_architect spring spring-commands-rspec diff --git a/lib/tasks/simplecov.rake b/lib/tasks/simplecov.rake index d5bc344f06..cc7f5c95e6 100644 --- a/lib/tasks/simplecov.rake +++ b/lib/tasks/simplecov.rake @@ -5,7 +5,7 @@ namespace :simplecov do task :collate_results, # rubocop:disable Rails/RakeEnvironment doesn't need the full env [:path_to_results, :coverage_dir] do |_t, args| require "simplecov" - require "simplecov-lcov" + require "undercover/simplecov_formatter" path_to_results = args[:path_to_results].presence || "tmp/simplecov" output_path = args[:coverage_dir].presence || "coverage" @@ -15,9 +15,8 @@ namespace :simplecov do coverage_dir(output_path) end - SimpleCov::Formatter::LcovFormatter.config.report_with_single_file = true SimpleCov.collate Dir[File.join(path_to_results, "**", ".resultset.json")], "rails" do - formatter(SimpleCov::Formatter::LcovFormatter) + formatter(SimpleCov::Formatter::Undercover) coverage_dir(output_path) end end diff --git a/spec/lib/tasks/simplecov_spec.rb b/spec/lib/tasks/simplecov_spec.rb index 68e9d0bc5e..62204b12ef 100644 --- a/spec/lib/tasks/simplecov_spec.rb +++ b/spec/lib/tasks/simplecov_spec.rb @@ -26,6 +26,10 @@ RSpec.describe "simplecov.rake" do and change { File.exist?(File.join(output_dir, "index.html")) }. from(false). + to(true). + + and change { File.exist?(File.join(output_dir, "coverage.json")) }. + from(false). to(true) end end