# yaml-language-server: $schema=https://json.schemastore.org/github-workflow.json name: Quality (Full) run-name: >- Quality (Full) · ${{ github.event_name == 'pull_request' && format('PR #{0} · {1}', github.event.pull_request.number, github.event.pull_request.title) || (github.event_name == 'schedule' && 'Weekly drift scan' || github.event_name) }} # ───────────────────────────────────────────────────────────────────────────── # Heavy half of the Quality Gate — Build, Tests, Typecheck, Portability Audit. # # Triggers (the "promote" gate): # - `pull_request: types: [ready_for_review, labeled, synchronize]` — fires # once a PR leaves draft (ready_for_review), is re-synced while non-draft, # or gets the `run-full-ci` label. # - `workflow_dispatch` — manual on demand. # - `schedule` — weekly Sunday 04:00 UTC for drift detection. # # A gate job filters out the cheap-loop case (draft PR without the label) by # computing `should-run`. Downstream jobs `needs: gate` + `if: gate.outputs.run`. # # Run the same battery locally with `npm run ci:local` before promoting a PR. # ───────────────────────────────────────────────────────────────────────────── on: # Post-merge verification: the heavy gate is PR-gated for cost, so a merge # (incl. an --admin / draft-merged PR that skipped it) could land broken on # main and sit red only until the weekly cron. Running on push to main turns # that into immediate detection. Non-PR events run the full battery via the # gate job (event != pull_request → run=true). push: branches: [main] pull_request: branches: [main] # `opened`/`reopened` so a PR created directly as non-draft (single push, # no later `synchronize`) still runs the heavy gate — otherwise it can be # required by branch protection yet never report. The `gate` job below # still skips drafts unless they carry the `run-full-ci` label. types: [opened, reopened, ready_for_review, labeled, synchronize] workflow_dispatch: # A merge queue builds `refs/heads/gh-readonly-queue/...` and waits for the # REQUIRED checks to report on this event. Without this trigger the check # never reports and every queued merge blocks forever with no error — a worse # failure than the amplification the queue exists to fix. See # docs/intents/merge-latency/design.md; this ships BEFORE the queue is enabled. merge_group: schedule: - cron: '0 4 * * 0' concurrency: group: quality-full-${{ github.ref }} cancel-in-progress: true permissions: contents: read # For the Turborepo Remote Cache OIDC exchange in ./.github/actions/setup. # The minted token grants Remote Cache access on the Vercel team and nothing # else. Deliberately NOT added to release.yml or supply-chain-attestation.yml # — `infra-metrics-lock` asserts those never enable the remote cache at all, # because a cache write is a path into what we publish. id-token: write env: # No `--filter=...[origin/main]`. It made both Build and Unit Tests report a # green check having executed nothing whenever a PR touched only workflows, # root docs or configs — observed on PR #355: # # • Packages in scope: // # • Running test in 1 packages # WARNING No tasks were executed as part of this run. # Tasks: 0 successful, 0 total # # Turbo's own cache already provides the affected-detection speedup: packages # whose inputs are unchanged replay from cache instead of rebuilding. The # filter bought nothing the cache wasn't already giving us, and cost the # correctness of every check that used it. TURBO_TELEMETRY_DISABLED: '1' # Turborepo Remote Cache (Vercel). Free on every plan, and off the 10 GB # Actions cache allowance that node_modules and Next.js compete for. # Absent -> empty -> the setup action falls back to the Actions-backed cache, # which is also what a fork PR gets, since forks receive no secrets. TURBO_TOKEN: ${{ secrets.TURBO_TOKEN }} TURBO_TEAM: ${{ vars.TURBO_TEAM }} jobs: gate: name: Gate runs-on: ubuntu-latest timeout-minutes: 1 outputs: run: ${{ steps.decide.outputs.run }} shards: ${{ steps.matrix.outputs.shards }} any: ${{ steps.matrix.outputs.any }} shard_count: ${{ steps.matrix.outputs.count }} web_shards: ${{ steps.web_matrix.outputs.shards }} web_any: ${{ steps.web_matrix.outputs.any }} web_count: ${{ steps.web_matrix.outputs.count }} heavy: ${{ steps.matrix.outputs.heavy }} build_shards: ${{ steps.build_matrix.outputs.build_shards }} build_any: ${{ steps.build_matrix.outputs.build_any }} bench_configs: ${{ steps.bench_configs.outputs.run }} steps: - id: decide env: EVENT_NAME: ${{ github.event_name }} IS_DRAFT: ${{ github.event.pull_request.draft }} ACTION: ${{ github.event.action }} HAS_LABEL: ${{ contains(github.event.pull_request.labels.*.name, 'run-full-ci') }} run: | set -euo pipefail if [[ "$EVENT_NAME" != "pull_request" ]]; then # workflow_dispatch / schedule always run. echo "run=true" >> "$GITHUB_OUTPUT" exit 0 fi # On pull_request, run if the PR is not a draft OR has the label. if [[ "$IS_DRAFT" == "false" ]]; then echo "run=true" >> "$GITHUB_OUTPUT" elif [[ "$HAS_LABEL" == "true" ]]; then echo "run=true" >> "$GITHUB_OUTPUT" else echo "run=false" >> "$GITHUB_OUTPUT" echo "::notice::Draft PR without \`run-full-ci\` label — skipping heavy quality gates. Mark ready-for-review or apply the label to promote." fi # Compute the shard matrix here, in the job that already exists, so the # test matrix contains only shards that actually have work. Runners are # the scarce resource (measured on PR #356: 4640s queueing vs 1052s # computing, 82%), so spawning ten jobs for a one-package PR would cost # nine runner acquisitions to print "nothing to do". - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 if: steps.decide.outputs.run == 'true' with: fetch-depth: 50 persist-credentials: false # Pin Node from .nvmrc before running a .mts file. The runner default is # Node 22, which cannot execute type annotations without # --experimental-strip-types: the step would error, emit no `shards` # output, and every test shard would be skipped while this gate still # reported success — precisely the silent-pass class this workflow exists # to prevent. `install: false` because matrix mode imports only node: # builtins and ./lib, so npm ci would be pure cost. - uses: ./.github/actions/setup if: steps.decide.outputs.run == 'true' with: turbo-cache: 'false' install: 'false' # Four, not ten. Measured on run 33345687707 with the lanes in place: the # ten node-lane shards did 24s of test work between them and paid 141s of # checkout+setup — 5.9:1. The shards were never the critical path; the # slots they held were. `Benchmark configs load` (42s) could not start # until 00:49:40 because ten shards were ahead of it, and the run's wall # clock is gate + that queue + 42s. # # Four keeps a cold shard bounded (docs, the 144s indivisible item, left # this lane in the same change) while returning six slots to the wave. - id: matrix if: steps.decide.outputs.run == 'true' env: CI_TEST_SHARD_ALL: ${{ github.event_name == 'pull_request' && '0' || '1' }} # The base COMMIT, handed over by the event payload. `origin/main` is # not a ref that exists in a pull_request checkout — actions/checkout # fetches refs/pull/N/merge and nothing else — so merge-base against # it always failed and every PR silently ran the full matrix. CI_TEST_SHARD_BASE: ${{ github.event.pull_request.base.sha || 'origin/main' }} run: node scripts/ci-test-shard.mts --matrix 4 --lane node # The web lane: `docs` and `@interlace/ui`, the only two workspaces whose # tests need the Next.js/React tree. Kept to a separate, small matrix so # the node lane can restore a lean `node_modules` — see the `deps` input # on .github/actions/setup. Three shards because `docs` is split three # ways; `@interlace/ui` rides along in the first. - id: web_matrix if: steps.decide.outputs.run == 'true' env: CI_TEST_SHARD_ALL: ${{ github.event_name == 'pull_request' && '0' || '1' }} CI_TEST_SHARD_BASE: ${{ github.event.pull_request.base.sha || 'origin/main' }} run: node scripts/ci-test-shard.mts --matrix 3 --lane web # Same treatment for the build matrix. It was static [1,2,3,4], so on a # PR touching one plugin all four shards acquired a runner, paid ~24s of # checkout+setup, found they owned nothing affected, and exited 0. Warm, # a build shard does 2-8s of real work inside a ~24s job — the overhead # IS the job — so dispatching empty ones is pure waste of the scarce # resource. Measured on a true single-plugin diff: 1 of 4 shards. - id: build_matrix if: steps.decide.outputs.run == 'true' env: CI_TEST_SHARD_ALL: ${{ github.event_name == 'pull_request' && '0' || '1' }} # The base COMMIT, handed over by the event payload. `origin/main` is # not a ref that exists in a pull_request checkout — actions/checkout # fetches refs/pull/N/merge and nothing else — so merge-base against # it always failed and every PR silently ran the full matrix. CI_TEST_SHARD_BASE: ${{ github.event.pull_request.base.sha || 'origin/main' }} run: node scripts/ci-build.mts --matrix 4 # The matrix step is now a single point of failure for the whole test # gate: if it dies, `shards` is empty, every shard's `if` evaluates false, # all of them skip, and the aggregate gate still goes green. That is the # exact silent-pass this workflow was rewritten to eliminate, so assert # the output exists rather than trusting the step's exit code alone. - name: Guard — the shard matrix must have been computed if: steps.decide.outputs.run == 'true' env: SHARDS: ${{ steps.matrix.outputs.shards }} HEAVY: ${{ steps.matrix.outputs.heavy }} BUILD_SHARDS: ${{ steps.build_matrix.outputs.build_shards }} WEB_SHARDS: ${{ steps.web_matrix.outputs.shards }} run: | set -euo pipefail if [ -z "$SHARDS" ] || [ -z "$HEAVY" ]; then echo "::error::The shard matrix step produced no output. Every test shard would skip while this gate reported success. Failing instead." exit 1 fi if [ -z "$BUILD_SHARDS" ]; then echo "::error::The build shard matrix is empty. scripts/ci-build.mts --matrix did not emit build_shards, so every build shard would silently skip while this gate reported success." exit 1 fi if [ -z "$WEB_SHARDS" ]; then echo "::error::The web-lane matrix is empty. scripts/ci-test-shard.mts --lane web emitted no shards, so docs and @interlace/ui would silently skip while this gate reported success." exit 1 fi echo "Shard matrix: node=$SHARDS web=$WEB_SHARDS (heavy=$HEAVY)" # The benchmark-config load check needs every plugin BUILT, so it cannot # ride along in a lock job. A build is ~4 minutes of a scarce runner, so # it fires only on a diff that can actually break a config: the config # files themselves, the benchmark workspace's dependency list, or any # package manifest (which is what a rename/removal shows up as — #414 # renamed eslint-plugin-pg/-jwt and every arena number silently went to # zero for two days). - id: bench_configs if: steps.decide.outputs.run == 'true' env: BASE_SHA: ${{ github.event.pull_request.base.sha }} run: | set -euo pipefail if [ -z "${BASE_SHA:-}" ]; then # Not a PR (main / cron / dispatch): always run, same backstop # posture as the test shards. echo "run=true" >> "$GITHUB_OUTPUT" exit 0 fi CHANGED=$(git diff --name-only "$BASE_SHA"...HEAD) # `packages/[^/]+/src/` is in this list because the job no longer only # loads benchmark configs — it also carries the artifact-size and # devkit-infra metrics, and those measure SHIPPED BYTES. Gating them on # manifest changes alone meant a PR that adds a rule (the most common # change in this repo) skipped measurement entirely while the workflow # comment claimed feedback was merely "slightly delayed". Source is # exactly what moves the number, so source has to open the gate. # # `benchmarks/suites/**` and `benchmarks/__tests__/**` are whole # directories rather than the two filenames that used to be listed. # ILB-Arena's runner and its peer-support module sit beside the # configs and are what the configs are loaded to exercise; a PR # rewriting run.js matched nothing here and this job did not run. if echo "$CHANGED" | grep -qE '^(benchmarks/suites/.*|benchmarks/package\.json|benchmarks/__tests__/.*|benchmarks/vitest\.configs-load\.mts|packages/[^/]+/package\.json|packages/[^/]+/src/.*|scripts/(check-artifact-size|devkit-infra-metrics)\.ts|\.agent/(artifact-size-baseline|devkit-infra-baseline)\.json|\.github/workflows/quality-full\.yml)$'; then echo "run=true" >> "$GITHUB_OUTPUT" else echo "run=false" >> "$GITHUB_OUTPUT" echo "::notice::No benchmark config, package source/manifest or size-metric input touched — skipping the config-load + size-metrics job." fi # A skipped job leaves NO row in the PR's checks list. That makes an # affected-filtered matrix that legitimately selected nothing look identical # to a matrix step that broke: in both cases the "Unit Tests + Coverage" # checks are simply absent, and the aggregate gate is green either way. The # absence was read as a regression by a reviewer ("how come we run no unit # tests now") — correct behaviour is not the same as visible behaviour. # # This job always runs and puts the decision in the checks list BY NAME, so # the PR page states which of the two happened without anyone opening a log. # It does no work: no checkout, no install, one echo. ~5s of a runner buys # the difference between "verified nothing was affected" and "verified # nothing". test-scope: name: "${{ (needs.gate.outputs.any == 'true' || needs.gate.outputs.web_any == 'true') && format('Unit tests — {0} node + {1} web shards affected', needs.gate.outputs.shard_count, needs.gate.outputs.web_count) || 'Unit tests SKIPPED — no package sources changed' }}" needs: gate if: needs.gate.outputs.run == 'true' runs-on: ubuntu-latest timeout-minutes: 1 steps: - name: Report what the gate selected env: ANY: ${{ needs.gate.outputs.any }} WEB_ANY: ${{ needs.gate.outputs.web_any }} WEB_COUNT: ${{ needs.gate.outputs.web_count }} COUNT: ${{ needs.gate.outputs.shard_count }} BUILD_ANY: ${{ needs.gate.outputs.build_any }} HEAVY: ${{ needs.gate.outputs.heavy }} BASE: ${{ github.event.pull_request.base.sha || 'origin/main' }} run: | set -euo pipefail if [ "$ANY" = "true" ] || [ "$WEB_ANY" = "true" ]; then headline="Unit tests ran: ${COUNT} of 4 node-lane shards and ${WEB_COUNT} of 3 web-lane shards held affected packages." else headline="Unit tests skipped: no package source changed vs the base commit, so no shard in either lane had anything to run." fi { echo "# ${headline}" echo "" echo "| Gate output | Value | Meaning |" echo "|---|---|---|" echo "| \`any\` | ${ANY} | whether any node-lane shard was dispatched |" echo "| \`shard_count\` | ${COUNT} | node-lane shards holding at least one affected package |" echo "| \`web_any\` | ${WEB_ANY} | whether any web-lane shard was dispatched |" echo "| \`web_count\` | ${WEB_COUNT} | web-lane shards holding \`docs\` or \`@interlace/ui\` |" echo "| \`build_any\` | ${BUILD_ANY} | whether any build shard was dispatched |" echo "| \`heavy\` | ${HEAVY} | whether Typecheck / Portability were dispatched |" echo "" echo "Affected packages are computed against \`${BASE}\` by" echo "\`scripts/ci-test-shard.mts --matrix 4 --lane node\`. \`scripts/__tests__\` is outside every" echo "workspace and runs unconditionally in **Script & Repo-Config Locks**, so a" echo "skip here never means *nothing* was verified." } >> "$GITHUB_STEP_SUMMARY" echo "::notice::${headline}" # `scripts/` is not an npm workspace (`workspaces` is apps/*, packages/*, # tools/*, benchmarks), so turbo has no task for it and `turbo run test` never # reaches scripts/__tests__. CI only ever executed the files pinned by name: # oxlint-export-lock.test.ts (oxlint-parity.yml) and runtime-deps.test.ts # (#354, in the Build job). gap-closure, sync-source-versions and the # turbo-cache-inputs lock from #343 were dead weight — committed, green # locally, never run by the gate. Pinning suites by filename is what let that # drift; this runs the directory. scripts-tests: name: Script & Repo-Config Locks needs: gate if: needs.gate.outputs.run == 'true' runs-on: ubuntu-latest timeout-minutes: 5 steps: # Shallow: vitest only, no turbo and no git range. - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 with: persist-credentials: false - uses: ./.github/actions/setup - name: Run scripts/__tests__ run: npm run --silent test:scripts # A lock nobody has broken is a lock nobody has tested. # # Three locks written in a single day were green while asserting nothing # — one matched the comment that explained the flag it guarded, one # matched an unrelated anchor pointing at the same URL. Both survived # every shape-based check, because the assertion was real and simply # matched the wrong thing. # # This breaks each lock's declared subject and requires the lock to go # red. Cheap: only locks that DECLARE a proof are executed, and the # remainder are a shrink-only baseline, so this adds seconds rather than # a full re-run of the suite. - name: Locks fail when their subject breaks run: npm run --silent check:lock-proofs # Executes every benchmark ESLint config on a built tree. A config that # throws is scored as "found nothing" by four suites, so this is the gate # between a package rename and a published F1 of 0%. Gated by the diff (see # the `bench_configs` step) because it has to build to mean anything. bench-configs: name: Benchmark configs load needs: gate if: needs.gate.outputs.run == 'true' && needs.gate.outputs.bench_configs == 'true' runs-on: ubuntu-latest timeout-minutes: 15 steps: - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 with: persist-credentials: false # Remote cache, not the `.turbo/cache` tarball. This workflow's `Quality # (Full) Gate` is a REQUIRED check, so its duration is merge latency for # every PR in the repo. Measured on run 33330044192: `Benchmark configs # load` was 153s of which 114s was the build, and the same pattern in # quality.yml went 159s -> 2s once the cache was addressed by task hash # instead of by commit SHA. # # Dropping the tarball here also stops the churn behind it: these four # jobs are most of the ~14 lineages that were re-tarballed at ~65 MB per # main push, against a 10 GB budget the store had already blown past # (36.89 GB / 210 entries), evicting the very entries a PR needed. - uses: ./.github/actions/setup with: turbo-cache: 'false' turbo-remote-cache: 'true' # Node lane. Every step below builds or reads `eslint-plugin-*` and # the devkit; none resolves the React tree, so this job was restoring # ~170 MB of compressed archive it never opened. It is the gate's # critical path (42s, 14s of it setup), so this comes off the wall # clock rather than only off machine time. deps: 'lean' # Same filter the weekly benchmark uses, for the same reason: the configs # import plugins by package name and resolve through `exports` to dist/. - name: Build plugins (dist/ is what the configs load) run: npx turbo run build --filter='eslint-plugin-*' --filter=@interlace/eslint-devkit - name: Load every benchmark config run: npm run --silent -w @interlace/benchmarks test:configs-load # The rest of `benchmarks/__tests__` runs on the unit lanes. This one is # pulled forward because it guards the arena, and the lanes are skipped # for exactly the PRs that touch the arena: their gate opens on # `packages/*/src`, which an arena-only change never touches. A lock that # never runs on the PRs that can break it is the "green locally, never # run by the gate" failure recorded above scripts-tests. - name: Benchmark harness locks run: >- npx vitest run --root benchmarks __tests__/peer-eslint-support.lock.test.ts __tests__/parity-corpus-integrity.lock.test.ts # Same job because it needs the same thing this one already paid for: the # built dist/. The contradiction only exists in the RENDERED message, and # the score in it is enriched from the rule's CWE — a source-only checker # would have to re-implement that enrichment and would then agree with # itself by construction. - name: Severity labels must agree with the CVSS band they render run: npm run --silent lint:severity-consistency # Both metric steps live here rather than in quality.yml's fast loop # because they need EVERY package built, and this job is the only one # that already builds every package. The fast loop deliberately builds # only the ten plugins its corpus gate imports (159s -> a fraction of # it); running these there would drag the full build back in and undo # that, or would silently measure 10 of 31 packages, which is worse than # not measuring — a partial run reports the other 21 as UNMEASURED. # # The trade, stated precisely: size feedback arrives at # ready_for_review, and only on a PR that touches package source, a # package manifest, a benchmark config, or the metric scripts/baselines # themselves — that is what the `bench_configs` gate above selects for. # A docs-only or workflow-only PR gets no size report, which is correct: # it ships no bytes. # # An earlier revision of this comment claimed feedback was merely # "slightly delayed". That was wrong while the gate keyed on manifests # alone — a PR adding a rule shipped bytes and was never measured. The # gate now includes `packages/*/src/`; this comment and that pattern # have to stay true together. # # Growth stays advisory; the step fails only when a PUBLISHED package # has no baseline at all — a hole in the instrument, not a judgement # about a number. - name: Artifact size report run: npx tsx scripts/check-artifact-size.ts # Consumer-facing cost of the layer 30 packages depend on: which peers it # forces on them, and whether importing the barrel drags in a native # binary or a compiler. Exits 1 if either regresses. - name: Devkit infrastructure metrics run: npx tsx scripts/devkit-infra-metrics.ts # Sharded by package, not by `vitest --shard`: Turbo caches per package-task, # so splitting inside a package would make each shard an uncacheable slice of # the same task and trade one cache hit for N cold runs. Whole-package buckets # keep every `#test:coverage` a normal, cacheable Turbo task. # # Runs `test:coverage` so the `thresholds: { lines: 100, ... }` each package # already declares in its vitest.config.mts are enforced on PRs. Previously # only plain `test` ran here, so those thresholds were dead config on every # PR and only took effect in the push-to-main codecov job. # 10 shards is the measured optimum, not a guess. Packages are bucketed # longest-first (LPT) by test-file count, so the longest bucket can never be # smaller than the largest single package: `docs` holds 83 of the repo's 738 # test files. Balance by shard count: # # N=4 max=185 files N=8 max=93 # N=6 max=123 N=10 max=83 <- equals `docs`, the floor # N=12/16/20 -> still 83, just with progressively more idle runners # # Going past 10 cannot shorten the critical path; it only adds ~17s-overhead # jobs that finish early. Dropping below 83 means splitting `docs` itself. test: name: Unit Tests — node lane (${{ matrix.shard }}/4) needs: gate if: needs.gate.outputs.run == 'true' && needs.gate.outputs.any == 'true' runs-on: ubuntu-latest timeout-minutes: 20 strategy: # Don't cancel sibling shards on the first failure — one broken package # shouldn't hide the results of the others. fail-fast: false matrix: shard: ${{ fromJSON(needs.gate.outputs.shards) }} steps: - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 # Enough history for `git merge-base HEAD origin/main` — the affected # filter needs it. Not fetch-depth: 0; a shallow window is plenty and # full history on this repo is real setup cost times ten shards. with: fetch-depth: 50 - uses: ./.github/actions/setup with: # Own lineage per shard. Sharing one key made the shards race to save # it on main, so only one shard's outputs were ever banked and the # rest ran cold every time (`Cached: 0 cached, 8 total`). turbo-cache: 'false' turbo-remote-cache: 'true' # No ESLint plugin, the devkit, the formatters or the tools resolve # anything in the web tree, so this shard skips ~600 MB of it. See # the input's docs and scripts/__tests__/lane-deps-lock.test.ts. deps: 'lean' - name: Run shard ${{ matrix.shard }} of 4 env: # Affected-filter on PRs; run the full battery everywhere else. # A PR's blast radius is knowable from its diff, so most PRs test 1-2 # packages instead of 33. main / cron / dispatch have no meaningful # base to diff against and are the backstop, so they run everything. CI_TEST_SHARD_ALL: ${{ github.event_name == 'pull_request' && '0' || '1' }} # The base COMMIT, handed over by the event payload. `origin/main` is # not a ref that exists in a pull_request checkout — actions/checkout # fetches refs/pull/N/merge and nothing else — so merge-base against # it always failed and every PR silently ran the full matrix. CI_TEST_SHARD_BASE: ${{ github.event.pull_request.base.sha || 'origin/main' }} run: node scripts/ci-test-shard.mts ${{ matrix.shard }} 4 --lane node # Workspace-level locks: keep slow, unbounded work out of the lefthook # pre-commit path — SDK compat suites excluded from the default run (and # still wired into sdk-compatibility.yml), whole-repo scans carrying a # cold-sized timeout. - name: Pre-commit gate locks run: npm run --silent test:precommit-locks # Runs LAST, and that placement is the whole mechanism: post steps (the # cache save among them) execute after every main step, so whatever this # deletes is what the lean archive contains. Path exclusions cannot do # this — actions/cache tars a matched directory whole and the negations # never apply, measured three times at ~451 MB before it was believed. # # `always()` so a failing shard still banks a correctly-trimmed archive; # the tests have already run by this point, so nothing here can mask a # failure. The size is printed rather than assumed, because "the lean # archive is smaller" was wrong three times while nothing went red. - name: Trim the web tree before the cache saves it if: always() run: | set -euo pipefail present=0 before=$(du -sk node_modules | cut -f1) while read -r pkg; do case "$pkg" in ''|'#'*) continue ;; esac [ -e "node_modules/${pkg:?}" ] && present=$((present + 1)) rm -rf "node_modules/${pkg:?}" done < .github/lean-node-modules.txt after=$(du -sk node_modules | cut -f1) # Presence, not size, decides whether this run had anything to do. # On a cache HIT the restored tree is already trimmed, so before == # after is the correct outcome and must not fail — the first version # of this guard asserted a size drop unconditionally and red-flagged # exactly the runs where the mechanism was working. if [ "$present" -eq 0 ]; then echo "::notice::node_modules was already lean ($((after / 1024)) MB) — restored from the lean cache, nothing to trim." exit 0 fi echo "::notice::Lean node_modules: $((before / 1024)) MB -> $((after / 1024)) MB (${present} package(s) removed) before cache save." if [ "$after" -ge "$before" ]; then echo "::error::${present} package(s) were present and removed, yet the tree did not shrink (${before} kB -> ${after} kB). The lean archive would be a no-op sold as a saving — see .github/lean-node-modules.txt." exit 1 fi # The web lane. Separate from `test` so the node lane can restore a lean # `node_modules`: as long as any shard might be handed `docs`, every shard # has to carry the Next.js tree, which is what made all ten pay a 451 MB # restore for 43s of tests (run 33337052316). # # This job keeps the FULL archive and the Next.js build cache, because these # two workspaces are the reason both exist. test-web: name: Unit Tests — web lane (${{ matrix.shard }}/3) needs: gate if: needs.gate.outputs.run == 'true' && needs.gate.outputs.web_any == 'true' runs-on: ubuntu-latest timeout-minutes: 20 strategy: fail-fast: false matrix: shard: ${{ fromJSON(needs.gate.outputs.web_shards) }} steps: - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 with: fetch-depth: 50 persist-credentials: false - uses: ./.github/actions/setup with: turbo-cache: 'false' turbo-remote-cache: 'true' next-cache: 'true' - name: Run web shard ${{ matrix.shard }} of 3 env: CI_TEST_SHARD_ALL: ${{ github.event_name == 'pull_request' && '0' || '1' }} CI_TEST_SHARD_BASE: ${{ github.event.pull_request.base.sha || 'origin/main' }} run: node scripts/ci-test-shard.mts ${{ matrix.shard }} 3 --lane web build: name: Build (${{ matrix.shard }}/4) needs: gate strategy: fail-fast: false matrix: shard: ${{ fromJSON(needs.gate.outputs.build_shards) }} # `heavy` is false when the diff touches no package source at all — a # root README, a workflow comment, a .md doc. Nothing those can break is # observable to build/typecheck/portability, and markdown still gets linted # by quality.yml, which is a separate workflow and always runs. if: needs.gate.outputs.run == 'true' && needs.gate.outputs.build_any == 'true' runs-on: ubuntu-latest timeout-minutes: 15 steps: - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 with: # 50, not 0. ci-build.mts only needs a merge-base with origin/main, # which the gate and the test shards already resolve at this depth. fetch-depth: 50 persist-credentials: false - uses: ./.github/actions/setup with: next-cache: 'true' # One lineage PER BUILD SHARD. A single `build` scope meant all four # shards raced to save the same key on main — GitHub reserves a cache # key atomically, so the first writer won and the other three were # discarded, banking one shard's outputs per commit. Because shard # assignment is a pure function of the repo (see ci-build.mts), shard # N always holds the same packages, so its lineage is exactly the set # it needs. The `turbo--build-` restore-key prefix still lets a # shard fall back to any sibling's lineage on a cold start. turbo-cache: 'false' turbo-remote-cache: 'true' - name: Build via Turbo (affected only) env: # Same affected filter as the test shards; main / cron / dispatch # build everything. CI_TEST_SHARD_ALL: ${{ github.event_name == 'pull_request' && '0' || '1' }} # The base COMMIT, handed over by the event payload. `origin/main` is # not a ref that exists in a pull_request checkout — actions/checkout # fetches refs/pull/N/merge and nothing else — so merge-base against # it always failed and every PR silently ran the full matrix. CI_TEST_SHARD_BASE: ${{ github.event.pull_request.base.sha || 'origin/main' }} CI_BUILD_SHARD: ${{ matrix.shard }} CI_BUILD_SHARD_TOTAL: '4' run: node scripts/ci-build.mts # Runs here because the artifacts already exist — no extra runner, no # second build, ~5s. Reads the emitted JS for module-scope requires of # packages the manifest does not guarantee are installed. Every package is # built now (the affected filter was removed — see the env block), so this # checks all of them on PRs as well as main. # The exhaustive `npm run verify:published-install` actually installs each # tarball and is ~2.5min — too slow for every push, kept for pre-release. - name: Runtime dependency check (published packages must be requirable) run: npm run verify:runtime-deps # Packaging lock that reads devkit's own dist/. It lives here, not in the # unit suite, so `test` does not have to dependOn `build` — a unit test # should never wait on a compile. Same invariant as the step above, # asserted at the source level. # Only on the shard that actually built devkit — the packaging lock reads # its dist/, which no other shard has. - name: Devkit must not require an optional peer at runtime run: | if grep -q '"@interlace/eslint-devkit"' .ci-built-packages.json; then npm run test:dist --workspace=@interlace/eslint-devkit else echo "devkit not built by shard ${{ matrix.shard }} — checked on the shard that owns it." fi # The detection logic itself is locked: a plausible tidy-up of either the # eager-require pattern or the optional-peer rule silently disarms the gate # above, so both mutations are asserted against. # # `npm run test:scripts` in quality.yml now also covers this file (it runs # the whole scripts/__tests__ directory). Kept here anyway: this step sits # next to the gate it protects, and the duplicate run costs ~5s. - name: Lock the runtime-dependency detection logic if: matrix.shard == 1 run: npm run test:runtime-deps # Every rule schema sets additionalProperties: false, so an option that # exists only in the docs aborts the consumer's whole lint run — and # configuring a rule means copying the name out of our documentation. # ~2s, no build needed. - name: Documented rule options must exist in the schema if: matrix.shard == 1 run: npm run test:documented-options typecheck: name: Typecheck (whole-graph tsgo) needs: gate if: needs.gate.outputs.run == 'true' && needs.gate.outputs.heavy == 'true' runs-on: ubuntu-latest timeout-minutes: 10 steps: - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 with: # Typecheck reads no git history — it is `tsgo --build` over the # solution plus `tsc --noEmit` for @interlace/ui, both file-based. # A full clone was pure cost. fetch-depth: 1 persist-credentials: false - uses: ./.github/actions/setup with: turbo-cache: 'false' turbo-remote-cache: 'true' - name: Typecheck (whole-graph tsgo / TS7 native) # One `tsgo --build tsconfig.solution.json` over the full plugin graph # (+ @interlace/ui). A single whole-graph build is what makes TS7 faster # here; per-package tsgo pays Go startup 21× and loses to TS6. # typescript-eslint stays on typescript@6.0.3. See TS7_MIGRATION_PLAN.md. run: npm run typecheck portability: name: Portability Audit needs: gate if: needs.gate.outputs.run == 'true' && needs.gate.outputs.heavy == 'true' runs-on: ubuntu-latest timeout-minutes: 5 steps: - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 with: persist-credentials: false - uses: ./.github/actions/setup with: turbo-cache: 'false' - run: npm run audit:portability:ci # Aggregate gate so a single PR check status surfaces the heavy-half result. quality-full-gate: name: Quality (Full) Gate runs-on: ubuntu-latest permissions: contents: read issues: write # open the failure issue (.github/actions/report-failure) timeout-minutes: 2 needs: [gate, test, test-web, scripts-tests, build, typecheck, portability] # `needs.gate.outputs.run` alone is not enough. If `gate` itself fails that # output is empty, this job is skipped — and GitHub reports a skipped # *required* check as passing, so a broken gate would wave a PR through with # none of the heavy suites having run. Stay eligible on gate # failure/cancellation and report it below. if: >- always() && (needs.gate.outputs.run == 'true' || needs.gate.result == 'failure' || needs.gate.result == 'cancelled') steps: # Both reporting steps below are LOCAL actions (`uses: ./...`), and a # local action is read off the workspace — without a checkout the runner # cannot find it. This job had none, so from the day the push trigger # landed until 2026-09-10 every alarm it declared failed with # `Can't find 'action.yml' ... under .github/actions/report-failure`. # main went red at 06:00 on the #964 merge and no issue was ever opened; # the immediate detection this job's own comments describe had never once # reached a human. `scripts/__tests__/local-action-needs-checkout.lock.test.ts` # holds it. ~2s on every run, including the green ones — which is the # price of the alarm being able to sound at all. - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 with: persist-credentials: false - name: Render gate report env: R_GATE: ${{ needs.gate.result }} R_SCRIPTS: ${{ needs['scripts-tests'].result }} R_TEST: ${{ needs.test.result }} R_TEST_WEB: ${{ needs['test-web'].result }} R_BUILD: ${{ needs.build.result }} R_TYPECHECK: ${{ needs.typecheck.result }} R_PORTABILITY: ${{ needs.portability.result }} # Needed to tell a LEGITIMATE skip from a broken one. `heavy` is false # when the diff touches no package source; `any` is false when no # testable package is affected. HEAVY: ${{ needs.gate.outputs.heavy }} ANY: ${{ needs.gate.outputs.any }} BUILD_ANY: ${{ needs.gate.outputs.build_any }} WEB_ANY: ${{ needs.gate.outputs.web_any }} run: | set -euo pipefail icon() { case "$1" in success) echo "✅" ;; failure) echo "❌" ;; cancelled) echo "⏹" ;; skipped) echo "⏭" ;; *) echo "⚠️" ;; esac } # A skipped job is a PASS only when the gate deliberately skipped it. # # This used to be a flat `[ "$r" = "success" ]`, which meant a # markdown-only PR — where `heavy=false` skips build/typecheck/ # portability and `any=false` skips the test shards — hard-FAILED the # required check instead of fast-passing. The skip optimisation was # unusable: skipping the work made the gate red. # # `cancelled` and `failure` are never a pass, and a skip is only # accepted against the gate output that authorised it, so an upstream # failure cascading into a skip is still caught. all_pass=true # The gate itself is never legitimately skipped — this job stays # eligible when the gate dies precisely so it can say so. If the gate # died, every downstream `result` is `skipped`, which check() would # read as an authorised skip and wave through. Assert it separately. if [ "$R_GATE" != "success" ]; then echo "::error::The gate job did not succeed ($R_GATE). Downstream skips cannot be trusted as passes." all_pass=false fi check() { # $1=result $2=allowed-to-be-skipped(true/false) $3=label case "$1" in success) return 0 ;; skipped) if [ "$2" = "true" ]; then echo "note: $3 skipped by the gate (nothing affected) — counted as pass." return 0 fi echo "::error::$3 was skipped but the gate did not authorise it." return 1 ;; *) return 1 ;; esac } [ "$ANY" = "true" ] && test_skip_ok=false || test_skip_ok=true [ "$WEB_ANY" = "true" ] && web_skip_ok=false || web_skip_ok=true [ "$HEAVY" = "true" ] && heavy_skip_ok=false || heavy_skip_ok=true check "$R_TEST" "$test_skip_ok" "Unit tests (node)" || all_pass=false check "$R_TEST_WEB" "$web_skip_ok" "Unit tests (web)" || all_pass=false [ "$BUILD_ANY" = "true" ] && build_skip_ok=false || build_skip_ok=true check "$R_BUILD" "$build_skip_ok" "Build" || all_pass=false check "$R_TYPECHECK" "$heavy_skip_ok" "Typecheck" || all_pass=false check "$R_PORTABILITY" "$heavy_skip_ok" "Rule portability" || all_pass=false # scripts-tests has no `any`/`heavy` condition — it runs whenever the # gate authorised the workflow at all, so a skip is never legitimate. check "$R_SCRIPTS" false "Script & repo-config locks" || all_pass=false if $all_pass; then header="✅ All heavy quality gates passed" else header="❌ One or more heavy quality gates failed" fi { echo "# $header" echo "" echo "| Gate | Result | Notes |" echo "|---|---|---|" echo "| Gate | $(icon "$R_GATE") $R_GATE | draft/label decision |" echo "| Unit tests (node) | $(icon "$R_TEST") $R_TEST | plugins/devkit/tools — 4 shards, lean deps, affected-filtered |" echo "| Unit tests (web) | $(icon "$R_TEST_WEB") $R_TEST_WEB | \`docs\` + \`@interlace/ui\` — 3 shards, full deps |" echo "| Script/config locks | $(icon "$R_SCRIPTS") $R_SCRIPTS | \`scripts/__tests__\` — outside every workspace |" echo "| Build | $(icon "$R_BUILD") $R_BUILD | \`turbo run build\`, 4 shards, affected-filtered |" echo "| Typecheck | $(icon "$R_TYPECHECK") $R_TYPECHECK | \`tsgo --build\` whole-graph (TS7 native) |" echo "| Rule portability | $(icon "$R_PORTABILITY") $R_PORTABILITY | oxlint/Biome/typescript-go compatibility |" echo "" echo "_Run \`npm run ci:local\` to mirror these gates locally before promoting a PR._" if ! $all_pass; then echo "" echo "**Investigate failures via the per-gate jobs above.**" fi } >> "$GITHUB_STEP_SUMMARY" $all_pass || { echo "::error::One or more heavy quality gates failed"; exit 1; } echo "All heavy quality gates passed." # A red cron notifies nobody by default. See .github/actions/report-failure. - name: 🚨 Report a scheduled failure if: >- failure() && github.event_name == 'schedule' && !contains(needs.*.result, 'cancelled') uses: ./.github/actions/report-failure with: title: 'Scheduled full quality gate is failing' body: 'The scheduled run of the full quality gate failed. main may be broken in a way the per-PR gates do not cover.' token: ${{ github.token }} # The push trigger is what turns "broken until Sunday" into "broken for # one merge" — but only if somebody is told. Without this the immediate # detection produces a red square in a tab nobody has open, which is the # same outcome as the weekly cron with extra Actions minutes spent. # # A SEPARATE title, because the title is the deduplication key and these # are different situations: a push failure names the merge that caused it # and is actionable now; a schedule failure means main has been broken for # up to a week and nobody noticed. Sharing one issue would let the second # hide inside the first. # `!contains(needs.*.result, 'cancelled')` — a shard cancelled by # `cancel-in-progress` means a newer push superseded this run, and that # newer run is the authority on main's health. #993 was filed for exactly # this: the release merge's `Build (4/4)` was cancelled when the next # merge landed, `check()` read cancelled as a fail (rightly — that sha was # never proven green), and the alarm announced a broken main while the run # for main's actual head was green. An alarm that cries wolf on every # back-to-back merge is one people learn to close unread. - name: 🚨 Report a broken main if: >- failure() && github.event_name == 'push' && !contains(needs.*.result, 'cancelled') uses: ./.github/actions/report-failure with: title: 'main is red — the full quality gate failed after a merge' body: >- The heavy gate failed on a push to main, so main is broken now and every branch cut from it inherits the failure. The merge that did it is the head of main. PR #745 is the worked example: it landed with unsynced MDX, failed rule-docs-sync-drift on main's tip, and was found four days later by accident. token: ${{ github.token }} # Without this the jobs above can fail on a schedule with nobody watching: # a red cron produces no PR, no reviewer and no notification, so silence and # success look identical. Tracked as debt in .github/cron-alerting-debt.json. report: name: "\U0001F6A8 Report a scheduled failure" needs: [bench-configs, test-scope] if: >- always() && github.event_name == 'schedule' && contains(needs.*.result, 'failure') runs-on: ubuntu-latest timeout-minutes: 5 permissions: contents: read issues: write steps: - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 with: persist-credentials: false - uses: ./.github/actions/report-failure with: title: 'Scheduled Quality (Full) job is failing' body: >- A job in the scheduled heavy gate did not complete, so the checks it owns are not running against main on their cadence. token: ${{ github.token }}