-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* add justfile * add pre-push hook * add setup scripts * rename `hooks` to `scripts`
- Loading branch information
Showing
2 changed files
with
60 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
export RUST_BACKTRACE := "1" | ||
alias s:= setup | ||
alias h:= set-hooks | ||
alias c:= clean | ||
|
||
@setup: | ||
# rustup install nightly | ||
rustup component add clippy-preview | ||
pip install pre-commit | ||
just h | ||
cargo build | ||
|
||
@clean: | ||
rm -rf pkg target dist | ||
|
||
@set-hooks: | ||
pre-commit | ||
bash ./scripts/pre-push |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
#!/bin/bash | ||
|
||
GREEN="\e[1;32m" | ||
RED="\e[31m" | ||
CYAN="\e[36m" | ||
ENDCOLOR="\e[0m" | ||
|
||
read -p "Would you like to run tests & clippy before you push remotely ? (y/n): " choice | ||
if [ "$choice" != "y" ]; then | ||
echo -e "${CYAN}pre-push hook will not be installed ${ENDCOLOR}" | ||
exit 0 | ||
else | ||
cat <<EOF >> .git/hooks/pre-push | ||
#!/bin/bash | ||
set -e | ||
echo "Running tests.." | ||
cargo test | ||
if [ \$? -ne 0 ]; then | ||
echo -e "${RED}hook failed, push aborted! ${ENDCOLOR}" | ||
exit 1 | ||
fi | ||
echo "Running Clippy.." | ||
cargo clippy -- -D warnings -A incomplete_features -W clippy::dbg_macro -W clippy::print_stdout | ||
if [ \$? -ne 0 ]; then | ||
echo -e "${RED}pre-push checks failed! ${ENDCOLOR}" | ||
exit 1 | ||
else | ||
echo -e "${GREEN}pre-push checks went successful!${ENDCOLOR}" | ||
fi | ||
exit 0 | ||
EOF | ||
chmod +x .git/hooks/pre-push | ||
printf "${GREEN}pre-push hook installed!${ENDCOLOR}" | ||
fi |