Stitch any CI into Tangled
1# In-repo Buildkite pipeline. The Buildkite-side pipeline only needs
2# one step that does `buildkite-agent pipeline upload`; everything
3# real lives here.
4
5steps:
6 - label: ":nix: format check"
7 # `nix fmt` dispatches to the flake's `formatter` output (alejandra).
8 # `--` forwards `--check` to alejandra, which exits non-zero on any
9 # file that would be reformatted so the build fails instead of
10 # silently rewriting files.
11 command: nix fmt -- --check .
12
13 - label: ":go: test"
14 # Run the full Go test suite inside the flake's dev shell so the
15 # toolchain (go, cgo deps for mattn/go-sqlite3) matches what the
16 # package build uses. `nix develop -c` runs the given command in the
17 # default devShell without dropping into an interactive shell.
18 command: nix develop -c go test ./...
19
20 - label: ":nix: package build & smoke"
21 # Build the `tack` flake package and smoke-test the resulting
22 # binary. This catches regressions that `go test` won't, such as a
23 # stale `vendorHash`, broken cgo wiring for mattn/go-sqlite3, or a
24 # linker failure inside the Nix sandbox.
25 #
26 # `tack -h` is the cheapest possible "did the binary load?" check:
27 # `flag.Parse()` runs before any required env-var validation, prints
28 # usage, and exits 0 — proving the binary was produced, links, and
29 # can execute Go init without spinning up the HTTP server, store,
30 # or jetstream consumer.
31 command: |
32 nix build .#tack
33 ./result/bin/tack -h
34
35 - label: ":docker: image build & smoke"
36 # Keep the community Dockerfile from drifting away from the real build.
37 # The image smoke test mirrors the Nix package smoke test: `tack -h` exits
38 # before env-var validation, so it proves the container starts without
39 # needing a database, Tangled credentials, or a live HTTP listener.
40 #
41 # Buildkite's Docker builder may be a remote BuildKit driver, so `--load`
42 # makes the tagged image available to the local daemon for `docker run`.
43 # `--quiet` also keeps the layer transfer logs below Buildkite's display
44 # limit while still surfacing a failing Dockerfile command.
45 command: |
46 docker build --pull --load --quiet --file docker/tack.Dockerfile --tag tack:ci .
47 docker run --rm tack:ci /app/bin/tack -h