Repository navigation
ci(workflows): auto-rerun Test attempts GitHub cancelled without a runner - #570
itsmiso-ai wants to merge 2 commits into
Conversation
…562) The 409/422 fallback keyed off regexing gh's human-readable error text; if that format drifted, a refused rerun would fail closed instead of recovering. The gate has already proven the attempt is a pure capacity cancel, so any refusal of the targeted rerun now gets the equivalent full rerun, and only a failed fallback exits 1. Adds stub cases for a status-less refusal and a failed fallback.
There was a problem hiding this comment.
{"schema":"review-handoff/v1","review_id":"fd4920e430896c58","head_sha":"ee9a7c7286608c4a74a9f0ad960e5bb9dfa04485","verdict":"approve","review_result":"partial","required_checks":"none","items":[{"id":"fb045b3a28d387398b859aae8e8d5875b908ca850ee8d341987be868e38aba69","severity":"info","category":"verification","path":".github/workflows/ci-rerun.yml","line":10,"message":"The second-attempt recovery depends on GitHub emitting a `workflow_run` event per re-run attempt; the stubbed test covers only the decision script, not the trigger, so the three-attempt ceiling is unverified end to end. (review thread PRRT_kwDOSBzTVM7AG5mh: open)"},{"id":"a31bb22d852a7d15fda690af455fff26e43363f8312533a854e1b7a65572f095","severity":"minor","category":"other","path":".github/scripts/ci-rerun-action.mjs","line":null,"message":"The full-rerun fallback re-executes every job of the attempt, including jobs that already succeeded, so a 409/422 refusal costs a complete matrix re-run rather than just the cancelled macOS jobs. (review thread PRRT_kwDOSBzTVM7AG5me: open)"}],"items_total":2,"items_truncated":false,"unresolved_requirement_ids":[],"unresolved_requirement_ids_total":0,"unresolved_requirement_ids_truncated":false,"unresolved_requirement_ids_source_total":0,"unresolved_required_checks":[],"unresolved_required_checks_total":0,"unresolved_required_checks_truncated":false,"unresolved_required_checks_source_total":0,"unresolved_review_obligations":[],"unresolved_review_obligations_total":0,"unresolved_review_obligations_truncated":false,"derived_obligation_state":null}AI Automated Review
🟡 Automated recommendation: INCOMPLETE — no blocking code defect proven; approval withheld (the reviewer declared a materially relevant question unresolved)
Full PR review.
Analysis engine: MiniMax-M3.1-Flash (anthropic) — primary route · pr-reviewer-action v3.11.2
Reviewer-declared material unknowns (unresolved questions, not proven defects):
It remains unverified whether GitHub emits a 'workflow_run' completion event for every rerun attempt, which is required for automatic recovery beyond the first attempt.
Findings (1 minor, 1 info)
| Severity | Location | Finding |
|---|---|---|
| Info | .github/workflows/ci-rerun.yml:10 |
The second-attempt recovery depends on GitHub emitting a `workflow_run` event per re-run attempt; the stubbed test covers only the decision script, not the trigger, so the three-attempt ceiling is unverified end to end. (review thread PRRT_kwDOSBzTVM7AG5mh: open) |
| Minor | .github/scripts/ci-rerun-action.mjs |
The full-rerun fallback re-executes every job of the attempt, including jobs that already succeeded, so a 409/422 refusal costs a complete matrix re-run rather than just the cancelled macOS jobs. (review thread PRRT_kwDOSBzTVM7AG5me: open) |
Recommendation: Incomplete — no blocking code defect proven; approval withheld (the reviewer declared a materially relevant question unresolved). (Model suggestion before validation, not authoritative: approve with an external-verification caveat; no blocker or major issue is established at the current head.)
Linked Issue Fit
The helper implements the requested capacity-only gate, three-attempt ceiling, least-privilege permissions, default-branch execution, and CI-wired structure test. The live API evidence confirms that the specified zero-step, runnerless jobs carry the failure-level “not acquired” annotation used by the gate.
Tool Harness Findings
The workflow-security checklist and current-head workflow/script were inspected. Live run and annotation responses corroborate the detection shape, while the stubbed tests cover the decision paths and fallback behavior. The tool loop was interrupted before observing a real rerun attempt end to end.
Unknowns or Needs Verification
GitHub’s behavior for emitting a workflow_run completion event for every rerun attempt remains externally unverified. The current implementation fails closed if an event is absent, but a live second-attempt recovery would settle whether the acceptance criterion is fulfilled end to end.
Sources
Current-head diff and files; linked issue PR 562; successful CI rerun gating (workflow structure) check; live run/job/annotation API responses.
Unresolved Review Threads
PRRT_kwDOSBzTVM7AG5mh: openPRRT_kwDOSBzTVM7AG5me: openPRRT_kwDOSBzTVM7AG5mb: fixed
Approval withheld — review incomplete: the reviewer declared a materially relevant question unresolved No blocking code defect was proven; this run needs review and no native approval is certified.
Closes #562.
GitHub's hosted
macos-latestpool cancelled queued Test jobs during capacity windows without ever acquiring a runner. A new helper workflow recovers those runs on its own, and it never touches a run that failed for a real reason.What ships
.github/workflows/ci-rerun.yml(new): triggers onworkflow_runcompletion of theTestworkflow, gated tofailureorcancelledconclusions. Job-scoped permissions only:contents: read,actions: write,pull-requests: read,checks: read. No app token, nocontents: write, no schedule..github/scripts/ci-rerun-action.mjs(new): the gate. An attempt reruns only when all of these hold:pull_requestrun with an open PR (looked up byhead=<owner>:<branch>, because the event payload'spull_requestsarray is empty on real fork and same-repo runs),run_attemptis below 3 (three total attempts, no stored state),success/non-skippedjob of that attempt is cancelled, ran zero steps, never had a runner, and carries a failure-level annotation matching "not acquired".The rerun POSTs
rerun-failed-jobs; if GitHub refuses it for any reason, one full rerun is the fallback. The decision never depends on parsing an HTTP status out of gh's error text. Any API error on the read path exits 1 without rerunning (fails closed).tests/test_ci_rerun_gating.sh(new): structure checks on the workflow plus 15 behavioral cases that run the script against a stubbedghAPI..github/workflows/test.yml: newci-rerun-gatingjob runs the test in the CI matrix.Verified against the live API, not memory
failure, notcancelled, while the two macOS jobs arecancelledwithrunner_id: 0,runner_name: "", and zero steps. The helper therefore accepts both run conclusions.GET /repos/.../check-runs/<job_id>/annotationsreturns the failure annotation "The job was not acquired by Runner of type hosted even after multiple attempts" plus a repo-wide notice "Due to capacity constraints...". The gate counts only the failure-level "not acquired" annotation as proof, because the notice rides along with unrelated cancels.needsfield, so dependency-cascaded cancels are excluded through the annotation rule instead: a cascaded cancel has no failure-level "not acquired" annotation.head=forkland%3Afeature%2Fxfilters correctly onGET /pulls; the test stub pins that encoded form, because a wrongly encoded value is silently ignored and would return every open PR.Invariants this change keeps, and the other paths for the same rule
test.ymlstill declarespermissions: contents: readand is not modified except for the appended structure-test job.ci-rerun.ymlchecks out the default branch only (noref:input, nohead_shareference anywhere), soactions: writeis never exposed to PR content.ai-pr-review.yamlenforces the same trust boundary for the reviewer by a different rule (same-repo, non-draft gate); neither workflow is weakened.tests/test_release_workflow_gating.shenforces that rule forrelease.yml; the new test enforces it forci-rerun.yml(nowritegrant beforejobs:, job block pinned to the four grants).release.ymlare untouched, and no rerun path bypasses them.rerun-failed-jobsfirst, then one fullrerunon any refusal, because the gate already proved the attempt is a pure capacity cancel. No decision path parses gh's error text for a status code.tests/test_ci_rerun_gating.shpins the fallback for a status-carrying refusal, a status-less refusal, and a failed fallback (fails closed).test.yml; the new job follows the identicalbash tests/...pattern.Local validation (re-run on head ee9a7c7)
bash tests/test_ci_rerun_gating.sh— exit 0, 33 OK lines (structure + 15 behavioral cases, including: real failure blocks rerun, attempt 3 stops before any API call, notice-only annotation does not qualify, stale event for an old attempt does not rerun, status-less refusal still falls back, failed fallback fails closed, GET error fails closed, dry run never posts).node --check .github/scripts/ci-rerun-action.mjs— clean.bash tests/test_release_workflow_gating.sh,test_release_tag_validation.sh,test_release_version_injection.sh— all pass (shared-file regression check).ci-rerun.ymlhas no top-levelpermissions:block; the job holds exactly the four grants.maintoo:test_release_notes_guard.sh,test_web_package_validation.sh,test_ai_review_comment_authorization.sh(they needpython3, absent here). CI has it..gdfiles and touches no Godot resource.External verification left pending
ci-rerun-gatingjob).workflow_runexecutes the default-branch copy of the workflow. Real recovery depends on the next macOS capacity window.rerun-failed-jobsincludes zero-step cancelled jobs; the any-refusal fallback to a full rerun covers a strict answer. The fallback is bounded by the three-attempt cap and the current-attempt assertion.One deviation from the issue text, deliberate:
checks: readis required in addition toactions: writeandpull-requests: read, because the per-job annotations endpoint demands it.