-
Notifications
You must be signed in to change notification settings - Fork 4
/
Makefile
155 lines (126 loc) · 5.18 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
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
# It'd be nice to keep these in sync with the defaults of the Dockerfiles
PYTHON_IMAGE_VER ?= 3.12
POSTGRES_IMAGE_VER ?= 12.3
.DEFAULT_GOAL := help
## toggle-prod: configure make to use the production stack
.Phony: toggle-prod
toggle-prod:
@ln -sf compose.override.production.yml compose.override.yml
## toggle-local: configure make to use the local stack
.Phony: toggle-local
toggle-local:
@ln -sf compose.override.local.yml compose.override.yml
# 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 compose.override.yml back to compose.override.local.yml no
# matter what, which is bad. Phony targets prevents this
## compose.override.yml: creates file compose.override.yml on first run (as a prereq)
compose.override.yml:
@ln -sf compose.override.local.yml compose.override.yml
## behave-all: runs behave inside the containers against all of your features
.Phony: behave-all
behave-all: compose.override.yml
@docker compose run --rm django coverage run -a manage.py behave --no-input --simple
## behave: runs behave inside the containers against a specific feature (append FEATURE=feature_name_here)
.Phony: behave
behave: compose.override.yml
@docker compose run --rm django python manage.py behave --no-input --simple -i $(FEATURE)
## behave-translator
.Phony: behave-translator
behave-translator: compose.override.yml
@docker compose exec -T translator /usr/local/bin/behave /app/tests/acceptance/features
## build: rebuilds all your containers or a single one if CONTAINER is specified
.Phony: build
build: compose.override.yml
@docker compose build --build-arg PYTHON_IMAGE_VER=$(PYTHON_IMAGE_VER) --build-arg POSTGRES_IMAGE_VER=$(POSTGRES_IMAGE_VER) $(CONTAINER)
@docker compose up -d --no-deps $(CONTAINER)
@docker compose restart $(CONTAINER)
## coverage.xml: generate coverage from test runs
coverage.xml: pytest behave-all behave-translator
@docker compose run --rm django coverage report
@docker compose run --rm 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
## clean: remove local containers and volumes
.Phony: clean
clean: compose.override.yml
@docker compose rm -f -s
@docker volume prune -f
## collect-static: run collect static admin command
.Phony: collectstatic
collectstatic: compose.override.yml
@docker compose run --rm django python manage.py collectstatic
## django-addr: get the IP and ephemeral port assigned to docker:8000
.Phony: django-addr
django-addr: compose.override.yml
@docker compose port django 8000
## django-url: get the URL based on http://$(make django-addr)
.Phony: django-url
django-url: compose.override.yml
@echo http://$$(make django-addr)
## django-open: open a browser for http://$(make django-addr)
.Phony: django-open
django-open: compose.override.yml
@open http://$$(make django-addr)
## down: turn down docker compose stack
.Phony: down
down: compose.override.yml
@docker compose down
## exec: executes a given command on a given container (append CONTAINER=container_name_here and COMMAND=command_here)
.Phony: exec
exec: compose.override.yml
@docker compose exec $(CONTAINER) $(COMMAND)
## gobgp-neighbor: shows the gobgp neighbor information (append neighbor IP for specific information)
.Phony: gobgp-neighbor
gobgp-neighbor: compose.override.yml
@docker compose exec gobgp gobgp neighbor $(NEIGHBOR)
# 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' $<
# TODO: When we move to flowspec this -a flag with change
## list-routes: list gobgp routes
.Phony: list-routes
list-routes: compose.override.yml
@docker compose exec gobgp gobgp global rib -a ipv4
@docker compose exec gobgp gobgp global rib -a ipv6
## migrate: makemigrations and then migrate
.Phony: migrate
migrate: compose.override.yml
@docker compose run --rm django python manage.py makemigrations
@docker compose run --rm django python manage.py migrate
## pass-reset: change admin's password
.Phony: pass-reset
pass-reset: compose.override.yml
@docker compose run --rm django python manage.py changepassword admin
## pytest: runs pytest inside the containers
.Phony: pytest
pytest: compose.override.yml
@docker compose run --rm django coverage run -m pytest
## run: brings up the containers as described in compose.override.yml
.Phony: run
run: compose.override.yml
@docker compose up -d
## stop: turns off running containers
.Phony: stop
stop: compose.override.yml
@docker compose stop
## tail-log: tail a docker container's logs (append CONTAINER=container_name_here)
.Phony: tail-log
tail-log: compose.override.yml
@docker compose logs -f $(CONTAINER)
## type-check: static type checking
.Phony: type-check
type-check: compose.override.yml
@docker compose run --rm django mypy scram
## docs-build: build the documentation
.Phony: docs-build
docs-build:
@docker compose run --rm docs mkdocs build
## docs-serve: build and run a server with the documentation
.Phony: docs-serve
docs-serve:
@docker compose run --rm docs mkdocs serve -a 0.0.0.0:8888