feat: add pre-push hook for lint checks (#254)
Some checks are pending
Lint / lint (push) Waiting to run
Test / test (macos-latest, 3.10) (push) Waiting to run
Test / test (macos-latest, 3.11) (push) Waiting to run
Test / test (macos-latest, 3.12) (push) Waiting to run
Test / test (ubuntu-latest, 3.10) (push) Waiting to run
Test / test (windows-latest, 3.10) (push) Waiting to run
Test / test (windows-latest, 3.11) (push) Waiting to run
Test / test (windows-latest, 3.12) (push) Waiting to run
Test / test (windows-latest, 3.13) (push) Waiting to run
Test / test-examples (3.11) (push) Blocked by required conditions
Test / test-examples (3.12) (push) Blocked by required conditions
Test / test-examples (3.13) (push) Blocked by required conditions
Test / test (macos-latest, 3.13) (push) Waiting to run
Test / test (ubuntu-latest, 3.11) (push) Waiting to run
Test / test (ubuntu-latest, 3.12) (push) Waiting to run
Test / test (ubuntu-latest, 3.13) (push) Waiting to run
Test / test-examples (3.10) (push) Blocked by required conditions
Test / test-e2e (macos-latest, 3.10) (push) Blocked by required conditions
Test / test-e2e (macos-latest, 3.11) (push) Blocked by required conditions
Test / test-e2e (macos-latest, 3.12) (push) Blocked by required conditions
Test / test-e2e (macos-latest, 3.13) (push) Blocked by required conditions
Test / test-e2e (ubuntu-latest, 3.10) (push) Blocked by required conditions
Test / test-e2e (ubuntu-latest, 3.11) (push) Blocked by required conditions
Test / test-e2e (ubuntu-latest, 3.12) (push) Blocked by required conditions
Test / test-e2e (ubuntu-latest, 3.13) (push) Blocked by required conditions
Test / test-e2e (windows-latest, 3.10) (push) Blocked by required conditions
Test / test-e2e (windows-latest, 3.11) (push) Blocked by required conditions
Test / test-e2e (windows-latest, 3.12) (push) Blocked by required conditions
Test / test-e2e (windows-latest, 3.13) (push) Blocked by required conditions

Adds a committable pre-push hook that runs ruff checks before pushing,
matching the CI lint workflow. Developers run ./scripts/initial-setup.sh
to install the hook locally.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-authored-by: Claude <noreply@anthropic.com>
This commit is contained in:
Ashwin Bhat 2025-10-14 09:26:49 -07:00 committed by GitHub
parent aebcf9d6a4
commit f896cd6f7f
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 62 additions and 0 deletions

View file

@ -280,6 +280,16 @@ If you're upgrading from the Claude Code SDK (versions < 0.1.0), please see the
- Settings isolation and explicit control
- New programmatic subagents and session forking features
## Development
If you're contributing to this project, run the initial setup script to install git hooks:
```bash
./scripts/initial-setup.sh
```
This installs a pre-push hook that runs lint checks before pushing, matching the CI workflow. To skip the hook temporarily, use `git push --no-verify`.
## License
MIT

22
scripts/initial-setup.sh Executable file
View file

@ -0,0 +1,22 @@
#!/bin/bash
# Initial setup script for installing git hooks
set -e
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
REPO_ROOT="$(cd "$SCRIPT_DIR/.." && pwd)"
echo "Setting up git hooks..."
# Install pre-push hook
echo "→ Installing pre-push hook..."
cp "$SCRIPT_DIR/pre-push" "$REPO_ROOT/.git/hooks/pre-push"
chmod +x "$REPO_ROOT/.git/hooks/pre-push"
echo "✓ pre-push hook installed"
echo ""
echo "✓ Setup complete!"
echo ""
echo "The pre-push hook will now run lint checks before each push."
echo "To skip the hook temporarily, use: git push --no-verify"

30
scripts/pre-push Executable file
View file

@ -0,0 +1,30 @@
#!/bin/bash
# Pre-push hook to run lint checks (matches .github/workflows/lint.yml)
echo "Running lint checks before push..."
echo ""
# Run ruff check
echo "→ Running ruff check..."
python -m ruff check src/ tests/
if [ $? -ne 0 ]; then
echo ""
echo "❌ ruff check failed. Fix lint issues before pushing."
echo " Run: python -m ruff check src/ tests/ --fix"
exit 1
fi
# Run ruff format check
echo "→ Running ruff format check..."
python -m ruff format --check src/ tests/
if [ $? -ne 0 ]; then
echo ""
echo "❌ ruff format check failed. Fix formatting before pushing."
echo " Run: python -m ruff format src/ tests/"
exit 1
fi
echo ""
echo "✓ All lint checks passed!"
exit 0