Skip to content

Commit d89c8bf

Browse files
Harden Python workflow
1 parent ca3c2b4 commit d89c8bf

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

.github/workflows/python-tests.yml

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -51,18 +51,22 @@ jobs:
5151
# Run tests with continue-on-error so that coverage and PR comments are always published.
5252
# The final step will explicitly fail the job if any test failed, ensuring PRs cannot be merged with failing tests.
5353
- name: Run pytest with coverage and generate JUnit XML
54+
id: pytest
5455
run: |
5556
PYTHONPATH=$(pwd) COVERAGE_FILE=tests/python/.coverage-${{ matrix.python-version }} pytest --cov=shared/python --cov-config=tests/python/.coveragerc --cov-report=html:tests/python/htmlcov-${{ matrix.python-version }} --junitxml=tests/python/junit-${{ matrix.python-version }}.xml tests/python/
5657
continue-on-error: true
5758

5859
- name: Upload coverage HTML report
60+
if: always()
5961
uses: actions/upload-artifact@v4
6062
with:
6163
name: coverage-html-${{ matrix.python-version }}
6264
path: tests/python/htmlcov-${{ matrix.python-version }}/
6365

6466
- name: Upload JUnit test results
67+
if: always()
6568
uses: actions/upload-artifact@v4
69+
continue-on-error: true
6670
with:
6771
name: junit-results-${{ matrix.python-version }}
6872
path: tests/python/junit-${{ matrix.python-version }}.xml
@@ -77,9 +81,7 @@ jobs:
7781
# Explicitly fail the job if any test failed (so PRs cannot be merged with failing tests).
7882
# This runs after all reporting steps, meaning coverage and PR comments are always published.
7983
- name: Fail if tests failed
80-
if: always()
84+
if: steps.pytest.outcome == 'failure'
8185
run: |
82-
if grep -q 'failures="[1-9]' tests/python/junit-${{ matrix.python-version }}.xml; then
83-
echo "::error ::Unit tests failed. See above for details."
84-
exit 1
85-
fi
86+
echo "::error ::Unit tests failed. See above for details."
87+
exit 1

0 commit comments

Comments
 (0)