Skip to content

Commit e177052

Browse files
committed
fix(ci): tolerate empty fallback shard under bash -e
GitHub Actions runs bash with -e, so the pytest exit 5 (no tests collected, expected for the fallback shard) aborted the step before the tolerance logic ran. Capture the exit code via || PYTEST_RC=$? instead of a bare command followed by $?. 署名:秦琼·CIOps@QPQAT
1 parent f4ccec6 commit e177052

1 file changed

Lines changed: 11 additions & 9 deletions

File tree

.github/workflows/tests.yml

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -440,11 +440,12 @@ jobs:
440440
run: |
441441
if [ -n "$QWENPAW_INTEGRATION_COVERAGE" ]; then
442442
# Subprocess coverage entry. Parent process must not carry
443-
# --cov, hence --no-cov here.
443+
# --cov, hence --no-cov here. Capture the exit code with
444+
# || so bash -e does not abort before the tolerance check.
445+
PYTEST_RC=0
444446
pytest tests/integration -v --no-cov \
445447
-n auto --dist=loadscope --timeout=300 \
446-
-m "${{ steps.marker.outputs.expr }}"
447-
PYTEST_RC=$?
448+
-m "${{ steps.marker.outputs.expr }}" || PYTEST_RC=$?
448449
# exit 5 = no tests collected: expected for the fallback
449450
# shard when every integration test carries a priority
450451
# marker. Any other nonzero code still fails.
@@ -460,14 +461,15 @@ jobs:
460461
-o coverage.integration.${{ matrix.shard }}.xml || [ "$?" -eq 2 ]
461462
fi
462463
else
464+
PYTEST_RC=0
463465
pytest tests/integration -v \
464466
-n auto --dist=loadscope --timeout=300 \
465-
-m "${{ steps.marker.outputs.expr }}" || {
466-
RC=$?
467-
# exit 5 = no tests collected: expected for the
468-
# fallback shard when nothing is unclassified.
469-
[ "$RC" -eq 5 ] || exit "$RC"
470-
}
467+
-m "${{ steps.marker.outputs.expr }}" || PYTEST_RC=$?
468+
# exit 5 = no tests collected: expected for the
469+
# fallback shard when nothing is unclassified.
470+
if [ "$PYTEST_RC" -ne 0 ] && [ "$PYTEST_RC" -ne 5 ]; then
471+
exit "$PYTEST_RC"
472+
fi
471473
fi
472474
473475
- name: Upload integration coverage data

0 commit comments

Comments
 (0)