forked from vkbottle/vkbottle
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
68 lines (56 loc) · 2.04 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
# Treat these arguments not as files, but as recipes
.PHONY: venv venv-no-dev githooks check fix publish autoflake_fix
# Used to execute all in one shell
.ONESHELL:
# Default recipe
DEFAULT: help
help:
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'
# Use poetry or activated venv
interpreter := $(shell poetry env info --path > /dev/null 2>&1 && echo "poetry run")
check-venv:
$(if $(interpreter),, $(error No poetry environment found, either run "make venv"))
venv: ## Create virtual environment and install all dependencies
@python3 -m pip install poetry
@poetry install && \
echo; echo "Poetry created virtual environment and installed all dependencies"
venv-no-dev: ## Create virtual environment and install only prod dependencies
@python3 -m pip install poetry
@poetry install --without dev && \
echo; echo "Poetry created virtual environment and installed only prod dependencies"
githooks: check-venv ## Install git hooks
@$(interpreter) pre-commit install -t=pre-commit -t=pre-push
check: check-venv ## Run tests and linters
@echo "flakeheaven"
@echo "======"
@$(interpreter) flakeheaven lint
@echo ; echo "black"
@echo "====="
@$(interpreter) black --check .
@echo ; echo "isort"
@echo "====="
@$(interpreter) isort --check-only .
@echo ; echo "mypy"
@echo "===="
@$(interpreter) mypy vkbottle
@echo ; echo "pytest"
@echo "======"
@$(interpreter) pytest --cov vkbottle vkbottle
autoflake_fix:
@$(interpreter) autoflake -i --remove-all-unused-imports $(filename)
fix: check-venv ## Fix code with black and autoflake
@echo "autoflake"
@echo "========="
@$(interpreter) autoflake -ri --remove-all-unused-imports .
@echo "black"
@echo "====="
@$(interpreter) black .
@echo ; echo "isort"
@echo "====="
@$(interpreter) isort .
publish: ## Publish to PyPi using PYPI_TOKEN
poetry build
@poetry config pypi-token.pypi ${PYPI_TOKEN}
@# "; true" is used to ignore command exit code so that rm -rf can execute anyway
poetry publish; true
rm -rf dist/