- Notifications
You must be signed in to change notification settings - Fork 0
fix(stub): stop a stale run from drafting a PR a newer commit fixed#14
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Uh oh!
There was an error while loading. Please reload this page.
Changes from all commits
File filter
Filter by extension
Conversations
Uh oh!
There was an error while loading. Please reload this page.
Jump to
Uh oh!
There was an error while loading. Please reload this page.
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|
| @@ -26,6 +26,13 @@ on: | ||||||||||
| # repository whether it is still clean; you have to push something to find out. | ||||||||||
| workflow_dispatch: | ||||||||||
| # One verdict at a time, per branch. Without this the ready_for_review retry | ||||||||||
| # path lets an older run finish after a newer one: the stale failure would put | ||||||||||
| # a pull request back into draft that the newer commit already fixed. | ||||||||||
| concurrency: | ||||||||||
| group: ${{ github.workflow }}-${{ github.head_ref || github.ref }} | ||||||||||
| cancel-in-progress: true | ||||||||||
Comment on lines
+33
to
+34
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🎯 Functional Correctness | 🟠 Major | ⚡ Quick win 🔎 Supported by static analysis🏁 Script executed: sed -n '20,42p;68,94p' stub/post-commit.yml
printf'\n--- workflow references ---\n'
rg -n "JUDGED|gh pr ready|pull_request|concurrency|head_ref|head.repo|repo.full_name" stub/post-commit.ymlRepository: kodflow/post-commit Length of output: 2738 🌐 Web query:
💡 Result: In GitHub Actions, the Citations:
Qualify the concurrency key by the source repository.
Include Proposed key- group: ${{ github.workflow }}-${{ github.head_ref || github.ref }}+ group: ${{ github.workflow }}-${{ github.event.pull_request.head.repo.full_name || github.repository }}-${{ github.head_ref || github.ref }}📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents | ||||||||||
| permissions: | ||||||||||
| contents: read | ||||||||||
| @@ -67,6 +74,16 @@ jobs: | ||||||||||
| GH_TOKEN: ${{ github.token }} | ||||||||||
| PR: ${{ github.event.pull_request.number }} | ||||||||||
| REPO: ${{ github.repository }} | ||||||||||
| JUDGED: ${{ github.event.pull_request.head.sha }} | ||||||||||
| run: | | ||||||||||
| # Cancellation narrows the race but does not close it: this job can | ||||||||||
| # already be running when a newer commit lands. Only act if the head | ||||||||||
| # this run judged is still the head, or a stale failure would undo a | ||||||||||
| # ready state that a later, passing commit earned. | ||||||||||
| CURRENT="$(gh pr view "$PR" -R "$REPO" --json headRefOid --jq .headRefOid)" | ||||||||||
| if [ "$CURRENT" != "$JUDGED" ]; then | ||||||||||
Comment on lines
+83
to
+84
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 3. Head check remains racy The head comparison is a time-of-check/time-of-use guard: a newer commit can land after gh pr view returns the judged SHA but before gh pr ready --undo executes. If cancellation reaches the old run after the mutation has begun, that stale failure still drafts the PR and reproduces the defect this change intends to prevent. Agent Prompt
| ||||||||||
| echo "::notice::head moved on from ${JUDGED:0:8} to ${CURRENT:0:8}; the newer run owns the verdict. Not drafting." | ||||||||||
| exit 0 | ||||||||||
Comment on lines
+83
to
+86
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 1. headrefoid check lacks tests The PR adds a stale-head decision path that controls whether a pull request is drafted, but adds no corresponding behavioral test. Existing CI only parses the workflow YAML, so regressions in the SHA comparison and early-exit behavior would pass validation. Agent Prompt
| ||||||||||
| fi | ||||||||||
Comment on lines
+83
to
+87
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🩺 Stability & Availability | 🟠 Major | 🏗️ Heavy lift 🔎 Supported by static analysis🏁 Script executed: sed -n '1,110p' stub/post-commit.ymlRepository: kodflow/post-commit Length of output: 4398 🌐 Web query:
💡 Result: The GitHub REST API endpoint to update a pull request is PATCH /repos/{owner}/{repo}/pulls/{pull_number} [1][2]. You can toggle a pull request's draft status by passing the draft boolean parameter in the request body [1][3]. Regarding your query about If-Match and optimistic concurrency: 1. Optimistic Concurrency with If-Match: The GitHub REST API does not universally use the If-Match header for "optimistic concurrency" across all PATCH endpoints (including pull request updates) to prevent concurrent modification conflicts in the way it is implemented in some other REST APIs [1][3]. While certain specific API operations (like those involving file contents or specific merge operations) may utilize SHA-based validation [4][5], the standard "Update a pull request" endpoint does not require or document an If-Match header for concurrency control [1][3]. 2. Pull Request Head Concurrency: If your goal is to ensure a pull request is merged or updated based on a specific commit head, the API provides mechanisms for that context. For example, when merging a pull request (via PUT /repos/{owner}/{repo}/pulls/{pull_number}/merge), you can optionally provide a sha parameter [5]. If provided, this SHA must match the pull request's current head; if the pull request is updated (pushed to) between the time you request the merge and the time it executes, the merge is cancelled to prevent unintended commits from being included [5]. In summary, for simply updating the draft status of a pull request, you perform a PATCH request with the draft parameter [1][3]. There is no standard If-Match optimistic concurrency mechanism for this specific update action [1]. Citations:
Treat stale-head protection as best effort.
🤖 Prompt for AI Agents | ||||||||||
| gh pr ready --undo "$PR" -R "$REPO" | ||||||||||
| echo "::notice::post-commit failed — pull request put back into draft. Fix the history, then mark it ready: that re-runs the gate." | ||||||||||
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
2. Fork branches cancel each other
🐞 Bug≡ CorrectnessAgent Prompt
ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools