This repository has been archived by the owner on Jul 1, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
90 lines (66 loc) · 2.99 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
# This Makefile is based on the Makefile defined in the Python Best Practices repository:
# https://git.datapunt.amsterdam.nl/Datapunt/python-best-practices/blob/master/dependency_management/
#
# VERSION = 2020.01.29
.PHONY = help pip-tools install requirements update test init
UID:=$(shell id --user)
GID:=$(shell id --group)
dc = docker-compose
run = $(dc) run --rm -u ${UID}:${GID}
manage = $(run) dev python manage.py
pytest = $(run) test pytest $(ARGS)
build_version := $(shell git describe --tags --exact-match 2> /dev/null || git symbolic-ref -q --short HEAD)
build_revision := $(shell git rev-parse --short HEAD)
build_date := $(shell date --iso-8601=seconds)
init: clean build migrate ## Init clean
help: ## Show this help.
@fgrep -h "##" $(MAKEFILE_LIST) | fgrep -v fgrep | sed -e 's/\\$$//' | sed -e 's/##//'
pip-tools:
pip install pip-tools
install: pip-tools ## Install requirements and sync venv with expected state as defined in requirements.txt
pip-sync requirements_dev.txt
requirements: pip-tools ## Upgrade requirements (in requirements.in) to latest versions and compile requirements.txt
pip-compile --upgrade --output-file requirements.txt requirements.in
pip-compile --upgrade --output-file requirements_dev.txt requirements_dev.in
upgrade: requirements install ## Run 'requirements' and 'install' targets
migrations: ## Make migrations
$(manage) makemigrations $(ARGS)
migrate: ## Migrate
$(manage) migrate
urls:
$(manage) show_urls
build: export BUILD_DATE=$(build_date)
build: export BUILD_REVISION=$(build_revision)
build: export BUILD_VERSION=$(build_version)
build: ## Build docker image
$(dc) build
push: build ## Push docker image to registry
$(dc) push
push_semver:
VERSION=$${VERSION} $(MAKE) push
VERSION=$${VERSION%\.*} $(MAKE) push
VERSION=$${VERSION%%\.*} $(MAKE) push
app: ## Run app
$(run) --service-ports app
bash: ## Run the container and start bash
$(run) dev bash
shell:
$(manage) shell_plus --print-sql
dev: ## Run the development app (and run extra migrations first)
$(run) --service-ports dev
lint: ## Execute lint checks
$(run) test isort /app/src /app/tests --check --diff
$(run) test black /app/src /app/tests --check --diff
lintfix: ## Execute lint checks
$(run) test isort /app/src /app/tests
$(run) test black /app/src /app/tests
test: lint ## Execute tests
$(run) test pytest /app/tests $(ARGS)
pdb:
$(run) test pytest --pdb $(ARGS)
superuser: ## Create a superuser (user with admin rights)
$(manage) createsuperuser
clean: ## Clean docker stuff
$(dc) down -v --remove-orphans
env: ## Print current env
env | sort