slash-commands/status: force pending on synchronize to close auto-merge race
When new commits are pushed, the status job and handle job both fire on the same synchronize event and run in parallel. The event payload's pr.labels reflect the PRE-push state — so if the PR was approved before the push, the status job reads 'approved' from the payload and sets success on the NEW SHA, even though handle is about to (or already did) remove the label. Observed in modelcontextprotocol#2375: label removed at 23:06:29, status set success at 23:06:30 (one second later, from stale payload), merged at 23:06:34. Fix: add invalidate-on-push input (default true, mirroring the main action). On synchronize with invalidation enabled, set pending unconditionally — don't trust the payload labels. The subsequent unlabeled event re-evaluates and stays pending.
This commit is contained in:
parent
ae45899358
commit
60ed112c52
1 changed files with 40 additions and 11 deletions
|
|
@ -208,11 +208,17 @@ enforces. Make the `status-context` value a required status check.
|
|||
|
||||
**States:**
|
||||
|
||||
| Labels | Commit status | Description |
|
||||
| Condition | Commit status | Description |
|
||||
|---|---|---|
|
||||
| `synchronize` event + `invalidate-on-push: true` | `pending` (🟡) | New commits — re-approve |
|
||||
| `do-not-merge/hold` present | `failure` (❌) | Blocked by hold |
|
||||
| `approved` present, no hold | `success` (✅) | Approved via /lgtm |
|
||||
| neither | `pending` (🟡) | Awaiting /lgtm |
|
||||
| otherwise | `pending` (🟡) | Awaiting /lgtm |
|
||||
|
||||
The `synchronize` special-case is a race guard: the event payload's labels
|
||||
reflect the *pre-push* state, so without it this action would read a stale
|
||||
`approved` and set `success` on the new SHA while the `handle` job is still
|
||||
removing the label in parallel — letting auto-merge slip through.
|
||||
|
||||
**Inputs:**
|
||||
|
||||
|
|
@ -222,6 +228,7 @@ enforces. Make the `status-context` value a required status check.
|
|||
| `approved-label` | | `approved` | Must match the main action's `approved-label` |
|
||||
| `hold-label` | | `do-not-merge/hold` | Must match the main action's `hold-label` |
|
||||
| `status-context` | | `slash-commands/approval` | Name shown in the merge box. Mark this as a required status check. |
|
||||
| `invalidate-on-push` | | `'true'` | On `synchronize`, force pending regardless of labels. **Must match** the main action's `invalidate-on-push`. Disabling this opens an auto-merge race. |
|
||||
|
||||
**Outputs:**
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue