-
Notifications
You must be signed in to change notification settings - Fork 73
Expand file tree
/
Copy pathTaskfile.dist.yaml
More file actions
369 lines (313 loc) · 10.7 KB
/
Copy pathTaskfile.dist.yaml
File metadata and controls
369 lines (313 loc) · 10.7 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
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
version: "3"
env:
EDA_MODE: development
DJANGO_SETTINGS_MODULE: "aap_eda.settings.default"
KIND_EXPERIMENTAL_PROVIDER: '{{.CONTAINER_ENGINE}}'
vars:
DOCKER_COMPOSE: '{{ default "docker-compose" .DOCKER_COMPOSE }}'
DOCKER_COMPOSE_ARGS: '{{ default "-p eda -f tools/docker/docker-compose-dev.yaml" .DOCKER_COMPOSE_ARGS }}'
PYTEST_CMD: "poetry run python -m pytest"
CONTAINER_ENGINE: '{{ default "podman" .CONTAINER_ENGINE }}'
SUSER_CMD: "scripts/create_superuser.sh"
PODMAN_CMD: "scripts/eda_podman.sh"
tasks:
default:
desc: "Show this message and exit"
cmds:
- command -v task > /dev/null && CMD=task || CMD=go-task; ${CMD} -l
silent: true
dev:init:
desc: "Initialize local development environment"
cmds:
- poetry install -E dev
- pre-commit install
run:api:
desc: "Run API server locally"
cmds:
- task: manage
vars:
CLI_ARGS: runserver
run:shell:
desc: "Run Django shell"
cmds:
- task: manage
vars:
CLI_ARGS: shell
run:scheduler:
desc: "Run tasking scheduler locally"
cmds:
- task: manage
vars:
CLI_ARGS: scheduler
run:worker:default:
desc: "Run default tasking worker locally"
cmds:
- task: manage
vars:
CLI_ARGS: dispatcherd --worker-class 'DefaultWorker'
run:worker:activation:
desc: "Run activation worker locally"
cmds:
- task: manage
vars:
CLI_ARGS: dispatcherd --worker-class 'ActivationWorker'
manage:
desc: "Run django management command"
cmds:
# This is a workaround for poetry incorrectly passing argv[0] to spawned subprocess
# See https://github.com/python-poetry/poetry/issues/965
- cmd: poetry run /usr/bin/env aap-eda-manage {{.CLI_ARGS}}
test:
desc: "Run project tests."
summary: |
Run poetry run python -m pytest with specified CLI arguments.
Example(s):
Run a single test module
$ task test -- tests/integration/api/test_activation.py
Run a single test from a module
$ task test -- tests/integration/api/test_activation.py::test_retrieve_activation
cmds:
- "{{.PYTEST_CMD}} {{.CLI_ARGS}}"
- "{{.PYTEST_CMD}} -m multithreaded {{.CLI_ARGS}}"
test:rotate-db-encryption-key:
desc: "Run DB encryption key rotation lifecycle tests (manual, requires Postgres)."
summary: |
Run integration lifecycle tests for rotate_db_encryption_key.
Skipped by default — requires RUN_ROTATION_TESTS=1.
Run when changing: rotate_db_encryption_key.py, EncryptedTextField,
or aap_eda/core/utils/crypto/.
Prerequisites:
Command-level tests: task docker:up:minimal
Service-level tests: EDA_SECRET_KEY=insecure task docker:up
See docs/development.md "DB encryption key rotation tests" for
full prerequisites, env var reference, examples and recovery steps.
env:
RUN_ROTATION_TESTS: "1"
EDA_SECRET_KEY: '{{.EDA_SECRET_KEY | default "insecure"}}'
EDA_DB_PASSWORD: '{{.EDA_DB_PASSWORD | default "secret"}}'
cmds:
- "{{.PYTEST_CMD}} tests/integration/commands/test_rotate_db_encryption_key_lifecycle.py {{.CLI_ARGS}}"
lint:
desc: "Run all linters."
cmds:
- task: lint:black
- task: lint:isort
- task: lint:ruff
- task: lint:flake8
- task: lint:migrations
lint:black:
desc: "Check code with `black`."
cmds:
- poetry run black -- {{.CLI_ARGS | default "."}}
lint:isort:
desc: "Check code with `isort`."
cmds:
- poetry run isort -- {{.CLI_ARGS | default "."}}
lint:ruff:
desc: "Check code with `ruff`."
cmds:
- poetry run ruff check -- {{.CLI_ARGS | default "."}}
lint:flake8:
desc: "Check code with `flake8`."
cmds:
- poetry run flake8 -- {{.CLI_ARGS | default "."}}
lint:migrations:
desc: "Check that all migrations are up to date."
cmds:
- task: manage
vars:
CLI_ARGS: makemigrations --dry-run --check
format:
desc: "Run code formatters"
cmds:
- task: lint:isort
- task: lint:black
docker:
desc: "Run docker-compose with specified CLI arguments."
summary: |
Run docker-compose with specified CLI arguments.
Example:
$ task docker -- ls
cmds:
- "{{.DOCKER_COMPOSE}} {{.DOCKER_COMPOSE_ARGS}} {{.CLI_ARGS}}"
docker:build:
desc: "Build container images."
cmds:
- task: docker
vars:
CLI_ARGS: build
docker:up:
desc: "Start all services."
cmds:
- task: docker
vars:
CLI_ARGS: up --detach
docker:up:minimal:
desc: "Start minimal set of services (PostgreSQL, Redis)."
cmds:
- task: docker
vars:
CLI_ARGS: up --detach postgres redis
docker:up:postgres:
desc: "Start PostgreSQL service."
cmds:
- task: docker
vars:
CLI_ARGS: up --detach postgres
docker:migrate:
desc: "Apply database migrations."
cmds:
- task: docker
vars:
CLI_ARGS: run --rm eda-api aap-eda-manage migrate
docker:down:
desc: "Stop all services."
cmds:
- task: docker
vars:
CLI_ARGS: down
docker:purge:
desc: "Stop all containers and delete all volumes."
cmds:
- task: docker
vars:
CLI_ARGS: down --volumes --remove-orphans
docker:psql:
desc: "Open PostgreSQL console."
cmds:
- task: docker
vars:
CLI_ARGS: exec postgres psql -U postgres eda
docker:shell:api:
desc: "Run the management shell in api container"
cmds:
- task: docker
vars:
CLI_ARGS: exec -it eda-api aap-eda-manage shell
docker:shell:worker:
desc: "Run the management shell in worker container"
cmds:
- task: docker
vars:
CLI_ARGS: exec -it eda-worker aap-eda-manage shell
create:superuser:
desc: "create a superuser to use with EDA API."
summary: |
Run create_superuser.sh with specified CLI arguments. If no arguments are
given the following defaults are used.
Defaults:
user: admin
password: testpass
email: admin@test.com
Examples:
$ task create:superuser
$ task create:superuser -- -u test_user -p none2tuff -e test_user@test.com
cmds:
- "{{.SUSER_CMD}} {{.CLI_ARGS}}"
kind:build:
desc: "Build EDA API image and load into kind cluster"
cmds:
- "{{.CONTAINER_ENGINE}} build -t localhost/aap-eda:latest -f tools/docker/Dockerfile ."
- kind load docker-image localhost/aap-eda:latest --name ${KIND_CLUSTER_NAME:-kind}
kind:deploy:
desc: "Deploy EDA to kind cluster using kustomize"
preconditions:
- sh: test -f tools/deploy/environment.properties
msg: "tools/deploy/environment.properties not found. Copy from environment.properties.example: cp tools/deploy/environment.properties.example tools/deploy/environment.properties"
cmds:
- kubectl create namespace ${NAMESPACE:-aap-eda} --dry-run=client -o yaml | kubectl apply -f -
- kubectl config set-context --current --namespace=${NAMESPACE:-aap-eda}
- >-
kubectl create secret generic eda-ui-certs
--from-file=wildcard.crt=tools/docker/nginx/certs/wildcard.crt
--from-file=wildcard.key=tools/docker/nginx/certs/wildcard.key
--from-file=client.crt=tools/docker/nginx/certs/client.crt
-n ${NAMESPACE:-aap-eda} --dry-run=client -o yaml | kubectl apply -f -
- >-
kubectl create configmap eda-ui-nginx-config
--from-file=default.conf.template=tools/docker/nginx/default.conf.template
-n ${NAMESPACE:-aap-eda} --dry-run=client -o yaml | kubectl apply -f -
- >-
kubectl create configmap eda-postgres-initdb
--from-file=create_event_persistence_db.sh=tools/docker/postgres/initdb.d/create_event_persistence_db.sh
-n ${NAMESPACE:-aap-eda} --dry-run=client -o yaml | kubectl apply -f -
- kustomize build tools/deploy | kubectl apply -f -
kind:clean:
desc: "Remove all EDA resources from kind cluster"
cmds:
- kustomize build tools/deploy | kubectl delete --ignore-not-found -f -
- kubectl delete secret eda-ui-certs -n ${NAMESPACE:-aap-eda} --ignore-not-found
- kubectl delete configmap eda-ui-nginx-config -n ${NAMESPACE:-aap-eda} --ignore-not-found
- kubectl delete configmap eda-postgres-initdb -n ${NAMESPACE:-aap-eda} --ignore-not-found
kind:clean:api:
desc: "Restart API, worker, and scheduler pods"
cmds:
- kubectl delete pods -l 'comp in (worker, api, ws, webhook-api, scheduler)' -n ${NAMESPACE:-aap-eda} --ignore-not-found
kind:fp:ui:
desc: "Forward local port to EDA UI (default: 8443)"
cmds:
- kubectl port-forward svc/eda-ui {{.CLI_ARGS | default "8443"}}:8443 -n ${NAMESPACE:-aap-eda}
kind:fp:api:
desc: "Forward local port to EDA API (default: 8000)"
cmds:
- kubectl port-forward svc/eda-api {{.CLI_ARGS | default "8000"}}:8000 -n ${NAMESPACE:-aap-eda}
kind:fp:pg:
desc: "Forward local port to PostgreSQL (default: 5432)"
cmds:
- kubectl port-forward svc/eda-postgres {{.CLI_ARGS | default "5432"}}:5432 -n ${NAMESPACE:-aap-eda}
kind:logs:eda:
desc: "Stream logs for EDA application"
cmds:
- kubectl logs -n ${NAMESPACE:-aap-eda} -l app=eda --max-log-requests=10 -f
kind:all:
desc: "Clean, build, and deploy EDA to kind cluster"
cmds:
- task: kind:clean
- task: kind:build
- task: kind:deploy
kind:api:
desc: "Rebuild and redeploy API pods"
cmds:
- task: kind:clean:api
- task: kind:build
- task: kind:deploy
kind:cluster:create:
desc: "Create a kind cluster for local development"
cmds:
- kind create cluster --name ${KIND_CLUSTER_NAME:-kind}
kind:cluster:delete:
desc: "Delete the kind cluster"
cmds:
- kind delete cluster --name ${KIND_CLUSTER_NAME:-kind}
macpodman:
desc: "Run eda_podman.sh with specified CLI arguments."
summary: |
Run eda_podman.sh with specified CLI arguments.
Example:
$ task podman -- help
cmds:
- "{{.PODMAN_CMD}} {{.CLI_ARGS}}"
macpodman:start:
desc: "start podman machine"
cmds:
- task: macpodman
vars:
CLI_ARGS: start
macpodman:stop:
desc: "stop podman machine"
cmds:
- task: macpodman
vars:
CLI_ARGS: stop
macpodman:restart:
desc: "restart podman machine"
cmds:
- task: macpodman
vars:
CLI_ARGS: restart
macpodman:tunnel:
desc: "tunnel for podman when running on host with docker"
cmds:
- task: macpodman
vars:
CLI_ARGS: tunnel