Merge pull request #24 from vrescobar/chore/pre-push-hook

chore: add pre-push hook enforcing fmt, clippy, and tests
This commit is contained in:
Argenis 2026-02-14 09:16:55 -05:00 committed by GitHub
commit f4f180ac41
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
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 git clone https://github.com/theonlyhennygod/zeroclaw.git
cd zeroclaw cd zeroclaw
# Enable the pre-push hook (runs fmt, clippy, tests before every push)
git config core.hooksPath .githooks
# Build # Build
cargo build cargo build
# Run tests (180 tests, all must pass) # Run tests (all must pass)
cargo test cargo test
# Format & lint (must pass before PR) # Format & lint (must pass before PR)
cargo fmt && cargo clippy -- -D warnings cargo fmt && cargo clippy -- -D warnings
# Release build (~3.1MB) # Release build (~3.4MB)
cargo build --release 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 ## 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. 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 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 ## License
MIT — see [LICENSE](LICENSE) MIT — see [LICENSE](LICENSE)