Skip to content

fix(smoke): reclaim deploy PRs by branch so a partial create stays recoverable - #1505

Merged
c-vigo merged 3 commits into
devfrom
bugfix/1499-reclaim-partial-deploy-pr
Aug 14, 2026
Merged

c-vigo merged 3 commits into
devfrom
bugfix/1499-reclaim-partial-deploy-pr

Conversation

@c-vigo

@c-vigo c-vigo commented Aug 14, 2026

Copy link
Copy Markdown
Contributor

Description

On the 1.9.0 rc1 train the smoke listener's deploy job failed on a transient GraphQL 500 whose wording was pull request update failed — update, not create. gh pr create --label creates the PR and then labels it in a second mutation: the create had succeeded (devkit-smoke-test#367 existed), the labelling is what 500'd, and the step exited 1.

Two consequences: pr_url never reached GITHUB_OUTPUT, so every downstream job skipped; and an unlabelled deploy PR was left open. Close stale deploy PRs selected candidates with --label deploy only, so that orphan was invisible to it — the documented recovery (re-run the failed jobs) re-entered the create and failed with "a pull request already exists" until a human added the label by hand.

The structural point: the one step whose partial success is most likely was the one the cleanup could not reclaim.

Type of Change

  • fix -- Bug fix

Modifiers

  • Breaking change (!) -- This change breaks backward compatibility

Changes Made

All in assets/smoke-test/.github/workflows/repository-dispatch.yml (the SSoT for the listener):

  1. Reclaim by head branch, not just by label. Close stale deploy PRs now selects every open PR on chore/deploy-* as well as any carrying the deploy label (one gh pr list --json number,headRefName,labels --limit 100 call). The branch name is deterministic and is pushed before the PR exists, so unlike the label it cannot be lost to a partial failure.
  2. Adopt, then record, then label. Create or adopt deploy PR first looks for an open PR on ${BRANCH_NAME} and adopts it instead of dying on "already exists", and writes pr_url to GITHUB_OUTPUT immediately — before anything else can fail.
  3. Labelling is its own step. Label deploy PR retries gh pr edit --add-label deploy three times with backoff and is non-fatal: now that the cleanup reclaims by branch, an unlabelled PR is still recoverable, so a label transient must not strand pr_url.
  4. notify-failure retries. The same transient class killed its gh issue create 20 s later, so no upstream incident issue was filed at all and [BUG] A partially-created deploy PR is invisible to the smoke listener's stale-PR cleanup, so re-run recovery fails #1499 had to be written by hand. It now retries three times and fails loudly if the issue never lands.

Changelog Entry

### Fixed

