Skip to content

Commit

Permalink
feat: pre-push hook (#1330)
Browse files Browse the repository at this point in the history
* feat: pre-push hook

* fix: check

* fix: readme and cargo fmt
  • Loading branch information
eugypalu authored Aug 20, 2024
1 parent 5a08abb commit e2433d8
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 0 deletions.
21 changes: 21 additions & 0 deletions .hooks/pre-push
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#!/bin/sh

cargo check --all-features
if [ $? -ne 0 ]; then
echo "Pre-push hook failed: cargo check detected errors."
exit 1
fi

cargo clippy --workspace --all-features --all-targets -- -D warnings
if [ $? -ne 0 ]; then
echo "Pre-push hook failed: cargo clippy detected warnings or errors."
exit 1
fi

cargo +nightly fmt --all --check
if [ $? -ne 0 ]; then
echo "Pre-push hook failed: cargo fmt detected formatting issues."
exit 1
fi

exit 0
2 changes: 2 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ setup: .gitmodules
cd lib/kakarot && make setup && make build && make build-sol && \
mv build/ssj/contracts_Cairo1Helpers.contract_class.json build/cairo1_helpers.json && rm -fr build/ssj
./scripts/extract_abi.sh
chmod +x ./scripts/install_hooks.sh
./scripts/install_hooks.sh

deploy-kakarot:
cd lib/kakarot && STARKNET_NETWORK=$(STARKNET_NETWORK) poetry run python ./kakarot_scripts/deploy_kakarot.py && cd ..
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,7 @@ Caveats:
2. the [kakarot](https://github.com/kkrt-labs/kakarot) submodule uses Python to build
and deploy Kakarot contracts. If you don't have the right version available, we
recommend to use [pyenv](https://github.com/pyenv/pyenv) to install it.
3. We use a pre-commit hook to ensure code quality and consistency. The hook will be installed automatically by running `make setup`, otherwise you can install it manually by running the script `scripts/install_hooks.sh`.

### Build from source

Expand Down
4 changes: 4 additions & 0 deletions scripts/install_hooks.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
cp .hooks/pre-push .git/hooks/pre-push
chmod +x .git/hooks/pre-push

echo "Git hooks installed successfully."

0 comments on commit e2433d8

Please sign in to comment.