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."

View file

@ -9,19 +9,34 @@ Thanks for your interest in contributing to ZeroClaw! This guide will help you g
git clone https://github.com/theonlyhennygod/zeroclaw.git
cd zeroclaw
# Enable the pre-push hook (runs fmt, clippy, tests before every push)
git config core.hooksPath .githooks
# Build
cargo build
# Run tests (180 tests, all must pass)
# Run tests (all must pass)
cargo test
# Format & lint (must pass before PR)
cargo fmt && cargo clippy -- -D warnings
# Release build (~3.1MB)
# Release build (~3.4MB)
cargo build --release
```
### Pre-push hook
The repo includes a pre-push hook in `.githooks/` that enforces `cargo fmt --check`, `cargo clippy -- -D warnings`, and `cargo test` before every push. Enable it with `git config core.hooksPath .githooks`.
To skip it during rapid iteration:
```bash
git push --no-verify
```
> **Note:** CI runs the same checks, so skipped hooks will be caught on the PR.
## Architecture: Trait-Based Pluggability
ZeroClaw's architecture is built on **traits** — every subsystem is swappable. This means contributing a new integration is as simple as implementing a trait and registering it in the factory function.

View file

@ -219,6 +219,20 @@ cargo fmt # Format
cargo test --test memory_comparison -- --nocapture
```
### Pre-push hook
A git hook runs `cargo fmt --check`, `cargo clippy -- -D warnings`, and `cargo test` before every push. Enable it once:
```bash
git config core.hooksPath .githooks
```
To skip the hook when you need a quick push during development:
```bash
git push --no-verify
```
## License
MIT — see [LICENSE](LICENSE)