diff --git a/docs/ci-cd.md b/docs/ci-cd.md index c011d2ed0..7ce0a4c42 100644 --- a/docs/ci-cd.md +++ b/docs/ci-cd.md @@ -369,9 +369,46 @@ API path / no `.cs` changed → they pass in ~5s), so they needed no change. `do `decisions-guard` and `ci-image-pin` keep running on docs-only changes — the first two are *about* docs and must. -Not in scope: the separate redundancy of running the **whole matrix on a PR and again on the -merge-to-`main`** over identical code (ersatztv#420), and the within-run triple `dotnet build` -(ersatztv#398). +Not in scope: the within-run triple `dotnet build` (ersatztv#398; measured and rejected as +build-once — see `docs/decisions.md`). The separate redundancy of running the **whole matrix on a +PR and again on the merge-to-`main`** over identical code (ersatztv#420) is addressed below. + +### Cross-run tree-identity skip (ersatztv#420) + +A merge to `main` re-runs the entire matrix over code the PR's last run already validated — the +same redundancy as docs-only, but for identical code rather than docs. On a `push` to `main` that +is a real merge commit, `test`/`migrations`/`functional-e2e` each run +`scripts/ci-detect-already-validated.sh` as a **second** detect step (`id: revalidate`, right after +the docs-only detect), and every heavy step gains an added `&& steps.revalidate.outputs.skip != +'true'` to its existing `if:`. + +**Skip condition — all four required, else fail-safe `skip=false`:** + +- the event is a push to `refs/heads/main`; +- `HEAD` has a second parent `HEAD^2` (a real merge commit — the PR head CI already validated; + squash, rebase, fast-forward, or a direct push have no `HEAD^2`, so they run); +- `git rev-parse HEAD^{tree}` equals `HEAD^2^{tree}` — main did not advance since the PR's last run, + a byte-identical tree; +- `HEAD^2` has a **green Gitea combined commit status**, queried via the API with + `ETV_STATUS_AUTH`. + +Those three jobs check out `fetch-depth: 2` so `HEAD^2` and its tree resolve. + +**Why it's safe: `build` is not gated.** The three heavy jobs skip their *steps* (same +required-context reasoning as docs-only — they still run and report `success` in seconds), but +**`build` always runs on `main`, ungated**, building and pushing the image from that identical, +already-validated tree. No image ships from unvalidated source. The required contexts are +unchanged (`Build & test (.NET)`, `EF migration integrity (SQLite + MySql)`) — no branch-protection +change. + +**Fail-safe bias.** Any uncertainty — not a main push, no `HEAD^2`, a differing tree, a +missing/failing/non-`success` status, missing auth — resolves to `skip=false` and runs the full +matrix. A false skip could ship an under-validated image, so every ambiguous case runs everything. + +**Honest limitation.** The tree is identical only on a *fast-forward-equivalent* merge — main +didn't advance between the PR's last green run and its merge. Under parallel merges main usually +has advanced by then, so the skip fires mainly in quiet periods; it's correct-but-conservative by +construction, not a general dedup. ### `docs-reminder` job (non-blocking, PR-only) diff --git a/docs/decisions.md b/docs/decisions.md index 716c2be07..ebb246bca 100644 --- a/docs/decisions.md +++ b/docs/decisions.md @@ -97,6 +97,7 @@ in-file entries. - [2026-07-18 — Auto-Tune per-source weights ride #70's MultiCollection machinery; created at tune time, not a post-hoc PUT (#425)](#2026-07-18--auto-tune-per-source-weights-ride-70s-multicollection-machinery-created-at-tune-time-not-a-post-hoc-put-425) - [2026-07-18 — Search all-items is paged to cap DoS exposure; SPA add-all pages to completeness (#293)](#2026-07-18--search-all-items-is-paged-to-cap-dos-exposure-spa-add-all-pages-to-completeness-293) - [2026-07-18 — Unsupported PlaybackOrder is loud at build time; a declared support matrix and tripwire test make new orders safe by construction (#403)](#2026-07-18--unsupported-playbackorder-is-loud-at-build-time-a-declared-support-matrix-and-tripwire-test-make-new-orders-safe-by-construction-403) +- [2026-07-18 — CI build-once was measured and rejected; keep the #420 tree-skip](#2026-07-18--ci-build-once-was-measured-and-rejected-keep-the-420-tree-skip) --- @@ -1884,3 +1885,23 @@ the three still-**silent** build-time dispatch sites — the ones this issue nam `SeasonEpisodeMediaCollectionEnumerator`) that simply aren't reverse-mapped, so making it "loud" would emit false-positive warnings. Completing that reverse map is a separate concern from "an unsupported *order* degrades silently" and is not part of #403's scope. +## 2026-07-18 — CI build-once was measured and rejected; keep the #420 tree-skip + +Build-once (a `compile` job producing a single artifact, consumed by `test`/`migrations`/ +`functional-e2e` via `--no-build`) was fully implemented and went **green on CI** (PR #455, run +830), then **rejected on measurement**: it traded a ~12% slot-occupancy saving for a ~40–85% +**per-run wall-clock regression**. + +- **Why it regressed.** The `bin`+`obj` artifact is 2.5 GB raw / 972 MB gz; tar alone costs ~82s CPU + plus ~180s transport, consuming most of the ~465s the shared compile was meant to save. Worse, + `compile` serializes **before** `migrations`' long ef-replay, which is pure DB work a shared build + cannot shorten — the bottleneck was never the redundant compiles. +- **Incidental finding worth recording.** `actions/upload-artifact@v4` does not work on this Gitea + instance — it throws `GHESNotSupportedError`, because the `@actions/artifact` v2 client library + rejects any non-`github.com` host. `@v3` is required for any future artifact use here. +- **Kept: the #420 cross-run tree-identity skip** (`docs/ci-cd.md` → Cross-run tree-identity skip). + It is independent of build-once — it only *skips* redundant work on identical-tree main pushes, at + zero wall-clock cost, rather than trying to share a build across jobs. Don't re-attempt build-once + unless the runner's artifact storage or network changes materially. + +Refs: #398 (closed), #420, PR #455.