-
Notifications
You must be signed in to change notification settings - Fork 2
/
Makefile
102 lines (75 loc) · 2.63 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
# 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:
# Global tasks.
# =============================================================================
PYTHON_VERSION := python3.11
PGDATABASE ?= inclusion_connect
ifeq ($(shell uname -s),Linux)
REQUIREMENTS_PATH := requirements/dev.txt
else
REQUIREMENTS_PATH := requirements/dev-mac.txt
endif
PY_PACKAGES := \
inclusion_connect \
tests
VIRTUAL_ENV ?= .venv
export PATH := $(VIRTUAL_ENV)/bin:$(PATH)
.PHONY: run venv clean quality fix pylint compile-deps
# Run Docker images
run:
docker compose up
runserver: $(VIRTUAL_ENV)
$(VIRTUAL_ENV)/bin/python manage.py runserver
$(VIRTUAL_ENV): $(REQUIREMENTS_PATH)
$(PYTHON_VERSION) -m venv $@
$@/bin/pip install uv
$@/bin/uv pip sync --require-hashes $^
touch $@
venv: $(VIRTUAL_ENV)
PIP_COMPILE_FLAGS := --no-strip-extras --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/dev.txt requirements/dev.in
clean:
find . -type d -name "__pycache__" -depth -exec rm -rf '{}' \;
quality: $(VIRTUAL_ENV)
ruff format --check $(PY_PACKAGES)
ruff check $(PY_PACKAGES)
djlint --lint --check inclusion_connect
python manage.py makemigrations --check --dry-run --noinput
fix: $(VIRTUAL_ENV)
ruff format $(PY_PACKAGES)
ruff check --fix $(PY_PACKAGES)
djlint --reformat inclusion_connect
pylint: $(VIRTUAL_ENV)
pylint $(PY_PACKAGES)
# Django.
# =============================================================================
.PHONY: django_admin populate_db
# make django_admin
# make django_admin COMMAND=dbshell
# make django_admin COMMAND=createsuperuser
django_admin:
django-admin $(COMMAND)
populate_db:
bash -c "ls -d inclusion_connect/fixtures/django/* | xargs ./manage.py loaddata"
# Tests.
# =============================================================================
.PHONY: coverage test
test: $(VIRTUAL_ENV)
pytest --numprocesses=logical --create-db --verbosity=2 $(TARGET)
coverage: $(VIRTUAL_ENV)
coverage run -m pytest --create-db
# Docker shell.
# =============================================================================
.PHONY: shell_on_postgres_container
shell_on_postgres_container:
docker exec -ti inclusion_connect_postgres /bin/bash
# Deployment
# =============================================================================
.PHONY: deploy_prod
deploy_prod:
./scripts/deploy_prod.sh