@maniumek/suwgate 0.10.0 → 0.11.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
CHANGED
|
@@ -1,169 +1,207 @@
|
|
|
1
|
-
|
|
1
|
+
<picture>
|
|
2
|
+
<source media="(prefers-color-scheme: dark)" srcset="docs/visual/board/img/readme/hero-dark.png">
|
|
3
|
+
<img alt="suwgate, npm CLI and NuGet guards. One quality gate for every repository: one command runs the steps of its profiles and its guards, configured in one suwgate.yml. Tags: suwgate check, agent hooks, suwgate dev, CI workflows, Renovate preset. Terminal: suwgate check --quick prints PASS, all 8 steps in 4s (14 exceptions in suwgate.yml); suwgate step dotnet-test prints PASS, all 2 steps in 55s. Numbers: 4 profiles (web, library, dotnet, database), 25 steps the profiles bring, 36 repository guards, 14 .NET guards in xUnit, 3 hooks for agents and git, 3 reusable CI workflows." src="docs/visual/board/img/readme/hero-light.png" width="100%">
|
|
4
|
+
</picture>
|
|
2
5
|
|
|
3
|
-
|
|
6
|
+
suwgate is the one quality gate of a stack of repositories that agents and one developer work on: the CLI
|
|
7
|
+
[`@maniumek/suwgate`](https://www.npmjs.com/package/@maniumek/suwgate) on npm, and the .NET guards `Suwgate.Architecture` and
|
|
8
|
+
`Suwgate.Database` on NuGet. A repository says what it is in `suwgate.yml`; suwgate brings the steps, the guards, the hooks, the
|
|
9
|
+
tool presets, the local dev commands, the CI workflows and the Renovate preset.
|
|
4
10
|
|
|
5
|
-
##
|
|
11
|
+
## Install
|
|
12
|
+
|
|
13
|
+
Node 24 or later, pnpm, and a git repository:
|
|
6
14
|
|
|
7
15
|
```sh
|
|
8
|
-
pnpm add -D @maniumek/suwgate
|
|
9
|
-
pnpm exec suwgate check # the whole gate, the same CI runs
|
|
10
|
-
pnpm exec suwgate check --quick # the guards, and the quick steps for what changed since master
|
|
11
|
-
pnpm exec suwgate step # the steps of this repository, with their titles
|
|
12
|
-
pnpm exec suwgate step e2e -- --headed -g notes # one step and what it needs; after --, arguments for its tool
|
|
16
|
+
pnpm add -D --save-exact @maniumek/suwgate
|
|
13
17
|
```
|
|
14
18
|
|
|
15
|
-
pnpm installs a version only once it is a day old (`minimumReleaseAge`). To take a new suwgate the day it is published, exclude
|
|
16
|
-
|
|
17
|
-
(`@maniumek/suwgate@0.5.0`) has to be edited on every version bump, the name does not.
|
|
19
|
+
pnpm installs a version only once it is a day old (`minimumReleaseAge`). To take a new suwgate the day it is published, exclude the
|
|
20
|
+
package by name in `pnpm-workspace.yaml`: `minimumReleaseAgeExclude: ["@maniumek/suwgate"]`.
|
|
18
21
|
|
|
19
|
-
|
|
22
|
+
## Quick start
|
|
20
23
|
|
|
21
|
-
```
|
|
22
|
-
profiles: [web, dotnet, database
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
steps:
|
|
26
|
-
add:
|
|
27
|
-
- name: api-diff
|
|
28
|
-
run: scripts/.internal/api-diff.sh
|
|
29
|
-
after: [dotnet-build]
|
|
30
|
-
skip:
|
|
31
|
-
- step: knip
|
|
32
|
-
reason: the generated API client exports more than the app uses, and knip cannot tell
|
|
33
|
-
exceptions:
|
|
34
|
-
- guard: architecture/interfaces-have-two-implementations
|
|
35
|
-
target: Myapp.Server.Payments.IPaymentGateway
|
|
36
|
-
reason: the payment SDK takes an implementation of this interface; the second one is the SDK's test double
|
|
24
|
+
```sh
|
|
25
|
+
printf 'profiles: [web]\n' > suwgate.yml # or library, dotnet, database, several at once
|
|
26
|
+
pnpm exec suwgate agents-shared # writes AGENTS.shared.md, the rules every repository shares
|
|
27
|
+
pnpm exec suwgate check # the whole gate; every finding says how to fix it
|
|
37
28
|
```
|
|
38
29
|
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
- `quick.limitSeconds` is the budget of `suwgate check --quick` (default 20): the quick gate fails above it. A machine that is slow
|
|
47
|
-
across the board overrides it with `SUWGATE_QUICK_LIMIT=<seconds>`.
|
|
48
|
-
- `exceptions` let one target through one guard, always with a `reason`; `suwgate check` counts them in its report, and an
|
|
49
|
-
exception that no longer matches anything fails the gate until it is deleted. Two optional fields, for the repository guards
|
|
50
|
-
and the .NET guards alike:
|
|
51
|
-
- `message` narrows it to the target's findings whose message contains that text, so a second finding in the same file still
|
|
52
|
-
fails: `{ guard: no-raw-colors, target: Myapp.Web/src/mail.tsx, message: "#1e66f5", reason: … }`.
|
|
53
|
-
- `once: true` makes it a one-time exception, for a finding that goes away once the change is on master, such as an
|
|
54
|
-
owner-approved edit of an applied migration (`migrations-unchanged`). It holds only while master's `suwgate.yml` does not
|
|
55
|
-
have it, that is on the branch that adds it. After the merge it excepts nothing (a later edit of the same script fails
|
|
56
|
-
again) and is never stale, so the first run on master stays green; the report asks to delete it with the next change.
|
|
57
|
-
- A reason shared by many exceptions can be a YAML anchor (`reason: &sdk the SDK implements it`, then `reason: *sdk`), up to
|
|
58
|
-
10 000 aliases.
|
|
59
|
-
- `guards.skip` turns one whole guard off, always with a `reason`: a repository guard, or a .NET guard (`architecture/*`,
|
|
60
|
-
`database/*`), which `SuwgateGuards.VerifyAll` then does not run and the `dotnet-test` step does not ask evidence for. A
|
|
61
|
-
library, for example: `guards: { skip: [{ guard: architecture/endpoints, reason: a library has no server }] }`.
|
|
62
|
-
- The schema is in the package, `schema/suwgate.schema.json`. VS Code checks the file as you type with
|
|
63
|
-
`"yaml.schemas": { "./node_modules/@maniumek/suwgate/schema/suwgate.schema.json": "suwgate.yml" }` in `.vscode/settings.json`.
|
|
64
|
-
- `settings` configure a guard by its id, for example `dependency-direction: { applications: [Myapp.*] }`,
|
|
65
|
-
`agents-file: { acronyms: [NUGET] }` or `docs-paths: { ignore: [Myapp.Web/node_modules/], skip: [docs/notes/**] }` (`ignore`: names the
|
|
66
|
-
docs may mention that are not paths here; `skip`: documents, by glob, that docs-paths does not read at all); the schema of each
|
|
67
|
-
guard's settings is in its source, and `suwgate check` validates them.
|
|
68
|
-
|
|
69
|
-
## Hooks
|
|
70
|
-
|
|
71
|
-
Three lines wire the hooks; `.claude/settings.json`:
|
|
72
|
-
|
|
73
|
-
```json
|
|
74
|
-
{
|
|
75
|
-
"hooks": {
|
|
76
|
-
"Stop": [
|
|
77
|
-
{ "hooks": [{ "type": "command", "command": "\"${CLAUDE_PROJECT_DIR}/node_modules/.bin/suwgate\" hook stop", "timeout": 600 }] }
|
|
78
|
-
],
|
|
79
|
-
"PreToolUse": [
|
|
80
|
-
{
|
|
81
|
-
"matcher": "Edit|Write|MultiEdit|NotebookEdit",
|
|
82
|
-
"hooks": [{ "type": "command", "command": "\"${CLAUDE_PROJECT_DIR}/node_modules/.bin/suwgate\" hook guard-edit" }]
|
|
83
|
-
}
|
|
84
|
-
]
|
|
85
|
-
}
|
|
86
|
-
}
|
|
30
|
+
The first run lists what the repository still lacks (the hooks, the tool configs, the line in `AGENTS.md` that reads the shared
|
|
31
|
+
rules), each finding with its fix. Then, while working:
|
|
32
|
+
|
|
33
|
+
```sh
|
|
34
|
+
pnpm exec suwgate check --quick # the guards, and the quick steps for what changed since master (20 s budget)
|
|
35
|
+
pnpm exec suwgate step # the steps of this repository
|
|
36
|
+
pnpm exec suwgate step unit-tests -- -t "saves a note" # one step and what it needs; after --, its tool's arguments
|
|
87
37
|
```
|
|
88
38
|
|
|
89
|
-
|
|
39
|
+
Wiring the hooks (`.claude/settings.json`, `.githooks/pre-commit`) and every other detail: [docs/usage.md](docs/usage.md).
|
|
40
|
+
|
|
41
|
+
## Why
|
|
42
|
+
|
|
43
|
+
<picture>
|
|
44
|
+
<source media="(prefers-color-scheme: dark)" srcset="docs/visual/board/img/readme/why-dark.png">
|
|
45
|
+
<img alt="Why one gate. Each repository on its own: its own check script, ci.yml, hooks and lint configs, copied and drifting apart; an agent says done with the tests red; an agent loosens a lint rule or edits a lockfile to get through; eslint-disable, #pragma and skipped tests hide exceptions in the code; a test file deleted or filtered out passes in silence; CI runs the gate again on a merge commit it already tested; dependency pull requests every day, merged by hand. With suwgate: one package, the repository keeps suwgate.yml and its own code; the Stop hook runs the quick gate after every turn and red blocks the end of the turn; guard-edit refuses an agent's edit of the gate and of generated files; every exception is in suwgate.yml with a reason and a stale one fails; 0 tests run fails, and every .NET guard must leave evidence it ran; a tree stamp skips a tree that already passed; one Renovate run a week, two pull requests, merged when green." src="docs/visual/board/img/readme/why-light.png" width="100%">
|
|
46
|
+
</picture>
|
|
47
|
+
|
|
48
|
+
## How a change goes through it
|
|
49
|
+
|
|
50
|
+
<picture>
|
|
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 check runs the full gate (every step, in parallel, browser tests included). 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 (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
|
+
</picture>
|
|
54
|
+
|
|
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
|
|
56
|
+
run here (its tool is missing) is reported as not verified, never as passed.
|
|
57
|
+
|
|
58
|
+
## The gate
|
|
59
|
+
|
|
60
|
+
<picture>
|
|
61
|
+
<source media="(prefers-color-scheme: dark)" srcset="docs/visual/board/img/readme/gate-dark.png">
|
|
62
|
+
<img alt="The gate: profiles and their steps. web, a web app: pnpm-install, typecheck, lint, unit-tests, format, knip, e2e (Playwright, fresh database). library, an npm package: the Node steps, stories, publint, attw, consumer-app, visual, changeset (packed as npm ships it). dotnet, a .NET solution: dotnet-build, dotnet-format, dotnet-test, which runs the .NET guards (xUnit v3, CSharpier). database, PostgreSQL: database-up, the database guards, migrations stay unchanged (compose or your script). web and dotnet together: api-contract, api-version (oasdiff), contract-pins. Every repository: guards, compose, criteria, criteria-ran, shellcheck, gitleaks. Proof, not presence: 0 tests fail (Vitest, Playwright and xUnit reports, a run with no test is red); .NET evidence (every .NET guard of the profiles writes that it ran, or dotnet-test fails); configs in effect (tsc --showConfig and eslint --print-config keep the strict options on); criteria-ran (each acceptance criterion a test names ran and passed in this run). --quick: the guards and the quick steps, only for what changed since master, budget 20 s (quick.limitSeconds, SUWGATE_QUICK_LIMIT)." src="docs/visual/board/img/readme/gate-light.png" width="100%">
|
|
63
|
+
</picture>
|
|
64
|
+
|
|
65
|
+
Independent steps run in parallel, and each looks only where its profile lives. The steps of each profile, the criteria kinds and
|
|
66
|
+
what each step proves: [docs/usage.md](docs/usage.md#the-steps-of-the-profiles).
|
|
67
|
+
|
|
68
|
+
## The guards
|
|
69
|
+
|
|
70
|
+
<picture>
|
|
71
|
+
<source media="(prefers-color-scheme: dark)" srcset="docs/visual/board/img/readme/guards-dark.png">
|
|
72
|
+
<img alt="The guards. Repository guards, 36, in-process, the step guards. Agents: agents-shared, agents-file, hooks, human-docs, docs-paths. Layout and names: repository-layout, forbidden-names, required-files, just-modules. Configs: config-contents, vscode-settings, image-pins, compose-ports. Scripts: scripts-called, scripts-help (answers --help). Dependencies: banned-npm-packages, banned-nuget-packages, unused-nuget-versions, dependency-direction. No comments: comments-hash, comments-css, comments-json, comments-markup, comments-sql, comments-csharp, comments-eslint, no-in-place-switches. Tests: test-timing, tests drive a fake clock, never real time. Kits wired: suwfrontkit-wiring, suwbackkit-wiring, openapi-versions, no-raw-colors, appsettings-bound. Database: connection-host, migrations-unchanged. Criteria: criteria-kinds, a repository's own kinds of guardrail are explained. .NET guards, NuGet, one xUnit test calls SuwgateGuards.VerifyAll. Suwgate.Architecture: architecture/ layers, endpoints, project-references, every-project-guarded, interfaces-have-two-implementations, nothing-obsolete, no-unused-types, forbidden-type-names, unique-type-names, one-type-per-file, no-escape-hatches, no-fixture-in-field, build-settings; and the build defaults: warnings as errors, analyzers, banned APIs. Suwgate.Database: database/ migration-script-names, NNNN_snake_case.sql, each number once. suwgate.yml: exceptions let one target through one guard, with a reason; a stale one fails; once: true for one branch; guards.skip and steps.skip, with a reason." src="docs/visual/board/img/readme/guards-light.png" width="100%">
|
|
73
|
+
</picture>
|
|
74
|
+
|
|
75
|
+
A guard reports every finding with its fix and never decides an exception itself: `suwgate.yml` holds the exceptions, each with
|
|
76
|
+
its reason. The .NET guards and build defaults: [Suwgate.Architecture](dotnet/Suwgate.Architecture/README.md).
|
|
77
|
+
|
|
78
|
+
## For agents
|
|
79
|
+
|
|
80
|
+
<picture>
|
|
81
|
+
<source media="(prefers-color-scheme: dark)" srcset="docs/visual/board/img/readme/agents-dark.png">
|
|
82
|
+
<img alt="For agents. hook guard-edit, Claude Code PreToolUse: refuses an edit of the gate (suwgate.yml, hooks, workflows, lint and type configs) and of generated files; ALLOW_GATE_EDIT=1 lifts the gate part. hook stop, Claude Code Stop: runs the quick gate after every turn, unless nothing changed since it last passed; red, the agent keeps working. hook pre-commit, git: gitleaks on the staged changes, then the quick gate; .githooks/pre-commit. AGENTS.shared.md: the rules every repository shares (test last, git, specs, names, secrets, no comments); suwgate agents-shared writes the copy; the agents-shared guard fails until it is current and AGENTS.md reads it first. Acceptance criteria as guardrails: every criterion id of a spec in docs/visual/spec/ is named by a test, a lint rule or a build rule (criteria), and the tests that name it ran and passed (criteria-ran)." src="docs/visual/board/img/readme/agents-light.png" width="100%">
|
|
83
|
+
</picture>
|
|
84
|
+
|
|
85
|
+
## suwgate dev
|
|
86
|
+
|
|
87
|
+
<picture>
|
|
88
|
+
<source media="(prefers-color-scheme: dark)" srcset="docs/visual/board/img/readme/dev-dark.png">
|
|
89
|
+
<img alt="suwgate dev: the local stack. db (up, down, reset, psql, logs, status): the PostgreSQL of the compose file, or your own script. server (dotnet watch): restarted when it exits, output teed to a JSON log. tmux (start [--restart], stop): shell, server and web app in one session. logs (why did it fail?): the last warnings and errors; --trace one request. smoke (read-only requests): --ci builds and starts its own stack on free ports. checkout-env (eval in a worktree): own test databases and e2e ports per linked worktree. sibling (image, up, rebuild, down, status), new: a sibling repository's images, rebuilt when its checkout moved on. dev: in suwgate.yml: only name is required; portOffset keeps repositories on one machine apart." src="docs/visual/board/img/readme/dev-light.png" width="100%">
|
|
90
|
+
</picture>
|
|
90
91
|
|
|
91
92
|
```sh
|
|
92
|
-
|
|
93
|
-
|
|
93
|
+
suwgate dev tmux start # the whole local stack in one tmux session
|
|
94
|
+
eval "$(suwgate dev checkout-env)" # in a linked worktree: its own test databases and e2e ports
|
|
95
|
+
suwgate dev sibling suwagcms up # a sibling's images, rebuilt if its checkout moved on, then started
|
|
94
96
|
```
|
|
95
97
|
|
|
96
|
-
|
|
97
|
-
- `hook guard-edit` refuses an agent's edit of the gate (`suwgate.yml`, the criteria file, the hooks, the workflows, `.editorconfig`,
|
|
98
|
-
and the lint, type and build configs of the repository's profiles, the layers file of a .NET server among them) until the owner starts a session
|
|
99
|
-
with `ALLOW_GATE_EDIT=1`. It always refuses generated files (lockfiles, the API contract and types) with the command that
|
|
100
|
-
regenerates them and an existing migration script, and refuses a recorded characterization test that git tracks. It guards only
|
|
101
|
-
files of its own project (`CLAUDE_PROJECT_DIR`, else the checkout it runs in), so a session never blocks another repository.
|
|
102
|
-
`settings.hooks` adds the repository's own: `protected` (globs), `generated` (`path` and `command`), `recordings`, `migrations`.
|
|
103
|
-
- `hook pre-commit` runs gitleaks on the staged changes, then the quick gate, and refuses the commit if either fails
|
|
104
|
-
([docs/adr/0001-suwgate-hook-pre-commit.md](docs/adr/0001-suwgate-hook-pre-commit.md)).
|
|
105
|
-
- The `hooks` guard checks that these lines are there.
|
|
98
|
+
Every subcommand answers `--help`. The `dev` section and what each command does: [docs/dev.md](docs/dev.md).
|
|
106
99
|
|
|
107
|
-
##
|
|
100
|
+
## CI, releases and dependencies
|
|
108
101
|
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
102
|
+
<picture>
|
|
103
|
+
<source media="(prefers-color-scheme: dark)" srcset="docs/visual/board/img/readme/ci-dark.png">
|
|
104
|
+
<img alt="CI, releases and dependencies. Reusable workflows, pinned by commit: gate.yml (proof, gate, smoke, stamp; tools installed with checksums; consumer: a kit tested in a real app); release-npm.yml (changesets: the Version Packages pull request, then build and pack; npm trusted publishing); release-nuget.yml (full history, dotnet pack in Release, the artifact nupkg; NuGet trusted publishing). Self-hosted fallback: private repositories move to local runners when the month's Actions minutes run out: CI_RUNNER=suw-local, set and cleared by a timer. Renovate for every repository: once a week (new pull requests on Monday before 6:00 Warsaw time); two pull requests (minor and patch in one, majors in the other); merged on green (Renovate merges once the checks pass, a red one stays open); holds follow peers (TypeScript held to what typescript-eslint accepts, moved by pull request)." src="docs/visual/board/img/readme/ci-light.png" width="100%">
|
|
105
|
+
</picture>
|
|
113
106
|
|
|
114
|
-
|
|
115
|
-
|
|
107
|
+
A repository's whole `ci.yml` can be one job:
|
|
108
|
+
|
|
109
|
+
```yaml
|
|
110
|
+
jobs:
|
|
111
|
+
gate:
|
|
112
|
+
permissions:
|
|
113
|
+
contents: read
|
|
114
|
+
statuses: write
|
|
115
|
+
pull-requests: read
|
|
116
|
+
uses: Manomenu/suwgate/.github/workflows/gate.yml@<full commit sha>
|
|
117
|
+
with:
|
|
118
|
+
browser: chromium
|
|
116
119
|
```
|
|
117
120
|
|
|
118
|
-
|
|
119
|
-
|
|
121
|
+
The inputs, the tree stamp, the consumer test, trusted publishing and the Renovate preset: [docs/ci.md](docs/ci.md); the
|
|
122
|
+
self-hosted runners: [ci/self-hosted](ci/self-hosted/README.md).
|
|
123
|
+
|
|
124
|
+
## Which command, when
|
|
125
|
+
|
|
126
|
+
<picture>
|
|
127
|
+
<source media="(prefers-color-scheme: dark)" srcset="docs/visual/board/img/readme/choose-dark.png">
|
|
128
|
+
<img alt="Which command, when. While an agent works, after every turn: suwgate check --quick (the Stop hook). Before calling a change done: suwgate check (the full gate). 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%">
|
|
129
|
+
</picture>
|
|
120
130
|
|
|
121
|
-
|
|
131
|
+
<details>
|
|
132
|
+
<summary>suwgate --help</summary>
|
|
122
133
|
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
134
|
+
```text
|
|
135
|
+
usage: suwgate check [--quick] [--verbose] | suwgate step [<id> [--only] [--verbose] [-- <args>]] | suwgate hook <guard-edit|stop|pre-commit> | suwgate dev <command> | suwgate agents-shared | suwgate --help | --version
|
|
136
|
+
suwgate check every step of the repository's profiles (suwgate.yml) and the repository guards
|
|
137
|
+
suwgate check --quick the guards, and the quick steps only for what changed since master; has a time budget
|
|
138
|
+
(SUWGATE_QUICK_LIMIT seconds, default 20) because the Stop hook runs it after every turn
|
|
139
|
+
--verbose list every step with its time, also when all pass, and the whole output of a failed step
|
|
140
|
+
suwgate step the steps of this repository, with their titles and the tool that takes -- arguments
|
|
141
|
+
suwgate step <id> one step and the steps it needs (after, transitively), with the same report; not a gate
|
|
142
|
+
pass: the Stop hook does not count it. --only: that step alone. After --, arguments for the
|
|
143
|
+
step's tool: suwgate step e2e -- --headed -g notes (Playwright), suwgate step unit-tests --
|
|
144
|
+
-t "name" (Vitest), suwgate step dotnet-test -- --filter-method "*Notes*" (xUnit v3)
|
|
145
|
+
suwgate hook guard-edit Claude Code PreToolUse hook: refuses an agent's edit of the gate and of generated files
|
|
146
|
+
(ALLOW_GATE_EDIT=1 lifts the gate part for one session); only files of its own project
|
|
147
|
+
(CLAUDE_PROJECT_DIR, else the git checkout it runs in), with the lists of its profiles
|
|
148
|
+
suwgate hook stop Claude Code Stop hook: runs the quick gate unless nothing changed since it last passed
|
|
149
|
+
suwgate hook pre-commit git pre-commit hook: gitleaks on the staged changes, then the quick gate
|
|
150
|
+
suwgate dev <db|logs|smoke|server|tmux|sibling|checkout-env>
|
|
151
|
+
the local stack of the repository (the dev section of suwgate.yml), and the images of the
|
|
152
|
+
sibling repositories it runs, rebuilt from their checkouts when stale; suwgate dev --help
|
|
153
|
+
suwgate agents-shared writes AGENTS.shared.md, the rules every repository shares, as this suwgate ships it, into the
|
|
154
|
+
repository root (the agents-shared guard fails until the copy is current)
|
|
155
|
+
suwgate verdict <tests|guards|tsconfig|eslint> ...
|
|
156
|
+
what the steps call after their tool: did tests run, did the .NET guards run (evidence),
|
|
157
|
+
are the strict compiler options and the eslint rules in effect
|
|
158
|
+
Every step has a ceiling (SUWGATE_STEP_LIMIT seconds overrides them all). A step whose tool is missing is SKIP,
|
|
159
|
+
and a SKIP fails the gate when CI is set. Exit code: 0 green, 1 red, 2 a usage or suwgate.yml problem.
|
|
160
|
+
```
|
|
126
161
|
|
|
127
|
-
|
|
128
|
-
(Playwright), `suwgate step unit-tests -- -t "saves a note"` (Vitest), `suwgate step dotnet-test -- --filter-class "*Notes*"`
|
|
129
|
-
(xUnit v3 on Microsoft.Testing.Platform: `--filter-class`, `--filter-method`, `--filter-namespace`, `--filter-trait name=value`
|
|
130
|
-
and their `--filter-not-*`). The steps that take them: `unit-tests`, `stories`, `e2e`, `visual`, `consumer-app`, `dotnet-test`;
|
|
131
|
-
any other step refuses `--` and names these.
|
|
132
|
-
- A step named on the command line runs even when `steps.skip` leaves it out of the gate, so a repository that keeps `e2e`
|
|
133
|
-
out of `suwgate check` still runs it with `suwgate step e2e`; the steps it needs keep their skips.
|
|
134
|
-
- A step waits for some steps only for the order of the full gate (`e2e` for `dotnet-test` and `api-contract`, which rebuild the
|
|
135
|
-
server): `suwgate step e2e` does not run them.
|
|
136
|
-
- It is not a gate pass: the Stop hook does not count it, and the next turn still runs the quick gate.
|
|
137
|
-
- The evidence still applies where it makes sense for one step: a test step that ran 0 tests fails (a filter that matches
|
|
138
|
-
nothing is a mistake). With arguments, `dotnet-test` counts the tests of the whole run, not of each test project
|
|
139
|
-
(`--ignore-exit-code 8` for each test project, then xUnit's reports of all of them), so `--filter-class "*Notes*"` passes in a
|
|
140
|
-
repository with more than one test project and fails only when no test anywhere matched; `dotnet-test` asks the .NET guards' evidence only when it gets no arguments, because a filtered run
|
|
141
|
-
leaves guards out on purpose; `criteria-ran` reads the reports of the same run, so `suwgate step criteria-ran` runs every
|
|
142
|
-
test step first, and with `--only` it has no reports and fails.
|
|
162
|
+
</details>
|
|
143
163
|
|
|
144
|
-
|
|
164
|
+
## Configuration
|
|
145
165
|
|
|
146
|
-
|
|
166
|
+
<picture>
|
|
167
|
+
<source media="(prefers-color-scheme: dark)" srcset="docs/visual/board/img/readme/settings-dark.png">
|
|
168
|
+
<img alt="What suwgate.yml configures. profiles: what the repository is, the steps and guards follow (web, library, dotnet, database). directories: where each profile's project lives (web: Myapp.Web). steps.add, skip, configure: more steps; one left out with a reason; a step's ceiling, after, env, settings. quick.limitSeconds: the budget of the quick gate (20). exceptions: guard, target, reason; optional message and once; a stale one fails. guards.skip: a whole guard off, with a reason. settings.guard: a guard's own knobs, validated by its schema (docs-paths: ignore). env and unset: variables of every step; unset: [Models__*]. dev: name, portOffset, ports, compose, database, siblings (name: myapp). schema: checked as you type in VS Code, exit 2 when invalid, always on. Tool presets your configs extend: ESLint app() and strict(); Prettier, the shared options; knip(); Vitest unitTests() and storyTests(); Playwright e2eTests() and visualTests(); tsconfig strict, browser, node." src="docs/visual/board/img/readme/settings-light.png" width="100%">
|
|
169
|
+
</picture>
|
|
147
170
|
|
|
148
171
|
```yaml
|
|
172
|
+
profiles: [web, dotnet, database]
|
|
173
|
+
directories:
|
|
174
|
+
web: Myapp.Web
|
|
149
175
|
steps:
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
before: ["rm -rf .artifacts/e2e/versions"]
|
|
176
|
+
skip:
|
|
177
|
+
- step: knip
|
|
178
|
+
reason: the generated API client exports more than the app uses, and knip cannot tell
|
|
179
|
+
exceptions:
|
|
180
|
+
- guard: architecture/interfaces-have-two-implementations
|
|
181
|
+
target: Myapp.Server.Payments.IPaymentGateway
|
|
182
|
+
reason: the payment SDK takes an implementation of this interface; the second one is the SDK's test double
|
|
158
183
|
```
|
|
159
184
|
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
185
|
+
| Key | What it does |
|
|
186
|
+
| :----------------------- | :------------------------------------------------------------------------------------------------- |
|
|
187
|
+
| `profiles` | `web`, `library`, `dotnet`, `database`: the steps and guards the repository gets |
|
|
188
|
+
| `directories` | where a profile's project lives when it is not the root |
|
|
189
|
+
| `steps.add` | more steps: `name`, `run`, optionally `title`, `quick`, `after`, `limitSeconds` |
|
|
190
|
+
| `steps.skip` | a step of the profiles left out, with its `reason` |
|
|
191
|
+
| `steps.configure.<step>` | a profile's step: `limitSeconds`, more `after`, `env`, `unset`, `settings` (below) |
|
|
192
|
+
| `env`, `unset` | variables set for every step, and variables no step sees (`*` and `?` match) |
|
|
193
|
+
| `quick.limitSeconds` | the budget of `suwgate check --quick` (default 20; `SUWGATE_QUICK_LIMIT` on a machine) |
|
|
194
|
+
| `exceptions` | `guard`, `target`, `reason`, optionally `message` and `once: true`; one that matches nothing fails |
|
|
195
|
+
| `guards.skip` | a whole guard off, repository or .NET, with its `reason` |
|
|
196
|
+
| `settings.<guard>` | a guard's own settings, checked by its schema |
|
|
197
|
+
| `dev` | the local stack of `suwgate dev` ([docs/dev.md](docs/dev.md)) |
|
|
198
|
+
|
|
199
|
+
The schema ships in the package (`schema/suwgate.schema.json`); VS Code checks the file as you type with `yaml.schemas` in
|
|
200
|
+
`.vscode/settings.json`. The tool presets (`@maniumek/suwgate/eslint`, `/prettier`, `/knip`, `/vitest`, `/playwright`,
|
|
201
|
+
`/tsconfig/strict`, `/tsconfig/browser`, `/tsconfig/node`): [docs/usage.md](docs/usage.md#the-tool-presets).
|
|
202
|
+
|
|
203
|
+
<details>
|
|
204
|
+
<summary>The settings of the steps</summary>
|
|
167
205
|
|
|
168
206
|
| Step | Setting | What it does |
|
|
169
207
|
| :------------- | :------------------------------------ | :-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
@@ -172,160 +210,22 @@ The settings of the steps:
|
|
|
172
210
|
| `api-contract` | `contract: Myapp.Server/openapi.json` | where the contract is, relative to the dotnet directory (default `contract/openapi.json`); `api-version` compares the same file and reads its version from the `package.json` beside it |
|
|
173
211
|
| `api-version` | `breaking: never` | every breaking change fails; the default, `major`, lets one through with a new major version |
|
|
174
212
|
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
### The steps of the profiles
|
|
180
|
-
|
|
181
|
-
Each step looks where its profile lives (`directories`) and passes with nothing to check when the repository has nothing for it.
|
|
182
|
-
|
|
183
|
-
| Profile | Steps |
|
|
184
|
-
| :--------------- | :-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
185
|
-
| `web`, `library` | `pnpm-install` (only without `node_modules`), `typecheck` (every `tsconfig*.json` but `tsconfig.build.json`, with `tsc --showConfig`), `lint` (with `eslint --print-config`), `unit-tests` (the Vitest project `unit` when the config names one; 0 tests fail), `format`, `knip` |
|
|
186
|
-
| `web` | `e2e`: `playwright test -c e2e/playwright.config.ts`, after the build and the database (and, in the full gate, the .NET tests and the contract); with a `dev` section, first the checkout's variables (`suwgate dev checkout-env`) and a fresh, empty `E2E_DATABASE` (`dev db up`, then drop and create it), then `settings.before`; Playwright's `webServer` starts and stops the server and the web app |
|
|
187
|
-
| `library` | `stories` (with `.storybook/`), `publint`, `attw`, `consumer-app` (packs the library into a copy of `gate/consumer/app`, builds it, runs `gate/consumer/playwright.config.ts`; a real consumer's whole gate against the packed package runs in CI, [docs/ci.md](docs/ci.md)), `visual` (`visual/playwright.config.ts` in the Playwright image of the installed `@playwright/test`), `changeset` |
|
|
188
|
-
| `dotnet` | `dotnet-build`, `dotnet-format`, `dotnet-test` (fails on 0 tests and unless every .NET guard of the profiles ran; with a `dev` section, under the checkout's variables, so two worktrees never share a test database; `--quick`: only the test projects that use `Suwgate.Architecture` or `Suwgate.Database`); every .NET step leaves no idle MSBuild worker or build server behind |
|
|
189
|
-
| `dotnet`, `web` | with `contract/openapi.json` (or `settings.contract`): `api-contract` (the contract and `src/api/openapi.d.ts` of the web app regenerated from the server's project, the one that references `Microsoft.Extensions.ApiDescription.Server`), `api-version` (oasdiff against master; a break needs a new major version in the `package.json` beside the contract, or fails with `breaking: never`), `contract-pins` (every test tagged `contract <name>@<version>` names a version) |
|
|
190
|
-
| `database` | `database-up`: `docker compose --profile db up -d --wait db`, or `dev.database.up`; not in CI, where the workflow starts it |
|
|
191
|
-
| every repository | `compose` (with a compose file), `criteria`, `shellcheck`, `gitleaks` |
|
|
192
|
-
|
|
193
|
-
`criteria` runs `vdoc.py criteria` of the suwagent plugin, pinned by commit and SHA-256: every acceptance criterion of the specs in
|
|
194
|
-
`docs/visual/spec/` is named by a guardrail. The kinds of guardrail come with the profiles; `criteria.json` in the repository root
|
|
195
|
-
adds the repository's own (`{ "kinds": [{ "kind", "paths", "how" }] }`, optionally `specs` and `prose`), and the guard
|
|
196
|
-
`criteria-kinds` asks for a row of each in a table of `README.md` or `docs/development.md`. The default kinds:
|
|
197
|
-
|
|
198
|
-
| Kind | Profile | Where (in the profile's directory) | How the id is written |
|
|
199
|
-
| :------------------------------ | :--------------- | :---------------------------------- | :----------------------------------------- |
|
|
200
|
-
| `test (xunit)` | `dotnet` | every project that references xunit | `[Trait("criterion", "<id>")]` on the test |
|
|
201
|
-
| `lint (.NET analyzer)` | `dotnet` | `.editorconfig` | `# <id>` on its own line above the rule |
|
|
202
|
-
| `banned API` | `dotnet` | `BannedSymbols.txt` | in the message: `P:…;<id> use …` |
|
|
203
|
-
| `build rule` | `dotnet` | `Directory.Build.props` | `<!-- <id> -->` above the property |
|
|
204
|
-
| `e2e test (playwright)` | `web` | `src/**/*.e2e.ts` | in the title: `test("<id>: …")` |
|
|
205
|
-
| `web test (vitest)` | `web` | `src/**/*.test.ts(x)` | in the title: `it("<id>: …")` |
|
|
206
|
-
| `unit test (vitest)` | `library` | `src/**/*.test.ts(x)` | in the title: `it("<id>: …")` |
|
|
207
|
-
| `story test (vitest, Chromium)` | `library` | `src/**/*.stories.tsx` | in the story's name: `name: "<id>: …"` |
|
|
208
|
-
| `visual test (playwright)` | `library` | `visual/*.visual.ts` | in the title: `test("<id>: …")` |
|
|
209
|
-
| `consumer test (playwright)` | `library` | `gate/consumer/*.spec.ts` | in the title: `test("<id>: …")` |
|
|
210
|
-
| `lint (eslint)` | `web`, `library` | `eslint.config.js` | `// <id>` on the line above the rule |
|
|
211
|
-
| `type check (tsc)` | `web`, `library` | `tsconfig*.json` | `// <id>` on the line above the option |
|
|
212
|
-
|
|
213
|
-
### The tool presets
|
|
214
|
-
|
|
215
|
-
The configs of the tools the steps run extend suwgate's, so an application keeps only its own paths:
|
|
216
|
-
|
|
217
|
-
| Tool | The application's file |
|
|
218
|
-
| :--------- | :------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
219
|
-
| Prettier | `.prettierrc.json`: `"@maniumek/suwgate/prettier"` (with a plugin: spread it in `prettier.config.js`) |
|
|
220
|
-
| TypeScript | `{ "extends": "@maniumek/suwgate/tsconfig/browser", "include": ["src"] }`; `tsconfig/node` for the configs, scripts and tests run by Node; `tsconfig/strict` for the options alone |
|
|
221
|
-
| knip | `knip.config.ts`: `export { default } from "@maniumek/suwgate/knip"`, or `knip({ entry: [...] })`; it ignores the tools the steps run (Prettier among them) and the issues of the generated API types, and reads the steps' Playwright configs |
|
|
222
|
-
| Vitest | `unitTests({ environment: "jsdom" })` and `storyTests({ plugin, provider })` from `@maniumek/suwgate/vitest`: the projects `unit` and `stories` the steps run |
|
|
223
|
-
| Playwright | `defineConfig(e2eTests({ use: { baseURL }, webServer, reporter }))` or `defineConfig(visualTests())` from `@maniumek/suwgate/playwright`; `e2eTests` keeps the app's `reporter` (an HTML report in CI) and adds the JSON report the `e2e` step reads |
|
|
224
|
-
| ESLint | `app({ root, features, shared, sharedImports, storage })` from `@maniumek/suwgate/eslint`: a feature imports itself and the shared folders, a shared folder only itself and what `sharedImports` allows it (`[["design", "api"]]`: design may import api); the import resolver reads the first of `projects`, the one of `src/` (or a root tsconfig with references) |
|
|
225
|
-
|
|
226
|
-
### What the config files must say
|
|
227
|
-
|
|
228
|
-
`required-files` asks for the files; `config-contents` checks that they say what the gate relies on, each where its profile lives
|
|
229
|
-
(`directories`), and only when the profile is on and the file is there:
|
|
230
|
-
|
|
231
|
-
| File | Profile | Must contain |
|
|
232
|
-
| :---------------------------------------------------------------------------- | :--------------- | :----------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
233
|
-
| `global.json` | `dotnet` | an exact `sdk.version` (`10.0.100`), a `sdk.rollForward` other than `major` and `latestMajor`, `test.runner` `Microsoft.Testing.Platform` |
|
|
234
|
-
| `.editorconfig` (the root's, then the dotnet directory's) | `dotnet` | `max_line_length = 140` for `*.cs`, `*.csproj`, `*.props` and `*.targets`: CSharpier's width; a `.csharpierrc*` anywhere must go, it would win over it |
|
|
235
|
-
| `Directory.Packages.props` | `dotnet` | `<ManagePackageVersionsCentrally>true</ManagePackageVersionsCentrally>` |
|
|
236
|
-
| `tsconfig*.json` (not `tsconfig.build.json`, which the typecheck step skips) | `web`, `library` | `extends` `@maniumek/suwgate/tsconfig/...`, directly or through another tsconfig of the repository |
|
|
237
|
-
| `eslint.config.js`, `knip.config.ts`, the Vitest config | `web`, `library` | an import of `@maniumek/suwgate/eslint`, `/knip`, `/vitest` |
|
|
238
|
-
| `.prettierrc.json` or `prettier.config.js` | `web`, `library` | exactly `"@maniumek/suwgate/prettier"`, or an import of it |
|
|
239
|
-
| `e2e/playwright.config.ts`, `visual/playwright.config.ts` | `web`, `library` | an import of `@maniumek/suwgate/playwright` |
|
|
240
|
-
| `package.json` that installs suwgate (the root or a web or library directory) | every | `@maniumek/suwgate` at an exact version: no `^`, `~`, range or tag |
|
|
241
|
-
| `pnpm-workspace.yaml` (web, library, and where suwgate is installed) | every | no `minimumReleaseAge` of 0 (pnpm waits 1440 minutes by default); `minimumReleaseAgeExclude` is fine |
|
|
242
|
-
| `.vscode/settings.json` | every | `yaml.schemas` mapping `./node_modules/@maniumek/suwgate/schema/suwgate.schema.json` (or under a profile's directory) to `suwgate.yml` |
|
|
243
|
-
| `.github/workflows/*.yml` | every | a job with `uses: Manomenu/suwgate/.github/workflows/gate.yml@<full 40-character commit sha>` |
|
|
244
|
-
|
|
245
|
-
`required-files` also asks the `dotnet` profile for exactly one `*.slnx` in its directory, and for `Directory.Build.rsp`
|
|
246
|
-
(`-nodeReuse:false`, so no idle MSBuild worker stays behind).
|
|
247
|
-
|
|
248
|
-
### The .NET guards
|
|
249
|
-
|
|
250
|
-
One xUnit test in the gate's test project runs every guard of the `dotnet` and `database` profiles:
|
|
251
|
-
|
|
252
|
-
```csharp
|
|
253
|
-
public sealed class GuardTests
|
|
254
|
-
{
|
|
255
|
-
[Fact]
|
|
256
|
-
public void Every_guard_of_suwgate_passes() =>
|
|
257
|
-
SuwgateGuards.VerifyAll(
|
|
258
|
-
new GuardInputs { Production = [typeof(ServerApp).Assembly], Tests = [typeof(GuardTests).Assembly], Server = typeof(ServerApp) },
|
|
259
|
-
new DatabaseProfile()
|
|
260
|
-
);
|
|
261
|
-
}
|
|
262
|
-
```
|
|
213
|
+
</details>
|
|
214
|
+
|
|
215
|
+
## Documentation
|
|
263
216
|
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
### The tests and the docs for people
|
|
269
|
-
|
|
270
|
-
- `test-timing` (`dotnet`, `web`, `library`): no test measures, sleeps on, waits for or limits real time, because a test that
|
|
271
|
-
waits on the clock flakes on a slow machine and a speed promise, in milliseconds or in steps counted instead of them, does not
|
|
272
|
-
belong on the gate. It reads the `.cs` files of the `*.Tests` and `*.Testing` projects (`Stopwatch`, `GetTimestamp`,
|
|
273
|
-
`GetElapsedTime`, `TickCount`, `DateTime.Now`, `UtcNow` and `Today`, `TimeProvider.System`, `Thread.Sleep`, `Task.Delay`, `Timeout =` in an attribute,
|
|
274
|
-
a `TimeSpan.From…` or `new TimeSpan(…)` handed to a constructor that gets no `TimeProvider`),
|
|
275
|
-
and the `*.test`, `*.spec`, `*.e2e`, `*.visual`
|
|
276
|
-
and `*.stories` files and the helpers of an `e2e/` folder (`performance.now`, `Date.now()` in a subtraction, `setTimeout`,
|
|
277
|
-
`sleep(<n>)`, `waitForTimeout`, `interruptAfterTimeLimit`, and `timeout: <n>` in a Vitest file, such as the options of `it`, `test`
|
|
278
|
-
or `describe`). It lets through a call that is
|
|
279
|
-
handed a `TimeProvider` (a `FakeTimeProvider` in the tests; `TimeProvider.System` is the real clock and fails), `Task.Delay` inside a `while`, `for`, `foreach` or `do` loop (a poll)
|
|
280
|
-
or with `Timeout.Infinite`, the timers and the clock of a file that calls `vi.useFakeTimers()`, Playwright's auto-waiting
|
|
281
|
-
`expect` with its own `timeout`, a ceiling against a hang (`CancelAfter`, `new CancellationTokenSource(<delay>)`,
|
|
282
|
-
`WaitAsync(<TimeSpan>)`, an `HttpClient`'s `Timeout`, and the `timeout` option of a Vitest wait for an event: `vi.waitFor`, `vi.waitUntil`, `expect.poll`,
|
|
283
|
-
Testing Library's `waitFor`, `findBy*` and `findAllBy*`; the test waits for the event and fails fast, with its name, if it never
|
|
284
|
-
comes: a ceiling, not a speed promise), and the tools' configs
|
|
285
|
-
(`playwright.config.ts`), whose ceilings stop a hang.
|
|
286
|
-
- `human-docs` (every profile): `README.md`, `docs/development.md` and the README of a profile's directory never tell a person to
|
|
287
|
-
run a script meant for agents, one in `scripts/.internal/` or `<name>.Gate/scripts/`; people run `just` recipes. A command is a
|
|
288
|
-
line of a shell code block or an inline code span with a space in it, and a span in parentheses or right after "runs", "calls",
|
|
289
|
-
"starts", "through" or "via" explains what runs the script, so it passes. The message names the recipe that calls the script, or
|
|
290
|
-
asks for one.
|
|
291
|
-
|
|
292
|
-
### What the gate proves ran
|
|
293
|
-
|
|
294
|
-
A check counts only when the tool shows it ran, not because a file or a line of text is there:
|
|
295
|
-
|
|
296
|
-
- The .NET guards: `dotnet-test` points `SUWGATE_EVIDENCE` at a fresh folder of this gate run, and every guard that runs (through
|
|
297
|
-
`VerifyAll` or `Guards.Verify`) writes its id and outcome there. The step fails unless every guard of the profiles that
|
|
298
|
-
`guards.skip` does not name is in it, so a deleted guard test, a `[Fact(Skip = …)]` or a filtered-out one fails the gate.
|
|
299
|
-
- Zero tests fail: `unit-tests`, `stories` (Vitest, its JSON report), `e2e` (Playwright, its JSON report) and `dotnet-test`
|
|
300
|
-
(`--zero-tests-policy strict` of Microsoft.Testing.Platform for each test project, and xUnit's XML reports for the whole run)
|
|
301
|
-
fail when the tool ran no test, also when every test was skipped. A repository with truly no tests for a profile skips the step in `suwgate.yml` with a reason.
|
|
302
|
-
- `typecheck` reads `tsc --showConfig` of every tsconfig it checks: the strict options of the suwgate preset must be in effect, so
|
|
303
|
-
an override that turns one off fails, naming the option.
|
|
304
|
-
- `lint` reads `eslint --print-config` of a source file of `src/`: `suwgate/no-comments` and `boundaries/dependencies` must be
|
|
305
|
-
errors there.
|
|
306
|
-
- `criteria-ran`, after the test steps: every acceptance criterion of a living spec (`docs/visual/spec/`) that a test names
|
|
307
|
-
(`[Trait("criterion", "<id>")]`, a title or story name `"<id>: …"`) must have a test naming it that ran and passed in this run,
|
|
308
|
-
by the reports of xUnit, Vitest and Playwright. A criterion named only by tests of a step `steps.skip` names is not checked; one
|
|
309
|
-
named only by tests that `excludeTraits` of `dotnet-test` keeps out of the gate fails with the fix: a gate test with a stand-in.
|
|
310
|
-
- The kits are wired, not only installed: `suwbackkit-wiring` (dotnet) asks a web server that references `Suwbackkit.Server` to
|
|
311
|
-
call `AddServerDefaults` and `MapServerDefaults`; `suwfrontkit-wiring` (web, library) asks an app whose `package.json` depends
|
|
312
|
-
on `@maniumek/suwfrontkit` to load `@maniumek/suwfrontkit/theme.css` from the main module of its `index.html`, or from a
|
|
313
|
-
stylesheet that module imports. Both read the sources: the evidence (a run hitting `/health`, a built stylesheet with the
|
|
314
|
-
kit's tokens) needs a running server or a production build, which the gate does not have in every repository.
|
|
315
|
-
- The reports live in a temporary folder of the run (`SUWGATE_RUN`), deleted when `suwgate check` ends. `dotnet-test` asks xUnit
|
|
316
|
-
for its XML report (`--report-xunit-xml`), so every .NET test project tests with xUnit v3. Each test project writes its own
|
|
317
|
-
report, `<project>.<target framework>.xunit.xml` (`--report-xunit-xml-filename` through `TestingPlatformCommandLineArguments`,
|
|
318
|
-
from a targets file the step passes as `-p:CustomAfterMicrosoftCommonTargets`): xUnit's own name is the moment the project
|
|
319
|
-
started, which two projects that start together share, and one report would overwrite the other.
|
|
320
|
-
|
|
321
|
-
`suwgate dev db|logs|smoke|server|tmux|checkout-env` runs the local stack of the template (database, logs, smoke test, server, tmux
|
|
322
|
-
session, worktree databases) from a `dev` section of `suwgate.yml`: [docs/dev.md](docs/dev.md).
|
|
217
|
+
- [docs/usage.md](docs/usage.md): the gate, `suwgate.yml`, the steps and guards, the hooks, the shared rules, the presets, the .NET guards
|
|
218
|
+
- [docs/dev.md](docs/dev.md): `suwgate dev` and the `dev` section
|
|
219
|
+
- [docs/ci.md](docs/ci.md): the reusable workflows, the tree stamp, releases and Renovate
|
|
220
|
+
- [CHANGELOG.md](CHANGELOG.md): what each version changed, and what a repository must change with it
|
|
323
221
|
|
|
324
222
|
## Work on suwgate
|
|
325
223
|
|
|
326
224
|
[AGENTS.md](AGENTS.md) holds the rules, [docs/development.md](docs/development.md) the setup, [docs/architecture.md](docs/architecture.md)
|
|
327
|
-
the contract of a guard and a step, and [docs/inventory.md](docs/inventory.md) what is still to be moved here from the template and
|
|
225
|
+
the contract of a guard and a step, and [docs/inventory.md](docs/inventory.md) what is still to be moved here from the template and
|
|
226
|
+
the kits. The pictures of this README are panels of `docs/visual/board/readme.html`: edit the board, then redraw them with
|
|
227
|
+
`vdoc.py render docs/visual/board/readme.html` of the suwagent plugin.
|
|
328
228
|
|
|
329
|
-
##
|
|
229
|
+
## License
|
|
330
230
|
|
|
331
231
|
MIT, see [LICENSE](LICENSE).
|
|
@@ -1,5 +1,12 @@
|
|
|
1
1
|
import { appsettingsBound } from "./appsettingsBound.js";
|
|
2
2
|
import { bannedNugetPackages } from "./bannedNugetPackages.js";
|
|
3
|
+
import { openApiVersions } from "./openApiVersions.js";
|
|
3
4
|
import { suwbackkitWiring } from "./suwbackkitWiring.js";
|
|
4
5
|
import { unusedNugetVersions } from "./unusedNugetVersions.js";
|
|
5
|
-
export const dotnetGuards = [
|
|
6
|
+
export const dotnetGuards = [
|
|
7
|
+
bannedNugetPackages,
|
|
8
|
+
unusedNugetVersions,
|
|
9
|
+
appsettingsBound,
|
|
10
|
+
suwbackkitWiring,
|
|
11
|
+
openApiVersions,
|
|
12
|
+
];
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { centralPackagesFile } from "./msbuild.js";
|
|
2
|
+
const TOOL = "Microsoft.Extensions.ApiDescription.Server";
|
|
3
|
+
const LIBRARY = "Microsoft.AspNetCore.OpenApi";
|
|
4
|
+
export function centralVersion(text, name) {
|
|
5
|
+
for (const match of text.matchAll(/<PackageVersion\b[^>]*>/g)) {
|
|
6
|
+
const element = match[0];
|
|
7
|
+
if (!new RegExp(`\\bInclude\\s*=\\s*"${name.replaceAll(".", "\\.")}"`).test(element))
|
|
8
|
+
continue;
|
|
9
|
+
return /\bVersion\s*=\s*"([^"]+)"/.exec(element)?.[1];
|
|
10
|
+
}
|
|
11
|
+
return undefined;
|
|
12
|
+
}
|
|
13
|
+
export const openApiVersions = {
|
|
14
|
+
id: "openapi-versions",
|
|
15
|
+
description: `${TOOL}, which writes the OpenAPI contract at build, is pinned in Directory.Packages.props to the same version as ${LIBRARY}, whose OpenAPI library it loads`,
|
|
16
|
+
profiles: ["dotnet"],
|
|
17
|
+
check(context) {
|
|
18
|
+
const file = centralPackagesFile(context);
|
|
19
|
+
if (!context.files.includes(file))
|
|
20
|
+
return [];
|
|
21
|
+
const text = context.read(file);
|
|
22
|
+
const tool = centralVersion(text, TOOL);
|
|
23
|
+
if (tool === undefined)
|
|
24
|
+
return [];
|
|
25
|
+
const library = centralVersion(text, LIBRARY);
|
|
26
|
+
if (library === tool)
|
|
27
|
+
return [];
|
|
28
|
+
const pin = `<PackageVersion Include="${LIBRARY}" Version="${tool}" />`;
|
|
29
|
+
return [
|
|
30
|
+
{
|
|
31
|
+
target: file,
|
|
32
|
+
message: library === undefined
|
|
33
|
+
? `${TOOL} ${tool} loads the server's ${LIBRARY}, which only comes in through a package (Suwbackkit.Server) and can be another release, so the build of the contract fails with a Microsoft.OpenApi version mismatch: pin it beside the tool, ${pin} (transitive pinning makes it win), so an update moves both`
|
|
34
|
+
: `${TOOL} is ${tool} but ${LIBRARY} is ${library}: the tool loads the server's OpenAPI library and fails on a Microsoft.OpenApi version mismatch, so give both the same version`,
|
|
35
|
+
},
|
|
36
|
+
];
|
|
37
|
+
},
|
|
38
|
+
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@maniumek/suwgate",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.11.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",
|