Skip to content

fix: PR hygiene runs every event to the end and lets the newest payload decide (#526) - #528

Merged
CaffeinatedCoder merged 1 commit into
mainfrom
fix/526-hygiene-cancels
Oct 29, 2026
Merged

CaffeinatedCoder merged 1 commit into
mainfrom
fix/526-hygiene-cancels

Conversation

@CaffeinatedCoder

Copy link
Copy Markdown
Owner

Closes #526

Problem

pr-hygiene.yml had concurrency: { group: pr-hygiene-<number>, cancel-in-progress: true }. A PR pushed and then labelled and described within seconds starts one run per event, and the group cancelled every run still going when the next one started. GitHub counts each run in the commit's status, and a cancelled run counts as failing. So 61 of the last 100 merged PRs show a red status for nothing but cancelled hygiene runs, with every other check green. For example, #520 has three cancelled runs and one green one.

Dropping the group alone doesn't fix it. Measured on #527: five events in seven seconds all ran to the end, but the two whose payloads failed (no labels yet; two type labels at once) left the status FAILURE beside a green latest run.

Change

.github/workflows/pr-hygiene.yml:

  • No concurrency group, so no run is cancelled.
  • A first step waits 20 s for a burst of events to settle. Then it compares its payload's head SHA, base, labels and description with the PR as it is now (gh api with the read-only GITHUB_TOKEN, so pull-requests: read). If any of them changed, the event that changed it started a newer run, which decides, and this run passes without checking. Only those four fields are compared, because a change to any of them is itself a trigger (synchronize, edited, labeled, unlabeled). A milestone or assignee change can't make the newest run skip itself.
  • The checkout and pr-hygiene.sh run only when the payload is current. The script is unchanged and still needs no token.
  • The header records what was measured.

No changelog row: CI only, like #410.

Tests

On the throwaway PR #527 (CI workflows removed on that branch; a payload without labels held back 60 s so it finishes last):

Scenario Runs Cancelled Commit status
No group, no comparison: open, label, edit body, add a second type label, remove it 5 0 FAILURE (two stale payloads failed)
This change: push, label, edit body, add a second type label, remove it 5 0 SUCCESS (3 superseded, 2 checked)
This change: remove the label (held 60 s), put it back 3 s later 2 0 SUCCESS (the held run finished 55 s after its replacement and passed as superseded)
This change: remove the type label and leave it 1 0 the newest run checked the PR and failed: "Needs exactly one type label"

The last row is the fail-closed check. If the payload and the API spelled a field differently, every run would pass as superseded. Here the newest run compared equal and judged.

A run that judged a payload the PR really had (labels missing at that moment) still stays red after the labels are fixed, as before. Only a re-run clears it.

Once this merges, it gets cherry-picked with -x into release/10.x, because the workflow runs from the PR's base.

🤖 Generated with Claude Code

…ad decide (#526)

The concurrency group cancelled every run still going when the next event
arrived, and GitHub counts a cancelled run in the commit's status: 61 of the
last 100 merged PRs showed FAILURE for nothing but cancelled hygiene runs.

The group is gone, so no run is cancelled. Each run waits 20 s for a burst
of events to settle, then compares its payload's head, base, labels and
description with the PR as it is now. If any changed, the event that changed
it started a newer run, so this one passes without checking. Measured on the
throwaway PR #527; the numbers are in the workflow's header.

Found-By: IS
Defect-Class: PKG
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@CaffeinatedCoder CaffeinatedCoder added this to the 11.0.0 milestone Oct 29, 2026
@CaffeinatedCoder CaffeinatedCoder added bug Something isn't working area/release Versioning, changelogs, release wiring severity/low Cosmetic, message or documentation-level difference labels Oct 29, 2026
@CaffeinatedCoder
CaffeinatedCoder merged commit 176bcd3 into main Oct 29, 2026
14 checks passed
@CaffeinatedCoder
CaffeinatedCoder deleted the fix/526-hygiene-cancels branch October 29, 2026 14:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/release Versioning, changelogs, release wiring bug Something isn't working severity/low Cosmetic, message or documentation-level difference

Projects

None yet

Development

Successfully merging this pull request may close these issues.

PR hygiene cancels most of its own runs

1 participant