Skip to content

Commit be663c2

Browse files
committed
Simplify coverage extraction in CI workflow
Replaces the multi-line Python script for extracting coverage percentage from coverage.xml with a single-line command, improving readability and maintainability in the test-status GitHub Actions workflow.
1 parent 85e7f54 commit be663c2

File tree

1 file changed

+1
-10
lines changed

1 file changed

+1
-10
lines changed

.github/workflows/test-status.yml

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -50,16 +50,7 @@ jobs:
5050
5151
if [ -f coverage.xml ]; then
5252
# Extract coverage percentage
53-
COVERAGE=$(python3 -c "
54-
import xml.etree.ElementTree as ET
55-
try:
56-
tree = ET.parse('coverage.xml')
57-
root = tree.getroot()
58-
coverage = float(root.attrib['line-rate']) * 100
59-
print(f'{coverage:.0f}')
60-
except:
61-
print('0')
62-
")
53+
COVERAGE=$(python3 -c "import xml.etree.ElementTree as ET; tree = ET.parse('coverage.xml') if __import__('os').path.exists('coverage.xml') else None; print(int(float(tree.getroot().attrib['line-rate']) * 100) if tree else 0)")
6354
echo "COVERAGE=${COVERAGE}" >> $GITHUB_ENV
6455
else
6556
echo "COVERAGE=0" >> $GITHUB_ENV

0 commit comments

Comments
 (0)