-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathMakefile
68 lines (60 loc) · 2.19 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
PROJECT=fastapi-ml-scaffolding
PYTHON_VERSION=3.8.0
SOURCE_OBJECTS=app tests
deploy.requirements:
poetry export -f requirements.txt -o requirements.txt
poetry export --dev -f requirements.txt -o requirements-dev.txt
deploy:
poetry build
format.black:
poetry run black ${SOURCE_OBJECTS}
format.isort:
poetry run isort --atomic ${SOURCE_OBJECTS}
format: format.isort format.black
lints.format.check:
poetry run black --check ${SOURCE_OBJECTS}
poetry run isort --check-only ${SOURCE_OBJECTS}
lints.flake8:
git diff --diff-filter=d --name-only origin/development -- '*.py' | xargs poetry run flake8 --ignore=DAR,E203,W503
lints.flake8.strict:
poetry run flake8
lints.mypy:
poetry run mypy ${SOURCE_OBJECTS}
lints.pylint:
poetry run pylint --rcfile pyproject.toml ${SOURCE_OBJECTS}
lints: lints.flake8
lints.strict: lints lints.pylint lints.flake8.strict lints.mypy
setup: setup.python setup.sysdep.poetry setup.project
setup.uninstall: setup.python
poetry env remove ${PYTHON_VERSION} || true
setup.ci: setup.ci.poetry setup.project
setup.ci.poetry:
pip install poetry
setup.project:
@poetry env use $$(python -c "import sys; print(sys.executable)")
@echo "Active interpreter path: $$(poetry env info --path)/bin/python"
poetry install
setup.python.activation:
@pyenv local ${PYTHON_VERSION} >/dev/null 2>&1 || true
@asdf local python ${PYTHON_VERSION} >/dev/null 2>&1 || true
setup.python: setup.python.activation
@echo "Active Python version: $$(python --version)"
@echo "Base Interpreter path: $$(python -c 'import sys; print(sys.executable)')"
@test "$$(python --version | cut -d' ' -f2)" = "${PYTHON_VERSION}" \
|| (echo "Please activate python ${PYTHON_VERSION}" && exit 1)
setup.sysdep.poetry:
@command -v poetry \&> /dev/null \
|| (echo "Poetry not found. \n Installation instructions: https://python-poetry.org/docs/" \
&& exit 1)
test:
docker-compose up unit-tests
test.clean:
docker-compose down
-docker images -a | grep ${PROJECT} | awk '{print $3}' | xargs docker rmi
-docker image prune -f
test.shell:
docker-compose run unit-tests /bin/bash
test.shell.debug:
docker-compose run --entrypoint /bin/bash unit-tests
test.local: setup
poetry run coverage run -m pytest