.githooks/pre-push
38 lines · 1096 bytes · executable
1#!/bin/sh
2# Run the full test suite before every push. There is no CI for this repo; this
3# hook is the only gate, so it runs everything and a failure aborts the push.
4#
5# Wired up once per clone with:
6#
7# git config core.hooksPath .githooks
8set -eu
9
10root=$(git rev-parse --show-toplevel)
11cd "$root"
12
13# The differential secret-typing tests (the privacy ship-gate) drive a real
14# interactive zsh under zsh/zpty. Check for it up front so a missing zsh fails
15# with a clear message instead of deep inside cargo test, and is never silently
16# skipped.
17echo "pre-push: zsh/zpty preflight" >&2
18zsh -c 'zmodload zsh/zpty' || {
19 echo "pre-push: needs zsh with the zsh/zpty module" >&2
20 exit 1
21}
22
23echo "pre-push: cargo test" >&2
24cargo test --locked
25
26echo "pre-push: cargo clippy" >&2
27cargo clippy --all-targets --locked -- -D warnings
28
29# macos-collector is a Swift package; its tests only run on macOS.
30case "$(uname -s)" in
31Darwin)
32 echo "pre-push: swift test (macos-collector)" >&2
33 swift test --package-path "$root/macos-collector"
34 ;;
35*)
36 echo "pre-push: not macOS, skipping swift test" >&2
37 ;;
38esac