chore: add pre-push hook enforcing fmt, clippy, and tests

Adds .githooks/pre-push that runs cargo fmt --check, cargo clippy
-- -D warnings, and cargo test before every push. Enable with:

  git config core.hooksPath .githooks

Skip with git push --no-verify for rapid iteration.

Documented in README.md and CONTRIBUTING.md.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Víctor R. Escobar 2026-02-14 14:07:37 +01:00
parent ac540d2b63
commit 3162653695
3 changed files with 59 additions and 2 deletions

28
.githooks/pre-push Executable file
View file

@ -0,0 +1,28 @@
#!/usr/bin/env bash
#
# pre-push hook — runs fmt, clippy, and tests before every push.
# Install: git config core.hooksPath .githooks
# Skip: git push --no-verify
set -euo pipefail
echo "==> pre-push: checking formatting..."
cargo fmt -- --check || {
echo "FAIL: cargo fmt -- --check found unformatted code."
echo "Run 'cargo fmt' and try again."
exit 1
}
echo "==> pre-push: running clippy..."
cargo clippy -- -D warnings || {
echo "FAIL: clippy reported warnings."
exit 1
}
echo "==> pre-push: running tests..."
cargo test || {
echo "FAIL: some tests did not pass."
exit 1
}
echo "==> pre-push: all checks passed."