Skip to content

ci: make CI fast and reliable — every job under 20 minutes, recurring flake removed - #12247

Merged
Git-on-my-level merged 10 commits into
mainfrom
ci/fast-reliable-ci
Aug 26, 2026
Merged

Git-on-my-level merged 10 commits into
mainfrom
ci/fast-reliable-ci

Conversation

@Git-on-my-level

@Git-on-my-level Git-on-my-level commented Aug 26, 2026 •

Copy link
Copy Markdown
Member

Make CI fast and reliable again: every job under 20 minutes, and every recurring source of red that wasn't a real code defect removed. Based on a full audit of the last week of runs (per-workflow histories, job/step timings, and failure logs for every red run on main plus re-run-to-green pairs).

What was broken

Workflow Symptom Root cause
Desktop Swift CI p90 150 min, max 218 min macOS runner pool at ~98% utilization, self-inflicted: 674 SwiftPM process spawns per run (~29 min), a duplicate release build for an 11-test regression (~31 min), 9-min serial launcher loop, cold release builds (~20 min)
Backend Unit Tests 22 failures/100, p50 17 min, p90 20 min One module-stub trap broke main twice and 4 unrelated PRs; 919 per-file pytest processes paid ~9.3 min of import tax; checkout tail up to 13 min
Repo Checks 17 failures/100 Line-count ratchet demanded byte-exact counts against a moving main — correct declarations went stale with no author action (5 nondeterministic failures); one setup-uv "latest" manifest fetch died
Backend Hermetic E2E 4 re-run-to-green cycles 3 of 4: merge gate ran under always() and turned concurrency cancellations into hard red. 1 of 4: sync-stack health check had a 20s budget while the weak TCP probe had 120s
Desktop Windows CI 2 failures incl. main electron-builder re-downloads packaging tools from github.com every run; transient DNS/socket errors fail the build
Parakeet GPU Tests 23 consecutive failures, 46 min each, zero logs Pod unschedulable since 08-03 (L4 pool at capacity); workflow burned the full 45-min deadline, collected logs after pod deletion, and filtered pod events out of diagnostics
Mobile/Web Checks max 22 min / a 53-min checkout-only run fetch-depth: 0 full clones of a 1.25 GB repo; Gradle cache never written (every APK build ~700s cold); build_runner cache key ended in run_id (guaranteed miss); no job timeouts

What this PR does

Desktop Swift CI (demand drops from ~4.9 required concurrent macOS runners to well under 1, so the queue collapses; expected macOS-engaged wall clock 8–15 min):

  • Batch SwiftPM test invocations (25 suites per process, repeated --filter flags). Strictly optimistic: any red or timed-out batch is discarded and every member re-runs through the untouched per-suite path — isolation semantics, budgets, and failure attribution unchanged for anything red; serial shared-auth cluster never batched; OMI_SWIFT_TEST_SUITE_BATCH_SIZE=1 restores old behavior exactly. Full hermetic-fixture coverage added.
  • Run the release-mode UserNotifications regression inside the Release Compile job next to the release build it consumes, instead of a second from-scratch release build on the verify runner. The release planner still requires the "Desktop Swift Release Compile" check by exact name, and "Desktop Swift Build & Tests" now hard-fails on the release job's result, so release tagging and PR merges both still gate on it.
  • Cache SwiftPM deps + release Desktop/.build in the release job (saved from main pushes, readable by every ref) and drop the forced rm -rf cold build.
  • Launcher script tests 3-way parallel with per-test logs; build-lock recovery budgets widened from the 4s that saturated runners kept blowing.
  • blob:none checkout (history kept for diffing).
  • Also fixes a pre-existing bash-3.2 set -u break that made OMI_SWIFT_TEST_PREBUILD=0 kill every suite.
  • Measured on this PR's first run (all 41 checks green): the one batch carrying the 245s MemoryAtlasPerformanceHarnessTests blew its budget and paid the isolated fallback (~15 of the step's 40 min), so measure-block suites are now derived from source and always run solo with a doubled budget; and with per-invocation SwiftPM startup gone, workers go 2→3 to match the runner's cores (this PR's runs are the evidence; revert to 2 if the perf harness times out).