- **Smoke listener: a partially-created deploy PR is recoverable again**
  ([#1499](https://github.com/vig-os/devkit/issues/1499))
  - `gh pr create --label` labels in a second mutation. When that mutation hit
    a transient GraphQL 500 on the 1.9.0 rc1 train, the step failed *after*
    creating the PR: `pr_url` never reached `GITHUB_OUTPUT` (so every
    downstream job skipped) and an unlabelled deploy PR was left open, which
    the label-only stale-PR cleanup could not see. The documented recovery --
    re-run the failed jobs -- then deadlocked on "a pull request already
    exists" until a human labelled the PR by hand
  - Stale deploy PRs are now reclaimed by head branch (`chore/deploy-*`) as
    well as by label; the branch name is pushed before the PR exists, so no
    partial failure can lose it
  - The deploy step adopts an open PR already on the deploy branch instead of
    failing on it, and records `pr_url` before any labelling; labelling moved
    to its own retrying, non-fatal step
  - `notify-failure` retries the upstream incident issue, which died to the
    same transient 20 s later and filed nothing at all

Testing

  • Tests pass locally
  • Manual testing performed (describe below)

New suite tests/test_smoke_deploy_pr_reclaim.py (12 tests), following the harness pattern established by #1477's tests/test_smoke_dispatch_wait.py:

  • Shape — parses the listener YAML: the cleanup selects on headRefName and the label; the create step no longer passes --label; pr_url is recorded before a separate label step that consumes it; the label step contains no exit 1; notify retries.
  • Behaviour — executes each step's real bash against a stubbed gh (and a no-op sleep), replaying the rc1 timeline. --jq filters run through the real jq, so the selector under test is the one that runs:
    • an unlabelled PR on chore/deploy-1-9-0-rc1 is closed, a labelled legacy deploy PR is still closed, an unrelated feature/* PR is never touched
    • with labelling 500'ing on every attempt, pr_url still reaches GITHUB_OUTPUT and the job stays green
    • with an open PR already on the deploy branch, gh pr create is never called and the adopted url is recorded
    • two labelling 500s then success → three gh pr edit calls, exit 0
    • two notify 500s then success → three gh issue create calls; exhausted retries fail the step

Manual Testing Details

Run locally in a worktree:

  • prek run --all-files — full hook suite green (includes yamllint, shellcheck, actionlint, typos, sync-manifest)
  • uv run pytest tests --ignore=tests/test_image.py --ignore=tests/test_integration.py --ignore=tests/test_flake_checks.py — 740 passed, 1 skipped (container/image and nix flake check suites are CI-only; they need the built image)
  • bats tests/bats/just.bats — 57 passed, including the existing smoke-listener contract assertions
  • actionlint assets/smoke-test/.github/workflows/repository-dispatch.yml — clean (the hook only auto-discovers this repo's own .github/workflows/, so the asset was linted explicitly)

Checklist

  • My code follows the project's style guidelines
  • I have performed a self-review of my code
  • I have commented my code, particularly in hard-to-understand areas
  • I have updated the documentation accordingly
  • I have updated CHANGELOG.md in the [Unreleased] section (and pasted the entry above)
  • My changes generate no new warnings or errors
  • I have added tests that prove my fix is effective
  • New and existing unit tests pass locally with my changes
  • Any dependent changes have been merged and published

Additional Notes

This PR does not make the fix live. repository_dispatch always runs the listener from the smoke-test repo's default branch, so the asset here reaches devkit-smoke-test main only through that repo's own release cycle (docs/CROSS_REPO_RELEASE_GATE.md §Contract dependencies). A mirror hotfix on devkit-smoke-test main follows this merge, so the next train is covered and the next scaffold deploy converges rather than reverts — same dance as devkit-smoke-test#345 / #353.

docs/CROSS_REPO_RELEASE_GATE.md gains the reclaim invariant plus a Failure Signals entry for pull request update failed, including what to do on a listener version that predates this fix (add the label by hand before re-running).

Refs: #1499

@c-vigo c-vigo added bug Something isn't working area:ci CI/CD, GitHub Actions, workflows labels Aug 14, 2026
@c-vigo c-vigo added this to the 1.9.1 milestone Aug 14, 2026
@c-vigo
c-vigo enabled auto-merge August 14, 2026 07:33
@c-vigo
c-vigo merged commit dc3acf1 into dev Aug 14, 2026
12 checks passed
@c-vigo
c-vigo deleted the bugfix/1499-reclaim-partial-deploy-pr branch August 14, 2026 07:39
c-vigo added a commit to vig-os/devkit-smoke-test that referenced this pull request Aug 14, 2026
…erable (#373)

Hot-deploy of the listener fix from
[vig-os/devkit#1505](vig-os/devkit#1505)
directly to `main`, since the `repository_dispatch` listener executes
from this repo's **default branch** — a fix that only rides the normal
deploy path (next train's deploy PR to `dev`, then release to `main`)
would not protect the very trains that fail.

## What it fixes

On the 1.9.0 rc1 train the `deploy` job failed on a transient GraphQL
500 reading **`pull request update failed`** — *update*, not *create*.
`gh pr create --label` creates the PR and labels it in a **second**
mutation: the create had succeeded
([#367](#367) existed),
the labelling is what 500'd, and the step exited 1. So `pr_url` never
reached `GITHUB_OUTPUT` (every downstream job skipped) and an
**unlabelled** deploy PR was left open — invisible to a `Close stale
deploy PRs` that selected on `--label deploy` alone. Re-running the
failed jobs then deadlocked on *"a pull request already exists"* until
the label was added by hand.

## Changes

1. Stale deploy PRs are reclaimed by **head branch** (`chore/deploy-*`)
as well as by label. The branch name is deterministic and pushed before
the PR exists, so no partial failure can lose it.
2. `Create or adopt deploy PR` adopts an open PR already on the deploy
branch instead of failing on it, and records `pr_url` before anything
else can fail.
3. Labelling moved to its own step: three attempts with backoff,
non-fatal (the cleanup reclaims by branch, so an unlabelled PR stays
recoverable).
4. `notify-failure` retries `gh issue create` — it died to the same
transient 20 s later, so no upstream incident issue was filed at all and
vig-os/devkit#1499 had to be written by hand.

## Provenance

The file is a byte-exact copy of the fixed devkit asset
(`assets/smoke-test/.github/workflows/repository-dispatch.yml` on
vig-os/devkit#1505), so the next scaffold deploy converges rather than
reverts. Before this change the live listener on `main` was
byte-identical to the devkit asset, so this PR carries only that fix —
the same 72/15 diff.

`dev` is intentionally **not** patched: the next train's deploy PR
carries the fixed asset from the devkit release tag and converges `dev`
with identical content.

Tested upstream by `tests/test_smoke_deploy_pr_reclaim.py` (12 tests),
which executes these steps' real bash against a stubbed `gh` — including
the rc1 replay: an unlabelled deploy PR gets closed, and a labelling
failure leaves `pr_url` recorded and the job green.

Refs: [#1499](vig-os/devkit#1499)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:ci CI/CD, GitHub Actions, workflows bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant