File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 66 - main
77 - demo-v4
88 - dev-v4
9- - macae-v4-unittestcases-kd
109 paths :
1110 - ' src/backend/**/*.py'
1211 - ' src/tests/**/*.py'
@@ -68,14 +67,21 @@ jobs:
6867 - name : Run tests with coverage
6968 if : env.skip_tests == 'false'
7069 run : |
71- python -m pytest src/tests/backend/test_app.py --cov=backend --cov-config=.coveragerc
72- python -m pytest src/tests/backend --cov=backend --cov-append --cov-report=term --cov-config=.coveragerc --ignore=src/tests/backend/test_app.py
70+ if python -m pytest src/tests/backend/test_app.py --cov=backend --cov-config=.coveragerc && \
71+ python -m pytest src/tests/backend --cov=backend --cov-append --cov-report=term --cov-report=xml --cov-config=.coveragerc --ignore=src/tests/backend/test_app.py; then
72+ echo "Tests completed, checking coverage."
73+ if [ -f coverage.xml ]; then
74+ COVERAGE=$(python -c "import xml.etree.ElementTree as ET; tree = ET.parse('coverage.xml'); root = tree.getroot(); print(float(root.attrib.get('line-rate', 0)) * 100)")
75+ echo "Overall coverage: $COVERAGE%"
76+ if (( $(echo "$COVERAGE < 80" | bc -l) )); then
77+ echo "Coverage is below 80%, failing the job."
78+ exit 1
79+ fi
80+ fi
81+ else
82+ echo "No tests found, skipping coverage check."
83+ fi
7384
74- # - name: Run tests with coverage
75- # if: env.skip_tests == 'false'
76- # run: |
77- # pytest --cov=. --cov-report=term-missing --cov-report=xml --ignore=tests/e2e-test/tests
78-
7985 - name : Skip coverage report if no tests
8086 if : env.skip_tests == 'true'
8187 run : |
You can’t perform that action at this time.
0 commit comments