ci: skip main CI when the merged tree equals a green pull request head #363

Merged
ullrich merged 4 commits from ci/skip-identical-main into main 2026-11-18 08:58:19 +00:00
Owner

Contains the commits of #360 and #361. Merge those first; this PR then shows one commit.

Change

On a push to main, scripts/ci-scope.mjs asks the Forgejo API for the pull request that the commit merged. The expensive steps are skipped when all of these are true:

  • The commit is the merge commit of that pull request into main.
  • The pull request came from this repository.
  • The tree of the commit is byte-identical to the tree of the pull request head.
  • Each CI / * (pull_request) check on that head is green.

The pull request run tested the same tree with the same workflow file (a PR run checks out the head commit, not a merge result). A merge that changed the tree, a direct push, an API error or a missing status falls through to the path rule of #361. The jobs still run and report, so the CI / * contexts on main do not change.

Verification

  • 5 new unit tests for the decision (11 in total).
  • Replay with the real API on the 74 main pushes of the last 30 days, each in a shallow checkout:
Result Runs Runner minutes
Skipped: identical tree, green head 18 43
Inert by path (#361) 6 20
Full suite: tree differs from the head (branch was behind main) 47 199
Full suite: identical tree, but the head was not fully green 3 17

The skip cannot run in this PR. The first merge of an up-to-date PR after this is on main shows it: each job logs CI scope: … tree identical to the green head of pull request #N.

Effect

43 minutes in 30 days (1.7% of all runner time, 16% of CI on main). For a skipped push, CI on main takes about 40 s and not about 6.5 minutes, and the two runner slots are free for the CD jobs of the same push.

🤖 Generated with Claude Code

Contains the commits of #360 and #361. Merge those first; this PR then shows one commit. ## Change On a push to main, `scripts/ci-scope.mjs` asks the Forgejo API for the pull request that the commit merged. The expensive steps are skipped when all of these are true: - The commit is the merge commit of that pull request into main. - The pull request came from this repository. - The tree of the commit is byte-identical to the tree of the pull request head. - Each `CI / * (pull_request)` check on that head is green. The pull request run tested the same tree with the same workflow file (a PR run checks out the head commit, not a merge result). A merge that changed the tree, a direct push, an API error or a missing status falls through to the path rule of #361. The jobs still run and report, so the `CI / *` contexts on main do not change. ## Verification - 5 new unit tests for the decision (11 in total). - Replay with the real API on the 74 main pushes of the last 30 days, each in a shallow checkout: | Result | Runs | Runner minutes | |---|---|---| | Skipped: identical tree, green head | 18 | 43 | | Inert by path (#361) | 6 | 20 | | Full suite: tree differs from the head (branch was behind main) | 47 | 199 | | Full suite: identical tree, but the head was not fully green | 3 | 17 | The skip cannot run in this PR. The first merge of an up-to-date PR after this is on main shows it: each job logs `CI scope: … tree identical to the green head of pull request #N`. ## Effect 43 minutes in 30 days (1.7% of all runner time, 16% of CI on main). For a skipped push, CI on main takes about 40 s and not about 6.5 minutes, and the two runner slots are free for the CD jobs of the same push. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
fix(ci): hash root configs and infra fixtures into the Turbo cache
All checks were successful
CI / Security Scan (pull_request) Successful in 9s
CI / Dockerfile Package Check (pull_request) Successful in 4s
CI / Visual Tests (pull_request) Successful in 45s
CI / Journal Image Smoke Test (pull_request) Successful in 1m31s
CI / Checks (pull_request) Successful in 2m59s
CI / E2E Tests (pull_request) Successful in 4m37s
CD Staging / Build & Push journal Image (pull_request) Has been skipped
CD Staging / Build & Push planner Image (pull_request) Has been skipped
CD Staging / Deploy Staging (pull_request) Has been skipped
CD Staging / Deploy PR Preview (pull_request) Has been skipped
Cancel superseded CI / Cancel in-flight CI (pull_request) Successful in 4s
CD Staging / Tear Down PR Preview (pull_request) Successful in 12s
6bc22e5ec4
CI keeps the Turbo cache between runs, and a cache hit replays the old
result. Turbo hashed only the files inside each package, so these inputs
did not invalidate the cache:

- tsconfig.base.json, vitest.shared.ts, vitest.setup.ts and
  eslint.config.js, which every package uses
- infrastructure/scripts/poi-selectors.sql and
  infrastructure/brouter-host/poi-extract/osmium-filters.txt, which the
  map-core sync tests read

A change to one of them got a cached green result for typecheck, lint
and test. Declare the root configs as globalDependencies and the two
fixtures as inputs of the map-core test task.

Verified with turbo --dry=json: the task hashes now change when one of
these files changes, and stay the same for unrelated files.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
scripts/ci-scope.mjs compares the tested commit with its base and says
if the change can affect code checks or only OpenSpec validation. A path
must be proven inert (docs, infrastructure, agent config, non-CI
workflows) to be left out. An unknown path, a missing base, or an error
selects the full suite.

Files that tests read from infrastructure/ are declared as Turbo inputs,
and each declared Turbo input counts as code. A test fails when source
reads an inert directory without that declaration.

The script is not used by a workflow yet.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
ci: skip steps that a change cannot affect
Some checks failed
CI / Security Scan (pull_request) Successful in 10s
CI / Dockerfile Package Check (pull_request) Successful in 7s
CI / Checks (pull_request) Successful in 1m41s
CI / Visual Tests (pull_request) Successful in 48s
CI / Journal Image Smoke Test (pull_request) Successful in 53s
CI / E2E Tests (pull_request) Successful in 3m44s
CI / Dockerfile Package Check (push) Has been cancelled
CI / Checks (push) Has been cancelled
CI / Visual Tests (push) Has been cancelled
CI / E2E Tests (push) Has been cancelled
CI / Journal Image Smoke Test (push) Has been cancelled
CI / Security Scan (push) Has been cancelled
CD Staging / Build & Push journal Image (pull_request) Has been skipped
CD Staging / Build & Push planner Image (pull_request) Has been skipped
CD Staging / Deploy Staging (pull_request) Has been skipped
CD Staging / Deploy PR Preview (pull_request) Has been skipped
Cancel superseded CI / Cancel in-flight CI (pull_request) Successful in 3s
CD Staging / Tear Down PR Preview (pull_request) Successful in 12s
fe55272831
Each heavy job (Checks, Visual Tests, E2E Tests, Journal Image Smoke
Test) now runs scripts/ci-scope.mjs after checkout and skips its
expensive steps when the change is inert. A change below openspec/ runs
only the install and the OpenSpec validation.

The jobs always run and always report, so the required CI / * status
contexts do not change. The conditions fail open: steps are skipped only
when the scope output is the literal string false.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
ci: skip main CI when the merged tree equals a green pull request head
All checks were successful
CI / Dockerfile Package Check (pull_request) Successful in 6s
CI / Security Scan (pull_request) Successful in 7s
CI / Visual Tests (pull_request) Successful in 35s
CI / Checks (pull_request) Successful in 57s
CI / Journal Image Smoke Test (pull_request) Successful in 56s
CI / E2E Tests (pull_request) Successful in 2m42s
CD Staging / Build & Push journal Image (pull_request) Has been skipped
CD Staging / Build & Push planner Image (pull_request) Has been skipped
CD Staging / Deploy Staging (pull_request) Has been skipped
CD Staging / Deploy PR Preview (pull_request) Has been skipped
Cancel superseded CI / Cancel in-flight CI (pull_request) Successful in 4s
CD Staging / Tear Down PR Preview (pull_request) Successful in 16s
3fba85a288
On a push to main, scripts/ci-scope.mjs now asks the Forgejo API for the
pull request that the commit merged. The steps are skipped when all of
these are true:

- the commit is the merge commit of that pull request into main
- the pull request came from this repository
- the tree of the commit is byte-identical to the tree of the pull
  request head
- every CI / * (pull_request) check on that head is green

The pull request run tested the same tree with the same workflow file,
so the second run can find nothing new. A merge that changed the tree
(the branch was behind main), a direct push, an API error or a missing
status falls through to the path rule.

Replay on the 74 main pushes of the last 30 days: 18 skip (43 runner
minutes), 6 are inert by path, 50 run the full suite. 3 pushes had an
identical tree but a pull request head that was not fully green; they
run the full suite.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
ullrich deleted branch ci/skip-identical-main 2026-11-18 08:58:19 +00:00
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
trails-cool/trails!363
No description provided.