fix(perf): enforce route budgets and ratchet coverage thresholds
CI / check (push) Successful in 31s
CI / tests-integration (push) Successful in 2m4s
CI / tests-unit (push) Successful in 2m16s
CI / tests-imaging-browsers (push) Successful in 1m30s
CI / tests-quality (push) Successful in 54s
CI / tests-ui (push) Successful in 3m1s
CI / preflight (push) Skipped
CI / deploy (push) Successful in 3m24s

Allow mode: enforce in the report config, fail the command on over-budget and
unavailable routes, and make the markdown wording follow the configured mode.
Recalibrate the budgets against the webpack build (baseline x1.15, rounded up to
the next 10 KiB) now that the old Turbopack numbers no longer apply, so the
Docker image build gate blocks genuine bundle regressions instead of only
warning. Raise the Vitest coverage thresholds to the measured floor
(37.17/30.1/31.79/38.17 -> 36/29/30/37).
This commit is contained in:
openhands committed 2026-10-16 16:57:08 +02:00
1 parent e70b96e3a7
commit 3a296551f6
5 files changed
+100 -33

No files matched your search

+19 -4
View File
@@ -7,12 +7,12 @@ const LIMIT_KEYS = ["route", "maxInitialRawBytes", "maxInitialGzipBytes"];
export function validateBudgets(config) {
if (
config?.schemaVersion !== 1 ||
config.mode !== "informational" ||
(config.mode !== "informational" && config.mode !== "enforce") ||
!Array.isArray(config.routes) ||
config.routes.length === 0
)
throw new Error(
"Budget config requires schemaVersion 1, mode informational and nonempty routes.",
"Budget config requires schemaVersion 1, mode informational or enforce, and nonempty routes.",
);
if (
Object.keys(config).some(
@@ -288,7 +288,7 @@ export function collectReport(nextDir, config, metadata = {}) {
});
return {
schemaVersion: 1,
mode: "informational",
mode: config.mode,
generatedAt: new Date().toISOString(),
buildId,
commitSha: metadata.commitSha ?? null,
@@ -308,6 +308,10 @@ export function collectReport(nextDir, config, metadata = {}) {
}
export function markdownReport(report) {
const modeLine =
report.mode === "enforce"
? `Build: ${report.buildId ?? "unavailable"}. Declared commit: ${report.commitSha ?? "not supplied"}. Mode: enforce; an over-budget or unavailable route fails the command and the image build.`
: `Build: ${report.buildId ?? "unavailable"}. Declared commit: ${report.commitSha ?? "not supplied"}. Mode: informational; exceeded budgets and unavailable metrics do not fail CI.`;
const lines = [
"# Route JavaScript size report",
"",
@@ -315,7 +319,7 @@ export function markdownReport(report) {
"",
report.gzip,
"",
`Build: ${report.buildId ?? "unavailable"}. Declared commit: ${report.commitSha ?? "not supplied"}. Mode: informational; exceeded budgets and unavailable metrics do not fail CI.`,
modeLine,
"",
"| Route | State | Unique JS | Raw bytes | Gzip bytes | Raw budget | Gzip budget |",
"| --- | --- | ---: | ---: | ---: | ---: | ---: |",
@@ -370,6 +374,17 @@ export function main(argv = process.argv.slice(2)) {
console.warn(
`Performance warning: ${row.route} ${row.status}${row.reason ? `: ${row.reason}` : ""}`,
);
if (report.mode === "enforce") {
const failed = report.routes.filter((row) => row.status !== "measured");
if (failed.length > 0) {
console.error(
`Performance budgets enforced: ${failed
.map((row) => `${row.route} (${row.status})`)
.join(", ")}`,
);
process.exitCode = 1;
}
}
return report;
}
if (