@antelopejs/tooling-configs 0.2.17 → 0.2.19
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +35 -21
- package/dist/bin/api-diff.mjs +25 -14
- package/dist/bin/body-check.mjs +3 -3
- package/dist/bin/capture.d.mts +1 -0
- package/dist/bin/capture.mjs +559 -0
- package/dist/bin/check-size.mjs +3 -3
- package/dist/bin/checks.mjs +24 -6
- package/dist/bin/comment-proof.mjs +3 -3
- package/dist/bin/garden.mjs +229 -28
- package/dist/bin/lease.d.mts +1 -0
- package/dist/bin/lease.mjs +1053 -0
- package/dist/bin/ratchet.mjs +146 -100
- package/dist/bin/suppressions.mjs +5 -5
- package/dist/bin/sync.mjs +150 -176
- package/dist/bin/verify.mjs +238 -125
- package/dist/capture/index.d.mts +50 -0
- package/dist/capture/index.mjs +2 -0
- package/dist/{ci-workflow-ChW4He0r.mjs → ci-workflow-DVkpwauQ.mjs} +12 -0
- package/dist/{files-Bc036sJW.mjs → files-DJ0TeaTU.mjs} +10 -4
- package/dist/formal/index.d.mts +40 -0
- package/dist/formal/index.mjs +205 -0
- package/dist/oxc/anti-slop/index.mjs +717 -16
- package/dist/oxc/fmt.mjs +1 -1
- package/dist/oxc/guardrails/index.d.mts +1 -1
- package/dist/oxc/guardrails/index.mjs +93 -5
- package/dist/oxc/lint.d.mts +9 -0
- package/dist/oxc/lint.mjs +14 -3
- package/dist/{oxlint-Bltmk8-6.mjs → oxlint-DIV-lLSS.mjs} +7 -3
- package/dist/{package-DTxLPNDu.mjs → package-BRTjkzt5.mjs} +26 -1
- package/dist/{proof-stamp-w-3j47A-.mjs → proof-stamp-DDDC0J6l.mjs} +3 -3
- package/dist/{ratchet-DwRj9h4L.mjs → ratchet-BAcLRYuM.mjs} +194 -21
- package/dist/scenes-DZVXkcxS.mjs +104 -0
- package/dist/shared-igPpEDpS.mjs +622 -0
- package/dist/{size-DNtWruCO.mjs → size-DBatLT-F.mjs} +2 -2
- package/dist/{suppression-base-DAfCXwjL.mjs → suppression-base-9L8dlMQK.mjs} +36 -11
- package/dist/{suppression-budget-Bd2GqMYb.mjs → suppression-budget-C0SkPO5R.mjs} +56 -19
- package/dist/{suppressions-BD_f8f7L.mjs → suppressions-DM60NkvL.mjs} +1 -1
- package/dist/templates-CypDm-j9.mjs +121 -0
- package/dist/{typescript-BmS5BmrS.mjs → typescript-CM0LrVP7.mjs} +2 -2
- package/dist/verify/index.d.mts +6 -1
- package/package.json +29 -4
- package/dist/shared-CoUt4GUm.mjs +0 -73
package/dist/bin/verify.mjs
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import { a as VERIFY_KINDS, c as isVerifyKind, l as skillFolder } from "../shared-
|
|
2
|
+
import { a as VERIFY_KINDS, c as isVerifyKind, l as skillFolder } from "../shared-igPpEDpS.mjs";
|
|
3
3
|
import { a as isString, f as parseJson, i as isObject, u as optStr } from "../json-CG2L7YFl.mjs";
|
|
4
4
|
import { a as exitIs, c as interrupted, i as exists, r as equal, u as refused } from "../checks-CxkSu2E6.mjs";
|
|
5
5
|
import { n as runCliAsync } from "../cli-4Tv71vYk.mjs";
|
|
6
|
-
import {
|
|
6
|
+
import { c as repositoryRoot } from "../files-DJ0TeaTU.mjs";
|
|
7
7
|
import { appendFileSync, closeSync, copyFileSync, cpSync, existsSync, lstatSync, mkdirSync, mkdtempSync, openSync, readFileSync, readdirSync, readlinkSync, realpathSync, rmSync, statSync, symlinkSync, writeFileSync } from "node:fs";
|
|
8
8
|
import { basename, dirname, extname, join, matchesGlob, posix, relative, resolve, sep } from "node:path";
|
|
9
9
|
import { execFileSync, spawn, spawnSync } from "node:child_process";
|
|
10
|
-
import { parseArgs } from "node:util";
|
|
11
10
|
import { pathToFileURL } from "node:url";
|
|
12
11
|
import ts from "typescript";
|
|
13
|
-
import { homedir, tmpdir } from "node:os";
|
|
14
12
|
import { randomBytes } from "node:crypto";
|
|
13
|
+
import { homedir, tmpdir } from "node:os";
|
|
14
|
+
import { parseArgs } from "node:util";
|
|
15
15
|
import { createServer } from "node:net";
|
|
16
16
|
//#region src/verify/doors.ts
|
|
17
17
|
const RELEASE_FILES = [
|
|
@@ -870,6 +870,123 @@ const BUILTIN_JOURNEYS = {
|
|
|
870
870
|
}
|
|
871
871
|
};
|
|
872
872
|
//#endregion
|
|
873
|
+
//#region src/verify/docker.ts
|
|
874
|
+
const READY_TIMEOUT_MS$1 = 9e4;
|
|
875
|
+
function docker(args) {
|
|
876
|
+
const run = spawnSync("docker", args, { encoding: "utf8" });
|
|
877
|
+
return {
|
|
878
|
+
status: run.status,
|
|
879
|
+
stdout: run.stdout ?? "",
|
|
880
|
+
stderr: `${run.stderr ?? ""}${run.error ? `${run.error.message}\n` : ""}`
|
|
881
|
+
};
|
|
882
|
+
}
|
|
883
|
+
function record(folder, args, result) {
|
|
884
|
+
mkdirSync(folder, { recursive: true });
|
|
885
|
+
writeFileSync(join(folder, "command.txt"), `docker ${args.join(" ")}\n`);
|
|
886
|
+
writeFileSync(join(folder, "stdout.txt"), result.stdout);
|
|
887
|
+
writeFileSync(join(folder, "stderr.txt"), result.stderr);
|
|
888
|
+
writeFileSync(join(folder, "exit-code.txt"), `${result.status}\n`);
|
|
889
|
+
}
|
|
890
|
+
function publishedPort(container, port) {
|
|
891
|
+
const mapping = docker([
|
|
892
|
+
"port",
|
|
893
|
+
container,
|
|
894
|
+
`${port}/tcp`
|
|
895
|
+
]).stdout;
|
|
896
|
+
const match = /127\.0\.0\.1:(\d+)/.exec(mapping);
|
|
897
|
+
if (!match) throw new Error(`${container} does not publish ${port}: ${mapping}`);
|
|
898
|
+
return Number(match[1]);
|
|
899
|
+
}
|
|
900
|
+
function waitReady(container, ready, folder) {
|
|
901
|
+
const deadline = Date.now() + READY_TIMEOUT_MS$1;
|
|
902
|
+
let last = docker([
|
|
903
|
+
"exec",
|
|
904
|
+
container,
|
|
905
|
+
...ready
|
|
906
|
+
]);
|
|
907
|
+
while (last.status !== 0 && Date.now() < deadline) {
|
|
908
|
+
spawnSync("sleep", ["0.5"]);
|
|
909
|
+
last = docker([
|
|
910
|
+
"exec",
|
|
911
|
+
container,
|
|
912
|
+
...ready
|
|
913
|
+
]);
|
|
914
|
+
}
|
|
915
|
+
record(folder, [
|
|
916
|
+
"exec",
|
|
917
|
+
container,
|
|
918
|
+
...ready
|
|
919
|
+
], last);
|
|
920
|
+
if (last.status !== 0) throw new Error(`${container} was not ready within ${READY_TIMEOUT_MS$1} ms: ${last.stderr}`);
|
|
921
|
+
}
|
|
922
|
+
/**
|
|
923
|
+
* Starts every service of verify.config.ts in its own container, named
|
|
924
|
+
* `<prefix>-<repo>-<service>-<run id>`, publishes its port on a free
|
|
925
|
+
* loopback port chosen by Docker, and waits for its readiness command. Each
|
|
926
|
+
* container is recorded before it is probed, so `clean` removes it even when
|
|
927
|
+
* it never became ready.
|
|
928
|
+
*/
|
|
929
|
+
function startServices(workspace, state, prefix) {
|
|
930
|
+
for (const [service, definition] of Object.entries(workspace.config.services ?? {})) {
|
|
931
|
+
const name = `${prefix}-${workspace.name}-${service}-${state.id}`.toLowerCase();
|
|
932
|
+
const env = Object.entries(definition.env ?? {}).flatMap(([key, value]) => ["-e", `${key}=${value}`]);
|
|
933
|
+
const args = [
|
|
934
|
+
"run",
|
|
935
|
+
"-d",
|
|
936
|
+
"--name",
|
|
937
|
+
name,
|
|
938
|
+
"-p",
|
|
939
|
+
`127.0.0.1::${definition.port}`,
|
|
940
|
+
...env,
|
|
941
|
+
definition.image
|
|
942
|
+
];
|
|
943
|
+
const folder = join(state.evidence, "services", service);
|
|
944
|
+
const started = docker(args);
|
|
945
|
+
record(join(folder, "01-run"), args, started);
|
|
946
|
+
if (started.status !== 0) throw new Error(`docker ${args.join(" ")} failed: ${started.stderr}`);
|
|
947
|
+
const container = {
|
|
948
|
+
service,
|
|
949
|
+
name,
|
|
950
|
+
host: "127.0.0.1",
|
|
951
|
+
port: 0
|
|
952
|
+
};
|
|
953
|
+
state.containers.push(container);
|
|
954
|
+
saveRun(state);
|
|
955
|
+
container.port = publishedPort(name, definition.port);
|
|
956
|
+
saveRun(state);
|
|
957
|
+
waitReady(name, definition.ready, join(folder, "02-ready"));
|
|
958
|
+
}
|
|
959
|
+
}
|
|
960
|
+
/** Runs a service's readiness command once in its container, recorded in `folder`: the stderr when it fails, `null` when it passes. */
|
|
961
|
+
function readinessFailure(container, ready, folder) {
|
|
962
|
+
const args = [
|
|
963
|
+
"exec",
|
|
964
|
+
container,
|
|
965
|
+
...ready
|
|
966
|
+
];
|
|
967
|
+
const result = docker(args);
|
|
968
|
+
record(folder, args, result);
|
|
969
|
+
return result.status === 0 ? null : result.stderr.trim().slice(-300) || `exit ${result.status}`;
|
|
970
|
+
}
|
|
971
|
+
/** Whether a recorded container is running. */
|
|
972
|
+
function containerRunning(name) {
|
|
973
|
+
return docker([
|
|
974
|
+
"inspect",
|
|
975
|
+
"-f",
|
|
976
|
+
"{{.State.Running}}",
|
|
977
|
+
name
|
|
978
|
+
]).stdout.trim() === "true";
|
|
979
|
+
}
|
|
980
|
+
/** Removes a container this run started, by its recorded name. */
|
|
981
|
+
function removeContainer(name) {
|
|
982
|
+
return docker([
|
|
983
|
+
"rm",
|
|
984
|
+
"-f",
|
|
985
|
+
"-v",
|
|
986
|
+
name
|
|
987
|
+
]).status === 0;
|
|
988
|
+
}
|
|
989
|
+
//#endregion
|
|
873
990
|
//#region src/verify/fixture-modules.ts
|
|
874
991
|
const WALK = String.raw`
|
|
875
992
|
const fs = require("node:fs");
|
|
@@ -1385,10 +1502,23 @@ function recordTree(folder, root) {
|
|
|
1385
1502
|
//#region src/verify/context.ts
|
|
1386
1503
|
var JourneyAbort = class extends Error {};
|
|
1387
1504
|
var NotVerified = class extends Error {};
|
|
1388
|
-
const READY_TIMEOUT_MS
|
|
1505
|
+
const READY_TIMEOUT_MS = 12e4;
|
|
1389
1506
|
const STOP_TIMEOUT_MS = 3e4;
|
|
1390
1507
|
const POLL_MS = 250;
|
|
1391
1508
|
const SETTLE_MS = 3e3;
|
|
1509
|
+
/** The waits between the readiness reruns after a failed journey: one miss under load does not hide a catch. */
|
|
1510
|
+
const READINESS_RETRY_MS = [
|
|
1511
|
+
500,
|
|
1512
|
+
1e3,
|
|
1513
|
+
2e3
|
|
1514
|
+
];
|
|
1515
|
+
/** The signals a process outside the run sends to end an app. Any other signal, such as SIGABRT or SIGSEGV, is the product crashing. */
|
|
1516
|
+
const OUTSIDE_KILLS = /* @__PURE__ */ new Set([
|
|
1517
|
+
"SIGKILL",
|
|
1518
|
+
"SIGTERM",
|
|
1519
|
+
"SIGHUP",
|
|
1520
|
+
"SIGINT"
|
|
1521
|
+
]);
|
|
1392
1522
|
function slug(text) {
|
|
1393
1523
|
return text.toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-|-$/g, "");
|
|
1394
1524
|
}
|
|
@@ -1403,6 +1533,7 @@ var VerifyContext = class {
|
|
|
1403
1533
|
home;
|
|
1404
1534
|
steps = [];
|
|
1405
1535
|
running = [];
|
|
1536
|
+
started = [];
|
|
1406
1537
|
fixtures = /* @__PURE__ */ new Map();
|
|
1407
1538
|
index = 0;
|
|
1408
1539
|
workspace;
|
|
@@ -1553,10 +1684,17 @@ var VerifyContext = class {
|
|
|
1553
1684
|
project,
|
|
1554
1685
|
port
|
|
1555
1686
|
};
|
|
1556
|
-
|
|
1687
|
+
const entry = {
|
|
1557
1688
|
app,
|
|
1558
|
-
handle
|
|
1689
|
+
handle,
|
|
1690
|
+
sent: [],
|
|
1691
|
+
exit: null
|
|
1692
|
+
};
|
|
1693
|
+
handle.exited.then((exit) => {
|
|
1694
|
+
entry.exit = exit;
|
|
1559
1695
|
});
|
|
1696
|
+
this.running.push(entry);
|
|
1697
|
+
this.started.push(entry);
|
|
1560
1698
|
this.state.processes.push({
|
|
1561
1699
|
name: `${name} (${project})`,
|
|
1562
1700
|
pid: handle.pid
|
|
@@ -1587,7 +1725,7 @@ var VerifyContext = class {
|
|
|
1587
1725
|
}
|
|
1588
1726
|
async waitReady(app, handle, fixture) {
|
|
1589
1727
|
const folder = this.step("ready");
|
|
1590
|
-
const deadline = Date.now() + READY_TIMEOUT_MS
|
|
1728
|
+
const deadline = Date.now() + READY_TIMEOUT_MS;
|
|
1591
1729
|
let exited = false;
|
|
1592
1730
|
handle.exited.then(() => {
|
|
1593
1731
|
exited = true;
|
|
@@ -1606,7 +1744,6 @@ var VerifyContext = class {
|
|
|
1606
1744
|
};
|
|
1607
1745
|
writeFileSync(join(folder, "ready.txt"), `${check.pass && !exited ? "ready" : exited ? "exited before ready" : "timed out"}\n`);
|
|
1608
1746
|
this.expect(folder, check.pass ? [check, alive] : [check], { critical: true });
|
|
1609
|
-
this.expect(folder, [check], { critical: true });
|
|
1610
1747
|
}
|
|
1611
1748
|
/** Posts a JSON body to a route of the driver module. */
|
|
1612
1749
|
async driver(name, app, route, body) {
|
|
@@ -1636,6 +1773,7 @@ var VerifyContext = class {
|
|
|
1636
1773
|
const folder = this.step(name);
|
|
1637
1774
|
writeFileSync(join(folder, "command.txt"), `kill -INT ${app.pid}\n`);
|
|
1638
1775
|
const running = this.running.find((entry) => entry.app.pid === app.pid);
|
|
1776
|
+
running?.sent.push("SIGINT");
|
|
1639
1777
|
try {
|
|
1640
1778
|
process.kill(app.pid, "SIGINT");
|
|
1641
1779
|
} catch {
|
|
@@ -1651,6 +1789,7 @@ var VerifyContext = class {
|
|
|
1651
1789
|
};
|
|
1652
1790
|
clearTimeout(timer);
|
|
1653
1791
|
if (!outcome) {
|
|
1792
|
+
running?.sent.push("SIGKILL");
|
|
1654
1793
|
killGroup(app.pid);
|
|
1655
1794
|
writeFileSync(join(folder, "note.txt"), `no exit within ${STOP_TIMEOUT_MS} ms of SIGINT; killed the process group\n`);
|
|
1656
1795
|
}
|
|
@@ -1701,6 +1840,40 @@ var VerifyContext = class {
|
|
|
1701
1840
|
async cleanup() {
|
|
1702
1841
|
for (const entry of this.running.slice()) await this.stop(`cleanup ${entry.app.name}`, entry.app);
|
|
1703
1842
|
}
|
|
1843
|
+
/**
|
|
1844
|
+
* Why the run's environment, not the product, explains a failed journey,
|
|
1845
|
+
* or `null` when nothing points away from the product: a service that
|
|
1846
|
+
* still fails its readiness command after a few reruns, an app killed by
|
|
1847
|
+
* SIGKILL, SIGTERM, SIGHUP or SIGINT that the harness did not send, or the
|
|
1848
|
+
* app the harness started failing to bind the driver's port. A break that
|
|
1849
|
+
* takes its own service down reads as an outage. Call it after `cleanup`,
|
|
1850
|
+
* when every app has exited.
|
|
1851
|
+
*/
|
|
1852
|
+
async environmentFault() {
|
|
1853
|
+
for (const [name, service] of Object.entries(this.workspace.config.services ?? {})) {
|
|
1854
|
+
const failure = await this.unready(name, service.ready);
|
|
1855
|
+
if (failure !== null) return `the service ${name} no longer passes its readiness command: ${failure}`;
|
|
1856
|
+
}
|
|
1857
|
+
for (const { app, sent, exit } of this.started) {
|
|
1858
|
+
const label = `${app.name} (pid ${app.pid})`;
|
|
1859
|
+
if (exit?.signal && OUTSIDE_KILLS.has(exit.signal) && !sent.includes(exit.signal)) return `${label} was killed by ${exit.signal}, a signal the harness did not send`;
|
|
1860
|
+
const output = readOutput(app.folder);
|
|
1861
|
+
const port = new RegExp(`(?<![0-9])${app.port}(?![0-9])`);
|
|
1862
|
+
const taken = `${output.stdout}\n${output.stderr}`.split("\n").find((line) => line.includes("EADDRINUSE") && port.test(line));
|
|
1863
|
+
if (taken !== void 0) return `${label} could not bind port ${app.port}, which another process holds: ${taken.trim().slice(0, 300)}`;
|
|
1864
|
+
}
|
|
1865
|
+
return null;
|
|
1866
|
+
}
|
|
1867
|
+
/** The last readiness failure of a service after the reruns, or `null` once one rerun passes. */
|
|
1868
|
+
async unready(name, ready) {
|
|
1869
|
+
let failure = null;
|
|
1870
|
+
for (const wait of [0, ...READINESS_RETRY_MS]) {
|
|
1871
|
+
await sleep(wait);
|
|
1872
|
+
failure = readinessFailure(this.service(name).container, ready, this.step(`${name} readiness after the failure`));
|
|
1873
|
+
if (failure === null) return null;
|
|
1874
|
+
}
|
|
1875
|
+
return failure;
|
|
1876
|
+
}
|
|
1704
1877
|
/** Records why the journey ended without a verdict on the product. */
|
|
1705
1878
|
static reasonOf(failure) {
|
|
1706
1879
|
if (failure instanceof NotVerified) return {
|
|
@@ -1940,6 +2113,13 @@ async function runOne(workspace, state, feature, id, journey) {
|
|
|
1940
2113
|
failure = VerifyContext.reasonOf(error instanceof Error ? error : new Error(String(error)));
|
|
1941
2114
|
}
|
|
1942
2115
|
await context.cleanup();
|
|
2116
|
+
if (statusOf(context, failure) === "FAIL") {
|
|
2117
|
+
const fault = await context.environmentFault();
|
|
2118
|
+
if (fault !== null) failure = {
|
|
2119
|
+
...failure,
|
|
2120
|
+
notVerified: fault
|
|
2121
|
+
};
|
|
2122
|
+
}
|
|
1943
2123
|
const result = {
|
|
1944
2124
|
feature,
|
|
1945
2125
|
journey: id,
|
|
@@ -2093,18 +2273,33 @@ function runFeatureIn(bin, worktree, feature, baseRef, ids = []) {
|
|
|
2093
2273
|
function failsACheck(result) {
|
|
2094
2274
|
return result.steps.some((step) => step.checks.some((check) => !check.pass));
|
|
2095
2275
|
}
|
|
2096
|
-
|
|
2276
|
+
function notVerifiedIn(results) {
|
|
2277
|
+
return results.filter((result) => result.status === "NOT VERIFIED").map((result) => `${result.journey} (${result.notVerified})`);
|
|
2278
|
+
}
|
|
2279
|
+
/**
|
|
2280
|
+
* A break is caught only by a journey that passes in the control and fails
|
|
2281
|
+
* one of its checks with the patch. A journey that ends NOT VERIFIED, because
|
|
2282
|
+
* its environment went away, never counts as a catch, and leaves an uncaught
|
|
2283
|
+
* break NOT VERIFIED rather than MISSED.
|
|
2284
|
+
*/
|
|
2097
2285
|
function judgeSeeded(feature, control, seeded) {
|
|
2098
2286
|
const passedInControl = new Set(control.results.filter((result) => result.status === "PASS").map((result) => result.journey));
|
|
2099
2287
|
const failed = seeded.results.filter((result) => result.status === "FAIL");
|
|
2288
|
+
const caughtBy = failed.filter((result) => passedInControl.has(result.journey) && failsACheck(result)).map((result) => result.journey);
|
|
2289
|
+
const notVerified = {
|
|
2290
|
+
control: notVerifiedIn(control.results),
|
|
2291
|
+
seeded: notVerifiedIn(seeded.results.filter((result) => passedInControl.has(result.journey)))
|
|
2292
|
+
};
|
|
2293
|
+
const unreached = notVerified.control.length + notVerified.seeded.length > 0;
|
|
2100
2294
|
return {
|
|
2101
2295
|
feature,
|
|
2102
|
-
|
|
2296
|
+
outcome: caughtBy.length > 0 ? "CAUGHT" : unreached ? "NOT VERIFIED" : "MISSED",
|
|
2103
2297
|
run: seeded.run,
|
|
2104
2298
|
controlRun: control.run,
|
|
2105
|
-
caughtBy
|
|
2106
|
-
failingInControl: control.results.filter((result) => result.status
|
|
2299
|
+
caughtBy,
|
|
2300
|
+
failingInControl: control.results.filter((result) => result.status === "FAIL").map((result) => result.journey),
|
|
2107
2301
|
harnessErrors: failed.filter((result) => !failsACheck(result)).map((result) => result.journey),
|
|
2302
|
+
notVerified,
|
|
2108
2303
|
output: seeded.output
|
|
2109
2304
|
};
|
|
2110
2305
|
}
|
|
@@ -2170,6 +2365,10 @@ function judgeContainment(control, withDoor) {
|
|
|
2170
2365
|
outcome: "CONTAINED",
|
|
2171
2366
|
detail: "it passes unpatched and fails a check with its door"
|
|
2172
2367
|
};
|
|
2368
|
+
if (withDoor.status === "NOT VERIFIED") return {
|
|
2369
|
+
outcome: "UNPROVEN",
|
|
2370
|
+
detail: `with the door it could not reach the product (${withDoor.notVerified}), so it proves nothing`
|
|
2371
|
+
};
|
|
2173
2372
|
return {
|
|
2174
2373
|
outcome: "UNPROVEN",
|
|
2175
2374
|
detail: `with the door it ended ${withDoor.status} without a failing check, a harness error rather than a caught door`
|
|
@@ -2847,112 +3046,6 @@ function readJudgement(file) {
|
|
|
2847
3046
|
};
|
|
2848
3047
|
}
|
|
2849
3048
|
//#endregion
|
|
2850
|
-
//#region src/verify/docker.ts
|
|
2851
|
-
const READY_TIMEOUT_MS = 9e4;
|
|
2852
|
-
function docker(args) {
|
|
2853
|
-
const run = spawnSync("docker", args, { encoding: "utf8" });
|
|
2854
|
-
return {
|
|
2855
|
-
status: run.status,
|
|
2856
|
-
stdout: run.stdout ?? "",
|
|
2857
|
-
stderr: `${run.stderr ?? ""}${run.error ? `${run.error.message}\n` : ""}`
|
|
2858
|
-
};
|
|
2859
|
-
}
|
|
2860
|
-
function record(folder, args, result) {
|
|
2861
|
-
mkdirSync(folder, { recursive: true });
|
|
2862
|
-
writeFileSync(join(folder, "command.txt"), `docker ${args.join(" ")}\n`);
|
|
2863
|
-
writeFileSync(join(folder, "stdout.txt"), result.stdout);
|
|
2864
|
-
writeFileSync(join(folder, "stderr.txt"), result.stderr);
|
|
2865
|
-
writeFileSync(join(folder, "exit-code.txt"), `${result.status}\n`);
|
|
2866
|
-
}
|
|
2867
|
-
function publishedPort(container, port) {
|
|
2868
|
-
const mapping = docker([
|
|
2869
|
-
"port",
|
|
2870
|
-
container,
|
|
2871
|
-
`${port}/tcp`
|
|
2872
|
-
]).stdout;
|
|
2873
|
-
const match = /127\.0\.0\.1:(\d+)/.exec(mapping);
|
|
2874
|
-
if (!match) throw new Error(`${container} does not publish ${port}: ${mapping}`);
|
|
2875
|
-
return Number(match[1]);
|
|
2876
|
-
}
|
|
2877
|
-
function waitReady(container, ready, folder) {
|
|
2878
|
-
const deadline = Date.now() + READY_TIMEOUT_MS;
|
|
2879
|
-
let last = docker([
|
|
2880
|
-
"exec",
|
|
2881
|
-
container,
|
|
2882
|
-
...ready
|
|
2883
|
-
]);
|
|
2884
|
-
while (last.status !== 0 && Date.now() < deadline) {
|
|
2885
|
-
spawnSync("sleep", ["0.5"]);
|
|
2886
|
-
last = docker([
|
|
2887
|
-
"exec",
|
|
2888
|
-
container,
|
|
2889
|
-
...ready
|
|
2890
|
-
]);
|
|
2891
|
-
}
|
|
2892
|
-
record(folder, [
|
|
2893
|
-
"exec",
|
|
2894
|
-
container,
|
|
2895
|
-
...ready
|
|
2896
|
-
], last);
|
|
2897
|
-
if (last.status !== 0) throw new Error(`${container} was not ready within ${READY_TIMEOUT_MS} ms: ${last.stderr}`);
|
|
2898
|
-
}
|
|
2899
|
-
/**
|
|
2900
|
-
* Starts every service of verify.config.ts in its own container, named
|
|
2901
|
-
* `<prefix>-<repo>-<service>-<run id>`, publishes its port on a free
|
|
2902
|
-
* loopback port chosen by Docker, and waits for its readiness command. Each
|
|
2903
|
-
* container is recorded before it is probed, so `clean` removes it even when
|
|
2904
|
-
* it never became ready.
|
|
2905
|
-
*/
|
|
2906
|
-
function startServices(workspace, state, prefix) {
|
|
2907
|
-
for (const [service, definition] of Object.entries(workspace.config.services ?? {})) {
|
|
2908
|
-
const name = `${prefix}-${workspace.name}-${service}-${state.id}`.toLowerCase();
|
|
2909
|
-
const env = Object.entries(definition.env ?? {}).flatMap(([key, value]) => ["-e", `${key}=${value}`]);
|
|
2910
|
-
const args = [
|
|
2911
|
-
"run",
|
|
2912
|
-
"-d",
|
|
2913
|
-
"--name",
|
|
2914
|
-
name,
|
|
2915
|
-
"-p",
|
|
2916
|
-
`127.0.0.1::${definition.port}`,
|
|
2917
|
-
...env,
|
|
2918
|
-
definition.image
|
|
2919
|
-
];
|
|
2920
|
-
const folder = join(state.evidence, "services", service);
|
|
2921
|
-
const started = docker(args);
|
|
2922
|
-
record(join(folder, "01-run"), args, started);
|
|
2923
|
-
if (started.status !== 0) throw new Error(`docker ${args.join(" ")} failed: ${started.stderr}`);
|
|
2924
|
-
const container = {
|
|
2925
|
-
service,
|
|
2926
|
-
name,
|
|
2927
|
-
host: "127.0.0.1",
|
|
2928
|
-
port: 0
|
|
2929
|
-
};
|
|
2930
|
-
state.containers.push(container);
|
|
2931
|
-
saveRun(state);
|
|
2932
|
-
container.port = publishedPort(name, definition.port);
|
|
2933
|
-
saveRun(state);
|
|
2934
|
-
waitReady(name, definition.ready, join(folder, "02-ready"));
|
|
2935
|
-
}
|
|
2936
|
-
}
|
|
2937
|
-
/** Whether a recorded container is running. */
|
|
2938
|
-
function containerRunning(name) {
|
|
2939
|
-
return docker([
|
|
2940
|
-
"inspect",
|
|
2941
|
-
"-f",
|
|
2942
|
-
"{{.State.Running}}",
|
|
2943
|
-
name
|
|
2944
|
-
]).stdout.trim() === "true";
|
|
2945
|
-
}
|
|
2946
|
-
/** Removes a container this run started, by its recorded name. */
|
|
2947
|
-
function removeContainer(name) {
|
|
2948
|
-
return docker([
|
|
2949
|
-
"rm",
|
|
2950
|
-
"-f",
|
|
2951
|
-
"-v",
|
|
2952
|
-
name
|
|
2953
|
-
]).status === 0;
|
|
2954
|
-
}
|
|
2955
|
-
//#endregion
|
|
2956
3049
|
//#region src/verify/sources.ts
|
|
2957
3050
|
const IDENTITY = [
|
|
2958
3051
|
"-c",
|
|
@@ -3397,10 +3490,19 @@ function short(sha) {
|
|
|
3397
3490
|
function bullets(entries, empty) {
|
|
3398
3491
|
return (entries.length > 0 ? entries : [empty]).map((entry) => `- ${entry}`);
|
|
3399
3492
|
}
|
|
3493
|
+
function journeyRow(label, result, link) {
|
|
3494
|
+
const outcome = result.status === "PASS" ? "pass" : result.status === "FAIL" ? "**fail**" : "**not verified**";
|
|
3495
|
+
return `| ${label} | \`${result.journey}\`: ${result.entryPoint} | ${outcome}: ${result.title} | [${result.folder}](${link(result.folder)}) |`;
|
|
3496
|
+
}
|
|
3497
|
+
/** The features outside the plan that have journey results in the run's evidence, in name order. */
|
|
3498
|
+
function featuresOutsidePlan(state, plan) {
|
|
3499
|
+
return readdirSync(state.evidence, { withFileTypes: true }).filter((entry) => entry.isDirectory() && !plan.run.includes(entry.name) && existsSync(join(state.evidence, entry.name, "feature.json"))).map((entry) => entry.name).sort();
|
|
3500
|
+
}
|
|
3400
3501
|
function journeyRows(workspace, state, plan, link) {
|
|
3401
3502
|
const rows = [];
|
|
3402
3503
|
const reasons = [];
|
|
3403
3504
|
const notVerified = [];
|
|
3505
|
+
const outsideNotVerified = [];
|
|
3404
3506
|
const byJourney = /* @__PURE__ */ new Map();
|
|
3405
3507
|
for (const feature of plan.run) {
|
|
3406
3508
|
const results = readResults(state, feature) ?? [];
|
|
@@ -3411,14 +3513,19 @@ function journeyRows(workspace, state, plan, link) {
|
|
|
3411
3513
|
byJourney.set(`${feature}/${result.journey}`, result);
|
|
3412
3514
|
if (result.status === "FAIL") reasons.push(`${feature}/${result.journey} failed`);
|
|
3413
3515
|
if (result.status === "NOT VERIFIED") notVerified.push(`${feature}/${result.journey}: ${result.notVerified}`);
|
|
3414
|
-
|
|
3415
|
-
rows.push(`| ${feature} | \`${result.journey}\`: ${result.entryPoint} | ${outcome}: ${result.title} | [${result.folder}](${link(result.folder)}) |`);
|
|
3516
|
+
rows.push(journeyRow(feature, result, link));
|
|
3416
3517
|
}
|
|
3417
3518
|
}
|
|
3519
|
+
for (const feature of featuresOutsidePlan(state, plan)) for (const result of readResults(state, feature) ?? []) {
|
|
3520
|
+
if (result.status === "FAIL") reasons.push(`${feature}/${result.journey} failed; ${feature} is outside the diff's features, so check its covers globs`);
|
|
3521
|
+
if (result.status === "NOT VERIFIED") outsideNotVerified.push(`${feature}/${result.journey}: ${result.notVerified}`);
|
|
3522
|
+
rows.push(journeyRow(`${feature} (outside the diff's features)`, result, link));
|
|
3523
|
+
}
|
|
3418
3524
|
return {
|
|
3419
3525
|
rows,
|
|
3420
3526
|
reasons,
|
|
3421
3527
|
notVerified,
|
|
3528
|
+
outsideNotVerified,
|
|
3422
3529
|
byJourney
|
|
3423
3530
|
};
|
|
3424
3531
|
}
|
|
@@ -3502,7 +3609,11 @@ function renderVerdict(workspace, state, pr, judgement) {
|
|
|
3502
3609
|
const journeys = journeyRows(workspace, state, plan, link);
|
|
3503
3610
|
const formal = formalSection(workspace, state, plan, link);
|
|
3504
3611
|
reasons.push(...journeys.reasons, ...plan.unmapped.map((file) => `unmapped surface ${file}`), ...docsReasons(judgement, plan), ...doorReasons(workspace, judgement, journeys.byJourney, plan), ...formal.reasons);
|
|
3505
|
-
const notVerified = [
|
|
3612
|
+
const notVerified = [
|
|
3613
|
+
...journeys.notVerified,
|
|
3614
|
+
...journeys.outsideNotVerified,
|
|
3615
|
+
...judgement.notVerified
|
|
3616
|
+
];
|
|
3506
3617
|
const result = resultOf(reasons, journeys.notVerified, notVerified.length + judgement.attention.length);
|
|
3507
3618
|
const touched = plan.touched.map((entry) => `\`${entry.feature}\` (diff: ${entry.files.map((file) => `\`${file}\``).join(", ")})`);
|
|
3508
3619
|
const markdown = [
|
|
@@ -3639,12 +3750,14 @@ function printDoors(workspace, files) {
|
|
|
3639
3750
|
function runSeeded(workspace, features, baseRef) {
|
|
3640
3751
|
const results = runSeededBreaks(workspace, process.argv[1], features, baseRef);
|
|
3641
3752
|
for (const result of results) {
|
|
3642
|
-
print(`${result.
|
|
3643
|
-
if (result.failingInControl.length > 0) print(`
|
|
3753
|
+
print(`${result.outcome} ${result.feature} by ${result.caughtBy.join(", ") || "no journey"} (evidence ${result.run}/evidence/${result.feature}, control ${result.controlRun}/evidence/${result.feature})`);
|
|
3754
|
+
if (result.failingInControl.length > 0) print(` failing without the patch, not counted: ${result.failingInControl.join(", ")}`);
|
|
3755
|
+
if (result.notVerified.control.length > 0) print(` not verified without the patch, not counted: ${result.notVerified.control.join(", ")}`);
|
|
3756
|
+
if (result.notVerified.seeded.length > 0) print(` not verified with the patch, not counted: ${result.notVerified.seeded.join(", ")}`);
|
|
3644
3757
|
if (result.harnessErrors.length > 0) print(` failed without a failing check (harness error), not counted: ${result.harnessErrors.join(", ")}`);
|
|
3645
3758
|
print(result.output.replace(/^/gm, " "));
|
|
3646
3759
|
}
|
|
3647
|
-
return results.every((result) => result.
|
|
3760
|
+
return results.every((result) => result.outcome === "CAUGHT") ? 0 : 1;
|
|
3648
3761
|
}
|
|
3649
3762
|
function runSeededDoors(workspace) {
|
|
3650
3763
|
const doors = checkSeededDoors(workspace);
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
//#region src/capture/scenes.d.ts
|
|
2
|
+
/** The size of the browser window a scene is captured in, in CSS pixels. */
|
|
3
|
+
interface CaptureViewport {
|
|
4
|
+
width: number;
|
|
5
|
+
height: number;
|
|
6
|
+
}
|
|
7
|
+
/** One action the browser performs to reach the state a scene shows. */
|
|
8
|
+
type CaptureStep = {
|
|
9
|
+
action: "click";
|
|
10
|
+
selector: string;
|
|
11
|
+
} | {
|
|
12
|
+
action: "fill";
|
|
13
|
+
selector: string;
|
|
14
|
+
value: string;
|
|
15
|
+
} | {
|
|
16
|
+
action: "press";
|
|
17
|
+
key: string;
|
|
18
|
+
} | {
|
|
19
|
+
action: "wait";
|
|
20
|
+
selector: string;
|
|
21
|
+
};
|
|
22
|
+
/**
|
|
23
|
+
* A scene as a `docs/captures.ts` declares it. A screenshot scene writes `output`, a `.webp` path
|
|
24
|
+
* relative to the repository root. A setup scene (`setup: true`, such as the onboarding that
|
|
25
|
+
* creates the administrator) runs its steps once, before any screenshot, and writes nothing.
|
|
26
|
+
*/
|
|
27
|
+
interface CaptureSceneInput {
|
|
28
|
+
id: string;
|
|
29
|
+
route: string;
|
|
30
|
+
viewport?: CaptureViewport;
|
|
31
|
+
steps?: CaptureStep[];
|
|
32
|
+
/** A selector: the screenshot is cropped to the element it matches. */
|
|
33
|
+
crop?: string;
|
|
34
|
+
output?: string;
|
|
35
|
+
setup?: boolean;
|
|
36
|
+
}
|
|
37
|
+
/** A scene with every default filled in. */
|
|
38
|
+
interface CaptureScene {
|
|
39
|
+
id: string;
|
|
40
|
+
route: string;
|
|
41
|
+
viewport: CaptureViewport;
|
|
42
|
+
steps: CaptureStep[];
|
|
43
|
+
crop?: string;
|
|
44
|
+
output?: string;
|
|
45
|
+
setup: boolean;
|
|
46
|
+
}
|
|
47
|
+
/** Types the `docs/captures.ts` default export: `export default defineScenes([...])`. */
|
|
48
|
+
declare function defineScenes(scenes: CaptureSceneInput[]): CaptureSceneInput[];
|
|
49
|
+
//#endregion
|
|
50
|
+
export { type CaptureScene, type CaptureSceneInput, type CaptureStep, type CaptureViewport, defineScenes };
|
|
@@ -127,6 +127,7 @@ jobs:
|
|
|
127
127
|
uses: ${CI_NODE_REF}
|
|
128
128
|
with:
|
|
129
129
|
renovate-sync: false
|
|
130
|
+
test-job: true
|
|
130
131
|
${RENOVATE_SYNC_JOB_ID}:
|
|
131
132
|
if: >-
|
|
132
133
|
github.event_name == 'pull_request'
|
|
@@ -251,6 +252,14 @@ function skipRenovateSync(document, job) {
|
|
|
251
252
|
else job.set("with", document.createNode({ "renovate-sync": false }));
|
|
252
253
|
return true;
|
|
253
254
|
}
|
|
255
|
+
function addTestJob(document, job) {
|
|
256
|
+
const inputs = job.get("with", true);
|
|
257
|
+
if (isMap(inputs)) {
|
|
258
|
+
if (inputs.has("test-job")) return false;
|
|
259
|
+
inputs.set("test-job", true);
|
|
260
|
+
} else job.set("with", document.createNode({ "test-job": true }));
|
|
261
|
+
return true;
|
|
262
|
+
}
|
|
254
263
|
function lines(text) {
|
|
255
264
|
return text.split("\n").map((line) => line.trim()).filter(Boolean);
|
|
256
265
|
}
|
|
@@ -312,6 +321,8 @@ function assertNoClash(jobs, callerId, hasSyncCaller) {
|
|
|
312
321
|
* Keeps the shared CI caller on the job id `ci` with no `name`, so the shared workflow reports `ci / checks`,
|
|
313
322
|
* dispatchable and read-only, with the Renovate sync it would otherwise run turned off. The write permissions the sync
|
|
314
323
|
* needs to push and dispatch the caller live on a separate job calling ci-renovate-sync.yml, which is added when missing.
|
|
324
|
+
* A caller without a `test-job` input gets `test-job: true`, which runs the tests in their own job; an explicit value
|
|
325
|
+
* is left as the repository set it.
|
|
315
326
|
* No `uses:` ref is ever rewritten. A workflow with no caller job is repository-specific CI and is left as it is.
|
|
316
327
|
* When `docsFiles` computes paths, every caller's `docs-files` input lists them first, then keeps its hand-listed paths
|
|
317
328
|
* that still exist, so sync never drops coverage.
|
|
@@ -340,6 +351,7 @@ function ciWorkflow(current, callers, syncCallers, docsFiles) {
|
|
|
340
351
|
}
|
|
341
352
|
changed = grant(document, pair.value, { contents: "read" }) || changed;
|
|
342
353
|
changed = skipRenovateSync(document, pair.value) || changed;
|
|
354
|
+
changed = addTestJob(document, pair.value) || changed;
|
|
343
355
|
changed = ensureSyncJob(document, jobs, syncCallers) || changed;
|
|
344
356
|
if (!hasDispatch(document)) {
|
|
345
357
|
addDispatch(document);
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import "./ceilings-B7KayYIG.mjs";
|
|
2
|
-
import { n as IGNORE_PATTERNS, t as AGENT_IGNORE_PATTERNS } from "./shared-
|
|
2
|
+
import { n as IGNORE_PATTERNS, r as SYNCED_AGENT_PATTERNS, t as AGENT_IGNORE_PATTERNS } from "./shared-igPpEDpS.mjs";
|
|
3
3
|
import { closeSync, existsSync, lstatSync, openSync, readSync } from "node:fs";
|
|
4
4
|
import { dirname, join, matchesGlob, relative, resolve } from "node:path";
|
|
5
5
|
import { execFileSync, spawnSync } from "node:child_process";
|
|
@@ -9,7 +9,7 @@ const SIZE_EXCLUSIONS = [
|
|
|
9
9
|
kind: "generated",
|
|
10
10
|
patterns: [
|
|
11
11
|
...IGNORE_PATTERNS,
|
|
12
|
-
...
|
|
12
|
+
...SYNCED_AGENT_PATTERNS,
|
|
13
13
|
"**/*.generated.*",
|
|
14
14
|
"**/generated/**",
|
|
15
15
|
"**/__snapshots__/**"
|
|
@@ -40,6 +40,8 @@ const SIZE_EXCLUSIONS = [
|
|
|
40
40
|
patterns: ["**/*.{png,jpg,jpeg,gif,webp,avif,ico,svg,bmp,tiff,pdf,mp3,wav,ogg,flac,mp4,webm,mov,avi,woff,woff2,ttf,otf,eot,zip,gz,tgz,bz2,xz,7z,tar,rar,wasm,bin,exe,dll,so,dylib,db,sqlite,sqlite3,icns}"]
|
|
41
41
|
}
|
|
42
42
|
];
|
|
43
|
+
/** A lint configuration file, which a measurement at an earlier revision keeps at its current content. */
|
|
44
|
+
const LINT_CONFIG = /(?:^|\/)(?:oxlint\.config\.[cm]?[jt]s|\.oxlintrc\.jsonc?)$/u;
|
|
43
45
|
function trackedManifests(root) {
|
|
44
46
|
return execFileSync("git", ["ls-files", "-z"], {
|
|
45
47
|
cwd: root,
|
|
@@ -160,7 +162,11 @@ function isBinary(root, file, staged) {
|
|
|
160
162
|
closeSync(descriptor);
|
|
161
163
|
}
|
|
162
164
|
}
|
|
163
|
-
/** Whether a repository path is
|
|
165
|
+
/** Whether a repository path is in an agent tooling directory, whose repository-authored files the budget records apart from the rest. */
|
|
166
|
+
function isAgentFile(file) {
|
|
167
|
+
return AGENT_IGNORE_PATTERNS.some((pattern) => file.startsWith(pattern.slice(0, -2)));
|
|
168
|
+
}
|
|
169
|
+
/** Whether a repository path is generated output the budget and the size guard skip: `dist`, `.nuxt`, the agent files `antelopejs-sync` writes, `*.generated.*`, snapshots, and package-root `build` or `output`. */
|
|
164
170
|
function generatedOutput(root) {
|
|
165
171
|
const packageOutputs = packageOutputPatterns(root);
|
|
166
172
|
const generated = SIZE_EXCLUSIONS.filter(({ kind }) => kind === "generated");
|
|
@@ -179,4 +185,4 @@ function authoredSizes(root, files = gitFiles(root), staged = false) {
|
|
|
179
185
|
return sizes;
|
|
180
186
|
}
|
|
181
187
|
//#endregion
|
|
182
|
-
export {
|
|
188
|
+
export { gitFiles as a, repositoryRoot as c, generatedOutput as i, resolveRevision as l, authoredSizes as n, isAgentFile as o, changedFiles as r, repositoryPath as s, LINT_CONFIG as t, trackedManifests as u };
|