Skip to content

Commit 51e46cc

Browse files
nbudinclaude
andcommitted
Fix coverage merge step: correct artifact paths and error on missing files
upload-artifact@v5 preserves directory structure, so downloaded artifacts land at e.g. minitest-coverage/coverage/coverage.xml, not minitest-coverage/coverage.xml. Also change the rescue from StandardError (which silently swallowed missing file errors) to only catch REXML::ParseException, and add an explicit abort for missing files. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent 92e4d25 commit 51e46cc

2 files changed

Lines changed: 4 additions & 2 deletions

File tree

.github/workflows/ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -326,7 +326,7 @@ jobs:
326326
- name: Check out repository
327327
uses: actions/checkout@v5
328328
- name: Merge coverage reports
329-
run: ruby scripts/merge_coverage.rb merged-coverage.xml minitest-coverage/coverage.xml vitest-coverage/cobertura-coverage.xml minitest-system-coverage/coverage.xml
329+
run: ruby scripts/merge_coverage.rb merged-coverage.xml minitest-coverage/coverage/coverage.xml vitest-coverage/coverage/cobertura-coverage.xml minitest-system-coverage/coverage/coverage.xml
330330
- name: Generate Coverage Report
331331
uses: clearlyip/code-coverage-report-action@v6
332332
id: code_coverage_report_action

scripts/merge_coverage.rb

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@
1818
file_lines = Hash.new { |h, k| h[k] = Hash.new(0) }
1919

2020
input_paths.each do |path|
21+
abort "Error: coverage file not found: #{path}" unless File.exist?(path)
22+
2123
doc = REXML::Document.new(File.read(path))
2224
doc
2325
.elements
@@ -27,7 +29,7 @@
2729
.elements
2830
.each("lines/line") { |line| file_lines[fname][line.attributes["number"].to_i] += line.attributes["hits"].to_i }
2931
end
30-
rescue StandardError => e
32+
rescue REXML::ParseException => e
3133
warn "Warning: could not parse #{path}: #{e}"
3234
end
3335

0 commit comments

Comments
 (0)