-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
113 lines (93 loc) · 2.78 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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
-include .env
APP=$(PIPO_APP)
CONFIG_PATH=pyproject.toml
POETRY=poetry
POETRY_VERSION=1.8.4
PRINT=python -c "import sys; print(str(sys.argv[1]))"
DOCUMENTATION=docs
DIAGRAMS_FORMAT=plantuml
TEST_FOLDER=./tests
TEST_SECRETS:=$(shell realpath $(TEST_FOLDER)/.secrets.*)
.PHONY: help
help:
$(PRINT) "Usage:"
$(PRINT) " help show this message"
$(PRINT) " poetry_setup install poetry to manage python envs and workflows"
$(PRINT) " setup build virtual environment and install dependencies"
$(PRINT) " test_setup build virtual environment and install test dependencies"
$(PRINT) " dev_setup build virtual environment and install dev dependencies"
$(PRINT) " lint run dev utilities for code quality assurance"
$(PRINT) " format run dev utilities for code format assurance"
$(PRINT) " docs generate code documentation"
$(PRINT) " test run test suite"
$(PRINT) " coverage run coverage analysis"
$(PRINT) " set_version set program version"
$(PRINT) " dist package application for distribution"
$(PRINT) " image build app docker image"
$(PRINT) " run_image run app docker image in a container"
$(PRINT) " run_app run docker compose"
.PHONY: poetry_setup
poetry_setup:
curl -sSL https://install.python-poetry.org | python - --version $(POETRY_VERSION)
poetry config virtualenvs.in-project true --local
.PHONY: setup
setup:
$(POETRY) install -n --all-extras --without dev
.PHONY: test_setup
test_setup:
$(POETRY) install -n --all-extras
.PHONY: dev_setup
dev_setup:
$(POETRY) install -n --all-extras --with docs
.PHONY: update_deps
update_deps:
$(POETRY) update
.PHONY: ruff
ruff:
-$(POETRY) run ruff check .
.PHONY: format
format:
-$(POETRY) run ruff format .
.PHONY: vulture
vulture:
-$(POETRY) run vulture
.PHONY: metrics
metrics:
$(POETRY) run radon cc -a -s -o SCORE $(APP)
$(POETRY) run radon raw -s $(APP)
$(POETRY) run radon mi -s $(APP)
.PHONY: lint
lint: ruff vulture
.PHONY: test
test:
if [ -f $(TEST_SECRETS) ]; then \
export SECRETS_FOR_DYNACONF=$(TEST_SECRETS) && $(POETRY) run pytest; \
else \
$(POETRY) run pytest; \
fi
.PHONY: coverage
coverage:
$(POETRY) run coverage report -m
.PHONY: docs
docs:
mkdir -p $(DOCUMENTATION)/_static $(DOCUMENTATION)/_diagrams/src
$(POETRY) run pyreverse -p $(APP) \
--colorized \
-o $(DIAGRAMS_FORMAT) \
-d $(DOCUMENTATION)/_diagrams/src $(APP)
$(POETRY) run make -C $(DOCUMENTATION) html
.PHONY: set_version
set_version:
$(POETRY) version $$VERSION
.PHONY: dist
dist:
$(POETRY) dist
.PHONY: image
image: docs
docker build . -t $(APP):latest
.PHONY: run_image
run_image: image
docker run -d --name $(APP) --env-file .env $(APP):latest
.PHONY: run_app
run_app:
docker compose up -d --build --remove-orphans