Repository navigation
fix(ci): supersede open flake-inputs update PR in place (#946) - #1014
Conversation
…acking a duplicate (#946)
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
Caution Review failedThe pull request is closed. Walkthrough
Merge Risk:
|
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 3c13a6314f
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| existing_number=$(gh pr list --state open --json number,headRefName \ | ||
| --jq '[.[] | select(.headRefName | startswith("automation/flake-inputs-update-"))] | .[0].number // empty') |
There was a problem hiding this comment.
Search beyond the default page before creating a replacement PR
If the existing automation PR falls outside the first 30 open PRs returned, this lookup misses it and the publish step creates another automation PR instead of updating it. gh pr list --help documents --limit as “Maximum number of items to fetch (default 30)”; the local --jq filter only filters that fetched subset. Use a server-side search or pagination that includes older matching PRs before deciding that none exists.
Useful? React with 👍 / 👎.
| if [ "${existing_title}" = "${pr_title}" ]; then | ||
| # Same revs: the open PR already carries exactly this | ||
| # update, so publishing again would only duplicate it. | ||
| echo "Open automation PR #${existing_number} already carries these exact revs (${pr_title}); reusing it and skipping publish." | ||
| pr_number="${existing_number}" | ||
| pr_url="${existing_url}" |
There was a problem hiding this comment.
Refresh the failure-issue reference when reusing unchanged pins
If an automation PR was opened before a failure issue existed, a subsequent transient validation failure can create that issue, and a later successful run with the same pins enters this branch. Skipping publication also skips updating the PR body, so the newly generated Fixes #${EXISTING_NUMBER} reference is never attached. In the protected-main handoff or auto-merge paths, the downstream comments promise that merging this PR will close the failure issue, but it remains open after merge. Refresh the PR body even when its title already matches.
Useful? React with 👍 / 👎.
| && git checkout -f -B "${existing_branch}" "origin/${existing_branch}" \ | ||
| && cp "$RUNNER_TEMP/new-flake.lock" flake.lock \ | ||
| && git add flake.lock \ | ||
| && git commit -m "${pr_title}" \ |
There was a problem hiding this comment.
Incorporate current main before publishing onto the old branch
If main independently advances either input while the automation PR remains open, copying the newly computed lock onto the old PR branch does not update its merge base. Main and the PR then contain different changes to the same locked revision, leaving the supposedly ready update unmergeable despite its lockfile being computed and validated against current main. An isolated Git fixture using this repository's lockfile reproduced a content conflict after this checkout/copy/commit sequence. Incorporate current main into the reused branch and resolve the lockfile to the computed result before pushing, rather than leaving the PR permanently conflicted across subsequent runs.
Useful? React with 👍 / 👎.
| existing_number=$(gh pr list --state open --json number,headRefName \ | ||
| --jq '[.[] | select(.headRefName | startswith("automation/flake-inputs-update-"))] | .[0].number // empty') |
There was a problem hiding this comment.
Restrict reused PRs to trusted automation branches
An external contributor can open a fork PR with this branch-name prefix and copy the expected update title while including arbitrary changes. This lookup selects that PR, and the matching-title path reuses it without checking its contents or provenance. Validation earlier in the job evaluated main with the computed lock, not the selected PR, yet the downstream logic attempts to merge that PR or comments that it is validated and ready for a privileged merge. The documented protected-main restrictions do not prevent that false validation handoff. Require a same-repository, workflow-owned PR before reuse; gh pr list --help exposes the isCrossRepository and headRepository JSON fields needed to distinguish fork heads.
Useful? React with 👍 / 👎.
What
Implements the #946 fix in the
flake-inputs-updateworkflow's publish step (.github/workflows/flake-inputs-update.yml), per the triage decision (queue task 1095): supersede an already-open automation update PR in place instead of stacking a duplicate.The publish step now, before creating anything:
automation/flake-inputs-update-*(the workflow previously had nogh pr listat all and created a PR unconditionally).flake.lockonto it, pushes to the same branch, andgh pr edits title/body to the new revs. No second PR; the PR's Fixes/handoff comments stay valid.The computed
flake.lockis copied aside before any branch switching and restored from that copy in both the update and fallback paths. Everything after publish (direct merge / auto-merge / handoff, failure-issue handling) is unchanged and simply operates on the reused-or-newpr_number.PR #974 — the live handoff PR that motivated this — is not touched by this change; it remains the fixture the next workflow run will supersede in place.
Verification
yaml.safe_load); publish-step script passesbash -nandshellcheck -s bash -S warningclean. (No actionlint in the sandbox; CI's checks will cover the workflow further.)gh pr create).checkout -f -Bonto the automation branch, restore computed lock, commit, fast-forward push,gh pr edit— one PR, updated.Closes #946 once merged.
🤖 Queue worker (repo-worker-code), task 1148.
Need help on this PR? Tag
@codesmith-botwith what you need.Summary by CodeRabbit