Backend Unit Tests: the recurring "flake" was one deterministic trap — a module-scope sys.modules['utils'] stub with __path__ = [] turned every new import in routers/conversations.py into a ModuleNotFoundError for whoever ran CI next (main broke twice on 08-25; four unrelated PRs inherited the red; the stub list already carried duplicate entries from repeated incident patching). The stub package now carries the real package __path__, so unlisted submodules resolve to the real module — verified by reproducing the incident against both versions. Checkout p90 267s/max 786s fixed with blob:none; timeout-minutes 45→30. Two standing runner bugs found while measuring were fixed: pytest's exit 5 on total xdist worker death was read as "no tests selected" and reported green, and the fast-unit duration guard's verdict was silently discarded under xdist. A single-session xdist partition of the suite (the obvious next speedup) was implemented, measured, and disproved on this tree — upb descriptor segfaults when co-collecting stub-heavy files, OOM at 815 files, and xdist collects the full selection per worker — so it ships opt-in (BACKEND_PYTEST_PARALLEL_SESSION=1) with the measurements recorded in comments, defaults unchanged. The real speed ceiling here is interpreter startup ×919 files; a fork-server runner that pre-imports the heavy common set and forks per file would keep per-file isolation exactly and is the recommended follow-up.

Repo Checks: the Line-Count-Exception declaration now approves a growth allowance (the delta, a property of the PR alone) instead of exact endpoints, making the check invariant under base drift; exceptions the diff no longer needs warn instead of failing. Grammar unchanged; existing PR bodies stay valid. Over-allowance growth, duplicates, malformed lines, unsupported paths still fail.

Backend Hermetic E2E: merge gate is !cancelled() and defers to the superseding run on partial cancellation; the sync Cloud Tasks stack drains its ports between scenarios and gives the authoritative health check 60s (TCP probes kept their generous budgets while the strong check had the tightest one).

Desktop Windows CI: cache electron + electron-builder downloads on both packaging jobs so steady-state builds never touch github.com mid-build.

Parakeet GPU Tests: fail in ~6 min with the truth (PodScheduled gate with a 5-min bound, pod FailedScheduling events in the output, live-streamed pod logs that survive deadline kills) instead of a silent 45-min burn.

Mobile/Web Checks: blob:none where history is needed, shallow where it isn't; Gradle cache written from main and read by PRs (org.gradle.caching=true); build_runner cache keys drop the run_id suffix; timeout caps on every job.

Everywhere: setup-uv pinned to 0.11.13 (matching the backend Dockerfiles) at all 14 call sites — an unpinned version resolves "latest" via a network fetch that has already hard-failed a run.

