@maniumek/suwgate 0.19.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/README.md +1 -1
- package/dist/cli.js +2 -2
- package/dist/gate/breakdown.d.ts +1 -0
- package/dist/gate/breakdown.js +2 -1
- package/dist/gate/check.js +19 -2
- package/dist/gate/config.d.ts +1 -0
- package/dist/gate/dashboard.js +17 -7
- package/dist/gate/history.d.ts +1 -0
- package/dist/gate/history.js +2 -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/package.json +1 -1
package/README.md
CHANGED
|
@@ -252,7 +252,7 @@ The plugin has two agents, each with its own clean context. `/suwgate:ship` star
|
|
|
252
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 |
|
|
253
253
|
| `suwgate:simplifier` | shell, files | makes the change simpler without changing its behaviour; commits it, never pushes |
|
|
254
254
|
|
|
255
|
-
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.
|
|
256
256
|
|
|
257
257
|
## Configuration
|
|
258
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";
|
|
@@ -92,7 +92,7 @@ Every step has a ceiling (SUWGATE_STEP_LIMIT seconds overrides them all). A step
|
|
|
92
92
|
and a SKIP fails the gate when CI is set. Exit code: 0 green, 1 red, 2 a usage or suwgate.yml problem.`;
|
|
93
93
|
const DEFAULT_PORT = 4780;
|
|
94
94
|
const PORT_FALLBACKS = 20;
|
|
95
|
-
const catalog = { guards, dotnetGuards, stepsFor, holdoutStep };
|
|
95
|
+
const catalog = { guards, dotnetGuards, stepsFor, holdoutStep, failedTests };
|
|
96
96
|
function version() {
|
|
97
97
|
const manifest = JSON.parse(readFileSync(new URL("../package.json", import.meta.url), "utf8"));
|
|
98
98
|
return manifest.version;
|
package/dist/gate/breakdown.d.ts
CHANGED
package/dist/gate/breakdown.js
CHANGED
|
@@ -44,7 +44,8 @@ export function stoppers(history, days, now) {
|
|
|
44
44
|
const key = `${kind}:${id}`;
|
|
45
45
|
const own = found.get(key);
|
|
46
46
|
if (own === undefined) {
|
|
47
|
-
|
|
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 });
|
|
48
49
|
}
|
|
49
50
|
else {
|
|
50
51
|
own.runs += 1;
|
package/dist/gate/check.js
CHANGED
|
@@ -71,7 +71,15 @@ async function run(command, prepared, options) {
|
|
|
71
71
|
const began = performance.now();
|
|
72
72
|
const keep = options.runFolder !== undefined;
|
|
73
73
|
const runFolder = options.runFolder ?? mkdtempSync(path.join(tmpdir(), "suwgate-run-"));
|
|
74
|
-
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(() => {
|
|
75
83
|
if (!keep)
|
|
76
84
|
rmSync(runFolder, { recursive: true, force: true });
|
|
77
85
|
});
|
|
@@ -93,6 +101,7 @@ async function run(command, prepared, options) {
|
|
|
93
101
|
...options.recorded,
|
|
94
102
|
root,
|
|
95
103
|
results,
|
|
104
|
+
failedTests,
|
|
96
105
|
passed,
|
|
97
106
|
elapsed: (performance.now() - began) / 1000,
|
|
98
107
|
overBudget: quickLimit !== null && totalSeconds > quickLimit && results.every((result) => result.status !== "fail"),
|
|
@@ -111,7 +120,15 @@ function runRecord(input) {
|
|
|
111
120
|
verdict: input.passed ? "green" : "red",
|
|
112
121
|
seconds: tenths(input.elapsed),
|
|
113
122
|
overBudget: input.overBudget,
|
|
114
|
-
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
|
+
}),
|
|
115
132
|
ran: tally?.ran ?? [],
|
|
116
133
|
guards: tally?.failed ?? {},
|
|
117
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,18 +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
|
-
.filter((stopper) => stopper.open.length > 0)
|
|
116
|
-
.map((stopper) => ({
|
|
117
|
-
kind: "broken",
|
|
118
|
-
text: `${stopper.id} stopped the gate ${stopper.runs} time${stopper.runs === 1 ? "" : "s"}`,
|
|
119
|
-
detail: `still red on ${stopper.open.join(", ")}`,
|
|
120
|
-
})),
|
|
130
|
+
...stopped.filter((stopper) => stopper.open.length > 0).flatMap(brokenItems),
|
|
121
131
|
...hooks
|
|
122
132
|
.filter((hook) => !hook.wired)
|
|
123
133
|
.map((hook) => ({ kind: "have", text: `the ${hook.id} hook is not wired`, detail: `in ${hook.where}` })),
|
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/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/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",
|