Skip to content

feat(upgrade): report a failed devkit upgrade as a tracking issue - #1535

Merged
c-vigo merged 3 commits into
devfrom
feature/1530-upgrade-failure-issue
Aug 17, 2026
Merged

c-vigo merged 3 commits into
devfrom
feature/1530-upgrade-failure-issue

Conversation

@c-vigo

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

Copy link
Copy Markdown
Contributor

Summary

Implements the failure alert from #1530: today a failed devkit-upgrade run leaves no artifact in the consumer repo (the remote ref only appears in the late Publish step), so a broken upgrade fails silently every week — observed live at org-config run 32002045870.

  • New report job in the scaffold devkit-upgrade.yml, gated !cancelled() && (needs.upgrade.result == 'failure' || == 'success') — a separate job rather than a late step so a job abort (timeout, lost runner) still reports, and resolve-step failures are covered for free. Silent on cancelled runs.
  • Failure leg: opens or re-uses a single tracking issue per repo, found by an HTML body marker with a version-free title (chore(devkit): automated devkit upgrade is failing) so a different target on the next failure lands in the same issue. Body carries the run URL, the failing step (read from the run's own job records via actions: read), and pinned vs target version (unknown when resolve itself died). Lookup via direct gh issue list, not the eventually-consistent search index. No label dependency.
  • Success leg: any fully green run (including no-ops) closes the open tracking issue with the green run URL — a fixed upgrade self-cleans, per the issue spec.
  • Degraded mode: the Issues grant is minted as a separate permission-issues: write token with continue-on-error — create-github-app-token fails a mint requesting an ungranted permission, so putting it on the primary mint would turn green upgrades red. All report steps are best-effort: without the grant the leg degrades to a ::warning:: and the upgrade path behaves exactly as today. (Both org installations of vigos-devkit-upgrade already have issues: write accepted, verified via API — so this fires for real from day one.)
  • Not a revert of refactor: drop the per-train adoption issue from devkit-upgrade.yml #1405: the success path still produces no adoption issue (pinned by test).

Review caught and fixed one real bug in the initial implementation: the job-level if lacked a status-check function, so the implicit success() gate would have skipped the report job on exactly the failed runs it exists for — now !cancelled()-gated and pinned by test.

Rollout note: consumers get this one train after it ships (the cron runs the workflow from their base branch).

Test plan

  • tests/test_workflow_devkit_upgrade.py: 26 passed (7 new structural pins: result-gated job, issues-only mint, marker + list-before-create, version-free title, env plumbing, close leg, !cancelled() gate; TDD red first: 7 failed)
  • tests/bats/devkit-upgrade-alert.bats (new): 9/9 — executes the extracted run: blocks against a stub gh (create vs comment vs close branching, unknown-target, missing-grant no-ops)
  • bats tests/bats/init-workspace.bats 257/257; release-mirror-fold-lint.bats 4/4 (typos + actionlint over the full render, both models)
  • prek run --all-files exit 0 (verified independently of the implementation run)

Closes #1530

c-vigo added 3 commits August 17, 2026 11:13
A failed devkit-upgrade leaves no artifact in the consumer repo today: the
adoption branch only reaches the remote in the publish step, so a resolve,
scaffold or in-shell-commit failure is visible only as a red scheduled run
(live: vig-os/org-config run 32002045870).

Two suites, both red:

- tests/test_workflow_devkit_upgrade.py pins the wiring — a separate
  result-gated `report` job (a step-level `if: failure()` cannot survive a
  job-level abort), an issues-scoped best-effort mint kept off the upgrade
  job's token, marker-based lookup before create, close-on-success, and the
  resolve outputs the alert names.
- tests/bats/devkit-upgrade-alert.bats executes the rendered `run:` blocks
  against a stub `gh` (the release-mirror-fold idiom) to cover the branching
  the structural pins cannot: create vs comment vs close, an unrelated open
  issue, an unresolved target, and the missing-grant degradation.

Refs: #1530
A failed run left no artifact in the consumer repo: the adoption branch only
reaches the remote in the publish step, so a resolve, scaffold or in-shell-commit
failure showed up only as a red scheduled run, and the pin then stopped moving
(live: vig-os/org-config run 32002045870, stuck on 1.9.0).

The new `report` job files ONE tracking issue per repo, comments on that same
issue on every repeat failure, and closes it on the next fully green run. It is
not a revert of #1405: that removed the SUCCESS-path adoption issue, where the
bot PR is already the artifact; this covers the failure path, where by
construction there is none. The rejected alternative stands rejected — nothing
half-applied is pushed, per #1308.

Design decisions:

- A separate `needs: upgrade` job rather than a late `if: failure()` step. A
  step never runs once the job itself is aborted (the 30-minute timeout, a lost
  runner), which is one of the silent failures being closed. Keying both legs on
  `needs.upgrade.result` covers a resolve-step failure (malformed pin, missing
  DEVKIT_VERSION) for free and stays quiet on a cancelled run.
- The issues grant is a SEPARATE, `continue-on-error` mint, not an extra
  `permission-issues: write` on the upgrade job's token.
  create-github-app-token fails the mint when it requests a permission the
  installation lacks, and this App has needed no Issues grant since #1405, so
  adding it to the primary mint would turn every green upgrade red on an org
  that has not re-granted it. Reporting may never break the path it reports on:
  without the grant both legs emit a warning and exit 0.
- De-duplication keys on an HTML body marker, so the title can stay
  version-free — a failure on a different target finds the same open issue and
  no title goes stale. `gh issue list` reads the REST index, not the
  eventually-consistent search index.
- The failing step name comes from the run's own job records via the default
  token (`actions: read`), so no per-step instrumentation has to be kept in
  sync. Versions come from the resolve step, promoted to job outputs, with
  `current` published before anything below it can fail.
- Closing on ANY green run, including the "already current" and
  DEVKIT_AUTO_UPGRADE=false no-ops: the workflow ran end to end, so the
  recorded failure no longer reproduces, and an opted-out consumer should not
  keep an open alert.

Org action required: grant Issues (write) to the devkit-upgrade App installation.
Until then the upgrade path is unchanged and reporting is a warning.

Refs: #1530
…ilure

A job-level if without a status-check function gets an implicit success()
gate, so the report job was skipped on exactly the failed runs it exists to
report. !cancelled() preserves the intended silence on cancelled runs while
letting both the failure and success legs evaluate. The structural test now
pins the status function alongside the result checks.

Refs: #1530
@c-vigo
c-vigo merged commit 9b86915 into dev Aug 17, 2026
12 checks passed
@c-vigo
c-vigo deleted the feature/1530-upgrade-failure-issue branch August 17, 2026 09:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant