Description
Hi there,
We currently have some custom code similar to what's in #920 that I'm trying to replace with simply using the public SimpleCov.collate
method. We run our specs in separate CI containers and merge the .resultset-n.json
files together in a separate task afterwards.
I'm looking for the coverage task to fail and raise an error if the final merged coverage is below ENV['MIN_COVERAGE']
or SimpleCov.minimum_coverage
setting, similar to how SimpleCov does after running specs and coverage is below SimpleCov.minimum_coverage
. (ENV['MIN_COVERAGE']
is probably our own personal implementation detail but I thought I'd include it anyway.)
This is the relevant code that we're running:
puts 'Merging coverage...'
glob = Dir['./coverage_results/.resultset*.json']
SimpleCov.collate glob
results = SimpleCov::Result.from_hash(JSON.parse(File.read('./coverage/.resultset.json'))).first
puts "Covered: #{results.covered_percent} %"
return if ENV['MIN_COVERAGE'].to_f <= results.covered_percent
raise "Minimum coverage set to #{ENV['MIN_COVERAGE']} but merged coverage was #{results.covered_percent}."
This code works as is, but I want to use public supported methods wherever possible. We did something pretty similar to #920 previously and I'm trying to get us fully onto public methods if possible.
So, is this supported already? I thought I'd ask before diving into the code too hard. I noticed that run_exit_tasks!
is called in the collate
method and expected that would do it. Am I missing something?
Line 96 in 818bc25
If not I'm happy to close this as is, or I can try to put up a PR.
- Include how you run your tests and which testing framework or frameworks you are running.
RSpec and cucumber on some apps, mostly Rails, some gems. - Include the SimpleCov version you are running in your report.
0.19.1 - Include your
ruby -e "puts RUBY_DESCRIPTION"
.
Mostly 2.6-2.7
Thanks!