Stitch any CI into Tangled
151
fork

Configure Feed

Select the types of activity you want to include in your feed.

configure buildkite

authored by

Mitchell Hashimoto and committed by
Tangled
0efa92e7 57fe7794

+88 -4
+35
.buildkite/hooks/pre-command
··· 1 + #!/bin/sh 2 + # 3 + # Buildkite pre-command hook: install Determinate Nix on the agent 4 + # before each command step runs. We rely on Nix (with flakes) for our 5 + # build environment, so every fresh agent needs it bootstrapped. 6 + # 7 + # Determinate's installer enables flakes and `nix-command` by default 8 + # and is more reliable in CI than the upstream installer, so we don't 9 + # need to stage a custom nix.conf. 10 + 11 + set -eu 12 + 13 + # Install Nix without touching the agent's init system. The `?ci=buildkite` 14 + # query param is informational; it lets Determinate tag installer telemetry. 15 + curl --proto '=https' --tlsv1.2 -sSf -L \ 16 + "https://install.determinate.systems/nix?ci=buildkite" \ 17 + | sh -s -- install linux --no-confirm --init none 18 + 19 + # Start the Determinate daemon ourselves since we passed `--init none`. 20 + # Point the Nix client at the daemon for the rest of this shell. 21 + nohup /usr/local/bin/determinate-nixd daemon & 22 + export NIX_REMOTE=daemon 23 + 24 + # Wait for the daemon to become responsive before handing control back 25 + # to the command step. 26 + while ! determinate-nixd status >/dev/null 2>&1; do 27 + sleep 0.1 28 + done 29 + 30 + # Put `nix` on PATH for the command step. Buildkite sources hooks, so 31 + # this export propagates. With `--init none` we never edited any shell 32 + # profile, so we have to do it ourselves. The default profile holds the 33 + # `nix` binary; the per-user profile holds anything `nix profile install` 34 + # adds later. 35 + export PATH="/nix/var/nix/profiles/default/bin:$HOME/.nix-profile/bin:$PATH"
+33
.buildkite/pipeline.yml
··· 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 + 5 + steps: 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
+12
.tangled/workflows/test.yml
··· 1 + when: 2 + - event: ["push"] 3 + branch: ["main"] 4 + - event: ["pull_request"] 5 + branch: ["main"] 6 + 7 + engine: nixery 8 + 9 + tack: 10 + buildkite: 11 + org: mitchellh 12 + pipeline: tack
+6 -2
flake.nix
··· 12 12 flake-utils, 13 13 ... 14 14 }: 15 - # Per-system outputs (packages, apps, devShells). nixosModules is 16 - # system-independent and is merged in below. 15 + # Per-system outputs (packages, apps, devShells). nixosModules is 16 + # system-independent and is merged in below. 17 17 flake-utils.lib.eachDefaultSystem ( 18 18 system: let 19 19 pkgs = nixpkgs.legacyPackages.${system}; ··· 39 39 env.CGO_ENABLED = "1"; 40 40 }; 41 41 in { 42 + # `nix fmt` formats the tree with alejandra. CI pins this same 43 + # binary via `nix run nixpkgs#alejandra` for the format check. 44 + formatter = pkgs.alejandra; 45 + 42 46 devShells.default = pkgs.mkShell { 43 47 packages = [ 44 48 pkgs.go
+2 -2
nix/modules/tack.nix
··· 1 - # NixOS module for the tack spindle. 1 + # NixOS module for the tack spindle. 2 2 { 3 3 config, 4 4 lib, ··· 127 127 ] 128 128 ++ optional cfg.dev "TACK_DEV=1" 129 129 ++ optional (cfg.buildkite.org != null) 130 - "TACK_BUILDKITE_ORG=${cfg.buildkite.org}"; 130 + "TACK_BUILDKITE_ORG=${cfg.buildkite.org}"; 131 131 132 132 ExecStart = "${cfg.package}/bin/tack -addr ${cfg.listenAddr}"; 133 133 Restart = "always";