-
Notifications
You must be signed in to change notification settings - Fork 12
770 lines (680 loc) · 27 KB
/
build.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
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
# SPDX-FileCopyrightText: 2017-2023 City of Espoo
#
# SPDX-License-Identifier: LGPL-2.1-or-later
name: Build
on:
pull_request:
push:
branches:
- master
workflow_dispatch:
inputs:
push:
required: false
default: 'true'
playwright_tag:
required: true
default: 'master'
env:
AWS_REGION: eu-west-1
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
permissions:
id-token: write
contents: read
packages: write
actions: read
jobs:
cache-bust:
runs-on: ubuntu-latest
steps:
- name: "Cache bust"
id: cache-bust
run: echo "cache-bust=$(date '+%Y-%V')" >> "$GITHUB_OUTPUT"
outputs:
cache-bust: ${{ steps.cache-bust.outputs.cache-bust }}
lint-shell:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: espoon-voltti/voltti-actions/shellcheck@v1
check-licenses:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Reuse Compliance Check
uses: fsfe/reuse-action@v5
keycloak:
runs-on: ubuntu-latest
needs:
- cache-bust
steps:
- uses: actions/checkout@v4
- name: Setup Docker building
if: ${{ github.actor != 'dependabot[bot]' && !github.event.pull_request.head.repo.fork }}
id: setup
uses: espoon-voltti/voltti-actions/docker-setup@master
with:
DOCKERHUB_USERNAME: ${{ secrets.DOCKERHUB_USERNAME }}
DOCKERHUB_TOKEN: ${{ secrets.DOCKERHUB_TOKEN }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
AWS_REGION: ${{ env.AWS_REGION }}
AWS_ROLE: ${{ secrets.AWS_ROLE }}
- name: Build keycloak image
if: ${{ github.actor != 'dependabot[bot]' && !github.event.pull_request.head.repo.fork }}
id: build
uses: espoon-voltti/voltti-actions/docker-build-registry@master
with:
registry: ${{ steps.setup.outputs.ecr_registry }}
name: evaka/keycloak
path: ./keycloak
push: ${{ inputs.push || 'true' }}
build-args: |
CACHE_BUST=${{ needs.cache-bust.outputs.cache-bust }}
build=${{ github.run_number }}
commit=${{ github.event.pull_request.head.sha || github.sha }}
- name: Docker cleanup
if: always()
uses: espoon-voltti/voltti-actions/docker-cleanup@master
outputs:
image: ${{ steps.build.outputs.image }}
frontend-common:
runs-on: ubuntu-latest
needs:
- cache-bust
steps:
- uses: actions/checkout@v4
- name: Setup Docker building
if: ${{ github.actor != 'dependabot[bot]' && !github.event.pull_request.head.repo.fork }}
id: setup
uses: espoon-voltti/voltti-actions/docker-setup@master
with:
DOCKERHUB_USERNAME: ${{ secrets.DOCKERHUB_USERNAME }}
DOCKERHUB_TOKEN: ${{ secrets.DOCKERHUB_TOKEN }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
AWS: false
- name: Build frontend image
if: ${{ github.actor != 'dependabot[bot]' && !github.event.pull_request.head.repo.fork }}
uses: espoon-voltti/voltti-actions/docker-build-registry@master
id: build
with:
registry: ghcr.io/espoon-voltti
name: evaka/frontend-common
path: ./frontend
push: ${{ inputs.push || 'true' }}
build-args: |
CACHE_BUST=${{ needs.cache-bust.outputs.cache-bust }}
SENTRY_PUBLISH_ENABLED=false
build=${{ github.run_number }}
commit=${{ github.event.pull_request.head.sha || github.sha }}
ICONS=free
build-contexts:
customizations=frontend/src/lib-customizations/espoo
- name: Build frontend image builder
if: ${{ github.actor != 'dependabot[bot]' && !github.event.pull_request.head.repo.fork }}
uses: espoon-voltti/voltti-actions/docker-build-registry@master
id: builder
with:
registry: ghcr.io/espoon-voltti
name: evaka/frontend-common-builder
cache_from: ${{ steps.build.outputs.image_cache }}
path: ./frontend
target: builder
push: ${{ inputs.push || 'true' }}
build-args: |
CACHE_BUST=${{ needs.cache-bust.outputs.cache-bust }}
SENTRY_PUBLISH_ENABLED=false
build=${{ github.run_number }}
commit=${{ github.event.pull_request.head.sha || github.sha }}
ICONS=free
build-contexts:
customizations=frontend/src/lib-customizations/espoo
- name: Docker cleanup
if: always()
uses: espoon-voltti/voltti-actions/docker-cleanup@master
outputs:
image: ${{ steps.build.outputs.image }}
image_name: ${{ steps.build.outputs.image_name }}
builder_image: ${{ steps.builder.outputs.image }}
builder_image_name: ${{ steps.builder.outputs.image_name }}
frontend:
runs-on: ubuntu-latest
needs:
- cache-bust
steps:
- uses: actions/checkout@v4
- name: Cache fortawesome
if: ${{ github.actor != 'dependabot[bot]' && !github.event.pull_request.head.repo.fork }}
id: fortawesome
uses: actions/cache@v4
with:
path: frontend/node_modules
key: fortawesome-${{ hashFiles('frontend/setup-pro-icons.sh') }}
- uses: actions/setup-node@v4
if: ${{ github.actor != 'dependabot[bot]' && !github.event.pull_request.head.repo.fork && steps.fortawesome.outputs.cache-hit != 'true' }}
with:
node-version: 18
- name: Install fortawesome
if: ${{ github.actor != 'dependabot[bot]' && !github.event.pull_request.head.repo.fork && steps.fortawesome.outputs.cache-hit != 'true' }}
run: |
cat << EOF > frontend/.npmrc
@fortawesome:registry=https://npm.fontawesome.com/
//npm.fontawesome.com/:_authToken="${{ secrets.FONTAWESOME_TOKEN }}"
EOF
./frontend/setup-pro-icons.sh
rm frontend/.npmrc
- name: Setup Docker building
if: ${{ github.actor != 'dependabot[bot]' && !github.event.pull_request.head.repo.fork }}
id: setup
uses: espoon-voltti/voltti-actions/docker-setup@master
with:
DOCKERHUB_USERNAME: ${{ secrets.DOCKERHUB_USERNAME }}
DOCKERHUB_TOKEN: ${{ secrets.DOCKERHUB_TOKEN }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
AWS_REGION: ${{ env.AWS_REGION }}
AWS_ROLE: ${{ secrets.AWS_ROLE }}
- name: Build frontend image
if: ${{ github.actor != 'dependabot[bot]' && !github.event.pull_request.head.repo.fork }}
uses: espoon-voltti/voltti-actions/docker-build-registry@master
id: build
with:
registry: ${{ steps.setup.outputs.ecr_registry }}
name: evaka/frontend
path: ./frontend
push: ${{ inputs.push || 'true' }}
build-args: |
CACHE_BUST=${{ needs.cache-bust.outputs.cache-bust }}
SENTRY_PUBLISH_ENABLED=${{ github.ref_name == 'master' && 'true' || 'false' }}
build=${{ github.run_number }}
commit=${{ github.event.pull_request.head.sha || github.sha }}
ICONS=pro
SENTRY_AUTH_TOKEN=${{ secrets.SENTRY_AUTH_TOKEN }}
build-contexts:
customizations=frontend/src/lib-customizations/espoo
- name: Docker cleanup
if: always()
uses: espoon-voltti/voltti-actions/docker-cleanup@master
outputs:
image: ${{ steps.build.outputs.image }}
image_name: ${{ steps.build.outputs.image_name }}
frontend-test:
needs:
- frontend-common
- frontend
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Login to GitHub Container Registry
if: ${{ github.actor != 'dependabot[bot]' && !github.event.pull_request.head.repo.fork }}
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Lint
if: ${{ github.actor != 'dependabot[bot]' && !github.event.pull_request.head.repo.fork }}
run: docker run --rm "${{ needs.frontend-common.outputs.builder_image }}" yarn lint
- name: Type check
if: ${{ github.actor != 'dependabot[bot]' && !github.event.pull_request.head.repo.fork }}
run: docker run --rm "${{ needs.frontend-common.outputs.builder_image }}" yarn type-check
- name: Test
if: ${{ github.actor != 'dependabot[bot]' && !github.event.pull_request.head.repo.fork }}
run: docker run --rm "${{ needs.frontend-common.outputs.builder_image }}" yarn test --maxWorkers=2
- name: Build and test fork
id: fork
if: ${{ github.actor == 'dependabot[bot]' || github.event.pull_request.head.repo.fork }}
run: |
cd ./frontend
./build-docker.sh test
- name: Docker cleanup
if: always()
uses: espoon-voltti/voltti-actions/docker-cleanup@master
api-gateway:
runs-on: ubuntu-latest
needs:
- cache-bust
steps:
- uses: actions/checkout@v4
- name: Setup Docker building
if: ${{ github.actor != 'dependabot[bot]' && !github.event.pull_request.head.repo.fork }}
id: setup
uses: espoon-voltti/voltti-actions/docker-setup@master
with:
DOCKERHUB_USERNAME: ${{ secrets.DOCKERHUB_USERNAME }}
DOCKERHUB_TOKEN: ${{ secrets.DOCKERHUB_TOKEN }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
AWS_REGION: ${{ env.AWS_REGION }}
AWS_ROLE: ${{ secrets.AWS_ROLE }}
- name: Build and run API-gateway tests
if: ${{ github.actor != 'dependabot[bot]' && !github.event.pull_request.head.repo.fork }}
uses: espoon-voltti/voltti-actions/docker-build-registry@master
id: test
with:
registry: ${{ steps.setup.outputs.ecr_registry }}
name: evaka/api-gateway-test
path: ./apigw
push: false
load: true
target: test
build-args: |
CACHE_BUST=${{ needs.cache-bust.outputs.cache-bust }}
build=${{ github.run_number }}
commit=${{ github.event.pull_request.head.sha || github.sha }}
- name: Build API-gateway image
if: ${{ github.actor != 'dependabot[bot]' && !github.event.pull_request.head.repo.fork }}
uses: espoon-voltti/voltti-actions/docker-build-registry@master
id: build
with:
registry: ${{ steps.setup.outputs.ecr_registry }}
name: evaka/api-gateway
path: ./apigw
push: ${{ inputs.push || 'true' }}
build-args: |
CACHE_BUST=${{ needs.cache-bust.outputs.cache-bust }}
build=${{ github.run_number }}
commit=${{ github.event.pull_request.head.sha || github.sha }}
- name: Build docker tests and image on fork
if: ${{ github.actor == 'dependabot[bot]' || github.event.pull_request.head.repo.fork }}
run: |
cd ./apigw
./build-docker.sh test
./build-docker.sh
outputs:
image: ${{ steps.build.outputs.image }}
service:
runs-on: ubuntu-latest
needs:
- cache-bust
steps:
- uses: actions/checkout@v4
- name: Setup Docker building
if: ${{ github.actor != 'dependabot[bot]' && !github.event.pull_request.head.repo.fork }}
id: setup
uses: espoon-voltti/voltti-actions/docker-setup@master
with:
DOCKERHUB_USERNAME: ${{ secrets.DOCKERHUB_USERNAME }}
DOCKERHUB_TOKEN: ${{ secrets.DOCKERHUB_TOKEN }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
AWS_REGION: ${{ env.AWS_REGION }}
AWS_ROLE: ${{ secrets.AWS_ROLE }}
- name: Build Evaka Service image
if: ${{ github.actor != 'dependabot[bot]' && !github.event.pull_request.head.repo.fork }}
uses: espoon-voltti/voltti-actions/docker-build-registry@master
id: build
with:
registry: ${{ steps.setup.outputs.ecr_registry }}
name: evaka/service
path: .
dockerfile: service/Dockerfile
push: ${{ inputs.push || 'true' }}
build-args: |
CACHE_BUST=${{ needs.cache-bust.outputs.cache-bust }}
build=${{ github.run_number }}
commit=${{ github.event.pull_request.head.sha || github.sha }}
- name: Build Evaka Service builder image
if: ${{ github.actor != 'dependabot[bot]' && !github.event.pull_request.head.repo.fork }}
uses: espoon-voltti/voltti-actions/docker-build-registry@master
id: builder
with:
registry: ${{ steps.setup.outputs.ecr_registry }}
name: evaka/service-builder
target: builder
cache_from: ${{ steps.build.outputs.image_cache }}
path: .
dockerfile: service/Dockerfile
push: ${{ inputs.push || 'true' }}
build-args: |
CACHE_BUST=${{ needs.cache-bust.outputs.cache-bust }}
build=${{ github.run_number }}
commit=${{ github.event.pull_request.head.sha || github.sha }}
- name: Docker cleanup
if: always()
uses: espoon-voltti/voltti-actions/docker-cleanup@master
outputs:
image: ${{ steps.build.outputs.image }}
image_name: ${{ steps.build.outputs.image_name }}
builder_image: ${{ steps.builder.outputs.image }}
builder_image_name: ${{ steps.builder.outputs.image_name }}
service-test:
needs:
- cache-bust
- service
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Setup Docker building
if: ${{ github.actor != 'dependabot[bot]' && !github.event.pull_request.head.repo.fork }}
id: setup
uses: espoon-voltti/voltti-actions/docker-setup@master
with:
DOCKERHUB_USERNAME: ${{ secrets.DOCKERHUB_USERNAME }}
DOCKERHUB_TOKEN: ${{ secrets.DOCKERHUB_TOKEN }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
AWS_REGION: ${{ env.AWS_REGION }}
AWS_ROLE: ${{ secrets.AWS_ROLE }}
- name: Build and run Evaka Service tests
if: ${{ github.actor != 'dependabot[bot]' && !github.event.pull_request.head.repo.fork }}
uses: espoon-voltti/voltti-actions/docker-build-registry@master
id: build
with:
registry: ${{ steps.setup.outputs.ecr_registry }}
name: evaka/service-test
path: .
dockerfile: service/test.Dockerfile
push: false
load: true
build-args: |
CACHE_BUST=${{ needs.cache-bust.outputs.cache-bust }}
build=${{ github.run_number }}
commit=${{ github.event.pull_request.head.sha || github.sha }}
BASE_IMAGE=${{ needs.service.outputs.builder_image }}
- name: Run service tests for fork
if: ${{ github.actor == 'dependabot[bot]' || github.event.pull_request.head.repo.fork }}
shell: bash
run: |
cd ./service
./build-docker.sh test
- name: Docker cleanup
if: always()
uses: espoon-voltti/voltti-actions/docker-cleanup@master
owasp:
needs:
- service
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Configure AWS credentials
if: ${{ github.actor != 'dependabot[bot]' && !github.event.pull_request.head.repo.fork }}
uses: aws-actions/configure-aws-credentials@v4
with:
aws-region: ${{ env.AWS_REGION }}
role-to-assume: ${{ secrets.AWS_ROLE }}
role-duration-seconds: 1200
- name: Login to Amazon ECR
if: ${{ github.actor != 'dependabot[bot]' && !github.event.pull_request.head.repo.fork }}
id: ecr
uses: aws-actions/amazon-ecr-login@v2
with:
mask-password: 'true'
- name: Cache dependency check database
if: ${{ github.actor != 'dependabot[bot]' && !github.event.pull_request.head.repo.fork }}
uses: actions/cache@v4
with:
path: dependency-check-data
key: dependency-check-data-${{ github.run_id }}-${{ github.run_attempt }}
restore-keys: |
dependency-check-data-
- name: Run service OWASP tests
if: ${{ github.actor != 'dependabot[bot]' && !github.event.pull_request.head.repo.fork }}
shell: bash
run: |
docker run --rm \
-e NVD_API_KEY=${{ secrets.NVD_API_KEY }} \
-v $(pwd)/dependency-check-data:/root/.gradle/dependency-check-data \
${{ needs.service.outputs.builder_image }} \
sh -c "./gradlew --no-daemon dependencyCheckUpdate && ./gradlew --no-daemon dependencyCheckAnalyze"
service-integration-test:
needs:
- keycloak
- service
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
test_chunk_number: [1, 2, 3, 4]
test_chunk_count: [4] # must max value of above list
steps:
- uses: actions/checkout@v4
- name: Login to GitHub Container Registry
if: ${{ !github.event.pull_request.head.repo.fork }}
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Run service integration tests
if: ${{ github.actor != 'dependabot[bot]' && !github.event.pull_request.head.repo.fork }}
shell: bash
env:
TAG: "${{ github.event.pull_request.head.sha || github.sha }}"
BUILD: "false"
run: |
cd ./compose
mkdir -p test-results/
./compose-integration pull
./compose-integration run integration-test $(../bin/split-integration-tests.sh "${{ matrix.test_chunk_number }}" "${{ matrix.test_chunk_count }}")
./compose-integration logs db > test-results/db.log
- name: Run service integration tests for fork
if: ${{ github.actor == 'dependabot[bot]' || github.event.pull_request.head.repo.fork }}
shell: bash
run: |
cd ./compose
./compose-integration run integration-test $(../bin/split-integration-tests.sh "${{ matrix.test_chunk_number }}" "${{ matrix.test_chunk_count }}")
- name: Store test results
uses: actions/upload-artifact@v4
if: always()
with:
name: integration-test-results-${{ matrix.test_chunk_number }}
path: ./compose/test-results/
retention-days: 2
e2e-split:
runs-on: ubuntu-latest
env:
GH_TOKEN: ${{ github.token }}
CHUNK_COUNT: 6 # must match the number of chunks in the e2e job
steps:
- uses: actions/checkout@v4
- name: Split e2e tests
run: |
./bin/timings.sh $CHUNK_COUNT e2e-test-chunk--{}.txt
- name: Upload test chunks
uses: actions/upload-artifact@v4
with:
name: e2e-test-chunks
path: e2e-test-chunk--*.txt
e2e:
needs:
- service
- api-gateway
- keycloak
- frontend-common
- frontend
- e2e-split
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
# If you change the number of chunks, remember to update CHUNK_COUNT in e2e-split job
test_chunk_number: [1, 2, 3, 4, 5, 6]
env:
PLAYWRIGHT_TAG: "${{ inputs.playwright_tag || 'master' }}"
steps:
- uses: actions/checkout@v4
- name: Login to Docker Hub
if: ${{ github.actor != 'dependabot[bot]' && !github.event.pull_request.head.repo.fork }}
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Login to GitHub Container Registry
if: ${{ github.actor != 'dependabot[bot]' && !github.event.pull_request.head.repo.fork }}
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Download test chunks
uses: actions/download-artifact@v4
with:
name: e2e-test-chunks
- name: Run e2e tests
if: ${{ github.actor != 'dependabot[bot]' && !github.event.pull_request.head.repo.fork }}
env:
TAG: "${{ github.event.pull_request.head.sha || github.sha }}"
BUILD: "false"
FRONTEND_IMAGE: "ghcr.io/espoon-voltti/evaka/frontend"
run: |
set -eo pipefail
cp e2e-test-chunk--${{ matrix.test_chunk_number }}.txt frontend/playwright-filenames.txt
echo "Tests to run:"
cat frontend/playwright-filenames.txt
cd ./compose
./test-e2e pull
./test-e2e run playwright | tee e2e.log
- name: Run e2e tests for fork
if: ${{ github.actor == 'dependabot[bot]' || github.event.pull_request.head.repo.fork }}
run: |
set -eo pipefail
cp e2e-test-chunk--${{ matrix.test_chunk_number }}.txt frontend/playwright-filenames.txt
echo "Tests to run:"
cat frontend/playwright-filenames.txt
cd ./compose
./test-e2e run playwright | tee e2e.log
- name: Get logs
if: always()
run: |
cd compose
./test-e2e logs > e2e-all.log
- name: Store screenshots and logs
if: always()
uses: actions/upload-artifact@v4
with:
name: e2e-test-results-${{ matrix.test_chunk_number }}
path: |
frontend/screenshots/
frontend/traces/
compose/e2e.log
compose/e2e-all.log
retention-days: 2
frontend-s3:
if: ${{ github.ref == 'refs/heads/master' && github.actor != 'dependabot[bot]' && !github.event.pull_request.head.repo.fork && inputs.push != 'false' }}
needs:
- frontend
- frontend-test
runs-on: ubuntu-latest
steps:
- name: Configure AWS credentials
if: ${{ github.actor != 'dependabot[bot]' && !github.event.pull_request.head.repo.fork }}
uses: aws-actions/configure-aws-credentials@v4
with:
aws-region: ${{ env.AWS_REGION }}
role-to-assume: ${{ secrets.AWS_ROLE }}
role-duration-seconds: 1200
- name: Login to Amazon ECR
id: login-ecr
uses: aws-actions/amazon-ecr-login@v2
with:
mask-password: 'true'
- name: Extract frontend files
run: |
rm -rf ./frontend-build/
docker create -ti --name frontend_instance "${{ needs.frontend.outputs.image }}" sh
docker cp frontend_instance:/static ./frontend-build
docker rm -f frontend_instance
- name: Configure AWS credentials
if: ${{ github.actor != 'dependabot[bot]' && !github.event.pull_request.head.repo.fork }}
uses: aws-actions/configure-aws-credentials@v4
with:
aws-region: ${{ env.AWS_REGION }}
role-to-assume: ${{ secrets.AWS_ROLE }}
role-duration-seconds: 1200
- name: Clean build from non-versioned files
run: |
cd ./frontend-build/
for filename in index.html service-worker.js service-worker.js.map; do
find . -name "$filename" -not -path "./maintenance-page/*" -type f -delete
done
aws s3 sync --exact-timestamps . s3://evaka-static/
tag:
if: ${{ github.actor != 'dependabot[bot]' && !github.event.pull_request.head.repo.fork }}
runs-on: ubuntu-latest
needs:
- service-test
- service-integration-test
- e2e
- frontend-test
- lint-shell
- check-licenses
steps:
- name: Configure AWS credentials
if: ${{ github.actor != 'dependabot[bot]' && !github.event.pull_request.head.repo.fork }}
uses: aws-actions/configure-aws-credentials@v4
with:
aws-region: ${{ env.AWS_REGION }}
role-to-assume: ${{ secrets.AWS_ROLE }}
role-duration-seconds: 1200
- name: Login to GitHub Container Registry
if: ${{ github.actor != 'dependabot[bot]' && !github.event.pull_request.head.repo.fork }}
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Docker metadata # Used to get the tag from DOCKER_METADATA_OUTPUT_VERSION
id: metadata
env:
DOCKER_METADATA_PR_HEAD_SHA: "true"
uses: docker/metadata-action@v5
with:
images: |
evaka/dummy
tags: |
type=ref,event=pr,prefix=pr-
type=ref,event=branch,prefix=
- name: Retag with branch
run: |
if test -z "$DOCKER_METADATA_OUTPUT_VERSION"; then
echo "Empty tag"
exit 1
fi
for repository in evaka/keycloak evaka/frontend evaka/frontend-common evaka/frontend-common-builder evaka/service evaka/service-builder evaka/api-gateway; do
ghcr_image_base="ghcr.io/espoon-voltti/${repository}"
ghcr_image="${ghcr_image_base}:${{ github.event.pull_request.head.sha || github.sha }}"
ghcr_target="${ghcr_image_base}:${DOCKER_METADATA_OUTPUT_VERSION}"
echo "Tagging GHCR with '${ghcr_target}'"
docker pull "$ghcr_image"
docker tag "$ghcr_image" "${ghcr_image_base}:${DOCKER_METADATA_OUTPUT_VERSION}"
docker push "${ghcr_image_base}:${DOCKER_METADATA_OUTPUT_VERSION}"
done
for repository in evaka/keycloak evaka/frontend evaka/service evaka/api-gateway; do
# ECR retag
MANIFEST=$(aws ecr batch-get-image --repository-name "$repository" --image-ids imageTag="${{ github.event.pull_request.head.sha || github.sha }}" --output json | jq --raw-output --join-output '.images[0].imageManifest')
aws ecr put-image --repository-name "$repository" --image-tag "${DOCKER_METADATA_OUTPUT_VERSION}" --image-manifest "$MANIFEST"
done
deploy:
if: ${{ github.ref == 'refs/heads/master' && github.actor != 'dependabot[bot]' && !github.event.pull_request.head.repo.fork }}
env:
DEPLOY_REPO_OWNER: 'espoon-voltti'
DEPLOY_REPO_NAME: 'evaka-deploy'
DEPLOY_REPO_WORKFLOW: 'deploy.yml'
runs-on: ubuntu-latest
needs:
- tag
- frontend-s3
steps:
- uses: actions/github-script@v7
with:
github-token: '${{ secrets.EVAKA_PAT }}'
script: |
await github.rest.actions.createWorkflowDispatch({
owner: '${{ env.DEPLOY_REPO_OWNER }}',
repo: '${{ env.DEPLOY_REPO_NAME }}',
workflow_id: '${{ env.DEPLOY_REPO_WORKFLOW }}',
ref: 'master',
inputs: {
version: '${{ github.event.pull_request.head.sha || github.sha }}'
}
})
notify:
if: ${{ always() && contains(needs.*.result, 'failure') && github.ref == 'refs/heads/master' }}
runs-on: ubuntu-latest
needs:
- deploy
steps:
- name: Report failure
uses: espoon-voltti/voltti-actions/notify@master
with:
webhook_url: ${{ secrets.SLACK_WEBHOOK_URL }}
channel: "#evaka-alerts"
message: "CI job for master branch failed"