Merge pull request #13441 from mkllnk/cover-more

Check more code for coverage
This commit is contained in:
Gaetan Craig-Riou
2025-08-04 16:49:56 +10:00
committed by GitHub
8 changed files with 12 additions and 18 deletions

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -1,5 +1,4 @@
#!/bin/env ruby
# frozen_string_literal: true
-l coverage/lcov/openfoodnetwork.lcov
-c master
-c master

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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