fix: stop poetry-lock-update from opening duplicate PRs - #49
Merged
Conversation
…cs, test coverage)
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.
References
Description
actions/poetry-lock-updategenerated a random branch suffix on every runand unconditionally opened a new PR whenever
poetry.lockchanged. If aprior week's update PR was still open when the next scheduled run fired,
this opened a second, competing PR instead of refreshing the first —
duplicate PRs pile up on any repo where the update isn't merged promptly.
This PR makes the action reuse a single, fixed branch and update the
existing open PR in place instead.
Changes
actions/poetry-lock-update/decide_pr_action.sh(new): given a branch,checks for an existing open PR (
gh pr list --head "$BRANCH" --state open) and eithergh pr edits it (refreshing body + reapplying labels)or
gh pr creates a new one. A merged or manually-closed PR is not"open", so the next run naturally opens a fresh PR — no extra state is
tracked to remember a rejection.
actions/poetry-lock-update/test_decide_pr_action.sh(new): tests bothbranches (PR found / not found) and both dry-run variants via a mocked
gh, wired into.github/workflows/tests.yml'stest_scriptsjob.actions/poetry-lock-update/action.yml: drops the random branch suffix,force-pushes the fixed
${{ inputs.branch }}branch every run (safe —it's exclusively bot-owned and rebuilt fresh from the base each time),
and delegates the create-vs-update decision to the new script.
.github/workflows/tests.yml:test_poetry_lock_updatejob gets apull-requests: readpermission override for the newgh pr listread.README.md/CLAUDE.md: documented the new behavior, including thatthe branch is force-pushed every run and shouldn't carry manual commits.
.gitignore: added.worktrees/(unrelated housekeeping needed to setup an isolated workspace for this change).
Backwards-incompatible changes
None. Consumers (e.g.
octave_kernel'slock-update.yml) need no inputchanges — this is a drop-in behavioral improvement. Note: any pre-existing
randomly-suffixed branches/PRs from before this change are orphaned (not
cleaned up by this PR); the first post-merge run creates the new canonical
poetry-lock-updatebranch alongside them.Testing
bash actions/poetry-lock-update/test_diff_lock.shandbash actions/poetry-lock-update/test_decide_pr_action.sh— both pass(18 assertions total)
just pre-commit --hook-stage=manual(includesactionlint) — all hookspass
just test— placeholder suite passestest_decide_pr_action.sh's mockedgh, but has no CI fixtureexercising it against a genuinely open PR end-to-end (deliberately
creating one in CI would itself produce the exact duplicate-PR noise
this change removes)
AI usage