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.
|
30672859
Keenan Nemetz
7d ago
|
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. | |
| 16 | set -eu | |
| 17 | ||
| 18 | ROOT=$(CDPATH= cd -- "$(dirname -- "$0")/.." && pwd) | |
| 19 | cd "$ROOT" | |
| 20 | ||
| 21 | printf 'check-macos: running the unit suite (go test ./...)\n' | |
| 22 | CGO_ENABLED=0 go test ./... | |
| 23 | ||
| 24 | tmp=$(mktemp -d) | |
| 25 | trap 'trap - 0; [ -n "${VOLE_PID:-}" ] && kill "$VOLE_PID" 2>/dev/null || true; rm -rf "$tmp"' 0 | |
| 26 | ||
| 27 | fail() { | |
| 28 | printf 'check-macos: %s\n' "$*" >&2 | |
| 29 | exit 1 | |
| 30 | } | |
| 31 | ||
| 32 | note() { | |
| 33 | printf 'check-macos: ok: %s\n' "$*" | |
| 34 | } | |
| 35 | ||
| 36 | instance="$tmp/instance" | |
| 37 | key="$tmp/id_ed25519" | |
| 38 | keypub="$tmp/id_ed25519.pub" | |
| 39 | ssh_cmd="$tmp/ssh" | |
| 40 | port=2222 | |
| 41 | ||
| 42 | for tool in ssh-keygen nc git go vole; do | |
| 43 | command -v "$tool" >/dev/null 2>&1 || fail "$tool is required" | |
| 44 | done | |
| 45 | ||
| 46 | # The instance, its account key, and every repository live under $tmp. | |
| 47 | vole admin init --dir "$instance" || fail "init did not prepare the instance" | |
| 48 | export VOLE_CONFIG="$instance/vole.toml" | |
| 49 | ||
| 50 | ssh-keygen -q -t ed25519 -N "" -f "$key" | |
| 51 | ssh-keygen -y -f "$key" >"$keypub" || fail "could not derive the public key" | |
| 52 | vole admin account create --key "$keypub" kevin || fail "account create failed" | |
|
d74e7e23
Keenan Nemetz
3d ago
|
53 | vole admin repo create demo || fail "repo create failed" |
| 54 | vole admin acl set-role demo kevin admin || fail "acl set-role failed" | |
|
30672859
Keenan Nemetz
7d ago
|
55 | note "init, account, and repository creation" |
| 56 | ||
| 57 | # The built-in SSH listener is what a Mac serves clones on out of the box. | |
| 58 | vole serve >"$tmp/serve.log" 2>&1 & | |
| 59 | VOLE_PID=$! | |
| 60 | ||
| 61 | ready=0 | |
| 62 | i=0 | |
| 63 | while [ "$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 | |
| 70 | done | |
| 71 | if [ "$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" | |
| 74 | fi | |
| 75 | note "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. | |
| 80 | cat >"$ssh_cmd" <<EOF | |
| 81 | #! /bin/sh | |
| 82 | exec ssh -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null \\ | |
| 83 | -i "$key" -p "$port" "\$@" | |
| 84 | EOF | |
| 85 | chmod +x "$ssh_cmd" | |
| 86 | export GIT_SSH_COMMAND="$ssh_cmd" | |
| 87 | ||
| 88 | remote="ssh://kevin@127.0.0.1:$port/demo.git" | |
| 89 | clone="$tmp/clone" | |
| 90 | git clone "$remote" "$clone" >/dev/null 2>&1 || | |
| 91 | fail "clone over the SSH listener failed" | |
| 92 | note "clone over the built-in SSH listener" | |
| 93 | ||
| 94 | git -C "$clone" config user.email kevin@example.com | |
| 95 | git -C "$clone" config user.name kevin | |
| 96 | printf 'hello from macOS\n' >"$clone/README.md" | |
| 97 | git -C "$clone" add README.md | |
| 98 | git -C "$clone" commit -q -m "first commit from the macOS check" | |
| 99 | git -C "$clone" push -q origin HEAD:refs/heads/main 2>&1 || | |
| 100 | fail "push over the SSH listener failed" | |
| 101 | note "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. | |
| 105 | issue=$(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" | |
| 110 | note "issue lifecycle" | |
| 111 | ||
| 112 | git -C "$clone" switch -q -c fix/readme | |
| 113 | printf 'second line\n' >>"$clone/README.md" | |
| 114 | git -C "$clone" add README.md | |
| 115 | git -C "$clone" commit -q -m "a change for the macOS check" | |
| 116 | git -C "$clone" push -q origin HEAD:refs/heads/fix/readme 2>&1 || | |
| 117 | fail "branch push over SSH failed" | |
| 118 | change=$(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" | |
| 124 | note "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. | |
| 128 | git -C "$clone" switch -q main | |
| 129 | git -C "$clone" tag -a v1.0.0 -m "checked on macOS" | |
| 130 | git -C "$clone" push -q origin main --follow-tags 2>&1 || fail "tag push failed" | |
| 131 | printf '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" | |
| 134 | note "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. | |
| 138 | sitedir="$tmp/site" | |
| 139 | mkdir -p "$sitedir" | |
| 140 | printf 'macOS check site\n' >"$sitedir/index.html" | |
| 141 | (cd "$clone" && vole pages deploy --remote origin "$sitedir" >/dev/null) || | |
| 142 | fail "pages deploy failed" | |
| 143 | note "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. | |
| 148 | if 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 | |
| 158 | else | |
| 159 | note "LFS (skipped: git-lfs not installed)" | |
| 160 | fi | |
| 161 | ||
| 162 | # Database integrity and the backup path a Mac operator runs after a migration. | |
| 163 | vole admin db check >/dev/null || fail "db check failed" | |
| 164 | vole 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" | |
| 166 | note "db check and backup" | |
| 167 | ||
| 168 | kill "$VOLE_PID" 2>/dev/null || true | |
| 169 | wait "$VOLE_PID" 2>/dev/null || true | |
| 170 | unset VOLE_PID | |
| 171 | ||
| 172 | note "all macOS checks passed" |