Skip to content

Conversation

@cfsmp3
Copy link
Contributor

@cfsmp3 cfsmp3 commented Dec 27, 2025

Summary

  • Fix race condition where tests fail with "Artifact not found" when GitHub API hasn't propagated the artifact yet
  • Add retry logic to GitHub status updates to prevent tests getting stuck in "pending" state

Problem

When a GitHub Actions build completes, there can be a brief delay before the artifact is visible via the GitHub API. If the Sample Platform cron runs during this window:

  1. Build completes at 07:40:57, artifact uploaded
  2. Cron runs at 07:41:04 (7 seconds later)
  3. find_artifact_for_commit() doesn't find artifact (API propagation delay)
  4. _diagnose_missing_artifact() sees build succeeded → marks as permanent failure
  5. Test shows "Artifact not found" error
  6. GitHub status stuck in "pending" (if status update also fails)

This was observed on CCExtractor/ccextractor#1913.

Solution

  1. Grace period for recently-completed builds: If a build completed within the last 5 minutes but artifact isn't visible, treat as retryable instead of permanent failure

  2. Retry logic for GitHub status updates: Use retry_with_backoff() (3 attempts, 2s initial backoff) when updating GitHub status in mark_test_failed() to handle transient API failures

Test plan

  • New test: test_recently_completed_build_is_retryable - verifies builds completed 1 minute ago are retryable
  • New test: test_old_completed_build_is_not_retryable - verifies builds completed 10 minutes ago are not retryable
  • New test: test_mark_test_failed_uses_retry_for_github - verifies retry logic is used for GitHub status updates
  • All existing TestDiagnoseMissingArtifact tests pass
  • All existing TestMarkTestFailedImproved tests pass

🤖 Generated with Claude Code

When a build completes successfully but the artifact isn't immediately
visible via the GitHub API (due to propagation delay), the test was
incorrectly marked as a permanent failure. This caused tests to fail
with "Artifact not found" even though the artifact existed.

Changes:
- Add 5-minute grace period in _diagnose_missing_artifact(): if a build
  completed recently but artifact isn't visible, treat as retryable
  instead of permanent failure
- Add retry logic (3 attempts with 2s backoff) to mark_test_failed()
  for GitHub status updates to prevent stuck "pending" status
- Add tests for new retry behavior

Fixes issue where PR #1913 showed "Tests queued" on GitHub but
"An error occurred" on Sample Platform - the artifact was uploaded
at 07:40:57 but the test ran at 07:41:04 (7 seconds later) before
the API reflected the new artifact.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@sonarqubecloud
Copy link

@cfsmp3 cfsmp3 merged commit 58cd57b into master Dec 27, 2025
6 checks passed
@cfsmp3 cfsmp3 deleted the fix/artifact-propagation-delay branch December 27, 2025 09:16
cfsmp3 added a commit that referenced this pull request Dec 27, 2025
The final GitHub status update in progress_type_request() was not using
retry logic, causing tests to complete but remain stuck in "pending" state
on GitHub if the status update failed (e.g., due to rate limiting or
network issues).

This is the same fix applied to mark_test_failed() in PR #976, now applied
to the normal test completion path.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants