fix: Retry tests when build is still in progress instead of failing #973
+257
−16
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.



Summary
This PR fixes a critical regression introduced in the Phase 2 reliability improvements (PRs #943/#946) that causes tests to be permanently marked as failed when the GitHub Actions build hasn't completed yet.
The Problem
When a PR is opened, both the GitHub Actions build and the Sample Platform test are triggered. If the cron job picks up the test before the build completes (which can take up to 40 minutes for Windows builds), the test is marked as permanently failed instead of being retried later.
Real-world example: PR CCExtractor/ccextractor#1896:
Root Cause Analysis
Previous behavior (before December 2025):
Regression behavior (after Phase 2 fixes):
The Fix
Modified
_diagnose_missing_artifact()to return a tuple indicating whether the failure is retryable:in_progress,queued)failure,cancelled)Fixed behavior:
Files Changed
mod_ci/controllers.py_diagnose_missing_artifact()to return(message, is_retryable)tuple; Updatedstart_test()to handle retryable vs permanent failurestests/test_ci/test_controllers.pyTest Coverage
New Tests Added
TestDiagnoseMissingArtifactclass (6 tests):test_build_in_progress_is_retryable- Build with statusin_progressreturnsis_retryable=Truetest_build_queued_is_retryable- Build with statusqueuedreturnsis_retryable=Truetest_build_failed_is_not_retryable- Build with conclusionfailurereturnsis_retryable=Falsetest_artifact_expired_is_not_retryable- Successful build with missing artifact returnsis_retryable=Falsetest_no_workflow_run_is_retryable- No workflow run found returnsis_retryable=Truetest_diagnostic_exception_is_retryable- API errors default tois_retryable=True(safe default)TestStartTestRetryBehaviorclass (2 tests):test_retryable_failure_does_not_mark_test_failed- Verifiesmark_test_failed()is NOT called for retryable failurestest_permanent_failure_marks_test_failed- Verifiesmark_test_failed()IS called for permanent failuresTest Results
How to Verify
Before This Fix
After This Fix
"Test {id}: Build still in progress: ... Will retry when build completes."Manual Verification
After deploying, monitor logs for:
This indicates the retry logic is working correctly.
Deployment Notes
Related Issues
🤖 Generated with Claude Code