-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
137 lines (111 loc) · 4.46 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
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
.DEFAULT_GOAL := help
## toggle-prod: configure make to use the production stack
.Phony: toggle-prod
toggle-prod:
@ln -sf production.yml docker-compose.yaml
## toggle-local: configure make to use the local stack
.Phony: toggle-local
toggle-local:
@ln -sf local.yml docker-compose.yaml
# Since toggle-(local|prod) are phony targets, this file is not tracked
# to compare if its "newer" so running another target with this as a prereq
# will not run this target again. That would overwrite docker-compose.yaml back to local.yml
# no matter what, which is bad. Phony targets prevents this
## docker-compose.yaml: creates file docker-compose.yaml on first run (as a prereq)
docker-compose.yaml:
@ln -sf local.yml docker-compose.yaml
## behave-all: runs behave inside the containers against all of your features
.Phony: behave-concerts
behave-concerts: docker-compose.yaml
@docker compose run django python manage.py behave --no-input --simple --no-capture concerts/tests/features/
## behave: runs behave inside the containers against a specific feature (append FEATURE=feature_name_here)
.Phony: behave
behave: docker-compose.yaml
@docker compose run django python manage.py behave --no-input --simple --no-capture concerts/tests/features/ -i $(FEATURE)
## build: rebuilds all your containers or a single one if CONTAINER is specified
.Phony: build
build: docker-compose.yaml
@docker compose up -d --no-deps --build $(CONTAINER)
@docker compose restart $(CONTAINER)
## coverage.xml: generate coverage from test runs
coverage.xml: pytest behave-all
@docker compose run django coverage report
@docker compose run django coverage xml
## ci-test: runs all tests just like Gitlab CI does
.Phony: ci-test
ci-test: | toggle-local build migrate run coverage.xml
## cleanup: remove local containers and volumes
.Phony: clean
clean: docker-compose.yaml
@docker compose rm -f -s
@docker volume prune -f
## collect-static: run collect static admin command
.Phony: collectstatic
collectstatic: docker-compose.yaml
@docker compose run django python manage.py collectstatic
## django-addr: get the IP and ephemeral port assigned to docker:8000
.Phony: django-addr
django-addr: docker-compose.yaml
@docker compose port django 8000
## django-url: get the URL based on http://$(make django-addr)
.Phony: django-url
django-url: docker-compose.yaml
@echo http://$$(make django-addr)
## django-open: open a browser for http://$(make django-addr)
.Phony: django-open
django-open: docker-compose.yaml
@open http://$$(make django-addr)
## down: turn down docker compose stack
.Phony: down
down: docker-compose.yaml
@docker compose down
## exec: executes a given command on a given container (append CONTAINER=container_name_here and COMMAND=command_here)
.Phony: exec
exec: docker-compose.yaml
@docker compose exec $(CONTAINER) $(COMMAND)
## generate-data: generates some test data of all types (users, artists, venues, concerts, concert reviews)
.Phony: generate-data
generate-data:
@docker compose run django python manage.py generate_test_data
# This automatically builds the help target based on commands prepended with a double hashbang
## help: print this help output
.Phony: help
help: Makefile
@sed -n 's/^##//p' $<
## tail-log: tail a docker container's logs (append CONTAINER=container_name_here)
.Phony: tail-log
tail-log: docker-compose.yaml
@docker compose logs -f $(CONTAINER)
## migrate: makemigrations and then migrate
.Phony: migrate
migrate: docker-compose.yaml
@docker compose run django python manage.py makemigrations
@docker compose run django python manage.py migrate
## musicbrainz: lookup musicbrainz IDs for artists missing them
.Phony: musicbrainz
musicbrainz:
@docker compose run django python manage.py musicbrainz_lookup
## pytest: runs pytest inside the containers
.Phony: pytest
pytest: docker-compose.yaml
@docker compose run django coverage run -m pytest
## run: brings up the containers as described in docker-compose.yaml
.Phony: run
run: docker-compose.yaml
@docker compose up -d
## stop: turns off running containers
.Phony: stop
stop: docker-compose.yaml
@docker compose stop
## type-check: static type checking
.Phony: type-check
type-check: docker-compose.yaml
@docker compose run django mypy scram
## pass-reset: change admin's password
.Phony: pass-reset
pass-reset: docker-compose.yaml
@docker compose run django python manage.py changepassword admin
## superuser: create an admin account
.Phony: superuser
superuser: docker-compose.yaml
@docker compose run django python manage.py createsuperuser