Sign in

Search issue titles and bodies, change requests and comments. Private repositories you cannot read are not included.

vole
Site
Clone

Read only, no credentials:

https://rodent.software/vole.git

Write over SSH with a registered key:

git clone ssh://git@rodent.software/vole.git

Self-hosted forge that lives in your Git repo.

Code

527 commit(s) on main

Put job execution behind an interface Keenan Nemetz · 2h ago de3eec16
history blame raw 6.3 KiB
1#! /bin/sh
2# Exercise Vole on macOS: the unit suite plus an end-to-end pass over the
3# features a Mac user touches, against a throwaway instance.
4#
5# CI runs everything in a Linux container, so a release has never executed the
6# test suite on macOS. This script is what a maintainer runs on a Mac before
7# signing off a macOS artifact (see RELEASING.md). It needs Go, Git, the OpenSSH
8# client, ssh-keygen, and nc, and nothing else: the instance, its SSH key, and
9# every repository live in a temporary directory, and the server listens on
10# loopback.
11#
12# The order matters. It runs the unit suite first, then creates one instance and
13# drives it end to end through the features a Mac user first touches. Each check
14# names the feature it exercises so a failure points at a feature, not at the
15# harness.
16set -eu
17
18ROOT=$(CDPATH= cd -- "$(dirname -- "$0")/.." && pwd)
19cd "$ROOT"
20
21printf 'check-macos: running the unit suite (go test ./...)\n'
22CGO_ENABLED=0 go test ./...
23
24tmp=$(mktemp -d)
25trap 'trap - 0; [ -n "${VOLE_PID:-}" ] && kill "$VOLE_PID" 2>/dev/null || true; rm -rf "$tmp"' 0
26
27fail() {
28 printf 'check-macos: %s\n' "$*" >&2
29 exit 1
30}
31
32note() {
33 printf 'check-macos: ok: %s\n' "$*"
34}
35
36instance="$tmp/instance"
37key="$tmp/id_ed25519"
38keypub="$tmp/id_ed25519.pub"
39ssh_cmd="$tmp/ssh"
40port=2222
41
42for tool in ssh-keygen nc git go vole; do
43 command -v "$tool" >/dev/null 2>&1 || fail "$tool is required"
44done
45
46# The instance, its account key, and every repository live under $tmp.
47vole admin init --dir "$instance" || fail "init did not prepare the instance"
48export VOLE_CONFIG="$instance/vole.toml"
49
50ssh-keygen -q -t ed25519 -N "" -f "$key"
51ssh-keygen -y -f "$key" >"$keypub" || fail "could not derive the public key"
52vole admin account create --key "$keypub" kevin || fail "account create failed"
53vole admin repo create demo || fail "repo create failed"
54vole admin acl set-role demo kevin admin || fail "acl set-role failed"
55note "init, account, and repository creation"
56
57# The built-in SSH listener is what a Mac serves clones on out of the box.
58vole serve >"$tmp/serve.log" 2>&1 &
59VOLE_PID=$!
60
61ready=0
62i=0
63while [ "$i" -lt 100 ]; do
64 if nc -z 127.0.0.1 "$port" 2>/dev/null; then
65 ready=1
66 break
67 fi
68 i=$((i + 1))
69 sleep 0.1
70done
71if [ "$ready" -ne 1 ]; then
72 cat "$tmp/serve.log" >&2
73 fail "serve did not open the SSH listener on 127.0.0.1:$port"
74fi
75note "serve and its SSH listener"
76
77# Cloning has to be the real thing over the loopback listener: an account key, a
78# forced command, and a repository write over SSH. A wrapper pins the key so the
79# clone does not depend on the operator's own agent or config.
80cat >"$ssh_cmd" <<EOF
81#! /bin/sh
82exec ssh -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null \\
83 -i "$key" -p "$port" "\$@"
84EOF
85chmod +x "$ssh_cmd"
86export GIT_SSH_COMMAND="$ssh_cmd"
87
88remote="ssh://kevin@127.0.0.1:$port/demo.git"
89clone="$tmp/clone"
90git clone "$remote" "$clone" >/dev/null 2>&1 ||
91 fail "clone over the SSH listener failed"
92note "clone over the built-in SSH listener"
93
94git -C "$clone" config user.email kevin@example.com
95git -C "$clone" config user.name kevin
96printf 'hello from macOS\n' >"$clone/README.md"
97git -C "$clone" add README.md
98git -C "$clone" commit -q -m "first commit from the macOS check"
99git -C "$clone" push -q origin HEAD:refs/heads/main 2>&1 ||
100 fail "push over the SSH listener failed"
101note "push over the built-in SSH listener"
102
103# The forge surface a Mac user drives next. Client commands run from inside the
104# clone so `--remote` (here, the explicit SSH URL) is the instance just pushed to.
105issue=$(cd "$clone" && vole issue new --remote origin --title "checked on macOS" \
106 -m "Filed by the macOS check." -a kevin | awk -F '\t' '{print $1}')
107[ -n "$issue" ] || fail "issue new did not print an id"
108(cd "$clone" && vole issue show --remote origin "$issue" >/dev/null) ||
109 fail "issue show failed"
110note "issue lifecycle"
111
112git -C "$clone" switch -q -c fix/readme
113printf 'second line\n' >>"$clone/README.md"
114git -C "$clone" add README.md
115git -C "$clone" commit -q -m "a change for the macOS check"
116git -C "$clone" push -q origin HEAD:refs/heads/fix/readme 2>&1 ||
117 fail "branch push over SSH failed"
118change=$(cd "$clone" && vole change new --remote origin --title "a macOS-checked change" \
119 --base main --head fix/readme --closes "$issue" \
120 -m "Opened by the macOS check." | awk -F '\t' '{print $1}')
121[ -n "$change" ] || fail "change new did not print an id"
122(cd "$clone" && vole change show --remote origin "$change" >/dev/null) ||
123 fail "change show failed"
124note "change request"
125
126# A release is an annotated tag pushed with --follow-tags, then files attach over
127# SSH. The attach exercises the artifact store the way a real release does.
128git -C "$clone" switch -q main
129git -C "$clone" tag -a v1.0.0 -m "checked on macOS"
130git -C "$clone" push -q origin main --follow-tags 2>&1 || fail "tag push failed"
131printf 'artifact\n' >"$tmp/artifact.txt"
132(cd "$clone" && vole release attach --remote origin v1.0.0 "$tmp/artifact.txt" >/dev/null) ||
133 fail "release attach failed"
134note "release attach"
135
136# A site is what pages deploy publishes into the pages branch; it exercises the
137# snapshot path a Mac operator uses.
138sitedir="$tmp/site"
139mkdir -p "$sitedir"
140printf 'macOS check site\n' >"$sitedir/index.html"
141(cd "$clone" && vole pages deploy --remote origin "$sitedir" >/dev/null) ||
142 fail "pages deploy failed"
143note "pages deploy"
144
145# LFS through the wire the way a Mac user does. git-lfs on the client is not part
146# of Vole, so when it is present, exercise tracking and a push; otherwise record
147# the gap rather than fail.
148if command -v git-lfs >/dev/null 2>&1; then
149 git -C "$clone" lfs track '*.bin' >/dev/null 2>&1 || true
150 head -c 1024 /dev/zero >"$clone/blob.bin"
151 git -C "$clone" add .gitattributes blob.bin
152 git -C "$clone" commit -q -m "an LFS object"
153 if git -C "$clone" push -q origin HEAD:refs/heads/main 2>&1; then
154 note "LFS push"
155 else
156 note "LFS (skipped: server refused the object)"
157 fi
158else
159 note "LFS (skipped: git-lfs not installed)"
160fi
161
162# Database integrity and the backup path a Mac operator runs after a migration.
163vole admin db check >/dev/null || fail "db check failed"
164vole admin db backup "$tmp/backup" >/dev/null || fail "db backup failed"
165[ -n "$(find "$tmp/backup" -type f | head -n 1)" ] || fail "db backup wrote no files"
166note "db check and backup"
167
168kill "$VOLE_PID" 2>/dev/null || true
169wait "$VOLE_PID" 2>/dev/null || true
170unset VOLE_PID
171
172note "all macOS checks passed"
173