Skip to content

Commit 37dead4

Browse files
authored
GHA: Fix publish test results for multiple drivers (#3143)
1 parent f7de112 commit 37dead4

1 file changed

Lines changed: 59 additions & 2 deletions

File tree

.github/workflows/publish-test-results.yml

Lines changed: 59 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,66 @@ jobs:
2222
event_file: event-file/event.json
2323
event_name: ${{ github.event.workflow_run.event }}
2424
files: "tests/*.xml"
25-
- name: Publish coverage results
25+
26+
# 5monkeys/cobertura-action has a bug where the `files` array that builds
27+
# each per-XML markdown table is declared once outside the loop over reports
28+
# and is never reset. When multiple XML files are passed via a glob, every
29+
# subsequent driver's table accumulates all files from earlier drivers.
30+
#
31+
# Fix: determine which XML files exist at runtime, then fan out into a matrix
32+
# job so each driver's XML is processed by its own isolated action invocation.
33+
list-coverage-files:
34+
runs-on: ubuntu-latest
35+
outputs:
36+
matrix: ${{ steps.build-matrix.outputs.matrix }}
37+
steps:
38+
- name: Download coverage artifact
39+
continue-on-error: true
40+
uses: dawidd6/action-download-artifact@v6
41+
with:
42+
workflow: run-tests.yml
43+
run_id: ${{ github.event.workflow_run.id }}
44+
name: coverage
45+
path: coverage
46+
- name: Build matrix of coverage files
47+
id: build-matrix
48+
run: |
49+
files=$(find coverage -maxdepth 1 -name '*_coverage.xml' -printf '%f\n' 2>/dev/null | sort)
50+
if [ -z "$files" ]; then
51+
echo 'matrix=[]' >> $GITHUB_OUTPUT
52+
else
53+
json=$(echo "$files" | python3 -c 'import sys,json; print(json.dumps([l.strip() for l in sys.stdin if l.strip()]))')
54+
echo "matrix=$json" >> $GITHUB_OUTPUT
55+
fi
56+
57+
publish-coverage:
58+
needs: list-coverage-files
59+
if: needs.list-coverage-files.outputs.matrix != '[]' && needs.list-coverage-files.outputs.matrix != ''
60+
runs-on: ubuntu-latest
61+
strategy:
62+
fail-fast: false
63+
matrix:
64+
coverage_file: ${{ fromJson(needs.list-coverage-files.outputs.matrix) }}
65+
steps:
66+
- name: Download coverage artifact
67+
uses: dawidd6/action-download-artifact@v6
68+
with:
69+
workflow: run-tests.yml
70+
run_id: ${{ github.event.workflow_run.id }}
71+
name: coverage
72+
path: coverage
73+
- name: Download pr_number artifact
74+
uses: dawidd6/action-download-artifact@v6
75+
with:
76+
workflow: run-tests.yml
77+
run_id: ${{ github.event.workflow_run.id }}
78+
name: pr_number
79+
path: pr_number
80+
- run: echo "pr_number=$(cat pr_number/pr_number.txt)" >> $GITHUB_ENV
81+
- name: Publish coverage for ${{ matrix.coverage_file }}
2682
uses: 5monkeys/cobertura-action@master
2783
with:
2884
pull_request_number: ${{ env.pr_number }}
29-
path: "coverage/*.xml"
85+
path: coverage/${{ matrix.coverage_file }}
3086
minimum_coverage: 90
87+
report_name: ${{ matrix.coverage_file }}

0 commit comments

Comments
 (0)