Skip to content

Commit fcbb1b9

Browse files
Update test workflow to refine branch triggers and enhance coverage reporting
1 parent 4551f12 commit fcbb1b9

1 file changed

Lines changed: 14 additions & 8 deletions

File tree

.github/workflows/test.yml

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,8 @@ on:
44
push:
55
branches:
66
- main
7-
- dev
8-
- demo
9-
- hotfix
7+
- demo-v4
108
- dev-v4
11-
- macae-v4-unittestcases-kd
129
pull_request:
1310
types:
1411
- opened
@@ -17,9 +14,8 @@ on:
1714
- synchronize
1815
branches:
1916
- main
20-
- dev
21-
- demo
22-
- hotfix
17+
- demo-v4
18+
- dev-v4
2319

2420
jobs:
2521
test:
@@ -54,10 +50,20 @@ jobs:
5450
if: env.skip_tests == 'false'
5551
run: |
5652
python -m pytest src/tests/backend/test_app.py --cov=backend.app --cov-report= --cov-config=.coveragerc -q > /dev/null 2>&1
57-
python -m pytest src/tests/backend --cov=backend --cov-append --cov-report= --cov-config=.coveragerc --ignore=src/tests/backend/test_app.py 2>&1 | tee /tmp/pytest_output.txt
53+
python -m pytest src/tests/backend --cov=backend --cov-append --cov-report=xml --cov-report= --cov-config=.coveragerc --ignore=src/tests/backend/test_app.py 2>&1 | tee /tmp/pytest_output.txt
5854
python -m coverage report --rcfile=.coveragerc
5955
tail -1 /tmp/pytest_output.txt
6056
57+
# Check coverage threshold
58+
if [ -f coverage.xml ]; then
59+
COVERAGE=$(python -c "import xml.etree.ElementTree as ET; tree = ET.parse('coverage.xml'); root = tree.getroot(); print(float(root.attrib['line-rate']) * 100)")
60+
echo "Coverage: $COVERAGE%"
61+
if (( $(echo "$COVERAGE < 80" | bc -l) )); then
62+
echo "Coverage is below 80%, failing the job."
63+
exit 1
64+
fi
65+
fi
66+
6167
- name: Skip coverage report if no tests
6268
if: env.skip_tests == 'true'
6369
run: |

0 commit comments

Comments
 (0)