Files
openclaw/scripts/lib/ci-test-timings.mts
Peter Steinberger 02f56eb6ce ci: replace hand-fitted shard timings with committed measurements (#131379)
* ci: use committed measurements for test sharding

Regenerate UI file and runner-specific compact weights from successful CI log medians, with outlier filtering and a 15% write threshold. Keep existing hints as cold-start fallbacks and account for per-file UI overhead without deriving membership from timing keys.

Add a daily standing-PR refit workflow, strict cached loading, fixture coverage, and operator docs. Verify all 302 UI files form identical complete partitions across 22 fresh processes.

* fix(ci): prune stale test timings and trust runner labels

Remove unobserved timing keys only after three sampled runs and report removals in the refit table. Bucket compact measurements using jobs API labels and include all main run attempts without counting retries as independent samples.

Document contended compact walls and the hosted cold-start fallback. Preserve committed timing data and existing sharding behavior; verify 70 focused tests, all 11 UI shards, five corruption fallbacks, live refit, changed checks, workflow checks, and Codex autoreview.

* fix(ci): prune timings per profile with observed evidence

Pruning used one global run count, so a profile with no observations in
the sampled window had its whole committed map deleted. Hosted weights
could never accumulate, and a partial log-fetch failure could drop every
UI E2E entry in a single refit.

* fix(ci): keep preflight timing validation dependency-free

PR preflight builds its manifest with bare Node before dependency installation. Replace the timing schema dependency with strict all-or-nothing validation and preserve the CiTestTimings type.

Walk workflow-derived planner imports in a bounded, cycle-safe regression guard. Keep the refit CLI outside that dependency-free boundary, and document the coercion-helper exception for preflight.

* test(ui): settle typography picker popup animations

* fix(ci): guard timing refit sampling and publication
2026-08-27 21:42:00 -07:00

41 lines
1.3 KiB
TypeScript

// Committed CI measurements are advisory weights, never a test inventory.
import { readFileSync } from "node:fs";
import { ciTestTimingsSchema, type CiTestTimings } from "./ci-test-timings-schema.mts";
const emptyUiTimings = { fileSeconds: {}, perFileOverheadSeconds: 0 };
const emptyGroupTimings: Readonly<Record<string, number>> = {};
let cachedTimings: CiTestTimings | null | undefined;
function readTestTimings(): CiTestTimings | null {
if (process.env.OPENCLAW_CI_TEST_TIMINGS === "0") {
return null;
}
if (cachedTimings === undefined) {
try {
// Every independent UI shard must read the same checkout bytes, not a
// restored cache or downloaded artifact that may differ between jobs.
cachedTimings = ciTestTimingsSchema.parse(
JSON.parse(
readFileSync(new URL("../../config/ci-test-timings.json", import.meta.url), "utf8"),
),
);
} catch {
cachedTimings = null;
}
}
return cachedTimings;
}
export function readUiE2eFileTimings(): {
readonly fileSeconds: Readonly<Record<string, number>>;
readonly perFileOverheadSeconds: number;
} {
return readTestTimings()?.uiE2e ?? emptyUiTimings;
}
export function readCompactGroupTimings(
profile: "blacksmith" | "github",
): Readonly<Record<string, number>> {
return readTestTimings()?.compactGroupSeconds[profile] ?? emptyGroupTimings;
}