Added pre-commit hook

develop
Jef Roosens 2020-08-28 13:15:08 +02:00
parent c9700618f7
commit 5855c931ca
2 changed files with 24 additions and 2 deletions

View File

@ -0,0 +1,11 @@
#!/bin/sh
#
# This hooks runs tests and checks if the linter doesn't hate you
# Linting
printf "flake8....."
make lint > /dev/null 2>&1 && printf "OK!\n" || { printf "Fail." && exit 1; }
# Running tests
printf "pytest....."
make test > /dev/null 2>&1 && printf "OK!\n" || { printf "Fail." && exit 1; }

View File

@ -10,7 +10,7 @@ DOCS=docs
# Interpreter to create venv with
INTERPRETER=python3.8
all: run
all: build-venv
# =====VENV=====
@ -38,10 +38,13 @@ clean-cache:
@ echo "Removing caches..."
@ find . -type d \( -name "__pycache__" -o -name ".pytest_cache" \) -exec rm -r "{}" +
# Removed generation documentation
clean-docs:
@ echo "Removing documentation build..."
@ [ ! -e "$(DOCS)/build" ] || rm -r "$(DOCS)/build"
@ [ ! -e "$(DOCS)/source/apidoc" ] || rm -r "$(DOCS)/source/apidoc"
# Remove build leftovers (not dist)
clean-setup:
@ echo 'Removing build artifacts...'
@ [ ! -e "build" ] || rm -rf build
@ -49,14 +52,22 @@ clean-setup:
# =====DOCS=====
# # Generate documentation
docs: docs/source/conf.py docs/source/index.rst build-venv
@ "$(VENV)/bin/sphinx-apidoc" -f -o "$(DOCS)/source/apidoc" "$(SRC)"
@ "$(VENV)/bin/sphinx-build" "$(DOCS)/source" "$(DOCS)/build"
# =====TESTS=====
# Run tests
test: pytest.ini build-venv
@ "$(VENV)/bin/pytest" --color=yes
@ "$(VENV)/bin/pytest" --color=auto
# =====LINTING=====
# Run flake8
lint: build-venv
@ "$(VENV)/bin/flake8" "$(SRC)"/**/*.py
# =====PACKAGING=====