Verified

  • All touched contract/fixture suites pass locally: desktop-swift-ci contract tests (26), swift-test-suites hermetic fixture (incl. new batch/fallback/BATCH_SIZE=1 coverage), run-swift-ci + build-lock launcher tests, check-launcher-test-skips, line-count-ratchet tests (16), release-eligibility contract tests (20), run_checks (47), pr_preflight (40). Backend: full 930-file suite green at shipped defaults (358s), stub-pollution checker 0 violations, runner/guard/wiring contract tests pass (43), incident reproduced against old and new stub code. Full run_checks.py --lane ci manifest (34 checks) passes on the final tree.
  • actionlint clean (with the repo's -shellcheck "" convention) on every touched workflow; YAML parses everywhere.
  • The PR's own CI: two full runs, every check green. Second run (with the measure-suite fix and 3 workers): batched Swift test step 40.4 → 21.0 min with zero fallback, verify job 50.9 → 32.9 min. Backend unit suite 16.5 min, Hermetic E2E 2.2 min, Windows/Linux packaging 6.0/7.2 min, mobile analyze 6.5 min, Android compile smoke 14.1 min (cold Gradle — main must merge once before PRs get warm-cache times). Desktop Swift verify ran 50.9 min on that first run, which exposed the measure-suite batching pathology fixed in the follow-up commit; Release Compile 20.0 min cold (its cache also seeds from the first main push after merge).

The honest residual

Every job is now under 20 minutes except two, both with a clear story:

  • Desktop Swift verify (32.9 min, only on runs that select the full suite — 60% of runs skip macOS entirely): the remainder is real test execution, ~60 suite-minutes of single-threaded Swift test time across 677 suites on a 3-core runner. Getting under 20 here means making the tests faster or paying for a larger macOS runner (which check_runner_cost_policy deliberately blocks) — not CI mechanics.
  • Release Compile (22.9 min cold): its release-build cache saves from main pushes, so the first merge to main seeds it; PR runs after that restore it and should land well under 20.

The 150-218 min p90 is gone regardless: it was queueing, and the demand that caused the queue no longer exists.

Not in this PR (needs decisions/permissions beyond the repo)

  1. Parakeet GPU capacity — the actual outage: dev-nllb-nllb-translation (no node selector beyond nvidia-l4) squats the second L4 in parakeet-pool, whose autoscaler is capped at 1 node/zone, so the CI pod has been unschedulable since 08-03. Fix is a cluster change: give NLLB its own pool or taint parakeet-pool, or raise maxNodeCount to 2.

  2. Branch protection — Repo Checks is not a required status check: both recent main failures were PRs merged red (their PR runs had already failed with the identical error). A settings change, and the highest-leverage reliability fix available.

  3. desktop_codemagic_failure_recovery.yml — its check_run trigger mints a skipped run for every check completing in the repo (~2,300/day, 42k total; the runs API now truncates at its 40k listing cap). Zero billable minutes, but it drowns run history. check_run has no trigger-level name filter and the producing check is Codemagic's (external app), so workflow_run can't replace it; the clean fix is a webhook→workflow_dispatch filter or a scheduled poll, which changes release-recovery mechanics and deserves its own review.

  4. Orphaned FluidAudio pin — desktop/macos/Desktop/Package.resolved pins FluidAudio revision 19600a485baa, which is no longer reachable from any branch/tag upstream (found while running the pre-push gate: a fresh SwiftPM mirror clone cannot resolve it; only warm caches keep it alive). Any cold-cache CI run or new contributor hits error: could not find the commit. The pin should be moved to a reachable revision/tag in its own PR.

🤖 Generated with Claude Code

Git-on-my-level and others added 10 commits August 26, 2026 00:21
The Linux package job failed on main (EAI_AGAIN github.com) and on PRs
(read ECONNRESET) because electron-builder re-downloads its packaging
tools on every run. Cache the tool and Electron archives so steady-state
builds never depend on those endpoints, on both the Linux and Windows
packaging jobs.

Co-Authored-By: Claude Fable 5 <[email protected]>
… sync stack readiness

The merge gate ran under always() and failed hard on 'cancelled' upstream
results whenever cancel-in-progress superseded a run — 3 of the last 4
re-run-to-green cycles on this workflow were exactly that. Gate now goes
neutral on cancellation and defers to the superseding run.

The sync Cloud Tasks stack's one genuine flake: scenarios run back-to-back,
a dying child of the previous stack can still answer a TCP probe, and the
authoritative health check had the tightest budget (20s) while the weak
port probe had the generous one. close() now drains the stack's ports and
health gets 60s.

Co-Authored-By: Claude Fable 5 <[email protected]>
…ry run

Desktop Swift CI's tail (p90 150 min, max 218 min) was queue time: the
repo's only macos-15 consumers demanded ~4.9 concurrent runners against a
cap of ~5. Cut the demand instead of the deadline:

- Run the release-mode UserNotifications regression inside the Release
  Compile job, next to the release build it consumes, instead of paying a
  second from-scratch release build (~31 min) on the verify runner. The
  planner still requires the Release Compile check by exact name, and the
  Build & Tests aggregate now hard-fails on the release job's result, so
  release tagging and PR merges both still gate on it (#11373/#11374
  protection preserved).
- Cache SwiftPM dependencies and the release Desktop/.build in the
  Release Compile job, saved from main pushes so every ref can restore
  it, and drop the forced rm -rf that guaranteed a ~20-min cold build.
- Run launcher script tests 3-way parallel with per-test logs (9.3 min
  serial p50), and widen the build-lock recovery budgets that saturated
  runners pushed past 4s.
- blob:none the verify checkout; full history stays for diffing.

Co-Authored-By: Claude Fable 5 <[email protected]>
…ulable burns

Mobile and Web Checks' p90-to-max tail was almost entirely actions/checkout
pulling all blobs of a ~1.25GB repo with fetch-depth: 0 (a 53-minute
checkout-only Web run happened); history-needing jobs now use blob:none and
worktree-only jobs go shallow, with timeout caps so no job can idle
unbounded again. The Android compile smoke paid a ~700s cold Gradle build
every run because the default cache policy never wrote from main; main now
seeds the cache PRs read, and the build_runner cache keys drop the
run_id suffix that guaranteed a miss on every single run.

Parakeet GPU tests have failed nightly since 08-03 burning exactly 45 min
each with zero logs: the pod is unschedulable (L4 pool at capacity) and the
workflow neither noticed nor captured pod events. Gate on PodScheduled
within 5 minutes with the real cause in the error, stream pod logs live so
deadline kills keep evidence, and include pod events in diagnostics. The
capacity fix itself (NLLB squatting the parakeet pool's second GPU) is a
cluster change tracked separately.

Co-Authored-By: Claude Fable 5 <[email protected]>
…ft; pin uv

13 of the last 17 Repo Checks failures were the line-count ratchet, and the
nondeterministic ones shared one cause: the check demanded byte-exact
absolute counts against a synthetic merge with origin/main, which moves
under every open PR (~90 pushes/hr). A correct declaration went stale with
no author action, in both directions (drifted endpoints, and previously-
mandatory exceptions turning fatally 'unused' when main absorbed an edit).
The declaration now approves a growth *allowance* — the delta is a property
of the PR alone — and an exception the diff no longer needs warns instead
of failing. Growth beyond the allowance, duplicates, malformed lines, and
unsupported paths still fail.

Also pin setup-uv's resolved version (matching backend/Dockerfile's
UV_VERSION) so it stops fetching the astral-sh 'latest' manifest, which
hard-failed a run.

Co-Authored-By: Claude Fable 5 <[email protected]>
Every unpinned astral-sh/setup-uv call resolves 'latest' by fetching the
astral-sh/versions manifest from raw.githubusercontent.com at job start —
one observed Repo Checks failure was exactly that fetch dying. Pin the
same 0.11.13 the backend Dockerfiles already use, which the action
resolves locally with no network call. repo-checks.yml was pinned in the
previous commit; this covers the remaining call sites and the
release-eligibility action (with its byte-exact contract fixture).

Co-Authored-By: Claude Fable 5 <[email protected]>
…back

The debug suite spawned one 'xcrun swift test' process per discovered
suite — 674 SwiftPM startups at ~5.1s each, ~28.7 min of the verify job's
wall clock, dwarfing actual test execution. Workers now run suites in
batches of 25 through one SwiftPM process (repeated --filter flags), with
batching kept strictly optimistic: a batch that exits non-zero or times
out is discarded and every member re-runs through the untouched per-suite
path, so isolation semantics, per-suite budgets, and failure attribution
are unchanged for anything red. The serial shared-auth cluster is never
batched, and OMI_SWIFT_TEST_SUITE_BATCH_SIZE=1 restores the old behavior
bit-for-bit.

Also fixes a pre-existing bash-3.2 set -u break (empty build_args
expansion) that made OMI_SWIFT_TEST_PREBUILD=0 kill every suite, and
restores the case-pattern skip list in the workflow's launcher step that
check-launcher-test-skips.py parses.

Co-Authored-By: Claude Fable 5 <[email protected]>
…unner verdicts

The suite's recurring 'flake' was one deterministic trap: a module-scope
sys.modules['utils'] stub with __path__ = [] turned every new import in
routers/conversations.py into a ModuleNotFoundError for whoever ran CI
next — main broke twice on 2026-08-25 and four unrelated PRs inherited
the red. The stub package now carries the real package __path__, so
unlisted submodules resolve to the real module instead of raising
(explicit stubs still stub; verified by reproducing the incident against
both versions).

Checkout p90 was 267s and max 786s from full-blob clones; blob:none keeps
the merge-base history scripts/changed-files needs. timeout 45→30 so a
hang stops burning a concurrency slot for 25 minutes past the p90.

Also two standing runner bugs found while measuring: pytest's exit 5 on
total worker death was read as 'no tests selected' and reported green,
and the fast-unit duration guard's verdict was silently discarded under
xdist (workers now hand offenders to the controller). A single-session
xdist partition of the suite was implemented, measured, and disproved on
this tree (upb descriptor segfaults, OOM at 815 files, per-worker
collection); it ships opt-in via BACKEND_PYTEST_PARALLEL_SESSION=1 with
the measurements in the comments, default behavior unchanged.

Co-Authored-By: Claude Fable 5 <[email protected]>
…rkers

The first PR run of the batched suite exposed one pathology: the batch
carrying MemoryAtlasPerformanceHarnessTests (245s of XCTest measure
blocks, slower still under contention) blew its 17-minute budget and paid
the 25-suite isolated fallback on top — 15 of the step's 40 minutes.
Measure suites are now derived from the source (like the serial cluster,
so a new one cannot silently join the batch pool) and run in their own
SwiftPM process with a doubled per-suite budget.

With per-invocation SwiftPM startup gone — the reason two workers were
the measured ceiling — workers now match the runner's three cores. This
PR's CI runs are the macOS-runner evidence; drop back to two if the
performance harness starts timing out.

Co-Authored-By: Claude Fable 5 <[email protected]>
@Git-on-my-level
Git-on-my-level merged commit 02062df into main Aug 26, 2026
47 checks passed
@Git-on-my-level
Git-on-my-level deleted the ci/fast-reliable-ci branch August 26, 2026 15:04
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