Artifact ce6475b76fc57f30162afe7295c01c468449edc4372cefa5eacfca579c2d53c9:
- File
tools/ci/mac-runner.sh
— part of check-in
[377cccd611]
at
2026-11-18 21:27:35
on branch ci
— Add CI: the full suite on every push, on a Mac runner
ci/test.yml runs make test-pic and, where an LLVM clang exists, a short fuzz pass. tools/ci installs and removes the zeitforge runner on the Mac mini as a LaunchAgent, and docs/ci.md covers setup and teardown. (user: dmestas, size: 3112) [annotate] [blame] [check-ins using]
#!/bin/sh # Installs or removes pi-c's zeitforge CI runner on a Mac over SSH. The runner # runs as the SSH user under a LaunchAgent (the user chose this over a # dedicated account: jobs can read that account's files). # mac-runner.sh install HOST copy the start script, load the LaunchAgent # (the token must already be in ~/pic-ci/token) # mac-runner.sh uninstall HOST unload, then delete ~/pic-ci and the plist # mac-runner.sh status HOST the agent's state and the log's tail # The runner binary is fetched separately and verified against # https://zeitforge.app/runner/SHA256SUMS (see docs/ci.md). Retiring the # worker token at the forge is a separate step (docs/ci.md). set -eu [ "$#" -eq 2 ] || { echo "usage: $0 install|uninstall|status HOST" >&2; exit 2; } action=$1 host=$2 here=$(cd "$(dirname "$0")" && pwd) label=app.zeitforge.pic-ci-runner case "$action" in install) ssh -o BatchMode=yes "$host" 'set -eu; umask 077; d=$HOME/pic-ci; [ -x "$d/quarry-runner" ] && [ -s "$d/token" ] && mkdir -p "$d/work" "$HOME/Library/LaunchAgents"' || { echo "install: $host needs ~/pic-ci/quarry-runner and ~/pic-ci/token first (docs/ci.md)" >&2; exit 1; } ssh -o BatchMode=yes "$host" 'cat > "$HOME/pic-ci/runner-start.sh" && chmod 700 "$HOME/pic-ci/runner-start.sh"' \ < "$here/runner-start.sh" ssh -o BatchMode=yes "$host" "set -eu; plist=\$HOME/Library/LaunchAgents/$label.plist cat > \"\$plist\" <<PLIST <?xml version=\"1.0\" encoding=\"UTF-8\"?> <!DOCTYPE plist PUBLIC \"-//Apple//DTD PLIST 1.0//EN\" \"http://www.apple.com/DTDs/PropertyList-1.0.dtd\"> <plist version=\"1.0\"><dict> <key>Label</key><string>$label</string> <key>ProgramArguments</key><array><string>/bin/sh</string><string>\$HOME/pic-ci/runner-start.sh</string></array> <key>RunAtLoad</key><true/> <key>KeepAlive</key><true/> <key>ThrottleInterval</key><integer>30</integer> <key>ExitTimeOut</key><integer>90</integer> <key>StandardOutPath</key><string>\$HOME/pic-ci/runner.log</string> <key>StandardErrorPath</key><string>\$HOME/pic-ci/runner.log</string> </dict></plist> PLIST launchctl bootout gui/\$(id -u)/$label 2>/dev/null || true launchctl bootstrap gui/\$(id -u) \"\$plist\" sleep 3 launchctl print gui/\$(id -u)/$label | grep -E '^\\s*(state|pid) =' tail -5 \$HOME/pic-ci/runner.log" ;; uninstall) ssh -o BatchMode=yes "$host" "set -eu launchctl bootout gui/\$(id -u)/$label 2>/dev/null || true rm -f \"\$HOME/Library/LaunchAgents/$label.plist\" rm -rf \"\$HOME/pic-ci\" if launchctl print gui/\$(id -u)/$label >/dev/null 2>&1; then echo 'uninstall: agent still loaded' >&2; exit 1; fi [ ! -e \"\$HOME/pic-ci\" ] || { echo 'uninstall: ~/pic-ci remains' >&2; exit 1; } echo 'uninstall: agent unloaded, ~/pic-ci and the plist removed'" ;; status) ssh -o BatchMode=yes "$host" "launchctl print gui/\$(id -u)/$label 2>/dev/null | grep -E '^\\s*(state|pid|last exit code) =' || echo 'not loaded'; tail -10 \$HOME/pic-ci/runner.log 2>/dev/null" ;; *) echo "usage: $0 install|uninstall|status HOST" >&2 exit 2 ;; esac