Skip to content

Publishing a release runs again only what no passing CI run checked - #2913

Merged
davidmckayv merged 1 commit into
mainfrom
publish-reuse-ci
Dec 4, 2026
Merged

davidmckayv merged 1 commit into
mainfrom
publish-reuse-ci

Conversation

@davidmckayv

@davidmckayv davidmckayv commented Dec 3, 2026 •

Copy link
Copy Markdown
Contributor

What this changes

Publishing a release no longer runs the same tests again on code that already passed them.

The checks needed job (scripts/release-ci-gate.ts) used to have one small path: when the release PR changed nothing but the release files on a commit whose CI passed, it skipped the suite. Any other diff ran everything. v1.2.10's release PRs carried a revert (#2903) and a one-test change (#2905), so each publish ran the whole suite again, and the same flaky WebKit renderer crash failed it four times.

Now the gate looks for a commit whose CI passed and whose tree differs from the release commit's only in what a run would check differently, and runs only that difference:

  • Same tree (the release commit's own passing run, or a revert back to a tree that passed): nothing runs again, except the 12-month support window, which counts from the day of the release.
  • Release files only (versions, CHANGELOG.md, release-policy.json, backend-images.env, Cargo): the release-file checks, as before.
  • Release files and tests (tests added or changed, none deleted): those test files and every test that names one, in each engine CI runs them in (bun test, Chromium, WebKit for a file on ci.yml's WebKit list or one that asks for it, and the desktop setup window), in a new release tests job. The release-file checks and a type check run in the gate.
  • Anything else: the full suite. That covers product code (app/src, shared/, desktop/src-tauri, server-facing code, workflows), fixtures, Python or TypeScript-engine tests, docs, a deleted test, a version file that changed beyond its version, and anything it cannot read.

The commits it compares with are the release commit itself, its first parents (main or the release branch), and main's first parents, 50 of each. It compares trees, not history, so a revert back to a green tree counts as that tree. A run counts only if it finished with every job succeeded or skipped: main's push run or main's merge queue at exactly that commit, or a Publish release run whose own checks ran and passed. That last kind lets a final reuse its candidate's checks. Pull request runs and the deciding run never count. It fails closed: an unreadable diff, an unreadable API, or an engine list it cannot find means the full suite. images publishes only after checks passed, or after the gate passed and, when it said tests run, release tests passed.

byEngine in scripts/ci-changes.ts is the existing engine sort, pulled out so the gate uses the same rules. Its two call sites are unchanged in behaviour (ci-changes.test.ts passes). docs/releasing.md ("What has to be green" and "What merging does") describes the new rules.

How others do it

The design follows the common pattern: key a pass on the code's content, not the commit, reuse only passes, and rerun a test only when it or what it depends on changed.

  • Bazel's default (--cache_test_results=auto) reruns a test only if "Bazel detects changes in the test or its dependencies", or "the test failed". Otherwise it replays the cached pass (user manual). Here, a changed test file reruns and unchanged tests on unchanged code do not.
  • Nx hashes a task's inputs and on a match "behaves like a local cache hit without running the task again". A later push reruns only the tasks its change reaches (remote cache).
  • Git's own CI kept a "good trees" file keyed by git rev-parse $commit^{tree}, and skipped a job when "the same tree has already been built and tested successfully before" (ci/lib.sh, v2.35.4). It was removed in 2022, partly because a tree could be marked good even when a later step such as make coccicheck failed (patch). That is why a run counts here only when every job succeeded or was skipped. A tree-keyed, pass-only cache for Actions also exists as an action (pleo-io/s3-cache-action).
  • Merge queues (GitHub's, and bors before it) test the exact commit that lands, so that commit does not need testing again (GitHub merge queue, bors and the "not rocket science" rule). This repo's CI already relies on that for main's push runs, and the gate now counts the queue's run at the release commit.

GitHub Actions has no built-in way to reuse a pass across commits with the same tree, since required checks attach to a commit SHA. So the gate reads past runs from the Actions API, as Git's file and the S3 action read their stores. The one place it is coarser than Bazel or Nx is that it has no per-test dependency graph. Any change outside the release files and tests runs the whole suite, rather than guessing which tests the change reaches.

Where it runs

  • New state that outlives a request? None. This is the release workflow and its script.
  • What happens on the second replica? Not applicable. No server code changes.
  • Anything serialised? No.
  • Anything fanned out to a browser? No.
  • New listener, port, or schedule? No. There is one new job in publish-release.yml, release tests, which runs only on a release.

Boundary and audit

  • Every acting call still goes through the gateway: resolve, decide, audit, then act. (No server change.)
  • New refusals and new failures each write a row. (None.)
  • Nothing new is trusted from the client that the server can resolve itself. (None.)

API and database

  • This changes nothing under api/, no app's requests, no database change and no release-policy.json.

Changelog

none

Proof

Red before, green after. scripts/release-ci-gate-script.test.ts runs the script itself, the way checks needed runs it, on a real git history in a temp repo, with a gh on PATH that answers gh api from runs and jobs in the Actions API's shapes. Its regression test replays v1.2.10: the last green commit, Cedar, the first release PR, the revert, and the last release PR changing app/tests/sidebar-current-row.test.tsx, with main's push run of the release commit still in progress.

  • Against the old gate (git restore --source=origin/main scripts/release-ci-gate.ts scripts/ci-changes.ts), it fails with Expected: "false" Received: "true" on full_checks. The old gate ran the full suite.
  • Against this branch it passes: mode=tests, baseline = the last green commit, tests=["app/tests/no-fixed-settle-waits.test.ts"], browser_tests and webkit_tests = ["app/tests/sidebar-current-row.test.tsx"].

The five cases, against real git histories in temp repos (scripts/release-ci-gate.test.ts):

  • a release-files-only diff takes the small path
  • a test-only diff runs only those files and the tests that name them, in Chromium, WebKit and the desktop window as CI would
  • a product-code diff runs everything (server, app, shared, desktop/src-tauri, a workflow, a new file)
  • a revert to a green tree reruns nothing
  • an unknown diff runs everything (an unlisted config, a fixture, a Python test, a TypeScript-engine test, docs, the workbench, a deleted test, a test turned into a link, an unreadable diff, an unreadable engine list)

They also cover runs marked success with a job that did not pass, PR, fork and other-workflow runs, the deciding run itself, waiting and the 10-minute cap, an unreadable API, picking the tree that leaves least to run, a final reusing its candidate's publish checks, and a release branch carrying main's tree.

Live, read-only, against this repository's real history and Actions API:

  • 1884dbd71 (v1.2.10's last release commit): mode=reuse. main's push run of that exact commit has since passed (run 47223608122), so a re-run of that publish runs nothing again. While that run was still in progress, the tree comparison picks 7bb2df5eb (green on push and in the queue), and only the changed test and the one that names it run.
  • 158ed37d0 (the first v1.2.10 release commit): mode=reuse on main's passing run of that commit (47216728184).

Checks run locally: bun run format:check, bun run lint, bun run typecheck, a strict tsc over the gate's files, actionlint (only the existing $/ notices) and zizmor (no findings) on publish-release.yml, plus every test that reads the changed workflows or scripts (release-ci-gate, release-ci-gate-script, release-publish-order, ci-changes, ci-runners, ci-budgets, workflow-concurrency, stop-on-failure, signing-workflows, release-latest, release-rerun, release-charts and others): all green.

No screen changes. This is the release workflow and its script, so there is nothing to show in Chrome or Safari.

The release gate now looks for a commit whose CI passed and whose tree differs from the release commit's only in the release files and tests: the release commit itself, its first parents, or main's. The same tree runs nothing again; release files alone run their checks; changed tests run on their own, in each engine CI runs them in; anything else, or anything unreadable, runs the full suite. A revert back to a tree that passed is that tree, and a final reuses its candidate's publish checks.

v1.2.10's last release PR changed one test on top of a revert, and each of its publishes ran the whole suite while a flaky WebKit crash failed it.
@davidmckayv
davidmckayv marked this pull request as ready for review December 4, 2026 03:22
@davidmckayv
davidmckayv added this pull request to the merge queue Dec 4, 2026
Merged via the queue into main with commit bf7a54b Dec 4, 2026
81 of 85 checks passed
@davidmckayv
davidmckayv deleted the publish-reuse-ci branch December 4, 2026 03:38
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