Skip to content

Commit

Permalink
Setup CI (#7)
Browse files Browse the repository at this point in the history
* add justfile

* add pre-push hook

* add setup scripts

* rename `hooks` to `scripts`
  • Loading branch information
ashgw authored Apr 9, 2024
1 parent 50363b9 commit 95ed4ed
Show file tree
Hide file tree
Showing 2 changed files with 60 additions and 0 deletions.
18 changes: 18 additions & 0 deletions justfile
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
42 changes: 42 additions & 0 deletions scripts/pre-push
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

0 comments on commit 95ed4ed

Please sign in to comment.