-
Notifications
You must be signed in to change notification settings - Fork 2
Handle Numba cleanup crash in GitHub Actions workflow #28
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -37,13 +37,45 @@ jobs: | |||||||||||||||
|
|
||||||||||||||||
| - name: Run unit tests | ||||||||||||||||
| run: | | ||||||||||||||||
| pytest -v --ignore=tests/accuracy --ignore=tests/benchmark -x | ||||||||||||||||
| # Run pytest and capture output, allowing the command to fail | ||||||||||||||||
| set +e | ||||||||||||||||
| pytest -v --ignore=tests/accuracy --ignore=tests/benchmark -x 2>&1 | tee pytest_output.txt | ||||||||||||||||
| PYTEST_EXIT_CODE=$? | ||||||||||||||||
| set -e | ||||||||||||||||
|
|
||||||||||||||||
| # Check if all tests passed by looking at the pytest summary line | ||||||||||||||||
| if grep -qE "^=+ .* passed" pytest_output.txt; then | ||||||||||||||||
| # If tests passed but exit code is non-zero (cleanup crash), treat as success | ||||||||||||||||
| if [ "$PYTEST_EXIT_CODE" -eq 134 ] || [ "$PYTEST_EXIT_CODE" -eq 139 ]; then | ||||||||||||||||
|
||||||||||||||||
| echo "::warning::Pytest cleanup crashed (exit code $PYTEST_EXIT_CODE) but all tests passed. This is a known Numba issue." | ||||||||||||||||
| exit 0 | ||||||||||||||||
| fi | ||||||||||||||||
| fi | ||||||||||||||||
|
|
||||||||||||||||
| # If we got here and exit code is non-zero, it's a real failure | ||||||||||||||||
| if [ "$PYTEST_EXIT_CODE" -ne 0 ]; then | ||||||||||||||||
| echo "Tests failed with exit code $PYTEST_EXIT_CODE" | ||||||||||||||||
| cat pytest_output.txt | ||||||||||||||||
| exit $PYTEST_EXIT_CODE | ||||||||||||||||
| fi | ||||||||||||||||
|
|
||||||||||||||||
| - name: Run tests with coverage | ||||||||||||||||
| if: matrix.python-version == '3.12' | ||||||||||||||||
| run: | | ||||||||||||||||
| pip install pytest-cov | ||||||||||||||||
| pytest --cov=numta --cov-report=xml --ignore=tests/accuracy --ignore=tests/benchmark | ||||||||||||||||
| set +e | ||||||||||||||||
| pytest --cov=numta --cov-report=xml --ignore=tests/accuracy --ignore=tests/benchmark 2>&1 | tee pytest_cov_output.txt | ||||||||||||||||
| PYTEST_EXIT_CODE=$? | ||||||||||||||||
| set -e | ||||||||||||||||
|
|
||||||||||||||||
| if grep -qE "^=+ .* passed" pytest_cov_output.txt; then | ||||||||||||||||
|
||||||||||||||||
| if grep -qE "^=+ .* passed" pytest_cov_output.txt; then | |
| if grep -qE "^=+ .* passed" pytest_cov_output.txt; then | |
| # Exit codes: 134 = SIGABRT (free() corruption), 139 = SIGSEGV (segfault) | |
| # These indicate Numba cleanup crashes that occur after all tests pass. | |
| # If all tests passed, we ignore these cleanup crashes and mark the run as successful. |
Copilot
AI
Dec 2, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The grep pattern ^=+ .* passed will match pytest summary lines that contain both "passed" and "failed" (e.g., "5 passed, 10 failed"). This could cause the workflow to incorrectly treat partial failures as success when a cleanup crash occurs.
Consider using a more precise pattern that ensures ALL tests passed:
if grep -qE "^=+ [0-9]+ passed in " pytest_cov_output.txt && ! grep -qE " failed" pytest_cov_output.txt; thenOr check for the absence of failures:
if grep -qE "^=+ .* passed" pytest_cov_output.txt && ! grep -qE "^=+ .* failed" pytest_cov_output.txt; then| if grep -qE "^=+ .* passed" pytest_cov_output.txt; then | |
| if grep -qE "^=+ [0-9]+ passed in " pytest_cov_output.txt && ! grep -qE " failed" pytest_cov_output.txt; then |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The grep pattern
^=+ .* passedwill match pytest summary lines that contain both "passed" and "failed" (e.g., "5 passed, 10 failed"). This could cause the workflow to incorrectly treat partial failures as success when a cleanup crash occurs.Consider using a more precise pattern that ensures ALL tests passed:
Or check for the absence of failures: