Skip to content

The fastest, cheapest, most efficient open-source agent harness. Run more than 500 agents on a $10 VPS.

chore: files changed scripts/__tests__/self-hosted-lanes.test.mjs,scripts/ci/self-hosted/lanes-plan.

Steven Enamakelc01b947fd778
diff --git a/scripts/__tests__/self-hosted-lanes.test.mjs b/scripts/__tests__/self-hosted-lanes.test.mjs
index 602117a814..f2a05576c6 100644
--- a/scripts/__tests__/self-hosted-lanes.test.mjs
+++ b/scripts/__tests__/self-hosted-lanes.test.mjs
@@ -16,10 +16,23 @@ import {
selectLanes,
validatePlan,
} from "../ci/self-hosted/lanes-plan.mjs";
-import { Runner, gatingFailures, orderProblems, parseArgs, renderSummary } from "../ci/self-hosted/lanes.mjs";
+import {
+ Runner,
+ gatingFailures,
+ orderProblems,
+ parseArgs,
+ renderSummary,
+} from "../ci/self-hosted/lanes.mjs";
-const repoRoot = path.join(path.dirname(fileURLToPath(import.meta.url)), "..", "..");
-const ciLite = fs.readFileSync(path.join(repoRoot, ".github", "workflows", "ci-lite.yml"), "utf8");
+const repoRoot = path.join(
+ path.dirname(fileURLToPath(import.meta.url)),
+ "..",
+ "..",
+);
+const ciLite = fs.readFileSync(
+ path.join(repoRoot, ".github", "workflows", "ci-lite.yml"),
+ "utf8",
+);
const ALL = Object.fromEntries(Object.keys(AREA_ENV).map((k) => [k, true]));
const NONE = Object.fromEntries(Object.keys(AREA_ENV).map((k) => [k, false]));
@@ -52,7 +65,11 @@ test("every hosted group resolves on its own, and every hosted lane has exactly
test("commands are static: no suite is ever narrowed to the diff", () => {
for (const plan of plans()) {
for (const run of allRuns(plan)) {
- assert.doesNotMatch(run, /\$\{\{|CI_AREA_|git diff|CHANGED|--changed|\brelated\b|--test-files/, run);
+ assert.doesNotMatch(
+ run,
+ /\$\{\{|CI_AREA_|git diff|CHANGED|--changed|\brelated\b|--test-files/,
+ run,
+ );
}
}
});
@@ -61,7 +78,10 @@ test("the complete suites run, not subsets", () => {
const runs = allRuns(plans()[0]).join("\n");
assert.match(runs, /pnpm --filter openhuman-app test:coverage(?! \S*\.test)/);
assert.match(runs, /bash scripts\/ci\/rust-coverage\.sh/);
- assert.match(runs, /cargo llvm-cov --no-rustc-wrapper --manifest-path crates\/openhuman-app\/Cargo\.toml/);
+ assert.match(
+ runs,
+ /cargo llvm-cov --no-rustc-wrapper --manifest-path crates\/openhuman-app\/Cargo\.toml/,
+ );
});
test("every ci-lite check the lanes claim to carry is still a ci-lite check", () => {
@@ -110,54 +130,108 @@ test("every ci-lite check the lanes claim to carry is still a ci-lite check", ()
test("untouched areas leave only the always-on gates", () => {
const plan = buildPlan({ profile: "hosted", areas: NONE });
- const on = plan.lanes.flatMap((l) => l.checks.filter((c) => c.when).map((c) => `${l.name}:${c.name}`));
- assert.deepEqual(on, ["static:orch-ip-gate", "static:feature-forwarding", "static:module-pins", "static:submodule-monotonic"]);
- assert.deepEqual(hostedMatrix(plan).map((g) => g.group), ["checks"]);
+ const on = plan.lanes.flatMap((l) =>
+ l.checks.filter((c) => c.when).map((c) => `${l.name}:${c.name}`),
+ );
+ assert.deepEqual(on, [
+ "static:orch-ip-gate",
+ "static:feature-forwarding",
+ "static:module-pins",
+ "static:submodule-monotonic",
+ ]);
+ assert.deepEqual(
+ hostedMatrix(plan).map((g) => g.group),
+ ["checks"],
+ );
});
test("hosted matrix only spins up groups with active lanes", () => {
- const docsOnly = hostedMatrix(buildPlan({ profile: "hosted", areas: { ...NONE, docs: true } }));
- assert.deepEqual(docsOnly.map((g) => g.group), ["checks"]);
- const core = hostedMatrix(buildPlan({ profile: "hosted", areas: { ...NONE, rustCore: true } }));
- assert.deepEqual(core.map((g) => g.group), ["checks", "rust-lint", "rust-cov"]);
- const pester = hostedMatrix(buildPlan({ profile: "hosted", areas: { ...NONE, installPs1: true } }));
+ const docsOnly = hostedMatrix(
+ buildPlan({ profile: "hosted", areas: { ...NONE, docs: true } }),
+ );
+ assert.deepEqual(
+ docsOnly.map((g) => g.group),
+ ["checks"],
+ );
+ const core = hostedMatrix(
+ buildPlan({ profile: "hosted", areas: { ...NONE, rustCore: true } }),
+ );
+ assert.deepEqual(
+ core.map((g) => g.group),
+ ["checks", "rust-lint", "rust-cov"],
+ );
+ const pester = hostedMatrix(
+ buildPlan({ profile: "hosted", areas: { ...NONE, installPs1: true } }),
+ );
assert.equal(pester.find((g) => g.group === "pester").container, "");
});
test("ex63 needs a scratch dir and gives every Rust lane its own target dir under it", () => {
- assert.throws(() => buildPlan({ profile: "ex63", areas: ALL, env: {} }), /CI_SCRATCH_DIR/);
+ assert.throws(
+ () => buildPlan({ profile: "ex63", areas: ALL, env: {} }),
+ /CI_SCRATCH_DIR/,
+ );
const plan = buildPlan({ profile: "ex63", areas: ALL, env: EX63_ENV });
const dirs = plan.lanes.map((l) => l.targetDir).filter(Boolean);
assert.equal(new Set(dirs).size, dirs.length);
for (const d of dirs) assert.match(d, /^\/scratch\/target\//);
// hosted keeps cargo's default target dirs (restored by rust-cache).
- assert.ok(buildPlan({ profile: "hosted", areas: ALL }).lanes.every((l) => !l.targetDir));
+ assert.ok(
+ buildPlan({ profile: "hosted", areas: ALL }).lanes.every(
+ (l) => !l.targetDir,
+ ),
+ );
});
test("instrumented coverage never runs under a rustc wrapper", () => {
for (const plan of plans()) {
const cov = plan.lanes.find((l) => l.name === "rust-cov");
assert.equal(cov.env.RUSTC_WRAPPER, undefined);
- const tauriCov = plan.lanes.find((l) => l.name === "tauri").checks.find((c) => c.name === "tauri-coverage");
+ const tauriCov = plan.lanes
+ .find((l) => l.name === "tauri")
+ .checks.find((c) => c.name === "tauri-coverage");
assert.match(tauriCov.run, /^unset RUSTFLAGS RUSTC_WRAPPER/);
}
});
test("area flags are read strictly from CI_AREA_*", () => {
- const areas = areasFromEnv({ CI_AREA_RUST_CORE: "true", CI_AREA_FRONTEND: "false", CI_AREA_DOCS: "1" });
+ const areas = areasFromEnv({
+ CI_AREA_RUST_CORE: "true",
+ CI_AREA_FRONTEND: "false",
+ CI_AREA_DOCS: "1",
+ });
assert.equal(areas.rustCore, true);
assert.equal(areas.frontend, false);
assert.equal(areas.docs, false);
});
test("argument parsing", () => {
- assert.deepEqual(parseArgs(["--profile", "hosted", "--lanes", "static, frontend", "--max-parallel", "2"]).lanes, ["static", "frontend"]);
+ assert.deepEqual(
+ parseArgs([
+ "--profile",
+ "hosted",
+ "--lanes",
+ "static, frontend",
+ "--max-parallel",
+ "2",
+ ]).lanes,
+ ["static", "frontend"],
+ );
assert.throws(() => parseArgs([]), /--profile/);
- assert.throws(() => parseArgs(["--profile", "ex63", "--bogus"]), /unknown argument/);
+ assert.throws(
+ () => parseArgs(["--profile", "ex63", "--bogus"]),
+ /unknown argument/,
+ );
});
function stubPlan() {
- const check = (name, run, extra = {}) => ({ name, run, when: true, needs: [], ...extra });
+ const check = (name, run, extra = {}) => ({
+ name,
+ run,
+ when: true,
+ needs: [],
+ ...extra,
+ });
return {
profile: "hosted",
lanes: [
@@ -172,7 +246,11 @@ function stubPlan() {
check("off", "exit 1", { when: false }),
],
},
- { name: "b", active: true, checks: [check("waits-on-a", "echo ok", { needs: ["a:still-runs"] })] },
+ {
+ name: "b",
+ active: true,
+ checks: [check("waits-on-a", "echo ok", { needs: ["a:still-runs"] })],
+ },
],
};
}
@@ -181,7 +259,11 @@ test("runner: a failure never stops later checks, blocks its dependants, and gat
const out = fs.mkdtempSync(path.join(os.tmpdir(), "lanes-test-"));
fs.mkdirSync(path.join(out, "logs"));
const lanes = await new Runner(stubPlan(), { out, maxParallel: 0 }).run();
- const status = Object.fromEntries(lanes.flatMap((l) => l.checks.map((c) => [`${l.name}:${c.name}`, c.status])));
+ const status = Object.fromEntries(
+ lanes.flatMap((l) =>
+ l.checks.map((c) => [`${l.name}:${c.name}`, c.status]),
+ ),
+ );
assert.deepEqual(status, {
"a:fails": "failure",
"a:still-runs": "success",
diff --git a/scripts/ci/self-hosted/lanes-plan.mjs b/scripts/ci/self-hosted/lanes-plan.mjs
index 24df729681..c9d60d3b99 100644
--- a/scripts/ci/self-hosted/lanes-plan.mjs
+++ b/scripts/ci/self-hosted/lanes-plan.mjs
@@ -39,9 +39,19 @@ export function areasFromEnv(env) {
/** Hosted-runner job groups: lanes that share one GitHub-hosted job. */
export const HOSTED_GROUPS = [
// Quick checks and the frontend suite fit one 4-core runner side by side.
- { group: "checks", lanes: ["static", "frontend", "frontend-tests"], maxParallel: 3, container: true },
+ {
+ group: "checks",
+ lanes: ["static", "frontend", "frontend-tests"],
+ maxParallel: 3,
+ container: true,
+ },
// Lint and gates-off share one `target/` on a ~14 GB disk, so run in turn.
- { group: "rust-lint", lanes: ["rust-lint", "rust-gates-off"], maxParallel: 1, container: true },
+ {
+ group: "rust-lint",
+ lanes: ["rust-lint", "rust-gates-off"],
+ maxParallel: 1,
+ container: true,
+ },
{ group: "rust-cov", lanes: ["rust-cov"], maxParallel: 1, container: true },
{ group: "tauri", lanes: ["tauri"], maxParallel: 1, container: true },
// pwsh ships on the bare ubuntu-latest image, not in the CI container.
@@ -67,7 +77,9 @@ export function buildPlan({ profile, areas, env = {}, isPullRequest = true }) {
const ex63 = profile === "ex63";
const scratch = env.CI_SCRATCH_DIR;
if (ex63 && !scratch) {
- throw new Error("profile ex63 needs CI_SCRATCH_DIR (set by the microVM guest)");
+ throw new Error(
+ "profile ex63 needs CI_SCRATCH_DIR (set by the microVM guest)",
+ );
}
const rust = areas.rustCore || areas.rustTauri;
const core = areas.rustCore;
@@ -117,13 +129,41 @@ export function buildPlan({ profile, areas, env = {}, isPullRequest = true }) {
name: "static",
checks: [
{ name: "rust-fmt", when: rust, run: "cargo fmt --all -- --check" },
- { name: "rust-layout", when: core, run: "node scripts/ci/check-openhuman-rust-layout.mjs" },
- { name: "agent-runtime-boundary", when: core, run: "pnpm agent:runtime-boundary" },
- { name: "ignored-tests-ratchet", when: rust, run: "pnpm rust:ignored-tests" },
- { name: "linux-tls-policy", when: rust, run: "bash scripts/check-linux-tls-dependencies.sh" },
- { name: "gated-test-allowlist", when: rust, run: "bash scripts/ci/check-gated-test-allowlist.sh" },
- { name: "orch-ip-gate", when: true, run: "bash scripts/ci/orch-ip-gate.sh" },
- { name: "feature-forwarding", when: true, run: "node scripts/ci/check-feature-forwarding.mjs" },
+ {
+ name: "rust-layout",
+ when: core,
+ run: "node scripts/ci/check-openhuman-rust-layout.mjs",
+ },
+ {
+ name: "agent-runtime-boundary",
+ when: core,
+ run: "pnpm agent:runtime-boundary",
+ },
+ {
+ name: "ignored-tests-ratchet",
+ when: rust,
+ run: "pnpm rust:ignored-tests",
+ },
+ {
+ name: "linux-tls-policy",
+ when: rust,
+ run: "bash scripts/check-linux-tls-dependencies.sh",
+ },
+ {
+ name: "gated-test-allowlist",
+ when: rust,
+ run: "bash scripts/ci/check-gated-test-allowlist.sh",
+ },
+ {
+ name: "orch-ip-gate",
+ when: true,
+ run: "bash scripts/ci/orch-ip-gate.sh",
+ },
+ {
+ name: "feature-forwarding",
+ when: true,
+ run: "node scripts/ci/check-feature-forwarding.mjs",
+ },
{
name: "module-pins",
when: true,
@@ -135,8 +175,16 @@ export function buildPlan({ profile, areas, env = {}, isPullRequest = true }) {
needs: ["module-pins"],
run: "node scripts/ci/check-submodule-monotonic.mjs",
},
- { name: "toolchain-image-drift", when: areas.toolchainImage, run: "node scripts/ci/check-toolchain-image.mjs" },
- { name: "test-inventory", when: areas.inventory, run: "pnpm test:inventory" },
+ {
+ name: "toolchain-image-drift",
+ when: areas.toolchainImage,
+ run: "node scripts/ci/check-toolchain-image.mjs",
+ },
+ {
+ name: "test-inventory",
+ when: areas.inventory,
+ run: "pnpm test:inventory",
+ },
],
},
{
@@ -148,13 +196,42 @@ export function buildPlan({ profile, areas, env = {}, isPullRequest = true }) {
when: areas.frontend || areas.i18n || areas.scripts,
run: "pnpm install --frozen-lockfile",
},
- { name: "tsc", when: areas.frontend, needs: ["pnpm-install"], run: "pnpm --filter openhuman-app compile" },
- { name: "prettier", when: areas.frontend, needs: ["pnpm-install"], run: "pnpm --filter openhuman-app format:check" },
- { name: "eslint", when: areas.frontend, needs: ["pnpm-install"], run: "pnpm --filter openhuman-app lint" },
- { name: "i18n", when: areas.i18n, needs: ["pnpm-install"], run: "pnpm i18n:check" },
- { name: "docs-generator-tests", when: areas.docs, run: "pnpm docs:test" },
+ {
+ name: "tsc",
+ when: areas.frontend,
+ needs: ["pnpm-install"],
+ run: "pnpm --filter openhuman-app compile",
+ },
+ {
+ name: "prettier",
+ when: areas.frontend,
+ needs: ["pnpm-install"],
+ run: "pnpm --filter openhuman-app format:check",
+ },
+ {
+ name: "eslint",
+ when: areas.frontend,
+ needs: ["pnpm-install"],
+ run: "pnpm --filter openhuman-app lint",
+ },
+ {
+ name: "i18n",
+ when: areas.i18n,
+ needs: ["pnpm-install"],
+ run: "pnpm i18n:check",
+ },
+ {
+ name: "docs-generator-tests",
+ when: areas.docs,
+ run: "pnpm docs:test",
+ },
{ name: "docs-drift", when: areas.docs, run: "pnpm docs:check" },
- { name: "scripts-self-tests", when: areas.scripts, needs: ["pnpm-install"], run: "pnpm test:scripts" },
+ {
+ name: "scripts-self-tests",
+ when: areas.scripts,
+ needs: ["pnpm-install"],
+ run: "pnpm test:scripts",
+ },
],
},
{
@@ -184,7 +261,13 @@ export function buildPlan({ profile, areas, env = {}, isPullRequest = true }) {
{
name: "test-modules",
when: core,
- env: ex63 ? { TINYCONNECTORS_TARGET_DIR: `${scratch}/target/tinyconnectors`, ...rustEnv, ...sccache } : {},
+ env: ex63
+ ? {
+ TINYCONNECTORS_TARGET_DIR: `${scratch}/target/tinyconnectors`,
+ ...rustEnv,
+ ...sccache,
+ }
+ : {},
run: `bash scripts/ci/self-hosted/install-test-modules.sh "${modulesDir}" ${modulesEnvFile}`,
},
{
@@ -203,17 +286,54 @@ export function buildPlan({ profile, areas, env = {}, isPullRequest = true }) {
env: { ...rustEnv, ...sccache },
checks: [
// `--features` is load-bearing: `default` is the contributor set.
- { name: "clippy-product", when: core, run: `cargo clippy -p openhuman --features ${PRODUCT} -- -D warnings` },
- { name: "clippy-default", when: core, run: "cargo clippy -p openhuman -- -D warnings" },
- { name: "embed-clippy", when: core, run: "cargo clippy -p openhuman-embed --all-targets -- -D warnings" },
- { name: "embed-check-no-default", when: core, run: "cargo check -p openhuman-embed --no-default-features" },
- { name: "embed-test", when: core, run: "cargo test -p openhuman-embed" },
- { name: "tinyhumans-clippy", when: core, run: "cargo clippy -p openhuman-tinyhumans --all-targets -- -D warnings" },
- { name: "tinyhumans-test", when: core, run: "cargo test -p openhuman-tinyhumans" },
- { name: "prompt-budget", when: core, run: "bash scripts/check-prompt-budget.sh --verbose" },
+ {
+ name: "clippy-product",
+ when: core,
+ run: `cargo clippy -p openhuman --features ${PRODUCT} -- -D warnings`,
+ },
+ {
+ name: "clippy-default",
+ when: core,
+ run: "cargo clippy -p openhuman -- -D warnings",
+ },
+ {
+ name: "embed-clippy",
+ when: core,
+ run: "cargo clippy -p openhuman-embed --all-targets -- -D warnings",
+ },
+ {
+ name: "embed-check-no-default",
+ when: core,
+ run: "cargo check -p openhuman-embed --no-default-features",
+ },
+ {
+ name: "embed-test",
+ when: core,
+ run: "cargo test -p openhuman-embed",
+ },
+ {
+ name: "tinyhumans-clippy",
+ when: core,
+ run: "cargo clippy -p openhuman-tinyhumans --all-targets -- -D warnings",
+ },
+ {
+ name: "tinyhumans-test",
+ when: core,
+ run: "cargo test -p openhuman-tinyhumans",
+ },
+ {
+ name: "prompt-budget",
+ when: core,
+ run: "bash scripts/check-prompt-budget.sh --verbose",
+ },
...(ex63 ? [juiceRegression] : []),
// Report-only in ci-lite (never in the gate), so report-only here.
- { name: "rss-bench-fixture-tests", when: core, reportOnly: true, run: "cargo test --features rss-bench --bin rss-bench" },
+ {
+ name: "rss-bench-fixture-tests",
+ when: core,
+ reportOnly: true,
+ run: "cargo test --features rss-bench --bin rss-bench",
+ },
],
},
{
@@ -221,7 +341,11 @@ export function buildPlan({ profile, areas, env = {}, isPullRequest = true }) {
targetDir: targetDir("gatesoff"),
env: { ...rustEnv, ...sccache, RUST_MIN_STACK: "67108864" },
checks: [
- { name: "check-gates-off", when: rust, run: "cargo check --manifest-path Cargo.toml -p openhuman --no-default-features" },
+ {
+ name: "check-gates-off",
+ when: rust,
+ run: "cargo check --manifest-path Cargo.toml -p openhuman --no-default-features",
+ },
{
name: "check-e2e-test-support",
when: rust,
@@ -249,8 +373,16 @@ export function buildPlan({ profile, areas, env = {}, isPullRequest = true }) {
"cargo test --manifest-path Cargo.toml -p openhuman --no-default-features --features e2e-test-support --lib --" +
" test_support::introspect::",
},
- { name: "kernel-floor", when: rust, run: "bash scripts/check-kernel-floor.sh --verbose" },
- { name: "dep-sim-calibration", when: rust, run: "bash scripts/ci/check-dep-sim-calibration.sh" },
+ {
+ name: "kernel-floor",
+ when: rust,
+ run: "bash scripts/check-kernel-floor.sh --verbose",
+ },
+ {
+ name: "dep-sim-calibration",
+ when: rust,
+ run: "bash scripts/ci/check-dep-sim-calibration.sh",
+ },
],
},
{
@@ -312,7 +444,11 @@ export function buildPlan({ profile, areas, env = {}, isPullRequest = true }) {
}
for (const lane of lanes) {
- lane.checks = lane.checks.map((c) => ({ ...c, when: Boolean(c.when), needs: c.needs ?? [] }));
+ lane.checks = lane.checks.map((c) => ({
+ ...c,
+ when: Boolean(c.when),
+ needs: c.needs ?? [],
+ }));
lane.active = lane.checks.some((c) => c.when);
}
return { profile, lanes };
@@ -334,12 +470,14 @@ export function selectLanes(plan, names) {
*/
export function hostedMatrix(plan) {
const active = new Set(plan.lanes.filter((l) => l.active).map((l) => l.name));
- return HOSTED_GROUPS.filter((g) => g.lanes.some((l) => active.has(l))).map((g) => ({
- group: g.group,
- lanes: g.lanes.join(","),
- "max-parallel": g.maxParallel,
- container: g.container ? "ghcr.io/tinyhumansai/openhuman_ci:latest" : "",
- }));
+ return HOSTED_GROUPS.filter((g) => g.lanes.some((l) => active.has(l))).map(
+ (g) => ({
+ group: g.group,
+ lanes: g.lanes.join(","),
+ "max-parallel": g.maxParallel,
+ container: g.container ? "ghcr.io/tinyhumansai/openhuman_ci:latest" : "",
+ }),
+ );
}
/**
@@ -356,7 +494,8 @@ export function validatePlan(plan) {
for (const c of lane.checks) {
for (const need of c.needs) {
const id = need.includes(":") ? need : `${lane.name}:${need}`;
- if (!ids.has(id)) problems.push(`${lane.name}:${c.name} needs unknown check ${id}`);
+ if (!ids.has(id))
+ problems.push(`${lane.name}:${c.name} needs unknown check ${id}`);
}
}
}
diff --git a/scripts/ci/self-hosted/lanes.mjs b/scripts/ci/self-hosted/lanes.mjs
index 601021d1a6..d2df95e963 100644
--- a/scripts/ci/self-hosted/lanes.mjs
+++ b/scripts/ci/self-hosted/lanes.mjs
@@ -15,11 +15,24 @@
// Exit status is non-zero when any gating check failed or was blocked by a
// failed dependency. A failed check never stops the checks after it (#6451).
import { spawn, spawnSync } from "node:child_process";
-import { appendFileSync, createWriteStream, existsSync, mkdirSync, readFileSync, writeFileSync } from "node:fs";
+import {
+ appendFileSync,
+ createWriteStream,
+ existsSync,
+ mkdirSync,
+ readFileSync,
+ writeFileSync,
+} from "node:fs";
import { dirname, join, resolve } from "node:path";
import { fileURLToPath } from "node:url";
-import { areasFromEnv, buildPlan, hostedMatrix, selectLanes, validatePlan } from "./lanes-plan.mjs";
+import {
+ areasFromEnv,
+ buildPlan,
+ hostedMatrix,
+ selectLanes,
+ validatePlan,
+} from "./lanes-plan.mjs";
const ROOT = resolve(dirname(fileURLToPath(import.meta.url)), "..", "..", "..");
const HEARTBEAT_MS = 5 * 60 * 1000;
@@ -30,7 +43,14 @@ function log(msg) {
}
export function parseArgs(argv) {
- const args = { profile: null, lanes: [], maxParallel: 0, out: "ci-out", dryRun: false, printMatrix: false };
+ const args = {
+ profile: null,
+ lanes: [],
+ maxParallel: 0,
+ out: "ci-out",
+ dryRun: false,
+ printMatrix: false,
+ };
for (let i = 0; i < argv.length; i++) {
const a = argv[i];
const next = () => {
@@ -38,8 +58,13 @@ export function parseArgs(argv) {
return argv[++i];
};
if (a === "--profile") args.profile = next();
- else if (a === "--lanes") args.lanes = next().split(",").map((s) => s.trim()).filter(Boolean);
- else if (a === "--max-parallel") args.maxParallel = Number.parseInt(next(), 10);
+ else if (a === "--lanes")
+ args.lanes = next()
+ .split(",")
+ .map((s) => s.trim())
+ .filter(Boolean);
+ else if (a === "--max-parallel")
+ args.maxParallel = Number.parseInt(next(), 10);
else if (a === "--out") args.out = next();
else if (a === "--dry-run") args.dryRun = true;
else if (a === "--print-matrix") args.printMatrix = true;
@@ -61,8 +86,14 @@ export function orderProblems(plan) {
for (const need of c.needs) {
if (!need.includes(":")) continue;
const provider = need.split(":")[0];
- if (!index.has(provider)) problems.push(`${lane.name}:${c.name} needs ${need}, whose lane is not selected`);
- else if (index.get(provider) > i) problems.push(`${lane.name}:${c.name} needs ${need}, whose lane is ordered after it`);
+ if (!index.has(provider))
+ problems.push(
+ `${lane.name}:${c.name} needs ${need}, whose lane is not selected`,
+ );
+ else if (index.get(provider) > i)
+ problems.push(
+ `${lane.name}:${c.name} needs ${need}, whose lane is ordered after it`,
+ );
}
}
});
@@ -71,15 +102,30 @@ export function orderProblems(plan) {
/** Render the per-check outcome table for $GITHUB_STEP_SUMMARY. */
export function renderSummary(results) {
- const rows = ["### CI lanes — per-check outcome", "", "| lane | check | outcome | time |", "| --- | --- | --- | --- |"];
+ const rows = [
+ "### CI lanes — per-check outcome",
+ "",
+ "| lane | check | outcome | time |",
+ "| --- | --- | --- | --- |",
+ ];
for (const lane of results.lanes) {
for (const c of lane.checks) {
- const time = c.durationS == null ? "—" : `${Math.floor(c.durationS / 60)}m${String(c.durationS % 60).padStart(2, "0")}s`;
- const outcome = c.reportOnly && c.status === "failure" ? "failure (report-only)" : c.status;
+ const time =
+ c.durationS == null
+ ? "—"
+ : `${Math.floor(c.durationS / 60)}m${String(c.durationS % 60).padStart(2, "0")}s`;
+ const outcome =
+ c.reportOnly && c.status === "failure"
+ ? "failure (report-only)"
+ : c.status;
rows.push(`| ${lane.name} | ${c.name} | ${outcome} | ${time} |`);
}
}
- rows.push("", "`skipped` = area untouched; `blocked` = a check it needs did not succeed. Neither is a pass for the check itself.", "");
+ rows.push(
+ "",
+ "`skipped` = area untouched; `blocked` = a check it needs did not succeed. Neither is a pass for the check itself.",
+ "",
+ );
return rows.join("\n");
}
@@ -89,7 +135,12 @@ export function gatingFailures(results) {
for (const lane of results.lanes) {
for (const c of lane.checks) {
if (c.reportOnly) continue;
- if (c.status === "failure" || c.status === "blocked" || c.status === "cancelled") failed.push(`${lane.name}:${c.name}`);
+ if (
+ c.status === "failure" ||
+ c.status === "blocked" ||
+ c.status === "cancelled"
+ )
+ failed.push(`${lane.name}:${c.name}`);
}
}
return failed;
@@ -102,7 +153,9 @@ function du(path) {
}
function sccacheStats() {
- const r = spawnSync("sccache", ["--show-stats", "--stats-format", "json"], { encoding: "utf8" });
+ const r = spawnSync("sccache", ["--show-stats", "--stats-format", "json"], {
+ encoding: "utf8",
+ });
if (r.status !== 0) return null;
try {
return JSON.parse(r.stdout);
@@ -159,7 +212,12 @@ export class Runner {
const argv = ["bash", "-o", "pipefail", "-c", check.run];
const cmd = lane.nice ? ["nice", "-n", String(lane.nice), ...argv] : argv;
return new Promise((res) => {
- const child = spawn(cmd[0], cmd.slice(1), { cwd: ROOT, env, detached: true, stdio: ["ignore", "pipe", "pipe"] });
+ const child = spawn(cmd[0], cmd.slice(1), {
+ cwd: ROOT,
+ env,
+ detached: true,
+ stdio: ["ignore", "pipe", "pipe"],
+ });
this.children.add(child);
child.stdout.pipe(logStream, { end: false });
child.stderr.pipe(logStream, { end: false });
@@ -177,10 +235,20 @@ export class Runner {
const logPath = join(this.out, "logs", `${lane.name}.log`);
const logStream = createWriteStream(logPath);
const results = [];
- log(`lane ${lane.name}: start${lane.targetDir ? ` (target ${lane.targetDir})` : ""}`);
+ log(
+ `lane ${lane.name}: start${lane.targetDir ? ` (target ${lane.targetDir})` : ""}`,
+ );
for (const check of lane.checks) {
const id = `${lane.name}:${check.name}`;
- const record = { name: check.name, status: "skipped", reportOnly: Boolean(check.reportOnly), exitCode: null, start: null, end: null, durationS: null };
+ const record = {
+ name: check.name,
+ status: "skipped",
+ reportOnly: Boolean(check.reportOnly),
+ exitCode: null,
+ start: null,
+ end: null,
+ durationS: null,
+ };
results.push(record);
if (!check.when) {
this.finish(id, "skipped");
@@ -191,31 +259,49 @@ export class Runner {
this.finish(id, "cancelled");
continue;
}
- const needs = check.needs.map((n) => (n.includes(":") ? n : `${lane.name}:${n}`));
- const needStatuses = await Promise.all(needs.map((n) => this.done.get(n) ?? Promise.resolve("missing")));
+ const needs = check.needs.map((n) =>
+ n.includes(":") ? n : `${lane.name}:${n}`,
+ );
+ const needStatuses = await Promise.all(
+ needs.map((n) => this.done.get(n) ?? Promise.resolve("missing")),
+ );
const unmet = needs.filter((_, i) => needStatuses[i] !== "success");
if (unmet.length > 0) {
record.status = "blocked";
- logStream.write(`\n[ci][lanes] ${check.name}: blocked — needs ${unmet.join(", ")}\n`);
+ logStream.write(
+ `\n[ci][lanes] ${check.name}: blocked — needs ${unmet.join(", ")}\n`,
+ );
log(`lane ${lane.name}: ${check.name} blocked by ${unmet.join(", ")}`);
this.finish(id, "blocked");
continue;
}
record.start = new Date().toISOString();
const t0 = Date.now();
- logStream.write(`\n[ci][lanes] ===== ${check.name} =====\n$ ${check.run}\n`);
+ logStream.write(
+ `\n[ci][lanes] ===== ${check.name} =====\n$ ${check.run}\n`,
+ );
log(`lane ${lane.name}: ${check.name} started`);
const beat = setInterval(() => {
- log(`lane ${lane.name}: ${check.name} still running (${Math.round((Date.now() - t0) / 60000)} min)`);
+ log(
+ `lane ${lane.name}: ${check.name} still running (${Math.round((Date.now() - t0) / 60000)} min)`,
+ );
}, HEARTBEAT_MS);
const { code } = await this.runCommand(lane, check, logStream);
clearInterval(beat);
record.end = new Date().toISOString();
record.durationS = Math.round((Date.now() - t0) / 1000);
record.exitCode = code;
- record.status = this.cancelled ? "cancelled" : code === 0 ? "success" : "failure";
- logStream.write(`[ci][lanes] ${check.name}: ${record.status} (exit ${code}, ${record.durationS}s)\n`);
- log(`lane ${lane.name}: ${check.name} ${record.status} in ${record.durationS}s${record.reportOnly ? " (report-only)" : ""}`);
+ record.status = this.cancelled
+ ? "cancelled"
+ : code === 0
+ ? "success"
+ : "failure";
+ logStream.write(
+ `[ci][lanes] ${check.name}: ${record.status} (exit ${code}, ${record.durationS}s)\n`,
+ );
+ log(
+ `lane ${lane.name}: ${check.name} ${record.status} in ${record.durationS}s${record.reportOnly ? " (report-only)" : ""}`,
+ );
this.finish(id, record.status);
}
await new Promise((res) => logStream.end(res));
@@ -260,8 +346,15 @@ export class Runner {
async function main() {
const args = parseArgs(process.argv.slice(2));
const areas = areasFromEnv(process.env);
- const isPullRequest = (process.env.GITHUB_EVENT_NAME ?? "pull_request").startsWith("pull_request");
- const fullPlan = buildPlan({ profile: args.profile, areas, env: process.env, isPullRequest });
+ const isPullRequest = (
+ process.env.GITHUB_EVENT_NAME ?? "pull_request"
+ ).startsWith("pull_request");
+ const fullPlan = buildPlan({
+ profile: args.profile,
+ areas,
+ env: process.env,
+ isPullRequest,
+ });
if (args.printMatrix) {
console.log(JSON.stringify({ include: hostedMatrix(fullPlan) }));
@@ -276,14 +369,22 @@ async function main() {
return 2;
}
- log(`profile=${args.profile} areas=${Object.entries(areas).filter(([, v]) => v).map(([k]) => k).join(",") || "(none)"}`);
+ log(
+ `profile=${args.profile} areas=${
+ Object.entries(areas)
+ .filter(([, v]) => v)
+ .map(([k]) => k)
+ .join(",") || "(none)"
+ }`,
+ );
for (const lane of plan.lanes) {
const on = lane.checks.filter((c) => c.when).map((c) => c.name);
log(`plan ${lane.name}: ${on.join(", ")}`);
}
if (args.dryRun) {
for (const lane of plan.lanes) {
- for (const c of lane.checks.filter((x) => x.when)) console.log(`${lane.name}:${c.name}\t${c.run}`);
+ for (const c of lane.checks.filter((x) => x.when))
+ console.log(`${lane.name}:${c.name}\t${c.run}`);
}
return 0;
}
@@ -291,7 +392,8 @@ async function main() {
const out = resolve(ROOT, args.out);
mkdirSync(join(out, "logs"), { recursive: true });
mkdirSync(join(out, "lcov"), { recursive: true });
- if (args.profile === "ex63") spawnSync("sccache", ["--start-server"], { stdio: "ignore" });
+ if (args.profile === "ex63")
+ spawnSync("sccache", ["--start-server"], { stdio: "ignore" });
const runner = new Runner(plan, { out, maxParallel: args.maxParallel });
process.on("SIGTERM", () => runner.cancel("SIGTERM"));
@@ -309,13 +411,18 @@ async function main() {
sccache: args.profile === "ex63" ? sccacheStats() : null,
cacheBytes: du(process.env.CI_CACHE_DIR),
};
- writeFileSync(join(out, "ci-timings.json"), `${JSON.stringify(results, null, 2)}\n`);
- if (process.env.GITHUB_STEP_SUMMARY) appendFileSync(process.env.GITHUB_STEP_SUMMARY, renderSummary(results));
+ writeFileSync(
+ join(out, "ci-timings.json"),
+ `${JSON.stringify(results, null, 2)}\n`,
+ );
+ if (process.env.GITHUB_STEP_SUMMARY)
+ appendFileSync(process.env.GITHUB_STEP_SUMMARY, renderSummary(results));
const failures = gatingFailures(results);
if (runner.cancelled) return 143;
if (failures.length > 0) {
- for (const f of failures) console.error(`::error::[ci][lanes] ${f} did not pass`);
+ for (const f of failures)
+ console.error(`::error::[ci][lanes] ${f} did not pass`);
return 1;
}
log("all gating checks passed");
diff --git a/scripts/ci/self-hosted/test-module-assets.mjs b/scripts/ci/self-hosted/test-module-assets.mjs
index 0ce39939c6..39209ebc0c 100644
--- a/scripts/ci/self-hosted/test-module-assets.mjs
+++ b/scripts/ci/self-hosted/test-module-assets.mjs
@@ -26,7 +26,9 @@ export function readRegistrySource(dir = REGISTRY_DIR) {
.filter((f) => /^records_.*\.rs$/.test(f))
.sort()
.map((f) => readFileSync(join(dir, "registry", f), "utf8"));
- return [readFileSync(join(dir, "registry.rs"), "utf8"), ...fragments].join("\n");
+ return [readFileSync(join(dir, "registry.rs"), "utf8"), ...fragments].join(
+ "\n",
+ );
}
/** `release_url` per record id, from the same source text. */
@@ -45,9 +47,11 @@ export function resolveTestModuleAssets(src, hostKey, ids = TEST_MODULE_IDS) {
const releaseUrls = parseReleaseUrls(src);
return ids.map((id) => {
const record = byId.get(id);
- if (!record) throw new Error(`registry has no ModuleRecord with id "${id}"`);
+ if (!record)
+ throw new Error(`registry has no ModuleRecord with id "${id}"`);
const asset = record.assets.find((a) => a.hostKey === hostKey);
- if (!asset) throw new Error(`${id} ${record.version} has no ${hostKey} asset`);
+ if (!asset)
+ throw new Error(`${id} ${record.version} has no ${hostKey} asset`);
const release = releaseUrls.get(id);
if (!release || !release.includes("/releases/tag/")) {
throw new Error(`${id}: release_url missing or not a /releases/tag/ URL`);