Files
ianitor/docs/release.md
T

137 lines
9.9 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# Releases: notes and screenshots on the Gitea release
Ianitor is server-only: what runs is built by Nix on the server and switched in by the `deploy` pipeline
(`.fabrica/artifex/deploy.yaml`, `fabrica-deploy@ianitor`). A release adds what a deploy does not leave behind: a
Gitea release for the `vX.Y.Z` tag with the release notes and screenshots of the web UI, under a `SHA256SUMS`
signed by `domi-release`. It ships no binary; the deploy stays the deploy.
The release kit is Fabrica's (Fabrica `docs/12_release_kit.md`, core `docs/FORMATS.md`, "Fabrica: release notes"
and "Fabrica: the Aula page"). Ianitor uses it as it is, with one difference: Fabrica's `fabrica aula shots`
drives a built Windows WebView2 exe, which Ianitor does not have, so a repo script takes the same files from the
web UI in a headless browser.
## The pipeline: `.fabrica/artifex/release.yaml`
`on: tag "v*"` and `manual: true`, on the Windows runner (the Fabrica app on Mark's PC: `fabrica`, node and pnpm
are on every step's PATH).
| Step | Does | Produces |
| :-- | :-- | :-- |
| `version` | `node scripts/check-version.mjs <version>`: the tag's version must be the workspace `Cargo.toml`'s and both `package.json`s' | |
| `install` | `pnpm install --frozen-lockfile` | |
| `check`, `test` | `svelte-check` and the vitest click smoke test of the web UI the shots show | |
| `notes` | `fabrica notes` (the range since the previous `v*` tag; the first release covers the whole history) | `target/notes/release-notes.md`, `release-notes.json` |
| `shots` | `node apps/web/scripts/shots.mjs` (below) | `target/aula/aula-<name>.png`, `aula.json` |
| `pin` | `node scripts/release-pin.mjs <version> <tag> <commit>`: the Nix pin committed before the tag (`.fabrica/nix/pin.json`, by `scripts/nix-pin.sh` on Linux) with the tag and commit; refuses a pin of another version | `target/nix/ianitor-nix.json` |
| `approve` | the run's Custos approval, before anything is published | |
| `publish` | the Gitea release of the tag: the notes, the shots, `aula.json` and `ianitor-nix.json`; `sums: domi-release` adds `SHA256SUMS` and `SHA256SUMS.minisig`; `release-notes.md` becomes the release's text | |
**The Nix build is pinned, not shipped.** The Windows runner has no Nix and Fabrica's `SHA256SUMS` covers only the
files of one `publish` step, so the release cannot carry a build made by the NixOS runner. It carries the build's
NAR hashes instead (`ianitor-nix.json`, under the signed `SHA256SUMS`), and the build is reproducible: anyone
rebuilds the tag and compares ([verify.md](verify.md)); the `verify-nix` pipeline does exactly that on every
`v*` tag on the NixOS runner.
The Rust tests are not in it: the edge, diff and ACME tests are Linux-only (ROADMAP §8.3) and the release builds
nothing. They run in WSL2 and in the Nix build.
**No landing page.** `fabrica aula page` and `aula-page.json` are left out while `.fabrica/app.yaml` has no
`aula: true`. Turning Aula on later is two lines: `aula: true` in `app.yaml` and a `page` step (`fabrica aula
page`, after `notes` and `shots`) whose `aula-page.json` is published; a brief (`.fabrica/aula/brief.md`) is
optional, its caption names are the shot names below.
**app.yaml stays as it is.** Its parts are `desktop` (a release pipeline started by the tag the card's Deploy
bumps and pushes, with installers) and `server` (a deploy pipeline). Ianitor has no installer and no version bump to
make, so it keeps its one `server` part; the release is started by its tag.
## Release notes
`fabrica notes` writes them from the first-parent commit subjects, the Pensum tickets done (Ianitor has none) and
`.fabrica/notes/<version>.md`, the highlights a person writes. The merges of PR 3 to 5 predate the
`[repo] Merge: <branch> (<title>, PR #n)` form and come out as bare "PR #n" lines; history is not rewritten, so
`.fabrica/notes/0.1.0.md` says in a few sentences what 0.1.0 is, and goes first.
## Screenshots: `apps/web/scripts/shots.mjs`
`node apps/web/scripts/shots.mjs [--out <dir>]` (default `target/aula` at the repo root):
1. empties the output folder of `aula-*.png` and `aula.json`;
2. builds the web UI (Vite, production) into a fresh temporary folder;
3. serves it on `127.0.0.1` (a free port), with `/api/v1` answered by the demo control plane
(`apps/web/tests/demo.ts`), and every other path falling back to `index.html` as in production;
4. starts headless Microsoft Edge (or Chrome; `IANITOR_SHOTS_BROWSER` names another) with a fresh profile in the
temporary folder, its DevTools port on loopback only, and a cleared environment (the system variables and the
temporary folder, nothing of the runner's: no `GITEA_TOKEN`, no hub token); a browser whose DevTools do not
answer within 20 s is stopped and started again, at most three times;
5. for each shot: sets the viewport (1440 × 900, scale 1), loads its page, clicks its selectors, waits for its
selector, the fonts, two frames and 400 ms, and saves `aula-<name>.png`; a wait that runs out (20 s) saves
`aula-<name>-failed.png` and fails;
6. writes `aula.json` in the format of core `docs/FORMATS.md` ("Fabrica: the Aula page"): `{"v":1,"shots":[…]}`,
each shot's `name`, `title`, `file`, `width` and `height` read from the PNG, and `sha256`;
7. on every way out kills the browser's process tree and, on Windows, any process left with a profile in the
temporary folder (Edge can start its browser again as a new process, outside the tree), stops the server, and
removes the temporary folder.
| Name | Page | Shows |
| :-- | :-- | :-- |
| `hosts` | `/` | the host list: health, chips, where each sends traffic, the last change |
| `host` | `/hosts/wiki.home.test/edit` | editing a host: upstreams, certificate, sign-in, health check |
| `engine` | `/`, then the engine chip | Pingora serving and the Caddy fallback ready, with its differences |
| `history` | `/history/<change>` | the history with a version picked and what restoring it changes |
| `certificates` | `/certificates` | the Domi intermediate and the device certificates |
**The demo control plane** (`apps/web/tests/demo.ts`) answers like control (docs/api.md), built on the click smoke
test's stand-in (`apps/web/tests/mockApi.ts`: the same host and apply shapes and every call the demo does not
replace). Its data is invented: hostnames under `.test`, upstream addresses in the documentation ranges
(192.0.2.0/24, 198.51.100.0/24, 203.0.113.0/24), people *ada* and *felix*, made-up commits, match codes and
fingerprints. A vitest test (`apps/web/tests/demo.test.ts`) asks every page's calls and fails on any other
hostname or address, so a real name cannot slip in through a later fixture.
## Risks
| Risk | Answer |
| :-- | :-- |
| A screenshot shows Mark's network | The UI talks only to the demo control plane; the demo data test refuses names outside `.test` and addresses outside the documentation ranges; the PNGs are looked at in the review. |
| The browser reaches out | It loads only `127.0.0.1`; the UI's own CSP allows no outside requests; background networking, sync and component updates are off; its profile is thrown away. |
| A secret reaches the browser | Its environment is cleared to the system variables. The demo serves no token, key or certificate. |
| A forged screenshot or note | They are release assets under `SHA256SUMS`, signed by `domi-release` through Custos; the Gitea text is not signed, the asset is. |
| The browser outlives the run | Its process tree is killed on every way out (`taskkill /T` on Windows). |
| A shot of a half-drawn screen | Each `wait` selector exists only once the screen's data is there; fonts and two frames are awaited. |
## Gaps
- Windows and Edge or Chrome only as tested; the script is plain Node and DevTools, so Linux with Chromium should
work, untested.
- One size (desktop); no phone layout shot.
- The release does not run the Rust tests (see above); the `layers` pipeline does, on the NixOS runner.
- No `[repo] Release:` bump: the version in `Cargo.toml` and the `package.json`s is changed by hand before tagging.
## GitHub mirror (later)
Decided by Mark: later. The repository on Gitea stays the source; GitHub gets a read-only push mirror for
discovery (ROADMAP §1.9). When it is time:
1. On GitHub, create an empty public repository `Ianitor` (no README, licence or .gitignore, so the first push is a
plain mirror), description "Ianitor Domi: a reverse proxy on Pingora with a small Domi CA" and the Gitea URL as
its website.
2. Create a **fine-grained personal access token** limited to that one repository, permission
*Contents: Read and write* (nothing else), with an expiry; keep it in Custos.
3. In Gitea, the repository's *Settings → Repository → Mirror settings → Add push mirror*: URL
`https://github.com/<owner>/Ianitor.git`, user name the GitHub owner, password the token, *Sync when commits
are pushed* on, an interval (e.g. 8h) as a backstop. *Synchronize now*, then check that branches and `v*` tags
arrived.
4. On GitHub: issues, wiki and projects off (or a pinned note pointing to Gitea), so nothing is filed where nobody
looks; releases stay on Gitea, where the signed `SHA256SUMS` is.
5. When the token expires, Gitea's mirror shows the error; renew it in Custos and in the mirror settings.
## Handover: releasing 0.1.0
0. Once phase 4 is merged (the `pin` step exists), before every tag: run `scripts/nix-pin.sh` on Linux at the commit to tag and commit `.fabrica/nix/pin.json`
([verify.md](verify.md)); the `pin` step refuses a missing or stale pin.
1. On main: `git tag v0.1.0 && git push origin v0.1.0`.
2. Start the `release` pipeline at `v0.1.0` from Fabrica (no Gitea webhook to the hub yet: the hub's
`POST /api/runs`, ref `v0.1.0`). Approve on the Custos card, then sign `SHA256SUMS` on Custos (`domi-release`).
3. The Gitea release `v0.1.0` has the notes as its text and `release-notes.md`, `release-notes.json`, five
`aula-*.png`, `aula.json`, `SHA256SUMS` and `SHA256SUMS.minisig`.
4. Deploy as before: Fabrica's *Apps* → Ianitor → *Deploy*, then deploy/test-access.sh from a LAN machine.