oficina / docs Public

Clone
git clone https://amadan.net/oficina/docs

Plain git — no account needed to clone.

Download

Download this file

1# CI
2
3`ci.d/10-gate` is the only CI this repo has. It runs on every push to the
4amadan remote, and it is the same script you can run locally — one
5definition rather than two that drift.
6
7It requires a Rust toolchain with the `wasm32-unknown-unknown` target and
8the `rustfmt` component, Go with `CGO_ENABLED=0`, and Node with `npm` on
9`PATH`. The gate sources `~/.cargo/env` itself and checks every tool up
10front, so a missing dependency fails on the first line with its own name
11rather than fifty lines in as `cargo: command not found`.
12
13The runner clones a fresh worktree per branch, so `fixtures/node_modules`
14never carries over — the gate runs `npm ci` itself, against
15`fixtures/package-lock.json`, so the installed `yjs` is always exactly
1613.6.27 rather than whatever a bare `npm install` would resolve.
17
18**Known tradeoff:** that `npm ci` needs the npm registry reachable at run
19time. It is the right fix for the fresh-worktree-per-branch problem above,
20and the lockfile is committed so the *version* resolved never drifts, but
21it does mean the gate is not fully offline-capable the way the Rust and Go
22steps are once their caches are warm. If the registry is ever unreachable
23from the runner, that is the failure this line produces — not a bug in
24the gate itself.
25
26## The runner
27
28Jobs are claimed by an `amadan runner` on the machine that has one. Two
29things about it were wrong when this repo was created, and both fail
30silently rather than loudly:
31
32- **The runner must be told to serve this repo.** `amadan runner -repo …`
33 is an allowlist. A repo nobody listed gets `amadan ci status` exit 3
34 forever — "no status recorded", which reads like the gate has not run yet
35 rather than like nothing will ever run it.
36- **The runner's `PATH` is the systemd unit's, not your shell's.**
37 `~/.cargo/bin` is not on it by default.
38
39Both were fixed on `DOCS-T1` on 2026-08-30 by editing
40`~/.config/systemd/user/amadan-runner.service` and restarting. A restart
41abandons any job already running, so check it is idle first.
42
43The gate fails if `internal/core/testdata/docs_core.wasm` is stale, because
44`go:embed` will otherwise embed a stale module and the tests will pass
45against it. It checks this two ways:
46
47- **On every host**, `scripts/wasm-stamp.sh check docs_core` recomputes a
48 SHA-256 over the files that decide the module's bytes and compares it with
49 `internal/core/testdata/docs_core.wasm.stamp`. The script lists those files:
50 the toolchain pin, `.cargo/config.toml`, `scripts/build-wasm.sh`, the
51 crate's manifest, lockfile and `src/`, and the vendored crates it patches
52 in. It also checks the committed wasm is the build the stamp was written
53 for. A failure reads "wasm is stale: inputs changed since it was built;
54 run scripts/build-wasm.sh".
55- **On Linux amd64** it also rebuilds the module and compares bytes.
56
57To refresh the module, run `./scripts/build-wasm.sh`, which writes the stamp,
58then copy `core/target/wasm32-unknown-unknown/release/docs_core.wasm` to
59`internal/core/testdata/` and commit the wasm and its `.stamp` together.
60
61It also fails if regenerating the Yjs fixtures changes them. Fixtures are
62the wire contract, not an output: a deliberate rule change regenerates them
63in the same commit as the change.
64
65## The app, not just the core
66
67`go vet ./...` and `go test ./...` already cover `cmd/docs` and
68`internal/docs` — the rastrillo app built on top of `internal/core` — but
69neither one proves the app actually links into a runnable binary. The gate
70also runs `CGO_ENABLED=0 go build ./...` for that.
71
72There used to be a further step here: a separate `-tags release` build,
73run with `-dev-auth` on its command line, asserting it refused to start —
74proving a release binary had no code path that could turn a
75development-only stand-in identity on. That identity
76(`internal/docs/devauth.go`) had zero readers once rastrillo/auth's
77`RequireSession` started guarding every document route unconditionally
78(a fix round on Task 1, once real per-person sign-in existed), so it was
79deleted rather than kept as dead code — and the `release` build tag it
80was the only user of went with it. There is no release/non-release
81distinction left for this gate to hold apart; `go test` covers the
82fail-closed properties that matter now
83(`TestNewRefusesMissingInstanceKeyOutsideDevelopment`,
84`TestNewRefusesMissingMailOutsideDevelopment`,
85`TestSignInRequiredForEverything` — all `internal/docs/auth_test.go`).
86`scripts/run-dev.sh` builds and runs the ordinary binary with `-env
87development`, a fixed port, and a scratch database — one command to see
88the app in a browser, signed in for real via a magic link logged to the
89terminal instead of mailed.
90
91The embedded WASM is built on Linux amd64 using fixed `/work`,
92`/usr/local/cargo` and `/usr/local/rustup` paths. Rust/Cargo's crate identities
93otherwise change code ordering across hosts, even with remapped source paths.
94Linux amd64 uses unprivileged bubblewrap when available; Macs use the pinned
95Rust Docker image, so install Docker on development Macs. Docker caches and
96writable targets are separate from source.
97
98Cargo also hashes the host architecture into crate identities, so no build on
99Linux arm64 (hosted CI) reproduces the committed amd64 bytes; it is about a
100kilobyte larger. There `scripts/build-wasm.sh` builds natively with the
101host's toolchain, for the tests that read the artifact, and writes no stamp.
102The gate holds freshness on arm64 with the input stamp alone.
103