Skip to content

Commit 63642b6

Browse files
ci: match reference repo coverage comment format
Use pytest-xml-coverage-path with coverage-path-prefix so the action correctly resolves XML paths (relative to subdir) against PR diff paths. Combined with report-only-changed-files: true, when no source files are in the diff this shows: badge + Coverage Report dropdown with TOTAL row + 'No files were changed' note + test summary table. Matches the format used in Multi-Agent-Custom-Automation-Engine PR #961. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent 0810e83 commit 63642b6

1 file changed

Lines changed: 6 additions & 32 deletions

File tree

.github/workflows/test.yml

Lines changed: 6 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -78,21 +78,6 @@ jobs:
7878
--junitxml=pytest.xml \
7979
-v
8080
81-
- name: Generate coverage summary
82-
if: env.skip_backend_tests == 'false'
83-
run: |
84-
python -c "
85-
import xml.etree.ElementTree as ET
86-
tree = ET.parse('src/backend-api/reports/coverage.xml')
87-
root = tree.getroot()
88-
stmts = int(root.attrib.get('lines-valid', 0))
89-
miss = stmts - int(root.attrib.get('lines-covered', 0))
90-
cover = int(float(root.attrib.get('line-rate', 0)) * 100)
91-
with open('src/backend-api/reports/coverage-summary.txt', 'w') as f:
92-
f.write('Name Stmts Miss Cover\n')
93-
f.write(f'TOTAL {stmts} {miss} {cover}%\n')
94-
"
95-
9681
- name: Pytest Coverage Comment
9782
if: |
9883
always() &&
@@ -101,8 +86,10 @@ jobs:
10186
env.skip_backend_tests == 'false'
10287
uses: MishaKav/pytest-coverage-comment@26f986d2599c288bb62f623d29c2da98609e9cd4 # v1.6.0
10388
with:
104-
pytest-coverage-path: src/backend-api/reports/coverage-summary.txt
89+
pytest-xml-coverage-path: src/backend-api/reports/coverage.xml
10590
junitxml-path: src/backend-api/pytest.xml
91+
coverage-path-prefix: src/backend-api/
92+
report-only-changed-files: true
10693

10794
- name: Skip Backend Tests
10895
if: env.skip_backend_tests == 'true'
@@ -150,21 +137,6 @@ jobs:
150137
--junitxml=pytest.xml \
151138
-v
152139
153-
- name: Generate coverage summary
154-
if: env.skip_processor_tests == 'false'
155-
run: |
156-
python -c "
157-
import xml.etree.ElementTree as ET
158-
tree = ET.parse('src/processor/reports/coverage.xml')
159-
root = tree.getroot()
160-
stmts = int(root.attrib.get('lines-valid', 0))
161-
miss = stmts - int(root.attrib.get('lines-covered', 0))
162-
cover = int(float(root.attrib.get('line-rate', 0)) * 100)
163-
with open('src/processor/reports/coverage-summary.txt', 'w') as f:
164-
f.write('Name Stmts Miss Cover\n')
165-
f.write(f'TOTAL {stmts} {miss} {cover}%\n')
166-
"
167-
168140
- name: Pytest Coverage Comment (Processor)
169141
if: |
170142
always() &&
@@ -173,10 +145,12 @@ jobs:
173145
env.skip_processor_tests == 'false'
174146
uses: MishaKav/pytest-coverage-comment@26f986d2599c288bb62f623d29c2da98609e9cd4 # v1.6.0
175147
with:
176-
pytest-coverage-path: src/processor/reports/coverage-summary.txt
148+
pytest-xml-coverage-path: src/processor/reports/coverage.xml
177149
junitxml-path: src/processor/pytest.xml
150+
coverage-path-prefix: src/processor/
178151
title: Processor Coverage Report
179152
unique-id-for-comment: processor
153+
report-only-changed-files: true
180154

181155
- name: Skip Processor Tests
182156
if: env.skip_processor_tests == 'true'

0 commit comments

Comments
 (0)