-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
95 lines (76 loc) · 2.96 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
# Source: http://clarkgrubb.com/makefile-style-guide
MAKEFLAGS += --warn-undefined-variables
.DEFAULT_GOAL := help
PIP_COMPILE = CUSTOM_COMPILE_COMMAND='make pip-compile' python -m piptools compile \
--resolver=backtracking \
--allow-unsafe \
--strip-extras \
--quiet
.PHONY: install
install: ## Install app dependencies
python -m pip install pip-tools -c requirements/constraints.txt
python -m piptools sync --pip-args "--no-deps" requirements/main.txt
.PHONY: install-dev
install-dev: ## Install app dependencies (including dev)
python -m pip install pip-tools -c requirements/constraints.txt
python -m piptools sync --pip-args "--no-deps" requirements/main.txt requirements/dev.txt
.PHONY: pip-compile
pip-compile: ## Compile requirements files
@$(PIP_COMPILE) --generate-hashes requirements/main.in
@$(PIP_COMPILE) --generate-hashes requirements/dev.in
@$(PIP_COMPILE) --output-file requirements/constraints.txt requirements/main.txt requirements/dev.txt
.PHONY: upgrade-package
upgrade-package: ## Upgrade Python package (pass "package=<PACKAGE_NAME>")
@$(PIP_COMPILE) --generate-hashes --upgrade-package $(package) requirements/main.in
@$(PIP_COMPILE) --generate-hashes --upgrade-package $(package) requirements/dev.in
@$(PIP_COMPILE) --output-file requirements/constraints.txt requirements/main.txt requirements/dev.txt
.PHONY: upgrade-all
upgrade-all: ## Upgrade all Python packages
@$(PIP_COMPILE) --generate-hashes --upgrade requirements/main.in
@$(PIP_COMPILE) --generate-hashes --upgrade requirements/dev.in
@$(PIP_COMPILE) --output-file requirements/constraints.txt requirements/main.txt requirements/dev.txt
.PHONY: run
run: ## Run the app
python src/manage.py runserver
.PHONY: create-migration
create-migration: ## Create Django migration (pass "name=<MIGRATION_NAME>")
python src/manage.py makemigrations -n $(name)
.PHONY: apply-migrations
apply-migrations: ## Apply Django migrations
python src/manage.py migrateć
.PHONY: format
format: ## Format code
black src/ tests/ noxfile.py
isort src/ tests/ noxfile.py
ruff check --fix src/ tests/ noxfile.py
.PHONY: test
test: ## Run the test suite
docker compose up --detach db
nox
.PHONY: docs-build
docs-build: ## Build docs
mkdocs build
.PHONY: docs-serve
docs-serve: ## Serve docs
mkdocs serve
.PHONY: docker-build
docker-build: ## Build Docker compose stack
docker compose build
.PHONY: docker-run
docker-run: ## Run Docker compose stack
docker compose up app
.PHONY: docker-stop
docker-stop: ## Stop Docker compose stack
docker compose down
.PHONY: docker-shell
docker-shell: ## Run bash inside dev Docker image
docker compose run --rm dev /bin/bash
.PHONY: clean
clean: ## Clean dev artifacts
rm -rf .coverage coverage.xml .mypy_cache/ .nox/ .pytest_cache/ .ruff_cache/ staticfiles/ htmlcov/ site/
# Source: https://www.client9.com/self-documenting-makefiles/
.PHONY: help
help: ## Show help message
@awk -F ':|##' '/^[^\t].+?:.*?##/ {\
printf "\033[36m%-40s\033[0m %s\n", $$1, $$NF \
}' $(MAKEFILE_LIST)