fix(ci): stop auto-merge-bot-prs.yml's self-referential check-polling deadlock - #328
Merged
Merged
Conversation
… deadlock The workflow's 'Wait for status checks' step polled checks.listForRef on the PR head SHA and waited for every check run to be 'completed' before merging — but that list includes the workflow's own currently-running check run, which can never be 'completed' mid-poll. Every bot PR timed out after 60 attempts / ~10 minutes (see #324, #325, #326). Replaced the hand-rolled wait-then-merge loop with native GitHub auto-merge (gh pr merge --squash --auto), which lets GitHub itself wait on branch protection's required-checks list and merge when green — no self-polling possible. Also made workflow_dispatch actually usable via a pr_number input (previously listed as a trigger but non-functional, since the script only ever read context.payload.pull_request). Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_013bghcqrffRB2LTwv2q2bTj
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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
auto-merge-bot-prs.ymlhas never actually been able to merge a bot PR — it always times out after ~10 minutes. Root cause, found while investigating why PRs #324, #325, #326 (dependabot) sat open despite passing CI:The workflow's own 'Wait for status checks' step polled
checks.listForRefon the PR's head SHA and waited for every check run on that SHA to reportcompletedbefore merging. That list includes the workflow's own currently-running check run — which by definition is nevercompletedwhile the polling step itself is still executing. The loop therefore always sees N-1 of N complete, forever, until its own 60-attempt (~10 min) timeout throws. This is unrelated to the earlier YAML-comment-placement fix in #327 — that fixed a cosmeticif:block-scalar corruption, not this logic bug.Fix
Replaced the hand-rolled wait-then-merge loop with GitHub's native
gh pr merge --squash --auto, which delegates 'wait for the branch's required status checks, then merge' to GitHub itself. No self-polling is possible, and it correctly waits only on branch protection's required-checks list (7 named contexts) rather than every check run present on the SHA (17, including unrelated ones like CodeQL/Sourcery/zizmor that were never required). Confirmedallow_auto_mergeis already enabled on this repo.Also fixed the
workflow_dispatchtrigger, which was listed but never actually functional (the old script only ever readcontext.payload.pull_request, which is absent on a manual dispatch) — it now accepts a `pr_number" input.Verification
ruff/format/mypy/full unit suite: clean (2950 passed, 3 skipped) — doc/workflow-only change, no source touchedzizmoron the new file: no findingsyaml.safe_loadconfirms theif:block parses to the exact intended boolean expression (no comment-splicing, unlike the pre-chore: internal audit remediation (25 tasks + security fix + ruff sweep) #327 bug)[Unreleased]→FixedFollow-up (not in this PR)
PRs #324, #325, #326 predate this fix and are stuck in
BEHIND/BLOCKEDmerge state (branch protection'sstrict: truerequires them to be updated against currentmain, which just took a large merge). Plan to update and merge them separately once this fix lands.🤖 Generated with Claude Code
Summary by Sourcery
Restore reliable bot pull request auto-merging by delegating required-check waiting to GitHub and support manually triggered merges.
New Features:
Bug Fixes:
CI:
Chores: