Skip to content

Open-source Grok Bot alternative with a virtual machine that bots can use

CI: run the source guards in the static job, before any runner is asked for (#4414)

Milind Soni92225e141563
diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml
index 39836ca7b4..2d7c0144ff 100644
--- a/.github/workflows/ci.yml
+++ b/.github/workflows/ci.yml
@@ -101,6 +101,10 @@ jobs:
- name: Validate locale catalogs
run: pnpm i18n:check
- run: pnpm lint
+ - name: Source guards
+ # The tests that only read the source: seconds here, and they stay in the shards. On Nov 3-4 2026 one of them was
+ # red on main for 11 hours, and each PR heard about it after about 70 minutes, once its shards had found a runner.
+ run: pnpm exec vitest run src/locales/ scripts/testing/file-size-ratchet.test.ts scripts/testing/index-route-ratchet.test.ts scripts/testing/tighten-ratchets.test.ts scripts/testing/comment-history.test.ts scripts/testing/lazy-server-modules.test.ts scripts/testing/duration-sequencer.test.ts scripts/testing/host-e2e.test.ts scripts/testing/ci-retry-list.test.ts src/lib/copy-text.guard.test.ts src/components/Select.guard.test.ts --reporter=default --reporter=github-actions
# A pull request that changes only docs, tests under scripts/ or the
# control plane cannot change what these three check.
- if: steps.scope.outputs.build == 'true'
diff --git a/docs/ci.md b/docs/ci.md
index d25cdd1824..65d109d1c2 100644
--- a/docs/ci.md
+++ b/docs/ci.md
@@ -1,8 +1,12 @@
# CI job selection
Every PR still runs the workflow, its `static` job and the `CI` gate: locale
-validation, lint, the CI-selection tests and the verification-documentation
-checks always run. Selection never skips the entire workflow.
+validation, lint, the CI-selection tests, the verification-documentation
+checks and the source guards always run. Selection never skips the entire
+workflow. The source guards are the tests that only read the source (the
+vocabulary and locale checks, the size and route ratchets, and the like): they
+take seconds, and they run in `static` as well as in the shards, so a change
+that breaks one fails before the run asks for its runners.
`scripts/ci-scope.mjs` sorts a pull request's changed files (a local
merge-base diff, rename detection off, so a moved file selects its old path
diff --git a/scripts/ci-workflow.test.ts b/scripts/ci-workflow.test.ts
index e774cf7c76..a0556091af 100644
--- a/scripts/ci-workflow.test.ts
+++ b/scripts/ci-workflow.test.ts
@@ -1,5 +1,5 @@
import { spawnSync } from "node:child_process";
-import { readdirSync, readFileSync } from "node:fs";
+import { existsSync, readdirSync, readFileSync } from "node:fs";
import { describe, expect, it } from "vitest";
import { parse } from "yaml";
import { EVALS_LANE, PACKAGED_SERVER_LANE, vitestLane } from "./ci-linux-lanes.mjs";
@@ -201,6 +201,21 @@ describe("CI concurrency", () => {
}
});
+ it("fails a broken source guard in static, before any runner is asked for", () => {
+ const steps = workflow.jobs.static.steps as { name?: string; run?: string; if?: string }[];
+ const guards = steps.find((step) => step.name === "Source guards")!;
+ expect(guards.if).toBeUndefined();
+ const named = guards.run!.split(" ").filter((word) => /\.test\.ts$|\/$/.test(word));
+ // A name vitest cannot match would silently drop that guard.
+ for (const path of named) expect(existsSync(new URL(`../${path}`, import.meta.url)), path).toBe(true);
+ expect(named).toContain("src/locales/");
+ expect(named).toContain("scripts/testing/file-size-ratchet.test.ts");
+ // Before the slow checks, so a failed guard reports within a minute.
+ expect(steps.indexOf(guards)).toBeLessThan(steps.findIndex((step) => step.run === "pnpm typecheck"));
+ // Every test the guards run stays in the suite: vitest's include has them, so the shards still deal them out.
+ expect(workflow.jobs.vitest.needs).toBe("static");
+ });
+
it.each(requiredRuntimeJobs)("accepts %s skipped only when static left it out", (job) => {
const others = SELECTABLE_JOBS.filter((name) => name !== job);
expect(runGate(gateNeeds(others)).status).toBe(0);