-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathMakefile
More file actions
80 lines (58 loc) · 2.34 KB
/
Makefile
File metadata and controls
80 lines (58 loc) · 2.34 KB
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
# Delete target on error.
# https://www.gnu.org/software/make/manual/html_node/Errors.html#Errors
# > This is almost always what you want make to do, but it is not historical
# > practice; so for compatibility, you must explicitly request it
.DELETE_ON_ERROR:
REQUIREMENTS_PATH ?= requirements/dev.txt
VIRTUAL_ENV ?= .venv
export PATH := $(VIRTUAL_ENV)/bin:$(PATH)
# Python dependencies
# =============================================================================
.PHONY: venv compile-deps
$(VIRTUAL_ENV): $(REQUIREMENTS_PATH)
uv venv
uv pip sync --require-hashes $^
touch $@
venv: $(VIRTUAL_ENV)
PIP_COMPILE_FLAGS := --generate-hashes $(PIP_COMPILE_OPTIONS)
compile-deps: $(VIRTUAL_ENV)
uv pip compile $(PIP_COMPILE_FLAGS) -o requirements/base.txt requirements/base.in
uv pip compile $(PIP_COMPILE_FLAGS) -o requirements/test.txt requirements/test.in
uv pip compile $(PIP_COMPILE_FLAGS) -o requirements/dev.txt requirements/dev.in
# Django
# =============================================================================
.PHONY: runserver
runserver: $(VIRTUAL_ENV)
python manage.py runserver $(RUNSERVER_DOMAIN)
# Quality
# =============================================================================
.PHONY: clean quality fast_fix fix
LINTER_CHECKED_DIRS := config pilotage tests
clean:
find . -type d -name "__pycache__" -depth -exec rm -rf '{}' \;
quality: $(VIRTUAL_ENV)
ruff format --check $(LINTER_CHECKED_DIRS)
ruff check $(LINTER_CHECKED_DIRS)
djlint --lint --check $(LINTER_CHECKED_DIRS)
python manage.py makemigrations --check --dry-run --noinput || (echo "⚠ Missing migration ⚠"; exit 1)
python manage.py collectstatic --no-input
fast_fix: $(VIRTUAL_ENV)
ruff format $(LINTER_CHECKED_DIRS)
ruff check --fix $(LINTER_CHECKED_DIRS)
fix: fast_fix
djlint --reformat pilotage
# Tests.
# =============================================================================
.PHONY: test
test: $(VIRTUAL_ENV)
pytest --create-db $(TARGET)
# Snapshot update
# =============================================================================
.PHONY: snapshot
snapshot: $(VIRTUAL_ENV)
pytest --snapshot-update $(TARGET)
# Deployment
# =============================================================================
.PHONY: deploy_prod
deploy_prod:
git fetch origin && git push origin origin/staging:main # Deploy by pushing the latest `staging` to `main`