-
Notifications
You must be signed in to change notification settings - Fork 37
Expand file tree
/
Copy pathMakefile
More file actions
235 lines (156 loc) · 7.48 KB
/
Makefile
File metadata and controls
235 lines (156 loc) · 7.48 KB
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
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
override SERVICE=backend
override paths = openslides_backend/ tests/ cli/
# Build images for different contexts
build-prod:
docker build ./ $(ARGS) --tag "openslides-$(SERVICE)" --build-arg CONTEXT="prod" --target "prod"
build-dev:
docker build ./ $(ARGS) --tag "openslides-$(SERVICE)-dev" --build-arg CONTEXT="dev" --target "dev"
build-tests:
docker build ./ $(ARGS) --tag "openslides-$(SERVICE)-tests" --build-arg CONTEXT="tests" --target "tests"
# Development redirects
.PHONY: dev
dev dev-help dev-standalone dev-detached dev-attached dev-stop dev-exec dev-enter dev-clean dev-build dev-log:
@@$(MAKE) -C .. $@ backend
# Tests
run-tests:
bash dev/run-tests.sh
lint:
bash dev/run-lint.sh -l
test:
pytest
coverage:
pytest --cov --cov-report html
test-file:
# f= to pass the file name
# k= to pass a test name
# v=1 to run verbose test output
# cap=1 to capture print to system out
# cov=1 to run coverage report
python -m debugpy --listen 0.0.0.0:5678 --wait-for-client /usr/local/bin/pytest $f $(if $(k),-k $k) $(if $(v),-vv) $(if $(cap),--capture=no) $(if $(cov),--cov --cov-report term-missing:skip-covered)
check-all: validate-models-yml check-models check-initial-data-json check-example-data-json check-permissions
# Models
generate-schema:
make -C meta/dev generate-relational-schema
join-models-yml:
make -C meta/dev join-models-yml
generate-db: | generate-schema create-database-with-schema
generate-models:
python cli/generate_models.py $(MODELS_PATH)
black openslides_backend/models/models.py
check-models:
python cli/generate_models.py --check
validate-models-yml:
make -C meta/dev validate-models
# Permissions
generate-permissions:
python cli/generate_permissions.py $(MODELS_PATH)
black openslides_backend/permissions/permissions.py
check-permissions:
python cli/generate_permissions.py --check
check-initial-data-json:
python cli/check_json.py data/initial-data.json
check-example-data-json:
python cli/check_json.py data/example-data.json
# The commands below can be called in the container to open the gunicorn control socket interfaces
# for the action and presenter services respectively.
# Environment setting OPENSLIDES_BACKEND_ENABLE_CONTROL_SOCKET needs to be true for this to be possible.
open-gunicornc-action:
gunicornc -s "openslides-action.ctl"
open-gunicornc-presenter:
gunicornc -s "openslides-presenter.ctl"
########################## Deprecation List ##########################
deprecation-warning:
@echo "\033[1;33m DEPRECATION WARNING: This make command is deprecated and will be removed soon! \033[0m"
deprecation-warning-alternative: | deprecation-warning
@echo "\033[1;33m Please use the following command instead: $(ALTERNATIVE) \033[0m"
stop-dev:
@make deprecation-warning-alternative ALTERNATIVE="dev and derivative maketargets are now only available in main repository. (use 'make dev-help' in main repository for more information)"
all: | pyupgrade black autoflake isort flake8 mypy
@make deprecation-warning-alternative ALTERNATIVE="run-lint"
pyupgrade:
@make deprecation-warning-alternative ALTERNATIVE="run-lint"
pyupgrade --py310-plus --exit-zero-even-if-changed $$(find . -name '*.py')
check-pyupgrade:
@make deprecation-warning-alternative ALTERNATIVE="run-lint"
pyupgrade --py310-plus $$(find . -name '*.py')
black:
@make deprecation-warning-alternative ALTERNATIVE="run-lint"
black $(paths)
check-black:
@make deprecation-warning-alternative ALTERNATIVE="run-lint"
black --check --diff $(paths)
autoflake:
@make deprecation-warning-alternative ALTERNATIVE="run-lint"
autoflake $(paths)
isort:
@make deprecation-warning-alternative ALTERNATIVE="run-lint"
isort $(paths)
check-isort:
@make deprecation-warning-alternative ALTERNATIVE="run-lint"
isort --check-only --diff $(paths)
flake8:
@make deprecation-warning-alternative ALTERNATIVE="run-lint"
flake8 $(paths)
mypy:
@make deprecation-warning-alternative ALTERNATIVE="run-lint"
mypy $(paths)
run-bash:
@make deprecation-warning-alternative ALTERNATIVE="dev"
make start-dev
make run-dev-attach
run-dev-attach:
@make deprecation-warning-alternative ALTERNATIVE="dev-attached"
CONTEXT="dev" USER_ID=$$(id -u $${USER}) GROUP_ID=$$(id -g $${USER}) docker compose -f dev/docker-compose.dev.yml exec backend ./entrypoint.sh bash --rcfile .bashrc
test-unit-integration: | deprecation-warning
pytest tests/unit tests/integration
run-debug: | deprecation-warning
OPENSLIDES_DEVELOPMENT=1 python -m openslides_backend
pip-check: | deprecation-warning
pip-check -H
extract-translations:
pybabel extract --no-location --sort-output -o openslides_backend/i18n/messages/template-en.pot openslides_backend
drop-database:
make -C meta/dev drop-database
create-database:
make -C meta/dev create-database
generate-relational-schema:
make -C meta/dev generate-relational-schema
apply-db-schema:
make -C meta/dev apply-db-schema
create-database-with-schema:
python cli/create_schema.py
recreate-database:
make -C meta/dev create-database-with-schema
run-psql:
make -C meta/dev run-psql
# Build and run production docker container (not usable inside the docker container)
run-prod: | deprecation-warning build-prod
docker run --interactive --tty \
--publish 9002:9002 --publish 9003:9003 --rm openslides-backend
# Build and run development docker container setup with docker compose (not usable inside docker container)
start-dev: | deprecation-warning
CONTEXT="dev" USER_ID=$$(id -u $${USER}) GROUP_ID=$$(id -g $${USER}) docker compose -f dev/docker-compose.dev.yml up --build --detach
start-dev-attach start-dev-interactive: | deprecation-warning
CONTEXT="dev" USER_ID=$$(id -u $${USER}) GROUP_ID=$$(id -g $${USER}) docker compose -f dev/docker-compose.dev.yml up --build
# Build and run development container with local datastore in use
start-dev-local: | deprecation-warning
CONTEXT="dev" USER_ID=$$(id -u $${USER}) GROUP_ID=$$(id -g $${USER}) docker compose -f dev/docker-compose.dev.yml -f dev/dc.local.yml up --build --detach
start-dev-attach-local start-dev-interactive-local: | deprecation-warning
CONTEXT="dev" USER_ID=$$(id -u $${USER}) GROUP_ID=$$(id -g $${USER}) docker compose -f dev/docker-compose.dev.yml -f dev/dc.local.yml up --build
stop-dev-local: | deprecation-warning
CONTEXT="dev" docker compose -f dev/docker-compose.dev.yml -f dev/dc.local.yml down --volumes
run-dev-attach-local: | deprecation-warning
CONTEXT="dev" docker compose -f dev/docker-compose.dev.yml -f dev/dc.local.yml exec backend ./entrypoint.sh bash --rcfile .bashrc
run-dev-local run-bash-local: | deprecation-warning start-dev-local dev-attach-local
# Build and run development container. Additionally run OpenTelemetry services
start-dev-otel: | deprecation-warning
CONTEXT="dev" USER_ID=$$(id -u $${USER}) GROUP_ID=$$(id -g $${USER}) docker compose -f dev/docker-compose.dev.yml -f dev/dc.otel.yml up --build --detach
start-dev-attach-otel start-dev-interactive-otel: | deprecation-warning
CONTEXT="dev" USER_ID=$$(id -u $${USER}) GROUP_ID=$$(id -g $${USER}) docker compose -f dev/docker-compose.dev.yml -f dev/dc.otel.yml up --build
stop-dev-otel: | deprecation-warning
CONTEXT="dev" docker compose -f dev/docker-compose.dev.yml -f dev/dc.otel.yml down --volumes
run-dev-attach-otel: | deprecation-warning
CONTEXT="dev" docker compose -f dev/docker-compose.dev.yml -f dev/dc.otel.yml exec backend ./entrypoint.sh bash --rcfile .bashrc
run-dev-otel run-bash-otel: | deprecation-warning start-dev-otel dev-attach-otel
rebuild-dev: | deprecation-warning
docker build . --tag=openslides-backend-dev --no-cache --build-arg CONTEXT=dev