Open whizzzkid opened 9 months ago
Hey @whizzzkid! Here's an example from https://undercover-ci.com/docs#parallel-tests. It uses SimpleCov.collate
also described in the SimpleCov documentation.
#!/usr/bin/env ruby
# frozen_string_literal: true
require 'simplecov'
require 'simplecov-lcov'
puts('Merging coverage results from parallel CircleCI tests containers into a single LCOV report...')
SimpleCov.collate(Dir['/home/circleci/rspec/*.resultset.json']) do
enable_coverage(:branch)
end
report_path = ARGV[0] || 'coverage.lcov'
SimpleCov.formatter = SimpleCov::Formatter::LcovFormatter
SimpleCov::Formatter::LcovFormatter.config.report_with_single_file = true
SimpleCov::Formatter::LcovFormatter.config.single_report_path = report_path
merged_result = SimpleCov.result
merged_result.format!
if File.size(report_path).zero?
puts('Written report has 0 bytes')
exit 1
end
puts("Done! LCOV saved to #{SimpleCov::Formatter::LcovFormatter.config.single_report_path}")
Depending on which CI you use, you'd need a script like this to run after all the workers have finished and then feed the merged coverage report to undercover
.
Let me know how it goes!
When splitting rspec across multiple workers using something like knapsack, what would be the best way to club all generated coverage reports into a single artifact?