@maniumek/suwgate 0.2.0 → 0.4.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 +132 -24
- package/dist/cli.js +49 -5
- package/dist/dev/db.d.ts +1 -1
- package/dist/dev/db.js +25 -0
- package/dist/dev/logs.js +9 -1
- package/dist/dev/settings.d.ts +2 -0
- package/dist/dev/settings.js +5 -2
- package/dist/eslint/index.js +4 -1
- package/dist/gate/check.d.ts +10 -0
- package/dist/gate/check.js +94 -18
- package/dist/gate/config.d.ts +19 -1
- package/dist/gate/config.js +119 -4
- package/dist/gate/contract.d.ts +13 -0
- package/dist/gate/guardsStep.d.ts +3 -1
- package/dist/gate/guardsStep.js +14 -3
- package/dist/gate/plan.d.ts +20 -1
- package/dist/gate/plan.js +92 -20
- package/dist/gate/report.d.ts +1 -0
- package/dist/gate/report.js +12 -3
- package/dist/gate/repository.d.ts +1 -0
- package/dist/gate/repository.js +8 -0
- package/dist/gate/runner.js +18 -3
- package/dist/guards/comments/hash.js +22 -1
- package/dist/guards/dotnet/appsettingsBound.js +29 -2
- package/dist/guards/dotnet/index.js +2 -1
- package/dist/guards/dotnet/suwbackkitWiring.d.ts +2 -0
- package/dist/guards/dotnet/suwbackkitWiring.js +31 -0
- package/dist/guards/repository/imagePins.js +1 -1
- package/dist/guards/repository/index.js +2 -0
- package/dist/guards/repository/justModules.js +28 -10
- package/dist/guards/repository/noRawColors.js +1 -1
- package/dist/guards/repository/scriptsCalled.js +38 -11
- package/dist/guards/repository/suwfrontkitWiring.d.ts +2 -0
- package/dist/guards/repository/suwfrontkitWiring.js +52 -0
- package/dist/profiles/contract.js +81 -38
- package/dist/profiles/criteria.d.ts +1 -0
- package/dist/profiles/criteria.js +1 -1
- package/dist/profiles/criteriaRan.d.ts +22 -0
- package/dist/profiles/criteriaRan.js +152 -0
- package/dist/profiles/database.js +11 -4
- package/dist/profiles/dotnet.d.ts +2 -0
- package/dist/profiles/dotnet.js +39 -6
- package/dist/profiles/dotnetGuards.d.ts +3 -0
- package/dist/profiles/dotnetGuards.js +54 -0
- package/dist/profiles/everyRepository.js +2 -0
- package/dist/profiles/index.d.ts +2 -0
- package/dist/profiles/index.js +2 -0
- package/dist/profiles/library.js +12 -7
- package/dist/profiles/node.js +21 -7
- package/dist/profiles/presets/knip.d.ts +1 -0
- package/dist/profiles/presets/knip.js +4 -2
- package/dist/profiles/presets/playwright.d.ts +3 -1
- package/dist/profiles/presets/playwright.js +7 -1
- package/dist/profiles/reports.d.ts +35 -0
- package/dist/profiles/reports.js +60 -0
- package/dist/profiles/shell.d.ts +6 -0
- package/dist/profiles/shell.js +39 -4
- package/dist/profiles/verdict.d.ts +9 -0
- package/dist/profiles/verdict.js +124 -0
- package/dist/profiles/web.js +25 -6
- package/package.json +2 -2
- package/schema/suwgate.schema.json +82 -4
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { existsSync, readdirSync, readFileSync } from "node:fs";
|
|
2
|
+
import path from "node:path";
|
|
3
|
+
const XUNIT_TEST = /<test\b([^>]*?)(?:\/>|>([\s\S]*?)<\/test>)/g;
|
|
4
|
+
const CRITERION_TRAIT = /<trait\s+name="criterion"\s+value="([^"]*)"/g;
|
|
5
|
+
export function vitestRun(report) {
|
|
6
|
+
const assertions = (report.testResults ?? []).flatMap((file) => file.assertionResults ?? []);
|
|
7
|
+
return {
|
|
8
|
+
executed: assertions.filter((assertion) => assertion.status === "passed" || assertion.status === "failed").length,
|
|
9
|
+
passed: assertions.filter((assertion) => assertion.status === "passed").map((assertion) => assertion.fullName ?? ""),
|
|
10
|
+
};
|
|
11
|
+
}
|
|
12
|
+
function specsOf(suite, titles) {
|
|
13
|
+
const own = suite.file === undefined || suite.title !== suite.file ? [...titles, suite.title ?? ""] : titles;
|
|
14
|
+
return [
|
|
15
|
+
...(suite.specs ?? []).map((spec) => ({
|
|
16
|
+
title: [...own, spec.title ?? ""].filter((title) => title !== "").join(" "),
|
|
17
|
+
statuses: (spec.tests ?? []).map((test) => test.status ?? ""),
|
|
18
|
+
})),
|
|
19
|
+
...(suite.suites ?? []).flatMap((inner) => specsOf(inner, own)),
|
|
20
|
+
];
|
|
21
|
+
}
|
|
22
|
+
export function playwrightRun(report) {
|
|
23
|
+
const specs = (report.suites ?? []).flatMap((suite) => specsOf(suite, []));
|
|
24
|
+
return {
|
|
25
|
+
executed: specs.filter((spec) => spec.statuses.some((status) => status !== "skipped")).length,
|
|
26
|
+
passed: specs
|
|
27
|
+
.filter((spec) => spec.statuses.length > 0 && spec.statuses.every((status) => status === "expected" || status === "flaky"))
|
|
28
|
+
.map((spec) => spec.title),
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
export function xunitRun(xml) {
|
|
32
|
+
const tests = [...xml.matchAll(XUNIT_TEST)].map((match) => ({
|
|
33
|
+
result: /\bresult="([^"]*)"/.exec(match[1] ?? "")?.[1] ?? "",
|
|
34
|
+
criteria: [...(match[2] ?? "").matchAll(CRITERION_TRAIT)].map((trait) => trait[1] ?? ""),
|
|
35
|
+
}));
|
|
36
|
+
return {
|
|
37
|
+
executed: tests.filter((test) => test.result === "Pass" || test.result === "Fail").length,
|
|
38
|
+
passed: tests.filter((test) => test.result === "Pass").flatMap((test) => test.criteria.map((id) => `${id}:`)),
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
export function files(location, extension) {
|
|
42
|
+
if (!existsSync(location))
|
|
43
|
+
return [];
|
|
44
|
+
return readdirSync(location)
|
|
45
|
+
.filter((file) => file.endsWith(extension))
|
|
46
|
+
.map((file) => path.join(location, file));
|
|
47
|
+
}
|
|
48
|
+
export function readRun(format, location) {
|
|
49
|
+
if (format === "xunit") {
|
|
50
|
+
const reports = files(location, ".xml");
|
|
51
|
+
if (reports.length === 0)
|
|
52
|
+
return null;
|
|
53
|
+
const runs = reports.map((report) => xunitRun(readFileSync(report, "utf8")));
|
|
54
|
+
return { executed: runs.reduce((sum, run) => sum + run.executed, 0), passed: runs.flatMap((run) => run.passed) };
|
|
55
|
+
}
|
|
56
|
+
if (!existsSync(location))
|
|
57
|
+
return null;
|
|
58
|
+
const report = JSON.parse(readFileSync(location, "utf8"));
|
|
59
|
+
return format === "vitest" ? vitestRun(report) : playwrightRun(report);
|
|
60
|
+
}
|
package/dist/profiles/shell.d.ts
CHANGED
|
@@ -10,4 +10,10 @@ export declare function script(lines: readonly string[]): string;
|
|
|
10
10
|
export declare function onPath(tool: string): boolean;
|
|
11
11
|
export declare function suwgate(args: string): string;
|
|
12
12
|
export declare function hasDevSection(context: StepContext): boolean;
|
|
13
|
+
export declare function databaseUpCommand(context: StepContext): string | null;
|
|
14
|
+
export declare function settingsOf<Settings>(context: StepContext, step: string): Partial<Settings>;
|
|
13
15
|
export declare const CHECKOUT_ENV: string[];
|
|
16
|
+
export declare function runDirectory(step: string): string;
|
|
17
|
+
export declare function verdictCommand(args: string): string;
|
|
18
|
+
export declare function countedVitest(step: string, command: string): string;
|
|
19
|
+
export declare function countedPlaywright(step: string, command: string, reporters?: string | null): string[];
|
package/dist/profiles/shell.js
CHANGED
|
@@ -67,13 +67,48 @@ export function onPath(tool) {
|
|
|
67
67
|
export function suwgate(args) {
|
|
68
68
|
return `${quoted(process.execPath)} ${quoted(CLI)} ${args}`;
|
|
69
69
|
}
|
|
70
|
-
|
|
70
|
+
const MAX_ALIASES = 10_000;
|
|
71
|
+
function devSection(context) {
|
|
71
72
|
try {
|
|
72
|
-
const parsed = parseYaml(readFileSync(path.join(context.root, "suwgate.yml"), "utf8"));
|
|
73
|
-
|
|
73
|
+
const parsed = parseYaml(readFileSync(path.join(context.root, "suwgate.yml"), "utf8"), { maxAliasCount: MAX_ALIASES });
|
|
74
|
+
if (typeof parsed !== "object" || parsed === null || !("dev" in parsed))
|
|
75
|
+
return null;
|
|
76
|
+
const dev = parsed.dev;
|
|
77
|
+
return typeof dev === "object" && dev !== null ? dev : {};
|
|
74
78
|
}
|
|
75
79
|
catch {
|
|
76
|
-
return
|
|
80
|
+
return null;
|
|
77
81
|
}
|
|
78
82
|
}
|
|
83
|
+
export function hasDevSection(context) {
|
|
84
|
+
return devSection(context) !== null;
|
|
85
|
+
}
|
|
86
|
+
export function databaseUpCommand(context) {
|
|
87
|
+
const database = devSection(context)?.["database"];
|
|
88
|
+
const up = typeof database === "object" && database !== null ? database["up"] : undefined;
|
|
89
|
+
return typeof up === "string" ? up : null;
|
|
90
|
+
}
|
|
91
|
+
export function settingsOf(context, step) {
|
|
92
|
+
return context.settings[step] ?? {};
|
|
93
|
+
}
|
|
79
94
|
export const CHECKOUT_ENV = [`variables="$(${suwgate("dev checkout-env")})"`, 'eval "$variables"'];
|
|
95
|
+
export function runDirectory(step) {
|
|
96
|
+
return `run="\${SUWGATE_RUN:-$(mktemp -d)}/${step}" && mkdir -p "$run"`;
|
|
97
|
+
}
|
|
98
|
+
export function verdictCommand(args) {
|
|
99
|
+
return suwgate(`verdict ${args}`);
|
|
100
|
+
}
|
|
101
|
+
export function countedVitest(step, command) {
|
|
102
|
+
return [
|
|
103
|
+
runDirectory(step),
|
|
104
|
+
`${command} --reporter=default --reporter=json --outputFile.json="$run/vitest.json" "$@"`,
|
|
105
|
+
verdictCommand(`tests vitest "$run/vitest.json" ${quoted(`vitest (${step})`)}`),
|
|
106
|
+
].join(" && ");
|
|
107
|
+
}
|
|
108
|
+
export function countedPlaywright(step, command, reporters = "list,json") {
|
|
109
|
+
return [
|
|
110
|
+
runDirectory(step),
|
|
111
|
+
`PLAYWRIGHT_JSON_OUTPUT_FILE="$run/playwright.json" ${command}${reporters === null ? "" : ` --reporter=${reporters}`} "$@"`,
|
|
112
|
+
verdictCommand(`tests playwright "$run/playwright.json" ${quoted(`playwright (${step})`)}`),
|
|
113
|
+
];
|
|
114
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { type ReportFormat } from "./reports.ts";
|
|
2
|
+
export declare function testsVerdict(format: ReportFormat, location: string, tool: string): string | null;
|
|
3
|
+
export declare function guardsVerdict(directory: string, required: readonly string[]): string | null;
|
|
4
|
+
export declare function tsconfigVerdict(file: string, shown: string, preset: Readonly<Record<string, unknown>>): string | null;
|
|
5
|
+
export declare function eslintVerdict(file: string, printed: string, rules: readonly string[]): string | null;
|
|
6
|
+
export declare function verdict(argv: readonly string[]): {
|
|
7
|
+
exitCode: number;
|
|
8
|
+
text: string;
|
|
9
|
+
};
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
import { readFileSync } from "node:fs";
|
|
2
|
+
import { criteriaRan } from "./criteriaRan.js";
|
|
3
|
+
import { files, readRun } from "./reports.js";
|
|
4
|
+
const STRICT_FAMILY = [
|
|
5
|
+
"noImplicitAny",
|
|
6
|
+
"strictNullChecks",
|
|
7
|
+
"strictFunctionTypes",
|
|
8
|
+
"strictBindCallApply",
|
|
9
|
+
"strictPropertyInitialization",
|
|
10
|
+
"strictBuiltinIteratorReturn",
|
|
11
|
+
"noImplicitThis",
|
|
12
|
+
"useUnknownInCatchVariables",
|
|
13
|
+
"alwaysStrict",
|
|
14
|
+
];
|
|
15
|
+
export function testsVerdict(format, location, tool) {
|
|
16
|
+
const run = readRun(format, location);
|
|
17
|
+
if (run === null) {
|
|
18
|
+
const hint = format === "playwright"
|
|
19
|
+
? "; Playwright writes it when its reporters include json, which e2eTests() of @maniumek/suwgate/playwright adds: keep the config's reporter inside e2eTests(), and pass no --reporter after --"
|
|
20
|
+
: "";
|
|
21
|
+
return `${tool} wrote no report, so suwgate cannot tell that any test ran: run it again and look at its output above${hint}`;
|
|
22
|
+
}
|
|
23
|
+
if (run.executed > 0)
|
|
24
|
+
return null;
|
|
25
|
+
return `${tool} ran 0 tests (every test skipped or filtered out, or none found), and a gate that ran nothing proves nothing: add a test that runs, or skip the step in suwgate.yml (steps.skip) with a reason`;
|
|
26
|
+
}
|
|
27
|
+
function missingGuards(evidence, required) {
|
|
28
|
+
const ran = new Set(evidence.split("\n").map((line) => line.split("\t")[0] ?? ""));
|
|
29
|
+
return required.filter((guard) => !ran.has(guard));
|
|
30
|
+
}
|
|
31
|
+
export function guardsVerdict(directory, required) {
|
|
32
|
+
const evidence = files(directory, ".tsv")
|
|
33
|
+
.map((file) => readFileSync(file, "utf8"))
|
|
34
|
+
.join("\n");
|
|
35
|
+
const missing = missingGuards(evidence, required);
|
|
36
|
+
if (missing.length === 0)
|
|
37
|
+
return null;
|
|
38
|
+
return [
|
|
39
|
+
`${missing.length} .NET guard(s) of the repository's profiles did not run in this gate run: ${missing.join(", ")}.`,
|
|
40
|
+
"Call SuwgateGuards.VerifyAll(new GuardInputs { ... }) from one xUnit test in a test project that references Suwgate.Architecture",
|
|
41
|
+
"(the Suwgate.Architecture README shows the test; pass new DatabaseProfile() with the database profile), and do not skip that test;",
|
|
42
|
+
"a guard that does not apply to this repository is skipped in suwgate.yml (guards.skip) with a reason.",
|
|
43
|
+
].join("\n");
|
|
44
|
+
}
|
|
45
|
+
function strictOptions(preset) {
|
|
46
|
+
return Object.keys(preset).filter((option) => /^(strict|no|exact)/.test(option) && option !== "noEmit");
|
|
47
|
+
}
|
|
48
|
+
export function tsconfigVerdict(file, shown, preset) {
|
|
49
|
+
const options = JSON.parse(shown).compilerOptions ?? {};
|
|
50
|
+
const off = [
|
|
51
|
+
...strictOptions(preset).filter((option) => options[option] !== preset[option]),
|
|
52
|
+
...(preset["strict"] === true ? STRICT_FAMILY.filter((option) => options[option] === false) : []),
|
|
53
|
+
];
|
|
54
|
+
if (off.length === 0)
|
|
55
|
+
return null;
|
|
56
|
+
return `${file}: tsc --showConfig shows ${off.map((option) => `${option}: ${JSON.stringify(options[option] ?? "unset")}`).join(", ")}; the strict preset of suwgate needs them on: extend @maniumek/suwgate/tsconfig/strict (or browser, node) and delete the override`;
|
|
57
|
+
}
|
|
58
|
+
export function eslintVerdict(file, printed, rules) {
|
|
59
|
+
const config = JSON.parse(printed);
|
|
60
|
+
const severity = (rule) => {
|
|
61
|
+
const setting = config.rules?.[rule];
|
|
62
|
+
return Array.isArray(setting) ? setting[0] : setting;
|
|
63
|
+
};
|
|
64
|
+
const off = rules.filter((rule) => severity(rule) !== 2 && severity(rule) !== "error");
|
|
65
|
+
if (off.length === 0)
|
|
66
|
+
return null;
|
|
67
|
+
return `${file}: eslint --print-config shows ${off.map((rule) => `${rule} ${JSON.stringify(severity(rule) ?? "off")}`).join(", ")}; it must be an error for every source file: build eslint.config.js on strict() or app() of @maniumek/suwgate/eslint and delete what turns it off`;
|
|
68
|
+
}
|
|
69
|
+
const STRICT_PRESET = new URL("./presets/tsconfig/strict.json", import.meta.url);
|
|
70
|
+
function presetOptions() {
|
|
71
|
+
return JSON.parse(readFileSync(STRICT_PRESET, "utf8")).compilerOptions;
|
|
72
|
+
}
|
|
73
|
+
function stdin() {
|
|
74
|
+
try {
|
|
75
|
+
return readFileSync(0, "utf8");
|
|
76
|
+
}
|
|
77
|
+
catch {
|
|
78
|
+
return "";
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
function format(value) {
|
|
82
|
+
return value === "vitest" || value === "playwright" || value === "xunit" ? value : null;
|
|
83
|
+
}
|
|
84
|
+
function judged(argv) {
|
|
85
|
+
const [command, first = "", ...rest] = argv;
|
|
86
|
+
switch (command) {
|
|
87
|
+
case "tests": {
|
|
88
|
+
const kind = format(first);
|
|
89
|
+
const [location, tool] = rest;
|
|
90
|
+
return kind === null || location === undefined || tool === undefined ? undefined : testsVerdict(kind, location, tool);
|
|
91
|
+
}
|
|
92
|
+
case "guards":
|
|
93
|
+
return guardsVerdict(first, rest);
|
|
94
|
+
case "tsconfig":
|
|
95
|
+
return tsconfigVerdict(first, stdin(), presetOptions());
|
|
96
|
+
case "eslint":
|
|
97
|
+
return eslintVerdict(first, stdin(), rest);
|
|
98
|
+
case "criteria": {
|
|
99
|
+
const [input] = rest;
|
|
100
|
+
if (input === undefined)
|
|
101
|
+
return undefined;
|
|
102
|
+
const problems = criteriaRan({ ...JSON.parse(input), run: first });
|
|
103
|
+
return problems.length === 0 ? null : problems.join("\n");
|
|
104
|
+
}
|
|
105
|
+
default:
|
|
106
|
+
return undefined;
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
export function verdict(argv) {
|
|
110
|
+
let problem;
|
|
111
|
+
try {
|
|
112
|
+
problem = judged(argv);
|
|
113
|
+
}
|
|
114
|
+
catch (error) {
|
|
115
|
+
problem = `suwgate verdict ${argv.join(" ")}: ${error instanceof Error ? error.message : String(error)}`;
|
|
116
|
+
}
|
|
117
|
+
if (problem === undefined) {
|
|
118
|
+
return {
|
|
119
|
+
exitCode: 2,
|
|
120
|
+
text: "usage: suwgate verdict tests <vitest|playwright|xunit> <report> <tool> | guards <evidence-dir> <guard>... | tsconfig <file> | eslint <file> <rule>... | criteria <run-dir> <input-json>",
|
|
121
|
+
};
|
|
122
|
+
}
|
|
123
|
+
return problem === null ? { exitCode: 0, text: "" } : { exitCode: 1, text: problem };
|
|
124
|
+
}
|
package/dist/profiles/web.js
CHANGED
|
@@ -2,14 +2,29 @@ import { API_CONTRACT } from "./contract.js";
|
|
|
2
2
|
import { DATABASE_UP } from "./database.js";
|
|
3
3
|
import { DOTNET_BUILD, DOTNET_TEST } from "./dotnet.js";
|
|
4
4
|
import { PNPM_INSTALL } from "./node.js";
|
|
5
|
-
import { CHECKOUT_ENV, has, hasDevSection, quoted, script, suwgate } from "./shell.js";
|
|
5
|
+
import { CHECKOUT_ENV, countedPlaywright, has, hasDevSection, quoted, script, settingsOf, suwgate } from "./shell.js";
|
|
6
|
+
const E2E = "e2e";
|
|
6
7
|
const E2E_CONFIG = "e2e/playwright.config.ts";
|
|
7
8
|
const PLAYWRIGHT = `pnpm exec playwright test -c ${E2E_CONFIG}`;
|
|
9
|
+
const E2E_SETTINGS = {
|
|
10
|
+
type: "object",
|
|
11
|
+
additionalProperties: false,
|
|
12
|
+
properties: {
|
|
13
|
+
before: {
|
|
14
|
+
description: "Commands run in the repository root after the database is fresh and before Playwright, in order (e.g. rm -rf .artifacts/e2e/versions); a failing one stops the step.",
|
|
15
|
+
type: "array",
|
|
16
|
+
minItems: 1,
|
|
17
|
+
items: { type: "string", minLength: 1 },
|
|
18
|
+
},
|
|
19
|
+
},
|
|
20
|
+
};
|
|
8
21
|
function e2e(context) {
|
|
9
22
|
if (!has(context, E2E_CONFIG))
|
|
10
23
|
return null;
|
|
24
|
+
const before = (settingsOf(context, E2E).before ?? []).map((command) => `(cd ${quoted(context.root)} && ${command})`);
|
|
25
|
+
const playwright = countedPlaywright(E2E, PLAYWRIGHT, null);
|
|
11
26
|
if (!hasDevSection(context))
|
|
12
|
-
return
|
|
27
|
+
return script(["set -euo pipefail", ...before, ...playwright]);
|
|
13
28
|
return script([
|
|
14
29
|
"set -euo pipefail",
|
|
15
30
|
...CHECKOUT_ENV,
|
|
@@ -17,17 +32,21 @@ function e2e(context) {
|
|
|
17
32
|
`${suwgate("dev db up")} >/dev/null`,
|
|
18
33
|
`${suwgate("dev db psql")} -q -d postgres -c "DROP DATABASE IF EXISTS $E2E_DATABASE WITH (FORCE)" -c "CREATE DATABASE $E2E_DATABASE"`,
|
|
19
34
|
`mkdir -p ${quoted(`${context.root}/.artifacts/logs`)}`,
|
|
20
|
-
|
|
35
|
+
...before,
|
|
36
|
+
...playwright,
|
|
21
37
|
]);
|
|
22
38
|
}
|
|
23
39
|
export const webSteps = [
|
|
24
40
|
{
|
|
25
|
-
id:
|
|
26
|
-
title: `browser tests against the real server and a fresh database of this checkout (playwright, ${E2E_CONFIG})`,
|
|
41
|
+
id: E2E,
|
|
42
|
+
title: `browser tests against the real server and a fresh database of this checkout (playwright, ${E2E_CONFIG}; 0 tests run fails)`,
|
|
27
43
|
profile: "web",
|
|
28
44
|
needs: ["pnpm"],
|
|
29
|
-
after: [PNPM_INSTALL, DOTNET_BUILD, DATABASE_UP
|
|
45
|
+
after: [PNPM_INSTALL, DOTNET_BUILD, DATABASE_UP],
|
|
46
|
+
orderAfter: [DOTNET_TEST, API_CONTRACT],
|
|
30
47
|
run: e2e,
|
|
48
|
+
args: "playwright test",
|
|
49
|
+
settingsSchema: E2E_SETTINGS,
|
|
31
50
|
limitSeconds: 600,
|
|
32
51
|
},
|
|
33
52
|
];
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@maniumek/suwgate",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.4.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",
|
|
@@ -93,7 +93,7 @@
|
|
|
93
93
|
"provenance": true
|
|
94
94
|
},
|
|
95
95
|
"scripts": {
|
|
96
|
-
"build": "
|
|
96
|
+
"build": "tsc -p tsconfig.build.json && mkdir -p dist/profiles/presets/tsconfig && cp -r src/profiles/presets/tsconfig/. dist/profiles/presets/tsconfig/",
|
|
97
97
|
"changeset": "changeset",
|
|
98
98
|
"release": "pnpm run build && changeset publish"
|
|
99
99
|
}
|
|
@@ -35,6 +35,11 @@
|
|
|
35
35
|
}
|
|
36
36
|
}
|
|
37
37
|
},
|
|
38
|
+
"env": { "$ref": "#/$defs/env", "description": "Variables set for every step (a step's own env in steps.configure wins)." },
|
|
39
|
+
"unset": {
|
|
40
|
+
"$ref": "#/$defs/unset",
|
|
41
|
+
"description": "Variables no step sees, removed before the steps run, e.g. [Models__*, LLM_MODEL_*] so no step reaches a real model."
|
|
42
|
+
},
|
|
38
43
|
"steps": {
|
|
39
44
|
"type": "object",
|
|
40
45
|
"additionalProperties": false,
|
|
@@ -73,6 +78,48 @@
|
|
|
73
78
|
"reason": { "$ref": "#/$defs/reason" }
|
|
74
79
|
}
|
|
75
80
|
}
|
|
81
|
+
},
|
|
82
|
+
"configure": {
|
|
83
|
+
"description": "Knobs of the profiles' own steps, by step id: their ceiling, more steps to wait for, their environment, and the step's own settings, which the step's schema checks. Replacing a step's command is a skip with its reason plus an added step.",
|
|
84
|
+
"type": "object",
|
|
85
|
+
"propertyNames": { "$ref": "#/$defs/id" },
|
|
86
|
+
"additionalProperties": {
|
|
87
|
+
"type": "object",
|
|
88
|
+
"additionalProperties": false,
|
|
89
|
+
"properties": {
|
|
90
|
+
"limitSeconds": { "type": "integer", "minimum": 1, "description": "The step is killed above this." },
|
|
91
|
+
"after": {
|
|
92
|
+
"type": "array",
|
|
93
|
+
"uniqueItems": true,
|
|
94
|
+
"items": { "$ref": "#/$defs/id" },
|
|
95
|
+
"description": "More steps that must finish first, on top of the step's own."
|
|
96
|
+
},
|
|
97
|
+
"env": { "$ref": "#/$defs/env" },
|
|
98
|
+
"unset": { "$ref": "#/$defs/unset" },
|
|
99
|
+
"settings": {
|
|
100
|
+
"description": "The step's own settings, checked by the step's settingsSchema (README: the settings of the steps)."
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
},
|
|
107
|
+
"guards": {
|
|
108
|
+
"type": "object",
|
|
109
|
+
"additionalProperties": false,
|
|
110
|
+
"properties": {
|
|
111
|
+
"skip": {
|
|
112
|
+
"description": "Whole guards that do not apply to this repository, each with its reason: repository guards, and the .NET guards (architecture/*, database/*) that SuwgateGuards.VerifyAll runs and the dotnet-test step asks evidence for.",
|
|
113
|
+
"type": "array",
|
|
114
|
+
"items": {
|
|
115
|
+
"type": "object",
|
|
116
|
+
"additionalProperties": false,
|
|
117
|
+
"required": ["guard", "reason"],
|
|
118
|
+
"properties": {
|
|
119
|
+
"guard": { "type": "string", "pattern": "^([a-z]+/)?[a-z][a-z0-9-]*$" },
|
|
120
|
+
"reason": { "$ref": "#/$defs/reason" }
|
|
121
|
+
}
|
|
122
|
+
}
|
|
76
123
|
}
|
|
77
124
|
}
|
|
78
125
|
},
|
|
@@ -86,7 +133,16 @@
|
|
|
86
133
|
"properties": {
|
|
87
134
|
"guard": { "type": "string", "pattern": "^([a-z]+/)?[a-z][a-z0-9-]*$" },
|
|
88
135
|
"target": { "type": "string", "minLength": 1 },
|
|
89
|
-
"reason": { "$ref": "#/$defs/reason" }
|
|
136
|
+
"reason": { "$ref": "#/$defs/reason" },
|
|
137
|
+
"message": {
|
|
138
|
+
"type": "string",
|
|
139
|
+
"minLength": 1,
|
|
140
|
+
"description": "Narrows the exception to the target's findings whose message contains this text; without it, every finding of the target is excepted. Repository guards only."
|
|
141
|
+
},
|
|
142
|
+
"once": {
|
|
143
|
+
"type": "boolean",
|
|
144
|
+
"description": "A one-time exception: it holds only while master's suwgate.yml does not have it yet (on the branch that adds it). After the merge it excepts nothing and is never stale; the report asks to delete it. Repository guards only."
|
|
145
|
+
}
|
|
90
146
|
}
|
|
91
147
|
}
|
|
92
148
|
},
|
|
@@ -139,7 +195,7 @@
|
|
|
139
195
|
}
|
|
140
196
|
},
|
|
141
197
|
"database": {
|
|
142
|
-
"description": "
|
|
198
|
+
"description": "The app's database: user, password and name default to the app name; up and psql replace the compose service with the repository's own commands.",
|
|
143
199
|
"type": "object",
|
|
144
200
|
"additionalProperties": false,
|
|
145
201
|
"properties": {
|
|
@@ -149,7 +205,17 @@
|
|
|
149
205
|
"minLength": 1,
|
|
150
206
|
"description": "A development password: the database is published on the loopback only."
|
|
151
207
|
},
|
|
152
|
-
"name": { "type": "string", "minLength": 1 }
|
|
208
|
+
"name": { "type": "string", "minLength": 1 },
|
|
209
|
+
"up": {
|
|
210
|
+
"type": "string",
|
|
211
|
+
"minLength": 1,
|
|
212
|
+
"description": "A bash command, run in the repository root, that starts the database (or leaves it running) and returns once it answers, e.g. scripts/.internal/db.sh up. suwgate dev db up, the database-up step and the e2e step run it instead of docker compose."
|
|
213
|
+
},
|
|
214
|
+
"psql": {
|
|
215
|
+
"type": "string",
|
|
216
|
+
"minLength": 1,
|
|
217
|
+
"description": "A bash command that runs psql in the database as its owner and takes psql's arguments after it, e.g. scripts/.internal/db.sh psql. suwgate dev db psql and the e2e step use it instead of docker compose exec."
|
|
218
|
+
}
|
|
153
219
|
}
|
|
154
220
|
},
|
|
155
221
|
"server": {
|
|
@@ -196,12 +262,24 @@
|
|
|
196
262
|
"settings": {
|
|
197
263
|
"description": "Settings of a guard, by its id; the guard's own schema checks them.",
|
|
198
264
|
"type": "object",
|
|
199
|
-
"propertyNames": { "pattern": "^[a-z][a-z0-9-]*$" }
|
|
265
|
+
"propertyNames": { "pattern": "^([a-z]+/)?[a-z][a-z0-9-]*$" }
|
|
200
266
|
}
|
|
201
267
|
},
|
|
202
268
|
"$defs": {
|
|
203
269
|
"id": { "type": "string", "pattern": "^[a-z][a-z0-9-]*$" },
|
|
204
270
|
"reason": { "type": "string", "pattern": "\\S", "description": "Why: a sentence a reviewer can judge." },
|
|
271
|
+
"env": {
|
|
272
|
+
"description": "Variables set for the commands, by name; quote a value YAML would read as a number or a boolean (\"1\").",
|
|
273
|
+
"type": "object",
|
|
274
|
+
"propertyNames": { "pattern": "^[A-Za-z_][A-Za-z0-9_]*$" },
|
|
275
|
+
"additionalProperties": { "type": "string" }
|
|
276
|
+
},
|
|
277
|
+
"unset": {
|
|
278
|
+
"description": "Variables removed from the environment, by name; * and ? match any characters (Models__* clears every Models__ setting), without regard to case, as .NET reads configuration.",
|
|
279
|
+
"type": "array",
|
|
280
|
+
"uniqueItems": true,
|
|
281
|
+
"items": { "type": "string", "pattern": "^[A-Za-z0-9_*?]+$" }
|
|
282
|
+
},
|
|
205
283
|
"port": { "type": "integer", "minimum": 1, "maximum": 65535 },
|
|
206
284
|
"relativePath": { "type": "string", "pattern": "^[^/\\\\][^\\\\]*$" }
|
|
207
285
|
}
|