Skip to content

Commit 9b022f7

Browse files
committed
feat(tests): refactor coverage summary parsing to use Python with Poetry
1 parent 3b101ac commit 9b022f7

File tree

1 file changed

+11
-5
lines changed

1 file changed

+11
-5
lines changed

.github/workflows/pr-test.yml

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -37,11 +37,17 @@ jobs:
3737
3838
- name: Parse Coverage and Write Summary
3939
run: |
40-
TOTAL=$(xmllint --xpath 'string(/coverage/@line-rate)' coverage.xml)
41-
PERCENTAGE=$(echo "$TOTAL * 100" | bc)
42-
echo "| Metric | Value |" >> $GITHUB_STEP_SUMMARY
43-
echo "|--------|-----|" >> $GITHUB_STEP_SUMMARY
44-
echo "| 📊 Line Coverage | ${PERCENTAGE}% |" >> $GITHUB_STEP_SUMMARY
40+
poetry run python -c "
41+
import xml.etree.ElementTree as ET
42+
tree = ET.parse('coverage.xml')
43+
root = tree.getroot()
44+
line_rate = float(root.attrib['line-rate'])
45+
percentage = line_rate * 100
46+
with open('${{ github.step_summary }}', 'a') as f:
47+
f.write('| Metric | Value |\n')
48+
f.write('|--------|-----|\n')
49+
f.write(f'| 📊 Line Coverage | {percentage:.2f}% |\n')
50+
"
4551
4652
- name: Publish Test Results Summary
4753
uses: test-summary/action@v2

0 commit comments

Comments
 (0)