Ajout des hooks de precommit pour vérifier la doc et les tests avant tout commit (il faut executer scripts/install-hooks.sh)

This commit is contained in:
Louis Chauvet 2020-04-14 03:22:13 +02:00
parent 190a7b9be8
commit 5f72e036a5
Signed by: fomys
GPG Key ID: 1ECA046A9615ABA0
4 changed files with 47 additions and 0 deletions

2
scripts/build-docs.sh Normal file
View File

@ -0,0 +1,2 @@
# Build html doc
pipenv run make html

9
scripts/install-hooks.sh Normal file
View File

@ -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"

23
scripts/pre-commit.sh Normal file
View File

@ -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."

13
scripts/run-tests.sh Normal file
View File

@ -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