diff --git a/scripts/build-docs.sh b/scripts/build-docs.sh new file mode 100644 index 0000000..138ea02 --- /dev/null +++ b/scripts/build-docs.sh @@ -0,0 +1,2 @@ +# Build html doc +pipenv run make html diff --git a/scripts/install-hooks.sh b/scripts/install-hooks.sh new file mode 100644 index 0000000..835e729 --- /dev/null +++ b/scripts/install-hooks.sh @@ -0,0 +1,9 @@ +#!/usr/bin/env bash + +GIT_DIR="$(git rev-parse --git-dir)" + +echo "Installing hooks..." +ln -s ../../scripts/pre-commit.sh $GIT_DIR/hooks/pre-commit +echo "Done" + + diff --git a/scripts/pre-commit.sh b/scripts/pre-commit.sh new file mode 100644 index 0000000..049c783 --- /dev/null +++ b/scripts/pre-commit.sh @@ -0,0 +1,23 @@ +#!/usr/bin/env bash + +cdroot() { + cd "${0%/*}/.." +} + + +echo "Running pre-commit hook" +./scripts/run-tests.sh + +if [ $? -ne 0 ]; then + echo "Tests must pass before commit!" + exit 1 +fi + +./scripts/build-docs.sh + +if [ $? -ne 0 ]; then + echo "Doc must pass before commit!" + exit 1 +fi + +echo "Done." diff --git a/scripts/run-tests.sh b/scripts/run-tests.sh new file mode 100644 index 0000000..5594408 --- /dev/null +++ b/scripts/run-tests.sh @@ -0,0 +1,13 @@ +#!/usr/bin/env bash + +# if any command inside script returns error, exit and return that error +set -e + + +cd "${0%/*}/.." + + +echo "Running tests" +# Run test and ignore warnings +pipenv run pytest -p no:warnings +