-
Notifications
You must be signed in to change notification settings - Fork 3
/
Makefile
66 lines (54 loc) · 1.85 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
# Treat these arguments not as files, but as recipes
.PHONY: venv venv-prod githooks check 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-prod: ## 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 "flake8"
@echo "------"
@$(interpreter) pflake8 .
@echo ; echo "black"
@echo "-----"
@$(interpreter) black --check .
@echo ; echo "isort"
@echo "----"
@$(interpreter) isort --check-only .
@echo ; echo "mypy"
@echo "----"
@$(interpreter) mypy .
@echo ; echo "pytest"
@echo "------"
@$(interpreter) pytest
fix: check-venv ## Fix code with black and isort
@echo "black"
@echo "-----"
@$(interpreter) black .
@echo ; echo "isort"
@echo "-----"
@$(interpreter) isort .
create-docs: check-venv
@echo "Generate documentation"
@echo "----------------------"
@sphinx-apidoc -f -o docs anicli_api/ anicli_api/extractors/* anicli_api/decoders/*
@echo "generate html"
@echo "-------------"
@make -C docs clean html
update-docs: check-venv
@make -C docs clean html