Added opinionated project config

This commit is contained in:
Jef Roosens 2021-05-18 08:57:40 +02:00
parent 2dde3cfe05
commit 4e35509619
Signed by: Jef Roosens
GPG key ID: 955C0660072F691F
10 changed files with 74 additions and 31 deletions

View file

@ -1,41 +1,51 @@
# =====CONFIG=====
PYTHON := python3.9
# This can't contain spaces (I think)
VENV := venv
VENV := .venv
# Minimum % coverage for tests to succeed
MIN_COV := 10
# By default, just create the venv when needed
all: venv
# Create the venv
$(VENV)/bin/activate: requirements.txt requirements-dev.txt
# =====RECIPES=====
## VENV
### Create the venv
$(VENV)/bin/activate: setup.py setup.cfg
@ '$(PYTHON)' -m venv '$(VENV)'
@ '$(VENV)'/bin/pip install -r requirements.txt -r requirements-dev.txt
@ '$(VENV)'/bin/pip install -e .[develop]
# Convenient alias for the venv
### Convenient alias for the venv
venv: $(VENV)/bin/activate
.PHONY: venv
## Formatting & linting
format: venv
'$(VENV)'/bin/black setup.py app
.PHONY: format
lint: venv
'$(VENV)'/bin/flake8 setup.py app
.PHONY: lint
## Testing
test: venv
'$(VENV)'/bin/pytest --cov=app --cov-fail-under='$(MIN_COV)' tests/
.PHONY: test
## Cleaning
# Remove the venv
clean:
@ rm -rf '$(VENV)'
.PHONY: clean
# Run the Flask server
# TODO
run: venv
# Format the codebase using black
format: venv
@ '$(VENV)/bin/python' -m black src
# Lint the codebase using flake8
lint: venv
@ '$(VENV)/bin/python' -m flake8 src
# Run rests using pytest
# TODO
test: venv