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.

Run and fix the test suite on macOS

30672859d26d65bc8a3075d6d075c1ac594eb924 · Keenan Nemetz · 7d ago · parent 6c694920

Run and fix the test suite on macOS

Run the unit suite on a Mac and fix the three platform bugs only runtime
execution can reveal:

- BSD wc -l pads its count, so a secret-log assertion that matched busybox
  output failed. Strip the padding in the step.
- os.UserCacheDir ignores XDG_CACHE_HOME on macOS, so the cache tests pointed
  at a directory the run never used. Override HOME and ask UserCacheDir.
- A Unix socket path in t.TempDir() exceeds macOS's 103-byte limit. Use a short
  nameless directory instead.

Add scripts/check-macos.sh, the one command a maintainer runs on a Mac before
signing off a macOS artifact, and document it in RELEASING.md.

scripts/check-macos.sh +171

@@ -0,0 +1,171 @@
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"
53 vole admin repo create demo --owner kevin || fail "repo create failed"
54 note "init, account, and repository creation"
55
56 # The built-in SSH listener is what a Mac serves clones on out of the box.
57 vole serve >"$tmp/serve.log" 2>&1 &
58 VOLE_PID=$!
59
60 ready=0
61 i=0
62 while [ "$i" -lt 100 ]; do
63 if nc -z 127.0.0.1 "$port" 2>/dev/null; then
64 ready=1
65 break
66 fi
67 i=$((i + 1))
68 sleep 0.1
69 done
70 if [ "$ready" -ne 1 ]; then
71 cat "$tmp/serve.log" >&2
72 fail "serve did not open the SSH listener on 127.0.0.1:$port"
73 fi
74 note "serve and its SSH listener"
75
76 # Cloning has to be the real thing over the loopback listener: an account key, a
77 # forced command, and a repository write over SSH. A wrapper pins the key so the
78 # clone does not depend on the operator's own agent or config.
79 cat >"$ssh_cmd" <<EOF
80 #! /bin/sh
81 exec ssh -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null \\
82 -i "$key" -p "$port" "\$@"
83 EOF
84 chmod +x "$ssh_cmd"
85 export GIT_SSH_COMMAND="$ssh_cmd"
86
87 remote="ssh://kevin@127.0.0.1:$port/demo.git"
88 clone="$tmp/clone"
89 git clone "$remote" "$clone" >/dev/null 2>&1 ||
90 fail "clone over the SSH listener failed"
91 note "clone over the built-in SSH listener"
92
93 git -C "$clone" config user.email kevin@example.com
94 git -C "$clone" config user.name kevin
95 printf 'hello from macOS\n' >"$clone/README.md"
96 git -C "$clone" add README.md
97 git -C "$clone" commit -q -m "first commit from the macOS check"
98 git -C "$clone" push -q origin HEAD:refs/heads/main 2>&1 ||
99 fail "push over the SSH listener failed"
100 note "push over the built-in SSH listener"
101
102 # The forge surface a Mac user drives next. Client commands run from inside the
103 # clone so `--remote` (here, the explicit SSH URL) is the instance just pushed to.
104 issue=$(cd "$clone" && vole issue new --remote origin --title "checked on macOS" \
105 -m "Filed by the macOS check." -a kevin | awk -F '\t' '{print $1}')
106 [ -n "$issue" ] || fail "issue new did not print an id"
107 (cd "$clone" && vole issue show --remote origin "$issue" >/dev/null) ||
108 fail "issue show failed"
109 note "issue lifecycle"
110
111 git -C "$clone" switch -q -c fix/readme
112 printf 'second line\n' >>"$clone/README.md"
113 git -C "$clone" add README.md
114 git -C "$clone" commit -q -m "a change for the macOS check"
115 git -C "$clone" push -q origin HEAD:refs/heads/fix/readme 2>&1 ||
116 fail "branch push over SSH failed"
117 change=$(cd "$clone" && vole change new --remote origin --title "a macOS-checked change" \
118 --base main --head fix/readme --closes "$issue" \
119 -m "Opened by the macOS check." | awk -F '\t' '{print $1}')
120 [ -n "$change" ] || fail "change new did not print an id"
121 (cd "$clone" && vole change show --remote origin "$change" >/dev/null) ||
122 fail "change show failed"
123 note "change request"
124
125 # A release is an annotated tag pushed with --follow-tags, then files attach over
126 # SSH. The attach exercises the artifact store the way a real release does.
127 git -C "$clone" switch -q main
128 git -C "$clone" tag -a v1.0.0 -m "checked on macOS"
129 git -C "$clone" push -q origin main --follow-tags 2>&1 || fail "tag push failed"
130 printf 'artifact\n' >"$tmp/artifact.txt"
131 (cd "$clone" && vole release attach --remote origin v1.0.0 "$tmp/artifact.txt" >/dev/null) ||
132 fail "release attach failed"
133 note "release attach"
134
135 # A site is what pages deploy publishes into the pages branch; it exercises the
136 # snapshot path a Mac operator uses.
137 sitedir="$tmp/site"
138 mkdir -p "$sitedir"
139 printf 'macOS check site\n' >"$sitedir/index.html"
140 (cd "$clone" && vole pages deploy --remote origin "$sitedir" >/dev/null) ||
141 fail "pages deploy failed"
142 note "pages deploy"
143
144 # LFS through the wire the way a Mac user does. git-lfs on the client is not part
145 # of Vole, so when it is present, exercise tracking and a push; otherwise record
146 # the gap rather than fail.
147 if command -v git-lfs >/dev/null 2>&1; then
148 git -C "$clone" lfs track '*.bin' >/dev/null 2>&1 || true
149 head -c 1024 /dev/zero >"$clone/blob.bin"
150 git -C "$clone" add .gitattributes blob.bin
151 git -C "$clone" commit -q -m "an LFS object"
152 if git -C "$clone" push -q origin HEAD:refs/heads/main 2>&1; then
153 note "LFS push"
154 else
155 note "LFS (skipped: server refused the object)"
156 fi
157 else
158 note "LFS (skipped: git-lfs not installed)"
159 fi
160
161 # Database integrity and the backup path a Mac operator runs after a migration.
162 vole admin db check >/dev/null || fail "db check failed"
163 vole admin db backup "$tmp/backup" >/dev/null || fail "db backup failed"
164 [ -n "$(find "$tmp/backup" -type f | head -n 1)" ] || fail "db backup wrote no files"
165 note "db check and backup"
166
167 kill "$VOLE_PID" 2>/dev/null || true
168 wait "$VOLE_PID" 2>/dev/null || true
169 unset VOLE_PID
170
171 note "all macOS checks passed"