@maniumek/suwgate 0.18.0 → 0.20.0
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/AGENTS.shared.md +1 -1
- package/README.md +6 -5
- package/dist/cli.js +7 -6
- package/dist/gate/breakdown.d.ts +2 -0
- package/dist/gate/breakdown.js +22 -2
- package/dist/gate/check.d.ts +1 -0
- package/dist/gate/check.js +20 -2
- package/dist/gate/config.d.ts +1 -0
- package/dist/gate/dashboard.js +17 -5
- package/dist/gate/dashboardPage.js +1 -3
- package/dist/gate/history.d.ts +1 -0
- package/dist/gate/history.js +2 -1
- package/dist/gate/plan.d.ts +2 -0
- package/dist/gate/plan.js +6 -2
- package/dist/gate/runner.js +3 -1
- package/dist/profiles/index.d.ts +1 -0
- package/dist/profiles/index.js +1 -0
- package/dist/profiles/reports.d.ts +1 -0
- package/dist/profiles/reports.js +39 -0
- package/dist/session/ship.d.ts +2 -1
- package/dist/session/ship.js +4 -3
- package/package.json +1 -1
package/AGENTS.shared.md
CHANGED
|
@@ -14,7 +14,7 @@ repository's own `AGENTS.md` adds what is only its own, and wins where it says o
|
|
|
14
14
|
one step (`suwgate step` lists them). The full gate runs only in CI: an agent never runs `suwgate check` itself. `AGENTS.md` says
|
|
15
15
|
how this repository runs suwgate.
|
|
16
16
|
- Done building? `/suwgate:ship`: a small change gets the gate only, a normal one also simplify and review, a careful one cannot drop the review.
|
|
17
|
-
It runs `suwgate ship` (the
|
|
17
|
+
It runs `suwgate ship` (every step of the gate except the e2e tests that did not change, which writes the ship record), pushes, opens the pull request,
|
|
18
18
|
waits for CI, fixes a red run and writes the PR proof. A push or a pull
|
|
19
19
|
request without a ship record for its commit is refused; a person without the plugin runs `suwgate ship` before pushing.
|
|
20
20
|
- What the PR proof shows, by the kind of change: a refactor, optimisation, performance or stability change none ("behaviour
|
package/README.md
CHANGED
|
@@ -49,7 +49,7 @@ Wiring the hooks (`.claude/settings.json`, `.githooks/pre-commit`) and every oth
|
|
|
49
49
|
|
|
50
50
|
<picture>
|
|
51
51
|
<source media="(prefers-color-scheme: dark)" srcset="docs/visual/board/img/readme/flow-dark.png">
|
|
52
|
-
<img alt="How a change goes through it. On your machine: an agent edits, and guard-edit runs before every edit (gate files refused; lockfiles, API types and migrations refused); the turn ends, and stop runs the quick gate within 20 seconds (guards and changed files, skipped when nothing changed); git commit runs pre-commit (gitleaks, then the quick gate; staged secrets refused); before done, suwgate ship runs
|
|
52
|
+
<img alt="How a change goes through it. On your machine: an agent edits, and guard-edit runs before every edit (gate files refused; lockfiles, API types and migrations refused); the turn ends, and stop runs the quick gate within 20 seconds (guards and changed files, skipped when nothing changed); git commit runs pre-commit (gitleaks, then the quick gate; staged secrets refused); before done, suwgate ship runs every step except the e2e tests that did not change and records the tree; an agent never runs the full gate, CI does. In CI, gate.yml: proof asks whether the tree already passed, in a few seconds (a green ci/tree stamp of the same tree skips the gate); gate runs suwgate check --verbose, every step in parallel, browser tests and the holdout scenarios included (a SKIP fails in CI); stack runs the smoke test when smoke is true (its own compose project, free ports); stamp writes ci/tree after green (the merge push is proven); release with release-npm or release-nuget (the publish job stays in the caller). Every step has a ceiling; a missing tool is SKIP, and SKIP fails in CI; exit 0 green, 1 red, 2 usage or suwgate.yml problem." src="docs/visual/board/img/readme/flow-light.png" width="100%">
|
|
53
53
|
</picture>
|
|
54
54
|
|
|
55
55
|
The quick gate is what an agent meets after every turn, so it has a time budget; the full gate is what CI runs. A step that cannot
|
|
@@ -130,7 +130,7 @@ self-hosted runners: [ci/self-hosted](ci/self-hosted/README.md).
|
|
|
130
130
|
|
|
131
131
|
<picture>
|
|
132
132
|
<source media="(prefers-color-scheme: dark)" srcset="docs/visual/board/img/readme/choose-dark.png">
|
|
133
|
-
<img alt="Which command, when. While an agent works, after every turn: suwgate check --quick (the Stop hook). Before calling a change done: suwgate ship (
|
|
133
|
+
<img alt="Which command, when. While an agent works, after every turn: suwgate check --quick (the Stop hook). Before calling a change done: suwgate ship (every step except the e2e tests that did not change; CI runs them all). What did the gate catch: suwgate stats. Is the main branch protected: suwgate doctor. Which steps does this repository have: suwgate step (lists them). One step, with what it needs, and its tool's flags: suwgate step e2e -- --headed. Run the whole local stack: suwgate dev tmux start. The server failed, why: suwgate dev logs. A linked worktree needs its own databases and ports: suwgate dev checkout-env, with eval. A sibling repository's images are behind its checkout: suwgate dev sibling name up. suwgate was upgraded and agents-shared is red: suwgate agents-shared (writes the copy)." src="docs/visual/board/img/readme/choose-light.png" width="100%">
|
|
134
134
|
</picture>
|
|
135
135
|
|
|
136
136
|
<details>
|
|
@@ -155,8 +155,9 @@ usage: suwgate check [--quick] [--verbose] | suwgate step [<id> [--only] [--verb
|
|
|
155
155
|
suwgate hook stop Claude Code Stop hook: runs the quick gate unless nothing changed since it last passed
|
|
156
156
|
suwgate hook pre-commit git pre-commit hook: gitleaks on the staged changes, then the quick gate
|
|
157
157
|
suwgate hook pre-push git pre-push hook: refuses a push of a branch whose tree has no ship record
|
|
158
|
-
suwgate ship needs a clean working tree: runs the
|
|
159
|
-
branch, then records the tree (the pre-push and guard-pr hooks let a
|
|
158
|
+
suwgate ship needs a clean working tree: runs every step of the gate except the e2e tests whose files did
|
|
159
|
+
not change on the branch (CI runs those), then records the tree (the pre-push and guard-pr hooks let a
|
|
160
|
+
push of it through)
|
|
160
161
|
suwgate stats what the gate caught: runs and red share per mode, quick gate times and budget overruns, the slowest
|
|
161
162
|
steps, the guards by findings and the guards with none, from suwgate-runs.jsonl in the git common
|
|
162
163
|
directory (every run of check, ship, step, the Stop and pre-commit hooks appends a line there)
|
|
@@ -251,7 +252,7 @@ The plugin has two agents, each with its own clean context. `/suwgate:ship` star
|
|
|
251
252
|
| `suwgate:shipper` | shell, files, `Agent`, `Skill` | takes the change to a pull request: `suwgate ship`, push, CI, and starts the simplifier and the suwagent skills |
|
|
252
253
|
| `suwgate:simplifier` | shell, files | makes the change simpler without changing its behaviour; commits it, never pushes |
|
|
253
254
|
|
|
254
|
-
The plugin describes suwgate 0.
|
|
255
|
+
The plugin describes suwgate 0.20.0; a repository on an older package lacks `stats`, `doctor`, `dashboard` and `garden-ran`, and the skills say so instead of working around it.
|
|
255
256
|
|
|
256
257
|
## Configuration
|
|
257
258
|
|
package/dist/cli.js
CHANGED
|
@@ -18,7 +18,7 @@ import { PROFILES } from "./gate/contract.js";
|
|
|
18
18
|
import { changedFiles, repositoryFiles, repositoryRoot } from "./gate/repository.js";
|
|
19
19
|
import { criterionIds } from "./profiles/criteriaRan.js";
|
|
20
20
|
import { guards, SHARED_RULES, writeSharedRules } from "./guards/index.js";
|
|
21
|
-
import { discoverApiIn, dotnetGuards, holdoutStep, stepsFor, verdict } from "./profiles/index.js";
|
|
21
|
+
import { discoverApiIn, dotnetGuards, failedTests, holdoutStep, stepsFor, verdict } from "./profiles/index.js";
|
|
22
22
|
import { readTimes, reportLocation } from "./profiles/reports.js";
|
|
23
23
|
import { doctor } from "./session/doctor.js";
|
|
24
24
|
import { lastGarden, parseFound, recordGarden } from "./session/gardenRecord.js";
|
|
@@ -27,7 +27,7 @@ import { guardPr } from "./session/guardPr.js";
|
|
|
27
27
|
import { guardEdit } from "./session/guardEdit.js";
|
|
28
28
|
import { preCommit, runTool } from "./session/preCommit.js";
|
|
29
29
|
import { prePush } from "./session/prePush.js";
|
|
30
|
-
import { ship } from "./session/ship.js";
|
|
30
|
+
import { LEFT_TO_CI, ship } from "./session/ship.js";
|
|
31
31
|
import { stop } from "./session/stop.js";
|
|
32
32
|
const USAGE = `usage: suwgate check [--quick] [--verbose] | suwgate step [<id> [--only] [--verbose] [-- <args>]] | suwgate hook <guard-edit|guard-pr|stop|pre-commit|pre-push> | suwgate ship | suwgate stats [--days <n>] [--json] | suwgate doctor | suwgate context | suwgate dashboard [--days <n>] [--no-ci] [--out <path> | --serve [--port <n>] | --json] | suwgate garden-ran <kind>=<count>... | suwgate dev <command> | suwgate agents-shared | suwgate --help | --version
|
|
33
33
|
suwgate check every step of the repository's profiles (suwgate.yml) and the repository guards
|
|
@@ -47,8 +47,9 @@ const USAGE = `usage: suwgate check [--quick] [--verbose] | suwgate step [<id> [
|
|
|
47
47
|
suwgate hook stop Claude Code Stop hook: runs the quick gate unless nothing changed since it last passed
|
|
48
48
|
suwgate hook pre-commit git pre-commit hook: gitleaks on the staged changes, then the quick gate
|
|
49
49
|
suwgate hook pre-push git pre-push hook: refuses a push of a branch whose tree has no ship record
|
|
50
|
-
suwgate ship needs a clean working tree: runs the
|
|
51
|
-
branch, then records the tree (the pre-push and guard-pr hooks let a
|
|
50
|
+
suwgate ship needs a clean working tree: runs every step of the gate except the e2e tests whose files did
|
|
51
|
+
not change on the branch (CI runs those), then records the tree (the pre-push and guard-pr hooks let a
|
|
52
|
+
push of it through)
|
|
52
53
|
suwgate stats what the gate caught: runs and red share per mode, quick gate times and budget overruns, the slowest
|
|
53
54
|
steps, the guards by findings and the guards with none, from suwgate-runs.jsonl in the git common
|
|
54
55
|
directory (every run of check, ship, step, the Stop and pre-commit hooks appends a line there)
|
|
@@ -91,7 +92,7 @@ Every step has a ceiling (SUWGATE_STEP_LIMIT seconds overrides them all). A step
|
|
|
91
92
|
and a SKIP fails the gate when CI is set. Exit code: 0 green, 1 red, 2 a usage or suwgate.yml problem.`;
|
|
92
93
|
const DEFAULT_PORT = 4780;
|
|
93
94
|
const PORT_FALLBACKS = 20;
|
|
94
|
-
const catalog = { guards, dotnetGuards, stepsFor, holdoutStep };
|
|
95
|
+
const catalog = { guards, dotnetGuards, stepsFor, holdoutStep, failedTests };
|
|
95
96
|
function version() {
|
|
96
97
|
const manifest = JSON.parse(readFileSync(new URL("../package.json", import.meta.url), "utf8"));
|
|
97
98
|
return manifest.version;
|
|
@@ -374,7 +375,7 @@ async function main(argv) {
|
|
|
374
375
|
const root = repositoryRoot(process.cwd()) ?? process.cwd();
|
|
375
376
|
const verdict = await ship(root, {
|
|
376
377
|
changedFiles: () => changedFiles(root),
|
|
377
|
-
|
|
378
|
+
gate: () => runCheck(root, false, false, { mode: "ship", without: LEFT_TO_CI }),
|
|
378
379
|
e2e: (files) => step({ cwd: root, id: "e2e", only: false, args: files, verbose: false, recordedAs: "ship", env: process.env, catalog }),
|
|
379
380
|
});
|
|
380
381
|
(verdict.exitCode === 0 ? console.log : console.error)(verdict.message);
|
package/dist/gate/breakdown.d.ts
CHANGED
package/dist/gate/breakdown.js
CHANGED
|
@@ -20,14 +20,32 @@ function stoppersOf(run) {
|
|
|
20
20
|
function newestFirst(a, b) {
|
|
21
21
|
return Date.parse(b.at) - Date.parse(a.at);
|
|
22
22
|
}
|
|
23
|
+
function ran(run, stopper) {
|
|
24
|
+
if (isRedIn(run, stopper))
|
|
25
|
+
return true;
|
|
26
|
+
if (stopper.kind === "guard")
|
|
27
|
+
return run.ran.includes(stopper.id);
|
|
28
|
+
return run.steps.some((record) => record.id === stopper.id && record.verdict !== "skip");
|
|
29
|
+
}
|
|
30
|
+
function isRedIn(run, stopper) {
|
|
31
|
+
return stoppersOf(run).some((other) => other.kind === stopper.kind && other.id === stopper.id);
|
|
32
|
+
}
|
|
33
|
+
function stillRedOn(runs, stopper) {
|
|
34
|
+
return stopper.branches.filter((branch) => {
|
|
35
|
+
const newest = runs.find((run) => run.branch === branch && ran(run, stopper));
|
|
36
|
+
return newest !== undefined && isRedIn(newest, stopper);
|
|
37
|
+
});
|
|
38
|
+
}
|
|
23
39
|
export function stoppers(history, days, now) {
|
|
24
40
|
const found = new Map();
|
|
25
|
-
|
|
41
|
+
const runs = runsInPeriod(history, days, now).toSorted(newestFirst);
|
|
42
|
+
for (const run of runs) {
|
|
26
43
|
for (const { kind, id } of stoppersOf(run)) {
|
|
27
44
|
const key = `${kind}:${id}`;
|
|
28
45
|
const own = found.get(key);
|
|
29
46
|
if (own === undefined) {
|
|
30
|
-
|
|
47
|
+
const tests = kind === "step" ? (run.steps.find((step) => step.id === id)?.failed ?? []) : [];
|
|
48
|
+
found.set(key, { kind, id, runs: 1, ci: run.ci ? 1 : 0, last: run.at, branches: [run.branch], open: [], tests });
|
|
31
49
|
}
|
|
32
50
|
else {
|
|
33
51
|
own.runs += 1;
|
|
@@ -38,6 +56,8 @@ export function stoppers(history, days, now) {
|
|
|
38
56
|
}
|
|
39
57
|
}
|
|
40
58
|
}
|
|
59
|
+
for (const stopper of found.values())
|
|
60
|
+
stopper.open = stillRedOn(runs, stopper);
|
|
41
61
|
return [...found.values()].sort((a, b) => Date.parse(b.last) - Date.parse(a.last) || b.runs - a.runs || a.id.localeCompare(b.id));
|
|
42
62
|
}
|
|
43
63
|
export function causeOf(run) {
|
package/dist/gate/check.d.ts
CHANGED
package/dist/gate/check.js
CHANGED
|
@@ -66,11 +66,20 @@ async function run(command, prepared, options) {
|
|
|
66
66
|
changed: () => (changed ??= changedFiles(root)),
|
|
67
67
|
merged,
|
|
68
68
|
...(options.target === undefined ? {} : { target: options.target }),
|
|
69
|
+
...(options.without === undefined ? {} : { without: options.without }),
|
|
69
70
|
});
|
|
70
71
|
const began = performance.now();
|
|
71
72
|
const keep = options.runFolder !== undefined;
|
|
72
73
|
const runFolder = options.runFolder ?? mkdtempSync(path.join(tmpdir(), "suwgate-run-"));
|
|
73
|
-
const
|
|
74
|
+
const failedTests = new Map();
|
|
75
|
+
const results = await runSteps(steps, { ...options.env, SUWGATE_ROOT: root, SUWGATE_QUICK: options.quick ? "1" : "", SUWGATE_RUN: runFolder }, prepared.stepLimit)
|
|
76
|
+
.then((finished) => {
|
|
77
|
+
for (const result of finished.filter((one) => one.status === "fail")) {
|
|
78
|
+
failedTests.set(result.step.id, options.catalog.failedTests?.(runFolder, result.step.id) ?? []);
|
|
79
|
+
}
|
|
80
|
+
return finished;
|
|
81
|
+
})
|
|
82
|
+
.finally(() => {
|
|
74
83
|
if (!keep)
|
|
75
84
|
rmSync(runFolder, { recursive: true, force: true });
|
|
76
85
|
});
|
|
@@ -92,6 +101,7 @@ async function run(command, prepared, options) {
|
|
|
92
101
|
...options.recorded,
|
|
93
102
|
root,
|
|
94
103
|
results,
|
|
104
|
+
failedTests,
|
|
95
105
|
passed,
|
|
96
106
|
elapsed: (performance.now() - began) / 1000,
|
|
97
107
|
overBudget: quickLimit !== null && totalSeconds > quickLimit && results.every((result) => result.status !== "fail"),
|
|
@@ -110,7 +120,15 @@ function runRecord(input) {
|
|
|
110
120
|
verdict: input.passed ? "green" : "red",
|
|
111
121
|
seconds: tenths(input.elapsed),
|
|
112
122
|
overBudget: input.overBudget,
|
|
113
|
-
steps: input.results.map((result) =>
|
|
123
|
+
steps: input.results.map((result) => {
|
|
124
|
+
const failed = input.failedTests.get(result.step.id) ?? [];
|
|
125
|
+
return {
|
|
126
|
+
id: result.step.id,
|
|
127
|
+
verdict: result.status,
|
|
128
|
+
seconds: tenths(result.elapsed ?? 0),
|
|
129
|
+
...(failed.length === 0 ? {} : { failed }),
|
|
130
|
+
};
|
|
131
|
+
}),
|
|
114
132
|
ran: tally?.ran ?? [],
|
|
115
133
|
guards: tally?.failed ?? {},
|
|
116
134
|
excepted: tally?.excepted ?? {},
|
package/dist/gate/config.d.ts
CHANGED
|
@@ -45,6 +45,7 @@ export interface Catalog {
|
|
|
45
45
|
dotnetGuards: readonly DotnetGuard[];
|
|
46
46
|
stepsFor(profiles: readonly Profile[]): readonly Step[];
|
|
47
47
|
holdoutStep?(holdout: Holdout): Step;
|
|
48
|
+
failedTests?(run: string, step: string): string[];
|
|
48
49
|
}
|
|
49
50
|
export type Loaded = {
|
|
50
51
|
config: Config;
|
package/dist/gate/dashboard.js
CHANGED
|
@@ -106,16 +106,28 @@ export function hookRows(read, hooksPath) {
|
|
|
106
106
|
return { id, where, wired };
|
|
107
107
|
});
|
|
108
108
|
}
|
|
109
|
+
const TESTS_NAMED = 5;
|
|
110
|
+
function brokenItems(stopper) {
|
|
111
|
+
const where = `still red on ${stopper.open.join(", ")}`;
|
|
112
|
+
if (stopper.tests.length === 0) {
|
|
113
|
+
return [
|
|
114
|
+
{ kind: "broken", text: `${stopper.id} stopped the gate ${stopper.runs} time${stopper.runs === 1 ? "" : "s"}`, detail: where },
|
|
115
|
+
];
|
|
116
|
+
}
|
|
117
|
+
const named = stopper.tests
|
|
118
|
+
.slice(0, TESTS_NAMED)
|
|
119
|
+
.map((test) => ({ kind: "broken", text: test, detail: `${stopper.id} · ${where}` }));
|
|
120
|
+
const rest = stopper.tests.length - named.length;
|
|
121
|
+
return rest === 0
|
|
122
|
+
? named
|
|
123
|
+
: [...named, { kind: "broken", text: `${rest} more failed test${rest === 1 ? "" : "s"} of ${stopper.id}`, detail: where }];
|
|
124
|
+
}
|
|
109
125
|
export function attentionOf(wall, stopped, hooks) {
|
|
110
126
|
return [
|
|
111
127
|
...wall
|
|
112
128
|
.filter((check) => check.state === "broken")
|
|
113
129
|
.map((check) => ({ kind: "wall", text: check.name, detail: "is not in place" })),
|
|
114
|
-
...stopped.
|
|
115
|
-
kind: "broken",
|
|
116
|
-
text: `${stopper.id} stopped the gate ${stopper.runs} time${stopper.runs === 1 ? "" : "s"}`,
|
|
117
|
-
detail: `on ${stopper.branches.join(", ")}`,
|
|
118
|
-
})),
|
|
130
|
+
...stopped.filter((stopper) => stopper.open.length > 0).flatMap(brokenItems),
|
|
119
131
|
...hooks
|
|
120
132
|
.filter((hook) => !hook.wired)
|
|
121
133
|
.map((hook) => ({ kind: "have", text: `the ${hook.id} hook is not wired`, detail: `in ${hook.where}` })),
|
|
@@ -122,14 +122,12 @@ function sentence(text) {
|
|
|
122
122
|
function noRuns(days) {
|
|
123
123
|
return sentence(`No runs recorded in the last ${days} days. Commands that record a run: ${RECORDING_COMMANDS}.`);
|
|
124
124
|
}
|
|
125
|
-
const PARTS = { wall: 1, broken: 3, have: 5 };
|
|
126
125
|
function attention(data) {
|
|
127
126
|
const count = data.attention.length;
|
|
128
127
|
const headline = count === 0 ? "Nothing needs you" : `${plural(count, "thing")} ${count === 1 ? "needs" : "need"} you`;
|
|
129
128
|
const rows = data.attention.map((item) => {
|
|
130
|
-
const target = PARTS[item.kind];
|
|
131
129
|
const label = mark("broken", item.kind === "have" ? "hook" : item.kind);
|
|
132
|
-
return row(`${label} ${escapeHtml(item.text)}`, [escapeHtml(item.detail), `<a href="#part-${item.kind}"
|
|
130
|
+
return row(`${label} ${escapeHtml(item.text)}`, [escapeHtml(item.detail), `<a href="#part-${item.kind}">details</a>`]);
|
|
133
131
|
});
|
|
134
132
|
return `<section class="panel"><p class="headline">${escapeHtml(headline)}</p>${keyed("attention", list(rows, "items"))}</section>`;
|
|
135
133
|
}
|
package/dist/gate/history.d.ts
CHANGED
package/dist/gate/history.js
CHANGED
|
@@ -69,7 +69,8 @@ function counts(value) {
|
|
|
69
69
|
}
|
|
70
70
|
function isStep(value) {
|
|
71
71
|
const step = value;
|
|
72
|
-
return (
|
|
72
|
+
return ((step?.failed === undefined || (Array.isArray(step.failed) && step.failed.every((name) => typeof name === "string"))) &&
|
|
73
|
+
typeof step?.id === "string" &&
|
|
73
74
|
typeof step.verdict === "string" &&
|
|
74
75
|
STEP_VERDICTS.includes(step.verdict) &&
|
|
75
76
|
typeof step.seconds === "number");
|
package/dist/gate/plan.d.ts
CHANGED
|
@@ -11,6 +11,7 @@ export interface PlannedStep {
|
|
|
11
11
|
id: string;
|
|
12
12
|
title: string;
|
|
13
13
|
after: readonly string[];
|
|
14
|
+
orderOnly?: readonly string[];
|
|
14
15
|
limitSeconds: number;
|
|
15
16
|
environment: readonly Environment[];
|
|
16
17
|
skipped?: {
|
|
@@ -38,6 +39,7 @@ export interface PlanInput {
|
|
|
38
39
|
changed: () => readonly string[];
|
|
39
40
|
merged?: readonly GuardException[];
|
|
40
41
|
target?: Target;
|
|
42
|
+
without?: readonly string[];
|
|
41
43
|
}
|
|
42
44
|
export interface ListedStep {
|
|
43
45
|
id: string;
|
package/dist/gate/plan.js
CHANGED
|
@@ -108,17 +108,21 @@ export function plan(input) {
|
|
|
108
108
|
const steps = allSteps(input.config, input.catalog);
|
|
109
109
|
const chosen = selected(steps, input);
|
|
110
110
|
const planned = chosen.has(GUARDS_STEP) ? [guardsStep(input)] : [];
|
|
111
|
-
|
|
111
|
+
const left = new Set(input.without ?? []);
|
|
112
|
+
for (const step of steps.filter((candidate) => chosen.has(candidate.id) && !left.has(candidate.id))) {
|
|
112
113
|
const asked = input.target?.id === step.id;
|
|
113
114
|
const run = chosenRun(step, input.quick);
|
|
114
115
|
if (run === undefined)
|
|
115
116
|
continue;
|
|
116
117
|
const cwd = path.join(input.root, (step.profile === undefined ? undefined : input.config.directories[step.profile]) ?? "");
|
|
117
118
|
const configured = input.config.configure[step.id];
|
|
119
|
+
const required = needed(step, input.config);
|
|
120
|
+
const orderOnly = (step.orderAfter ?? []).filter((id) => !required.includes(id));
|
|
118
121
|
const base = {
|
|
119
122
|
id: step.id,
|
|
120
123
|
title: step.title,
|
|
121
|
-
after: [...
|
|
124
|
+
after: [...required, ...orderOnly],
|
|
125
|
+
...(orderOnly.length === 0 ? {} : { orderOnly }),
|
|
122
126
|
limitSeconds: configured?.limitSeconds ?? step.limitSeconds ?? DEFAULT_LIMIT_SECONDS,
|
|
123
127
|
environment: environmentOf(step, input.config),
|
|
124
128
|
};
|
package/dist/gate/runner.js
CHANGED
|
@@ -68,7 +68,9 @@ export async function runSteps(steps, env, stepLimit) {
|
|
|
68
68
|
const finished = await Promise.all(dependencies);
|
|
69
69
|
if (step.skipped !== undefined)
|
|
70
70
|
return { step, status: "skip", seconds: 0, log: step.skipped.reason };
|
|
71
|
-
const failed = finished
|
|
71
|
+
const failed = finished
|
|
72
|
+
.filter((dependency) => dependency.status === "fail" && !(step.orderOnly ?? []).includes(dependency.step.id))
|
|
73
|
+
.map((dependency) => dependency.step.id);
|
|
72
74
|
if (failed.length > 0)
|
|
73
75
|
return { step, status: "fail", seconds: 0, log: `not run: ${failed.join(", ")} failed first` };
|
|
74
76
|
const began = performance.now();
|
package/dist/profiles/index.d.ts
CHANGED
|
@@ -2,5 +2,6 @@ import { type Profile, type Step } from "../gate/contract.ts";
|
|
|
2
2
|
export { discoverApiIn } from "./contract.ts";
|
|
3
3
|
export { dotnetGuards } from "./dotnetGuards.ts";
|
|
4
4
|
export { holdoutStep } from "./holdout.ts";
|
|
5
|
+
export { failedTests } from "./reports.ts";
|
|
5
6
|
export { verdict } from "./verdict.ts";
|
|
6
7
|
export declare function stepsFor(profiles: readonly Profile[]): Step[];
|
package/dist/profiles/index.js
CHANGED
|
@@ -9,6 +9,7 @@ import { webSteps } from "./web.js";
|
|
|
9
9
|
export { discoverApiIn } from "./contract.js";
|
|
10
10
|
export { dotnetGuards } from "./dotnetGuards.js";
|
|
11
11
|
export { holdoutStep } from "./holdout.js";
|
|
12
|
+
export { failedTests } from "./reports.js";
|
|
12
13
|
export { verdict } from "./verdict.js";
|
|
13
14
|
const BY_PROFILE = {
|
|
14
15
|
web: [...nodeSteps("web"), ...webSteps, ...contractSteps],
|
|
@@ -51,5 +51,6 @@ export declare function playwrightTimes(report: PlaywrightReport): TestTime[];
|
|
|
51
51
|
export declare function xunitTimes(xml: string): TestTime[];
|
|
52
52
|
export declare function files(location: string, extension: string): string[];
|
|
53
53
|
export declare function readRun(format: ReportFormat, location: string): TestRun | null;
|
|
54
|
+
export declare function failedTests(run: string, step: string): string[];
|
|
54
55
|
export declare function readTimes(format: ReportFormat, location: string): TestTime[] | null;
|
|
55
56
|
export {};
|
package/dist/profiles/reports.js
CHANGED
|
@@ -112,6 +112,45 @@ export function readRun(format, location) {
|
|
|
112
112
|
const report = JSON.parse(readFileSync(location, "utf8"));
|
|
113
113
|
return format === "vitest" ? vitestRun(report) : playwrightRun(report);
|
|
114
114
|
}
|
|
115
|
+
const FAILED_SHOWN = 20;
|
|
116
|
+
const NAME_LENGTH = 200;
|
|
117
|
+
function vitestFailed(report) {
|
|
118
|
+
return (report.testResults ?? [])
|
|
119
|
+
.flatMap((file) => file.assertionResults ?? [])
|
|
120
|
+
.filter((assertion) => assertion.status === "failed")
|
|
121
|
+
.map((assertion) => assertion.fullName ?? "");
|
|
122
|
+
}
|
|
123
|
+
function playwrightFailed(report) {
|
|
124
|
+
return (report.suites ?? [])
|
|
125
|
+
.flatMap((suite) => specsOf(suite, []))
|
|
126
|
+
.filter((spec) => spec.statuses.some((status) => status === "unexpected"))
|
|
127
|
+
.map((spec) => spec.title);
|
|
128
|
+
}
|
|
129
|
+
function xunitFailed(xml) {
|
|
130
|
+
return Array.from(xml.matchAll(XUNIT_TEST), (tag) => tag[1] ?? "")
|
|
131
|
+
.filter((attributes) => /\bresult="Fail"/.test(attributes))
|
|
132
|
+
.map((attributes) => unescaped(/\bname="([^"]*)"/.exec(attributes)?.[1] ?? ""));
|
|
133
|
+
}
|
|
134
|
+
function parsed(file) {
|
|
135
|
+
if (!existsSync(file))
|
|
136
|
+
return {};
|
|
137
|
+
try {
|
|
138
|
+
return JSON.parse(readFileSync(file, "utf8")) ?? {};
|
|
139
|
+
}
|
|
140
|
+
catch {
|
|
141
|
+
return {};
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
export function failedTests(run, step) {
|
|
145
|
+
return [
|
|
146
|
+
...vitestFailed(parsed(reportLocation(run, step, "vitest"))),
|
|
147
|
+
...playwrightFailed(parsed(reportLocation(run, step, "playwright"))),
|
|
148
|
+
...files(reportLocation(run, step, "xunit"), ".xml").flatMap((report) => xunitFailed(readFileSync(report, "utf8"))),
|
|
149
|
+
]
|
|
150
|
+
.filter((name) => name !== "")
|
|
151
|
+
.slice(0, FAILED_SHOWN)
|
|
152
|
+
.map((name) => name.slice(0, NAME_LENGTH));
|
|
153
|
+
}
|
|
115
154
|
export function readTimes(format, location) {
|
|
116
155
|
if (format === "xunit") {
|
|
117
156
|
const reports = files(location, ".xml");
|
package/dist/session/ship.d.ts
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
|
+
export declare const LEFT_TO_CI: string[];
|
|
1
2
|
export interface ShipVerdict {
|
|
2
3
|
exitCode: 0 | 1;
|
|
3
4
|
message: string;
|
|
4
5
|
}
|
|
5
6
|
export interface ShipSteps {
|
|
6
7
|
changedFiles: () => readonly string[];
|
|
7
|
-
|
|
8
|
+
gate: () => Promise<{
|
|
8
9
|
exitCode: number;
|
|
9
10
|
text: string;
|
|
10
11
|
}>;
|
package/dist/session/ship.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { isClean, treeOf, writeShipRecord } from "./shipRecord.js";
|
|
2
2
|
const SHOWN_LINES = 80;
|
|
3
|
+
export const LEFT_TO_CI = ["e2e", "criteria-ran"];
|
|
3
4
|
function tail(text) {
|
|
4
5
|
return text.trimEnd().split("\n").slice(-SHOWN_LINES).join("\n");
|
|
5
6
|
}
|
|
@@ -10,9 +11,9 @@ export async function ship(root, steps) {
|
|
|
10
11
|
message: "ship: the working tree has uncommitted or untracked changes: commit your work first, ship records the committed tree",
|
|
11
12
|
};
|
|
12
13
|
}
|
|
13
|
-
const
|
|
14
|
-
if (
|
|
15
|
-
return { exitCode: 1, message: `${tail(
|
|
14
|
+
const gate = await steps.gate();
|
|
15
|
+
if (gate.exitCode !== 0) {
|
|
16
|
+
return { exitCode: 1, message: `${tail(gate.text)}\nship: the gate is red (above): fix it, commit, and run ship again` };
|
|
16
17
|
}
|
|
17
18
|
const tests = steps.changedFiles().filter((file) => file.endsWith(".e2e.ts"));
|
|
18
19
|
if (tests.length > 0) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@maniumek/suwgate",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.20.0",
|
|
4
4
|
"description": "One quality gate for every repository: suwgate check runs the steps of the repository's profiles and its guards, configured in suwgate.yml",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "Manomenu",
|