-
-
Notifications
You must be signed in to change notification settings - Fork 49
/
Copy pathMakefile
103 lines (77 loc) · 2.94 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
DOCKERFILE_PATH = ./api/Dockerfile
API_DIR = ./api
PKG_DIR = .
DEMO_DIR = ./demo
DOCS_DIR = ./docs
PKG_CONFIG_FILE = ${PKG_DIR}/pyproject.toml
PKG_TEST_DIR = ${PKG_DIR}/tests
API_CONFIG_FILE = ${API_DIR}/pyproject.toml
API_LOCK_FILE = ${API_DIR}/uv.lock
API_REQ_FILE = ${API_DIR}/requirements.txt
DEMO_REQ_FILE = ${DEMO_DIR}/requirements.txt
DEMO_SCRIPT = ${DEMO_DIR}/app.py
DOCKER_NAMESPACE ?= holocron
DOCKER_REPO ?= backend
DOCKER_TAG ?= latest
########################################################
# Code checks
########################################################
install-quality: ${PKG_CONFIG_FILE}
uv pip install --system -e ".[quality]"
pre-commit install
lint-check: ${PKG_CONFIG_FILE}
ruff format --check . --config ${PKG_CONFIG_FILE}
ruff check . --config ${PKG_CONFIG_FILE}
lint-format: ${PKG_CONFIG_FILE}
ruff format . --config ${PKG_CONFIG_FILE}
ruff check --fix . --config ${PKG_CONFIG_FILE}
precommit: ${PKG_CONFIG_FILE} .pre-commit-config.yaml
pre-commit run --all-files
typing-check: ${PKG_CONFIG_FILE}
mypy --config-file ${PKG_CONFIG_FILE}
deps-check: .github/verify_deps_sync.py
python .github/verify_deps_sync.py
# this target runs checks on all files
quality: lint-check typing-check deps-check
style: lint-format precommit
########################################################
# Build
########################################################
# PACKAGE
install: ${PKG_CONFIG_FILE}
uv pip install --system -e .
# TESTS
install-test: ${PKG_CONFIG_FILE}
uv pip install --system -e ".[test]"
test: install-test ${PKG_TEST_DIR}
pytest --cov=holocron tests/
# DEMO
install-demo: ${DEMO_REQ_FILE}
uv pip install --system -r ${DEMO_REQ_FILE}
run-demo: install-demo ${DEMO_SCRIPT}
python ${DEMO_SCRIPT} --port 8080
# DOCS
install-docs: ${PKG_CONFIG_FILE}
uv pip install --system -e ".[docs]"
docs-latest: install-docs ${DOCS_DIR}
sphinx-build ${DOCS_DIR}/source ${DOCS_DIR}/_build -a
docs-full: install-docs ${DOCS_DIR}
cd ${DOCS_DIR} && bash build.sh
# API
lock: ${API_CONFIG_FILE}
uv lock --project ${API_DIR}
req: ${API_CONFIG_FILE} ${PYTHON_LOCK_FILE}
uv export --no-hashes --locked --no-dev -q -o ${API_REQ_FILE} --project ${API_DIR}
build-api: req ${DOCKERFILE_PATH}
docker build --platform linux/amd64 ${API_DIR} -t ${DOCKER_NAMESPACE}/${DOCKER_REPO}:${DOCKER_TAG}
push-api: build-api
docker push ${DOCKER_NAMESPACE}/${DOCKER_REPO}:${DOCKER_TAG}
start-api: build-api ${API_DIR}/docker-compose.yml
docker compose -f ${API_DIR}/docker-compose.yml up -d --wait
stop-api: ${API_DIR}/docker-compose.yml
docker compose -f ${API_DIR}/docker-compose.yml down
test-api: ${API_CONFIG_FILE} ${PYTHON_LOCK_FILE} ${DOCKERFILE_PATH} ${API_DIR}/tests
uv export --no-hashes --locked --extra test -q -o ${API_REQ_FILE} --project ${API_DIR}
docker compose -f ${API_DIR}/docker-compose.yml up -d --wait --build
- docker compose -f ${API_DIR}/docker-compose.yml exec -T backend pytest tests/
docker compose -f ${API_DIR}/docker-compose.yml down