From a99faf592823b3bba59becc408f979c8135759d8 Mon Sep 17 00:00:00 2001 From: Brent Date: Thu, 20 Aug 2026 14:46:08 -0400 Subject: [PATCH] Stop the release reporting failure when the changeset PR is already green MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The last step of every release run does `gh pr merge --auto --squash`, and GitHub refuses to ENABLE auto-merge on a PR that is already mergeable: GraphQL: Pull request is in clean status (enablePullRequestAutoMerge) So the whole release run goes red after it has already versioned, published, and tagged successfully — the worst kind of red, because it trains everyone to ignore the status. This was unreachable until now only by accident of timing: PR checks took ~20 minutes, so the changeset PR was always still pending when this step ran. Retiring the log-viewer crate cut them to ~2 minutes, so the PR is now routinely green first and the race inverted. Falls back to a plain `--squash` when `--auto` is refused, but only after confirming every check is pass/skipping. Note it does NOT use `gh pr checks --required`: this repo has no required checks configured, so that returns an empty list and would read as green — a guard that checks the wrong thing. An empty bucket list is treated as NOT green, so it fails closed. Co-Authored-By: Claude Fable 5 Claude-Session: https://claude.ai/code/session_0152bbE1veqfG1SVJdyLCBxC --- .github/workflows/release.yml | 34 +++++++++++++++++++++++++++++----- 1 file changed, 29 insertions(+), 5 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 5243aee8..4585b228 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -171,13 +171,37 @@ jobs: run: | PR_NUMBER=$(gh pr list --state open --head changeset-release/main --json number --jq '.[0].number') - if [[ -n "$PR_NUMBER" && "$PR_NUMBER" != "null" ]]; then - echo "Found Changeset PR #$PR_NUMBER, attempting to auto-merge..." - gh pr merge "$PR_NUMBER" --auto --squash + if [[ -z "$PR_NUMBER" || "$PR_NUMBER" == "null" ]]; then + echo "No open Changeset PR found, skipping merge." + exit 0 + fi + + echo "Found Changeset PR #$PR_NUMBER, attempting to auto-merge..." + + # `--auto` queues the merge behind pending checks, but GitHub REFUSES to + # enable it once a PR is already green: + # GraphQL: Pull request is in clean status (enablePullRequestAutoMerge) + # That used to be unreachable because PR checks took ~20 minutes; they now + # take ~2, so the changeset PR is routinely green before this step runs and + # the whole release run reports failure even though it published fine. + # Fall back to merging outright — but only after confirming the checks are + # green, so this never merges over a red lane. + if gh pr merge "$PR_NUMBER" --auto --squash; then # The merge push automatically triggers the Release workflow # so no need to manually re-trigger it - else - echo "No open Changeset PR found, skipping merge." + exit 0 + fi + + echo "Auto-merge was refused; checking whether #$PR_NUMBER is already green." + # Deliberately NOT `gh pr checks --required`: this repo has no required + # checks configured, so that would return an empty list and read as green. + # Every lane must be pass/skipping, and there must be at least one. + BUCKETS=$(gh pr checks "$PR_NUMBER" --json bucket --jq '[.[].bucket] | join(" ")' || echo "") + echo "Check buckets: [$BUCKETS]" + if [[ -z "$BUCKETS" ]] || [[ -n "$(tr ' ' '\n' <<<"$BUCKETS" | grep -vx -e pass -e skipping)" ]]; then + echo "::error::Changeset PR #$PR_NUMBER is not green ([$BUCKETS]); refusing to merge." + exit 1 fi + gh pr merge "$PR_NUMBER" --squash env: GH_TOKEN: ${{ secrets.GH_PAT }}