Merge coverage reports from parallel circle test containers
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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...') | |
results = [] | |
Dir['/home/circleci/rspec/*.resultset.json'].each do |path| | |
resultset = JSON.parse(File.read(path)) | |
resultset.each do |_, data| | |
cmd = File.basename(path) | |
results << SimpleCov::Result.from_hash(cmd => data) | |
end | |
print '.' | |
end | |
puts | |
merged_result = SimpleCov::ResultMerger.merge_results(*results) | |
SimpleCov::Formatter::LcovFormatter.config.report_with_single_file = true | |
SimpleCov::Formatter::LcovFormatter.config.single_report_path = ARGV[0] || 'coverage.lcov' | |
SimpleCov::Formatter::LcovFormatter.new.format(merged_result) | |
puts("Done! LCOV saved to #{SimpleCov::Formatter::LcovFormatter.config.single_report_path}") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment