-
Notifications
You must be signed in to change notification settings - Fork 6
494 lines (478 loc) · 18 KB
/
workflow.yml
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
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
name: Testing Workflow
on: [workflow_dispatch,push]
jobs:
clean:
strategy:
matrix:
package: ['neurosynth_compose', 'compose_nginx', 'compose_pgsql', 'compose_worker', 'neurostore', 'store_nginx', 'store_pgsql']
runs-on: ubuntu-latest
steps:
- uses: actions/delete-package-versions@v5
with:
package-name: ${{ matrix.package }}
package-type: 'container'
min-versions-to-keep: 10
delete-only-pre-release-versions: "true"
build_neurosynth_compose:
runs-on: ubuntu-latest
defaults:
run:
working-directory: compose
steps:
-
name: Checkout
uses: actions/checkout@v4
with:
submodules: recursive
-
name: Configuration
run: |
cp .env.example .env
-
name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
-
name: Login to GitHub Container Registry
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
-
name: Build and push
uses: docker/bake-action@master
with:
files: docker-compose.yml,docker-compose.dev.yml
push: true
load: false
workdir: compose
set: |
compose.tags=ghcr.io/${{ github.repository_owner }}/neurosynth_compose:${{ hashFiles('**/compose/neurosynth_compose/**') }}
compose.cache-from=type=registry,ref=ghcr.io/${{ github.repository_owner }}/neurosynth_compose:${{ hashFiles('**/compose/neurosynth_compose/**') }}
compose.cache-from=type=gha,scope=cached-compose
compose.cache-to=type=gha,scope=cached-compose,mode=max,ignore-error=true
compose_nginx.tags=ghcr.io/${{ github.repository_owner }}/compose_nginx:${{ hashFiles('**/compose/nginx/**') }}
compose_nginx.cache-from=type=registry,ref=ghcr.io/${{ github.repository_owner }}/compose_nginx:${{ hashFiles('**/compose/nginx/**') }}
compose_nginx.cache-from=type=gha,scope=cached-compose-nginx
compose_nginx.cache-to=type=gha,scope=cached-compose-nginx,mode=max,ignore-error=true
compose_pgsql.tags=ghcr.io/${{ github.repository_owner }}/compose_pgsql:${{ hashFiles('**/compose/postgres/**') }}
compose_pgsql.cache-from=type=registry,ref=ghcr.io/${{ github.repository_owner }}/compose_pgsql:${{ hashFiles('**/compose/postgres/**') }}
compose_pgsql.cache-from=type=gha,scope=cached-compose-pgsql
compose_pgsql.cache-to=type=gha,scope=cached-compose-pgsql,mode=max,ignore-error=true
compose_worker.tags=ghcr.io/${{ github.repository_owner }}/compose_worker:${{ hashFiles('**/compose/neurosynth_compose/**') }}
compose_worker.cache-from=type=registry,ref=ghcr.io/${{ github.repository_owner }}/compose_worker:${{ hashFiles('**/compose/neurosynth_compose/**') }}
compose_worker.cache-from=type=gha,scope=cached-compose-worker
compose_worker.cache-to=type=gha,scope=cached-compose-worker,mode=max,ignore-error=true
build_neurostore:
runs-on: ubuntu-latest
defaults:
run:
working-directory: store
steps:
-
name: Checkout
uses: actions/checkout@v4
with:
submodules: recursive
-
name: Configuration
run: |
cp .env.example .env
-
name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
-
name: Login to GitHub Container Registry
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
-
name: Build and push
uses: docker/bake-action@master
with:
files: docker-compose.yml,docker-compose.dev.yml
push: true
load: false
workdir: store
set: |
neurostore.tags=ghcr.io/${{ github.repository_owner }}/neurostore:${{ hashFiles('**/store/neurostore/**') }}
neurostore.cache-from=type=registry,ref=ghcr.io/${{ github.repository_owner }}/neurostore:${{ hashFiles('**/store/neurostore/**') }}
neurostore.cache-from=type=gha,scope=cached-neurostore
neurostore.cache-to=type=gha,scope=cached-neurostore,mode=max,ignore-error=true
store_nginx.tags=ghcr.io/${{ github.repository_owner }}/store_nginx:${{ hashFiles('**/store/nginx/**') }}
store_nginx.cache-from=type=registry,ref=ghcr.io/${{ github.repository_owner }}/store_nginx:${{ hashFiles('**/store/nginx/**') }}
store_nginx.cache-from=type=gha,scope=cached-store-nginx
store_nginx.cache-to=type=gha,scope=cached-store-nginx,mode=max,ignore-error=true
store_pgsql.tags=ghcr.io/${{ github.repository_owner }}/store_pgsql:${{ hashFiles('**/store/postgres/**') }}
store_pgsql.cache-from=type=registry,ref=ghcr.io/${{ github.repository_owner }}/store_pgsql:${{ hashFiles('**/store/postgres/**') }}
store_pgsql.cache-from=type=gha,scope=cached-store-pgsql
store_pgsql.cache-to=type=gha,scope=cached-store-pgsql,mode=max,ignore-error=true
neurostore_backend_tests:
runs-on: ubuntu-latest
needs: build_neurostore
defaults:
run:
working-directory: store
steps:
-
name: Checkout
uses: actions/checkout@v4
with:
submodules: recursive
-
name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
-
name: Configuration
run: |
cp .env.example .env
-
name: load images
uses: docker/bake-action@master
with:
files: docker-compose.yml,docker-compose.dev.yml
push: false
load: true
workdir: store
set: |
neurostore.cache-from=type=gha,scope=cached-neurostore
store_nginx.cache-from=type=gha,scope=cached-store-nginx
store_pgsql.cache-from=type=gha,scope=cached-store-pgsql
-
name: spin up backend
run: |
docker network create nginx-proxy
docker compose pull --ignore-buildable
docker compose \
-f docker-compose.yml \
-f docker-compose.dev.yml \
up -d --no-build
-
name: Create Test Database
run: |
until docker compose exec -T \
store_pgsql pg_isready -U postgres; do sleep 1; done
docker compose exec -T \
store_pgsql \
psql -U postgres -c "create database test_db"
-
name: Backend Tests
env:
AUTH0_CLIENT_ID: ${{ secrets.AUTH0_CLIENT_ID }}
AUTH0_CLIENT_SECRET: ${{ secrets.AUTH0_CLIENT_SECRET }}
AUTH0_BASE_URL: ${{ secrets.AUTH0_BASE_URL }}
AUTH0_ACCESS_TOKEN_URL: ${{ secrets.AUTH0_ACCESS_TOKEN_URL }}
AUTH0_AUTH_URL: ${{ secrets.AUTH0_AUTH_URL }}
run: |
docker compose run \
-e "APP_SETTINGS=neurostore.config.DockerTestConfig" \
-e "AUTH0_CLIENT_ID=${AUTH0_CLIENT_ID}" \
-e "AUTH0_CLIENT_SECRET=${AUTH0_CLIENT_SECRET}" \
-e "AUTH0_BASE_URL=${AUTH0_BASE_URL}" \
-e "AUTH0_ACCESS_TOKEN_URL=${AUTH0_ACCESS_TOKEN_URL}" \
-e "AUTH0_AUTH_URL=${AUTH0_AUTH_URL}" \
--rm -w /neurostore \
neurostore \
bash -c "python -m pytest neurostore/tests && python -m pytest --auth neurostore/tests/test_auth.py"
neurosynth_compose_backend_tests:
runs-on: ubuntu-latest
needs: build_neurosynth_compose
defaults:
run:
working-directory: compose
steps:
-
name: Checkout
uses: actions/checkout@v4
with:
submodules: recursive
-
name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
-
name: Configuration
run: |
cp .env.example .env
-
name: load images
uses: docker/bake-action@master
with:
files: docker-compose.yml,docker-compose.dev.yml
push: false
load: true
workdir: compose
set: |
compose.cache-from=type=gha,scope=cached-compose
compose_nginx.cache-from=type=gha,scope=cached-compose-nginx
compose_pgsql.cache-from=type=gha,scope=cached-compose-pgsql
compose_worker.cache-from=type=gha,scope=cached-compose-worker
-
name: Spin up backend
run: |
docker network create nginx-proxy
docker compose pull --ignore-buildable
docker compose \
-f docker-compose.yml \
-f docker-compose.dev.yml \
up -d --no-build
-
name: Create Test Database
run: |
until docker compose exec -T \
compose_pgsql pg_isready -U postgres; do sleep 1; done
docker compose exec -T \
compose_pgsql \
psql -U postgres -c "create database test_db"
-
name: Backend Tests
env:
AUTH0_CLIENT_ID: ${{ secrets.AUTH0_CLIENT_ID }}
AUTH0_CLIENT_SECRET: ${{ secrets.AUTH0_CLIENT_SECRET }}
AUTH0_BASE_URL: ${{ secrets.AUTH0_BASE_URL }}
AUTH0_ACCESS_TOKEN_URL: ${{ secrets.AUTH0_ACCESS_TOKEN_URL }}
AUTH0_AUTH_URL: ${{ secrets.AUTH0_AUTH_URL }}
NEUROVAULT_ACCESS_TOKEN: ${{ secrets.NEUROVAULT_ACCESS_TOKEN }}
run: |
docker compose run \
-e "APP_SETTINGS=neurosynth_compose.config.DockerTestConfig" \
-e "AUTH0_CLIENT_ID=${AUTH0_CLIENT_ID}" \
-e "AUTH0_CLIENT_SECRET=${AUTH0_CLIENT_SECRET}" \
-e "AUTH0_BASE_URL=${AUTH0_BASE_URL}" \
-e "AUTH0_ACCESS_TOKEN_URL=${AUTH0_ACCESS_TOKEN_URL}" \
-e "AUTH0_AUTH_URL=${AUTH0_AUTH_URL}" \
-e "NEUROVAULT_ACCESS_TOKEN=${NEUROVAULT_ACCESS_TOKEN}" \
--rm -w /compose \
compose \
bash -c "python -m pytest neurosynth_compose/tests && python -m pytest --celery neurosynth_compose/tests/api/celery_tests && python -m pytest --auth neurosynth_compose/tests/api/test_auth.py"
style_check:
runs-on: ubuntu-latest
steps:
-
name: Checkout
uses: actions/checkout@v4
with:
submodules: recursive
-
name: run flake8
run: |
pip install flake8
cd ./store
flake8 ./neurostore
cd ../compose
flake8 ./neurosynth_compose
neurosynth_compose_JUNIT_tests:
runs-on: ubuntu-latest
needs: build_neurosynth_compose
defaults:
run:
working-directory: compose
steps:
-
name: Checkout
uses: actions/checkout@v4
with:
submodules: recursive
-
name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
-
name: Configuration
run: |
cp .env.example .env
-
name: load images
uses: docker/bake-action@master
with:
files: docker-compose.yml,docker-compose.dev.yml
push: false
load: true
workdir: compose
set: |
compose.cache-from=type=gha,scope=cached-compose
compose_nginx.cache-from=type=gha,scope=cached-compose-nginx
compose_pgsql.cache-from=type=gha,scope=cached-compose-pgsql
compose_worker.cache-from=type=gha,scope=cached-compose-worker
-
name: Spin up backend
run: |
docker network create nginx-proxy
docker compose pull --ignore-buildable
docker compose \
-f docker-compose.yml \
-f docker-compose.dev.yml \
up -d --no-build
-
name: Create Test Database
run: |
until docker compose exec -T \
compose_pgsql pg_isready -U postgres; do sleep 1; done
docker compose exec -T \
compose_pgsql \
psql -U postgres -c "create database test_db"
-
name: Frontend Jest Unit Tests
env:
AUTH0_CLIENT_ID: ${{ secrets.AUTH0_CLIENT_ID }}
AUTH0_CLIENT_SECRET: ${{ secrets.AUTH0_CLIENT_SECRET }}
AUTH0_BASE_URL: ${{ secrets.AUTH0_BASE_URL }}
AUTH0_ACCESS_TOKEN_URL: ${{ secrets.AUTH0_ACCESS_TOKEN_URL }}
AUTH0_AUTH_URL: ${{ secrets.AUTH0_AUTH_URL }}
REACT_APP_AUTH0_CLIENT_ID: ${{ secrets.REACT_APP_AUTH0_CLIENT_ID }}
REACT_APP_AUTH0_DOMAIN: ${{ secrets.REACT_APP_AUTH0_DOMAIN }}
REACT_APP_AUTH0_CLIENT_SECRET: ${{ secrets.REACT_APP_AUTH0_CLIENT_SECRET }}
run: |
cp neurosynth-frontend/.env.example neurosynth-frontend/.env.dev && \
docker compose run \
-e "APP_SETTINGS=neurosynth_compose.config.DockerTestConfig" \
-e "AUTH0_CLIENT_ID=${AUTH0_CLIENT_ID}" \
-e "AUTH0_CLIENT_SECRET=${AUTH0_CLIENT_SECRET}" \
-e "AUTH0_BASE_URL=${AUTH0_BASE_URL}" \
-e "AUTH0_ACCESS_TOKEN_URL=${AUTH0_ACCESS_TOKEN_URL}" \
-e "AUTH0_AUTH_URL=${AUTH0_AUTH_URL}" \
-e "REACT_APP_AUTH0_DOMAIN=${REACT_APP_AUTH0_DOMAIN}" \
-e "REACT_APP_AUTH0_CLIENT_ID=${REACT_APP_AUTH0_CLIENT_ID}" \
-e "REACT_APP_AUTH0_AUDIENCE=localhost" \
-e "REACT_APP_AUTH0_CLIENT_SECRET=${REACT_APP_AUTH0_CLIENT_SECRET}" \
-e "REACT_APP_ENV=DEV" \
-e "REACT_APP_NEUROSTORE_API_DOMAIN=http://localhost/api" \
-e "CI=true" \
-e "REACT_APP_NEUROSYNTH_API_DOMAIN=http://localhost:81/api" \
--rm -w /compose/neurosynth-frontend \
compose \
bash -c "cd /compose/neurosynth-frontend && \
npm install && npm run test"
neurosynth_compose_cypress_tests:
runs-on: ubuntu-latest
needs:
- build_neurosynth_compose
- build_neurostore
steps:
-
name: Checkout
uses: actions/checkout@v4
with:
submodules: recursive
-
name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
-
name: Configuration
run: |
cp compose/.env.example compose/.env
cp store/.env.example store/.env
-
name: load compose images
uses: docker/bake-action@master
with:
files: docker-compose.yml,docker-compose.dev.yml
push: false
load: true
workdir: compose
set: |
compose.cache-from=type=gha,scope=cached-compose
compose_nginx.cache-from=type=gha,scope=cached-compose-nginx
compose_pgsql.cache-from=type=gha,scope=cached-compose-pgsql
compose_worker.cache-from=type=gha,scope=cached-compose-worker
-
name: load store images
uses: docker/bake-action@master
with:
files: docker-compose.yml,docker-compose.dev.yml
push: false
load: true
workdir: store
set: |
neurostore.cache-from=type=gha,scope=cached-neurostore
store_nginx.cache-from=type=gha,scope=cached-store-nginx
store_pgsql.cache-from=type=gha,scope=cached-store-pgsql
-
name: Spin up compose backend
run: |
cd compose
docker network create nginx-proxy
docker compose pull --ignore-buildable
docker compose \
-f docker-compose.yml \
-f docker-compose.dev.yml \
up -d --no-build
-
name: Spin up store backend
run: |
cd store
docker compose pull --ignore-buildable
docker compose \
-f docker-compose.yml \
-f docker-compose.dev.yml \
up -d --no-build
-
name: Create Compose Database
run: |
cd compose
until docker compose exec -T \
compose_pgsql pg_isready -U postgres; do sleep 1; done
docker compose exec -T \
compose_pgsql \
psql -U postgres -c "create database compose"
-
name: Create Store Database
run: |
cd store
until docker compose exec -T \
store_pgsql pg_isready -U postgres; do sleep 1; done
docker compose exec -T \
store_pgsql \
psql -U postgres -c "create database neurostore"
-
name: Initialize Compose Database
run: |
cd compose
docker compose exec -T compose \
bash -c \
"flask db merge heads && \
flask db stamp head && \
flask db migrate && \
flask db upgrade"
-
name: Initialize Store Database
run: |
cd store
docker compose exec -T neurostore \
bash -c \
"flask db merge heads && \
flask db stamp head && \
flask db migrate && \
flask db upgrade"
-
name: Ingest data into Store
run: |
cd store
docker compose exec -T neurostore bash -c "flask ingest-neurosynth --max-rows 100"
-
name: Ingest data into Compose
run: |
cd compose
ipaddr=$(docker inspect neurostore | python3 -c "import sys, json; print(json.load(sys.stdin)[0]['NetworkSettings']['Networks']['nginx-proxy']['IPAddress'])")
docker compose exec -T compose bash -c "flask create-meta-analyses --n-studysets 1 --neurostore-url http://${ipaddr}:8000"
-
name: Frontend Cypress E2E Tests
uses: cypress-io/github-action@v6
env:
CYPRESS_auth0ClientId: ${{ secrets.REACT_APP_AUTH0_CLIENT_ID }}
CYPRESS_auth0ClientSecret: ${{ secrets.REACT_APP_AUTH0_CLIENT_SECRET }}
CYPRESS_auth0Domain: ${{ secrets.REACT_APP_AUTH0_DOMAIN }}
CYPRESS_auth0Audience: localhost
REACT_APP_AUTH0_AUDIENCE: localhost
REACT_APP_AUTH0_CLIENT_ID: ${{ secrets.REACT_APP_AUTH0_CLIENT_ID }}
REACT_APP_AUTH0_DOMAIN: ${{ secrets.REACT_APP_AUTH0_DOMAIN }}
REACT_APP_AUTH0_CLIENT_SECRET: ${{ secrets.REACT_APP_AUTH0_CLIENT_SECRET }}
REACT_APP_ENV: DEV
REACT_APP_NEUROSTORE_API_DOMAIN: ${{ secrets.REACT_APP_NEUROSTORE_API_DOMAIN }}
REACT_APP_NEUROSYNTH_API_DOMAIN: ${{ secrets.REACT_APP_NEUROSYNTH_API_DOMAIN }}
with:
build: npm run build:dev
start: npm run start-ci:dev
browser: chrome
wait-on: http://localhost:3000
working-directory: /home/runner/work/neurostore/neurostore/compose/neurosynth-frontend