Skip to content

Commit b42dfc8

Browse files
author
EchoBT
committed
chore: add git hooks for format and CI checks
- pre-commit: auto-format code with cargo fmt - pre-push: run format check, clippy, and tests Run ./scripts/setup-hooks.sh to enable hooks.
1 parent fa85fea commit b42dfc8

File tree

4 files changed

+39
-1
lines changed

4 files changed

+39
-1
lines changed

.githooks/pre-commit

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
#!/bin/bash
2+
set -e
3+
4+
echo "Running pre-commit checks..."
5+
6+
# Format code
7+
echo "Formatting code..."
8+
cargo fmt --all
9+
10+
# Add formatted files back to staging
11+
git add -u
12+
13+
echo "Pre-commit checks passed!"

.githooks/pre-push

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
#!/bin/bash
2+
set -e
3+
4+
echo "Running pre-push CI checks..."
5+
6+
# Format check
7+
echo "Checking format..."
8+
cargo fmt --all -- --check
9+
10+
# Clippy
11+
echo "Running clippy..."
12+
cargo clippy --all-targets --workspace -- -W clippy::all
13+
14+
# Tests
15+
echo "Running tests..."
16+
cargo test --workspace
17+
18+
echo "All CI checks passed!"

Cargo.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

scripts/setup-hooks.sh

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
#!/bin/bash
2+
# Setup git hooks for platform-chain
3+
4+
REPO_ROOT="$(git rev-parse --show-toplevel)"
5+
git config core.hooksPath "$REPO_ROOT/.githooks"
6+
7+
echo "Git hooks configured. Pre-commit will format code, pre-push will run CI checks."

0 commit comments

Comments
 (0)