Skip to content

Commit e0a3da5

Browse files
committed
chore: add pre-commit hook running CI gates
1 parent 1d4ef52 commit e0a3da5

1 file changed

Lines changed: 25 additions & 0 deletions

File tree

.githooks/pre-commit

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
#!/usr/bin/env bash
2+
# Runs the same gates as .github/workflows/ci.yml before allowing a commit,
3+
# so a commit never lands a failure that CI would catch.
4+
#
5+
# Enable once per clone: git config core.hooksPath .githooks
6+
# Bypass for one commit: git commit --no-verify
7+
set -euo pipefail
8+
9+
cd "$(git rev-parse --show-toplevel)"
10+
11+
run() {
12+
printf '\033[1m▶ %s\033[0m\n' "$*"
13+
if ! "$@"; then
14+
printf '\033[31m✗ pre-commit gate failed: %s\033[0m\n' "$*" >&2
15+
printf ' fix it, or bypass with: git commit --no-verify\n' >&2
16+
exit 1
17+
fi
18+
}
19+
20+
run cargo fmt --check
21+
run cargo clippy --locked -- -D warnings
22+
run cargo build --locked
23+
run cargo test --locked
24+
25+
printf '\033[32m✓ all CI gates passed\033[0m\n'

0 commit comments

Comments
 (0)