-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
107 lines (79 loc) · 2.67 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
include .env
export HOST_PORT
export PORT
PROJECT_NAME := "indexes"
TAG_TESTS := indexes-tests
TAG_LINT := indexes-lint
TAG_PROD := indexes-prod
clean:
rm -rf .venv
rm -rf build
rm -rf Indexes.egg-info
# Use this only for Dockerfile
install-dev:
uv pip install --python=/usr/local/bin/python .[test,lint,debug]
install:
uv pip install --system --python=/usr/local/bin/python .
run-cov: install-dev
coverage run --branch --source=indexes -m pytest -ssvv tests
coverage report -m --fail-under=70
run-lint: install-dev
ruff check indexes tests
ruff format --check .
mypy --strict indexes tests # Why "." is not working? ):
run-dev: install-dev
uvicorn indexes.main:app --host $(HOST) --port $(PORT) --reload
run: install
rm -rf Indexes.egg-info/ build/
uvicorn indexes.main:app --host $(HOST) --port $(PORT)
# Use this for local development without Docker.
# Check if .venv exists before creating it and installing dependencies
.venv/bin/activate: pyproject.toml
uv venv
install-venv-dev: .venv/bin/activate
. .venv/bin/activate && uv pip install .[test,lint,debug]
run-venv-cov: install-venv-dev
. .venv/bin/activate \
&& coverage run --branch --source=app -m pytest -ssvv tests \
&& coverage report -m --fail-under=90
run-venv-cov-html: install-venv-dev
. .venv/bin/activate \
&& coverage run --branch --source=app -m pytest -ssvv tests \
&& coverage html --fail-under=90
run-venv-dev: install-venv-dev
. .venv/bin/activate && uvicorn indexes.main:app --host $(HOST) --port $(PORT) --reload
run-venv-pytest: install-venv-dev
. .venv/bin/activate && pytest -ssvv
run-venv-mypy: install-venv-dev
. .venv/bin/activate && mypy --strict indexes tests # Why "." is not working? ):
run-venv-ruff-check: install-venv-dev
. .venv/bin/activate && ruff check indexes tests
run-venv-ruff-fix: install-venv-dev
. .venv/bin/activate && ruff check indexes tests --fix
run-venv-ruff-format: install-venv-dev
. .venv/bin/activate && ruff format
run-venv-lint: install-venv-dev
. .venv/bin/activate \
&& ruff check indexes tests \
&& ruff format --check . \
&& mypy --strict indexes tests # Why "." is not working? ):
# Run service into Docker
docker-lint-build:
docker build \
--tag=$(TAG_LINT) \
--target=run-lint .
docker-lint-run: docker-lint-build
docker run --name $(TAG_LINT) --rm $(TAG_LINT)
docker-tests-build:
docker build \
--tag=$(TAG_TESTS) \
--target=tests-run .
docker-tests-run: docker-tests-build
docker run --name $(TAG_TESTS) --rm $(TAG_TESTS)
docker-prod-build:
docker build \
--tag=$(TAG_PROD) \
--target=run .
docker-prod-run: docker-prod-build
docker rm -f $(TAG_PROD) || true
docker run -p $(HOST_PORT):$(PORT) --detach --name $(TAG_PROD) $(TAG_PROD)