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