Skip to content

ci(rustcfml): approve auto-bump PR checks and retire superseded bumps - #4717

Merged
bpamiri merged 4 commits into
developfrom
fix/autobump-approval
Dec 1, 2026
Merged

bpamiri merged 4 commits into
developfrom
fix/autobump-approval

Conversation

@bpamiri

@bpamiri bpamiri commented Nov 30, 2026 •

Copy link
Copy Markdown
Collaborator

Security-review follow-up (head d309d4db9)

B1 — retire step never worked. gh pr close has no --reason flag (that is gh issue close); under set -euo pipefail the loop died on its first iteration. It now folds the explanation into gh pr close -c "…" (verified locally: gh pr close --help lists -c/--comment only). Proven for real, not dry-run: dispatch 46584135549 with dry_run=false logged Closing #4712 … ✓ Closed and Closing #4711 … ✓ Closed; both PRs are now CLOSED with the exact comment:

Superseded by #4713, which pins a newer RustCFML release. Closing so the bump queue does not stack.

That same run also approved 9 held runs on the new bump head (Approved 9 held run(s); saw 55 run(s)), so the comment-under-pull-requests: write path (H4) is exercised end-to-end.

H1 — fork filter. Both approval queries now require head_repository.full_name == "$GITHUB_REPOSITORY" before branch matching. Evidence with the exact filter and a fixture containing a same-repo run, a fork run on the same auto-bump/rustcfml-v0.754.0 branch, and a null-repo run: only the same-repo id passes —

backstop filter → 111        bump-step filter → 111  pull_request  action_required

and a mocked gh run of the backstop body approved only run 111 (APPROVE …/runs/111/approve), never 222/333.

H2 — pull-request-number can be 0. Both step guards now require != '0', and the retire step rejects anything that is not a positive integer before touching a PR. Locally: NEW_PR=0 → ::error::… no usable PR number ('0'), exit 1; '' → exit 1; abc → exit 1; 123 → passes. No PR can be closed as "superseded by #0".

H3 — silent backstop success. The backstop's run list and the retire PR list are now captured into variables before the loop, so a failed gh api/gh pr list exits non-zero instead of printing "Approved 0 held run(s)". Locally with a failing gh stub → exit 1, no success line.

LOW — TOCTOU. Before closing, each PR is re-read (gh pr view --json state,headRefName,headRefOid,author) and skipped with a warning if state, branch, head SHA or author changed since listing.

LOW — create-pull-request@v6 tag. Kept at @v6 to match the repo's existing convention (bump-develop-version.yml:105); noted, not changed in this PR.

Rebased onto develop 0a6946369 (#4716) with no conflicts. Gating jobs, triggers and branch protection untouched; no merge step; no --admin; no continue-on-error added.

@github-actions github-actions Bot added the bug label Nov 30, 2026
A bump PR is opened with the workflow token, so its author is
github-actions[bot] — not a repository member. GitHub therefore holds every
pull_request workflow on it as action_required waiting for a maintainer, and
nothing approved them; each weekly bump stranded with "checks not run" and the
PRs stacked (#4711/#4712/#4713).

The same PRs are same-repo branches (isCrossRepository false), so this is the
actor-trust gate, not the fork rule. Approve the held runs from the bump
workflow itself with the workflow token (the approve endpoint accepts it): the
checks then run normally, and branch protection still requires them to pass.

When a new bump supersedes an open one, retire the older PR with a comment
naming its replacement. Only github-actions[bot] PRs on auto-bump/rustcfml-*
are touched; a validation dispatch can pass dry_run=true to leave the backlog
for a human. A six-hour scheduled sweep approves any held run that appears on
an auto-bump branch later.

Signed-off-by: Peter Amiri <peter@alurium.com>
…request

checkout@v6 stores an Authorization extraheader, and
peter-evans/create-pull-request adds its own, so git rejected the push with
"Duplicate header: Authorization" before any PR was opened (dispatch
46500319558). The bump workflow uses the API for everything else, so it does
not need checkout's persisted credential.

Signed-off-by: Peter Amiri <peter@alurium.com>
The workflow checks out develop, so a helper added by this PR is not present
when the workflow is dispatched from its own branch (dispatch 46500811318 hit
'No such file or directory'). The step is short enough to live in the workflow
and then needs no checkout dependency.

Signed-off-by: Peter Amiri <peter@alurium.com>
`gh pr close` has no `--reason` flag (that is `gh issue close`), so under
`set -euo pipefail` the retire loop died on its first iteration and closed
nothing while the scheduled run went red. Fold the explanation into
`gh pr close -c` instead.

Also harden the auto-approval path per review:
- both approval filters now require head_repository == this repo, so a fork PR
  whose branch is named auto-bump/* cannot get its held runs approved;
- `create-pull-request` reports 0 when no PR was created/found, so both guards
  require != '0' and the retire step refuses a non-positive number instead of
  closing everything as "superseded by #0";
- the retire list and the backstop run list are captured before the loop, so a
  failed `gh api`/`gh pr list` fails the step instead of reporting success with
  zero work;
- before closing, each PR is re-read and skipped if its state, head SHA, branch
  or author changed since the list was taken (TOCTOU).

Signed-off-by: Peter Amiri <peter@alurium.com>
@bpamiri
bpamiri force-pushed the fix/autobump-approval branch from 968cc7e to d309d4d Compare December 1, 2026 05:35
@bpamiri
bpamiri merged commit 33d7ec8 into develop Dec 1, 2026
21 of 22 checks passed
@bpamiri
bpamiri deleted the fix/autobump-approval branch December 1, 2026 07:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant