Repository navigation
[16.0-stable] pr-gate: fix PR identification behind a finished build - #6693
Merged
rene merged 5 commits intoOct 7, 2026
Merged
Conversation
The GITHUB_TOKEN handed to a job inherits whichever scope the
repository default grants when a workflow does not declare its own
permissions:. pr-gate.yml's eden-gate job uses gh CLI to read PR
review state and the upstream build run; grant actions: read and
pull-requests: read over a permissions: {} default.
This is the pr-gate.yml part of the upstream commit only; the other
workflows it scoped are left as they are on this branch.
Signed-off-by: eriknordmark <erik@zededa.com>
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
(cherry picked from commit 0474ec0)
The gate found the PR behind a finished PR build with an issue search on the built commit and took the first hit. That search matches every open PR whose commit list contains the commit, so a stacked PR matches its parent's head too and the winner is decided by relevance ranking. The gate then judged the neighbour's approval state, and on a pass Eden tested the neighbour's image while publishing its verdict against the commit that was actually built. When the neighbour was unapproved the gate declined instead, and because the declining path skips every downstream job the PR showed no Eden row at all and nothing said why. Enumerate the open PRs and keep the one whose head is the built commit, taking the base branch from the same answer so a neighbour targeting a different branch cannot select the wrong suite set. Neither obvious alternative works here: the commit-to-PR endpoint returns nothing for a PR raised from a fork, and the workflow_run payload's pull_requests list is empty for those same PRs. Refuse to guess when several open PRs share a head commit, and distinguish a failed lookup from a genuine "not approved" rather than letting an empty PR number reach gh pr view. A declined gate now publishes the Eden Runner status itself, carrying the reason, so the common and legitimate case of an unreviewed PR reads as pending on the PR instead of as a missing check. Signed-off-by: eriknordmark <erik@zededa.com> Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> (cherry picked from commit 3133d58)
The gate's concurrency group asked the finished build's payload for the PR number, but that list is empty for a PR raised from a fork, which is almost every PR here. The expression fell through to a branch meant for review events, where a build-triggered run has no pull_request to read and the run id makes the group unique every time. Gate runs therefore never shared a group and nothing was ever superseded, so a burst of pushes left a queue of gates for commits already overtaken. Where the payload did carry PR numbers, on a same-repo PR, taking the first of them could put two stacked PRs in one group and let either cancel the other. Key the group on the repository and branch the build came from, which the payload always carries and which a stacked PR has its own copy of. Group names share one namespace across the whole repository, so prefix the workflow name as every other workflow here does. Signed-off-by: eriknordmark <erik@zededa.com> Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> (cherry picked from commit fd14184)
A gate run started by a review takes its workflow file from the pull request's head, so GitHub caps its token at read-only whenever that head lives in a fork. The commit status announcing a declined gate then fails with 403 and turns the whole Ready for Eden job red, on a path where the gate itself reached the right verdict. Restrict the status write to the leg that runs off a finished build, where the workflow file comes from the base branch and the token can carry statuses: write. Announcing the reason on the review leg as well requires the trusted workflow to do the writing. Signed-off-by: eriknordmark <erik@zededa.com> Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> (cherry picked from commit 81c663a)
rene
approved these changes
Oct 2, 2026
4 of 7 tasks
Three steps append to GITHUB_OUTPUT one echo at a time, which shellcheck flags as SC2129. Write each set of outputs through a single grouped redirect instead; the outputs themselves are unchanged. Signed-off-by: eriknordmark <erik@zededa.com> Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> (cherry picked from commit 989636b)
rene
approved these changes
Oct 7, 2026
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.
Description
Backport of #6595, plus part of #6698, to
16.0-stable.The PR gate identified the PR behind a finished
PR buildwith an issuesearch on the built commit and took the first hit, which for stacked PRs can
be a neighbour; when the search matched nothing (a force-push during a build)
the job crashed instead of declining. #6595 resolves the PR by head-commit
identity, keys the concurrency group on the source repository and branch, and
publishes a pending
Eden Runnerstatus when the gate declines. See #6595 forthe full analysis.
Commits, all
git cherry-pick -xfrom master:pr-gate: add scoped permissions block— thepr-gate.ymlpart only of0474ec035("github/workflows: add scoped permissions blocks"), which thisbranch lacks. The first fix commit adds
statuses: writeto the job-levelpermissions:block that commit created; without it the job would run withthe repository's default token, which is write-all. The other workflows
that commit scoped are left unchanged here.
pr-gate: resolve the built PR by head commit(3133d5806)pr-gate: group gate runs by source branch(fd14184ea)pr-gate: report a decline only where it can write(81c663a60)pr-gate: group writes to GITHUB_OUTPUT(989636b13) — thepr-gate.ymlcommit of actionlint: re-enable shellcheck #6698. Its other commit, which re-enables shellcheck in master's
Workflow Lint configuration, is not backported: this branch has no Workflow Lint.
Commits 2–5 apply cleanly, and their diffs are identical to those on master. With
commit 1,
pr-gate.ymlon this branch is byte-identical to master's.PR dependencies
None.
How to test and validate this PR
As with #6595, this PR cannot exercise its own change:
PR buildignores.github/**, and aworkflow_rungate always runs master's copy of theworkflow. The
pull_request_reviewleg runs this branch's copy, so after mergecheck the gate log on the next review of a
16.0-stablePR: the resolved PRshould match the reviewed one. The change touches no other file.
Checked on this branch:
eden-trusted.ymluses the sameEDEN_IN_PR_STATUS_TITLE_PREFIX(Eden Runner) andbuild.ymlthe sameworkflow name (
PR build) that the gate relies on.Changelog notes
None. CI tooling only, no user-facing changes.
PR Backports
Checklist
For backport PRs (remove it if it's not a backport):
And the last but not least:
check them.
Device testing does not apply: the change touches a GitHub Actions workflow
only.
🤖 Generated with Claude Code