-
Notifications
You must be signed in to change notification settings - Fork 19
1224 lines (1191 loc) · 47.8 KB
/
ci.yaml
File metadata and controls
1224 lines (1191 loc) · 47.8 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
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
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
name: Continous Integration
on:
push:
branches:
- main
paths-ignore:
- "VERSION"
- "CHANGELOG.md"
pull_request:
types: [opened, synchronize, labeled]
paths-ignore:
- "VERSION"
workflow_dispatch:
workflow_call:
repository_dispatch:
types: [start-ci, deploy-demo]
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
env:
MIX_ENV: test
ELIXIR_BC: "1.15.7-otp-26"
ERLANG_BC: "26.2.1"
NODEJS_BC: "20.20.0"
jobs:
# job to detect changed paths
# If not a PR, all jobs will run
# Otherwise, only jobs that are impacted from changed paths will run
detect-changes:
runs-on: ubuntu-24.04
outputs:
elixir-changed: ${{ steps.set-outputs.outputs.elixir-changed }}
assets-changed: ${{ steps.set-outputs.outputs.assets-changed }}
steps:
- name: Checkout
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
with:
fetch-depth: 0
- name: Check if running against a pull request
id: check-pr
run: |
if [[ "${{ github.event_name }}" == "pull_request" ]]; then
echo "running-on-pr=true" >> $GITHUB_OUTPUT
else
echo "running-on-pr=false" >> $GITHUB_OUTPUT
fi
- name: Detect file changes
uses: dorny/paths-filter@fbd0ab8f3e69293af611ebaee6363fc25e6d187d # v4
id: filter
if: steps.check-pr.outputs.running-on-pr == 'true'
with:
filters: |
# files that always trigger all jobs
all:
- '.tool-versions'
- '.github/**'
# files that only trigger elixir jobs
elixir:
- '*.ex'
- '*.exs'
- 'lib/**'
- 'config/**'
- 'mix.lock'
- 'test/fixtures/**'
- 'test/**/*.ex'
- 'test/**/*.exs'
- 'priv/repo/migrations/**'
# files that only trigger assets jobs
assets:
- 'assets/**'
- 'priv/static/**'
- name: Set final outputs
id: set-outputs
run: |
if [[ "${{ steps.check-pr.outputs.running-on-pr }}" == "false" ]]; then
echo "Not on a PR, running all jobs"
echo "elixir-changed=true" >> $GITHUB_OUTPUT
echo "assets-changed=true" >> $GITHUB_OUTPUT
elif [[ "${{ steps.filter.outputs.all }}" == "true" ]]; then
echo "It's a PR with changes in critical files, running all jobs"
echo "elixir-changed=true" >> $GITHUB_OUTPUT
echo "assets-changed=true" >> $GITHUB_OUTPUT
else
echo "It's a PR, we can run tests selectively"
echo "elixir-changed=${{ steps.filter.outputs.elixir || 'false' }}" >> $GITHUB_OUTPUT
echo "assets-changed=${{ steps.filter.outputs.assets || 'false' }}" >> $GITHUB_OUTPUT
fi
setup-matrix-env:
runs-on: ubuntu-24.04
needs: [detect-changes]
outputs:
ELIXIR_DEV: ${{ env.ELIXIR_VERSION }}
ERLANG_DEV: ${{ env.ERLANG_VERSION }}
NODEJS_DEV: ${{ env.NODEJS_VERSION }}
ELIXIR_BC: ${{ env.ELIXIR_BC }}
ERLANG_BC: ${{ env.ERLANG_BC }}
NODEJS_BC: ${{ env.NODEJS_BC }}
steps:
- name: Checkout
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
- name: gather versions
uses: endorama/asdf-parse-tool-versions@23a7edd74b0f97626c857c48e32ebbe4ba596a23 # v1.5.1
- name: Compute matrix
run: |
echo "ELIXIR_DEV=${{ env.ELIXIR_VERSION }}" >> $GITHUB_OUTPUT
echo "ERLANG_DEV=${{ env.ERLANG_VERSION }}" >> $GITHUB_OUTPUT
echo "NODEJS_DEV=${{ env.NODEJS_VERSION }}" >> $GITHUB_OUTPUT
echo "ELIXIR_BC=${{ env.ELIXIR_BC }}" >> $GITHUB_OUTPUT
echo "ERLANG_BC=${{ env.ERLANG_BC }}" >> $GITHUB_OUTPUT
echo "NODEJS_BC=${{ env.NODEJS_BC }}" >> $GITHUB_OUTPUT
elixir-deps:
name: Elixir ${{ matrix.mix_env }} dependencies
needs: [setup-matrix-env, detect-changes]
if: needs.detect-changes.outputs.elixir-changed == 'true' || always()
runs-on: ubuntu-24.04
strategy:
matrix:
include:
- mix_env: dev
elixir: ${{ needs.setup-matrix-env.outputs.ELIXIR_BC }}
otp: ${{ needs.setup-matrix-env.outputs.ERLANG_BC }}
- mix_env: dev
elixir: ${{ needs.setup-matrix-env.outputs.ELIXIR_DEV }}
otp: ${{ needs.setup-matrix-env.outputs.ERLANG_DEV }}
- mix_env: test
elixir: ${{ needs.setup-matrix-env.outputs.ELIXIR_BC }}
otp: ${{ needs.setup-matrix-env.outputs.ERLANG_BC }}
- mix_env: test
elixir: ${{ needs.setup-matrix-env.outputs.ELIXIR_DEV }}
otp: ${{ needs.setup-matrix-env.outputs.ERLANG_DEV }}
- mix_env: prod
elixir: ${{ needs.setup-matrix-env.outputs.ELIXIR_BC }}
otp: ${{ needs.setup-matrix-env.outputs.ERLANG_BC }}
- mix_env: prod
elixir: ${{ needs.setup-matrix-env.outputs.ELIXIR_DEV }}
otp: ${{ needs.setup-matrix-env.outputs.ERLANG_DEV }}
env:
MIX_ENV: ${{ matrix.mix_env }}
steps:
- name: Checkout
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
with:
fetch-depth: 0
- name: Setup
id: setup-elixir
uses: erlef/setup-beam@fc68ffb90438ef2936bbb3251622353b3dcb2f93 # v1
with:
otp-version: ${{ matrix.otp }}
elixir-version: ${{ matrix.elixir }}
- name: Retrieve Elixir Cached Dependencies
uses: actions/cache@668228422ae6a00e4ad889ee87cd7109ec5666a7 # v5
id: mix-cache
with:
path: |
deps
_build/${{ env.MIX_ENV }}
priv/plts
key: erlang-${{ steps.setup-elixir.outputs.otp-version }}-elixir-${{ steps.setup-elixir.outputs.elixir-version }}-${{ hashFiles('mix.lock') }}-${{ env.MIX_ENV }}
- name: Install Dependencies
if: steps.mix-cache.outputs.cache-hit != 'true'
run: |
mkdir -p priv/plts
mix local.rebar --force
mix local.hex --force
mix deps.get
mix deps.compile --warnings-as-errors
- name: Build Dialyzer PLT
if: steps.mix-cache.outputs.cache-hit != 'true' && matrix.mix_env != 'prod'
run: mix dialyzer --plt
npm-deps:
name: Npm dependencies
needs: [setup-matrix-env, detect-changes]
if: needs.detect-changes.outputs.assets-changed == 'true' || always()
runs-on: ubuntu-24.04
strategy:
matrix:
include:
- nodejs: ${{ needs.setup-matrix-env.outputs.NODEJS_BC }}
- nodejs: ${{ needs.setup-matrix-env.outputs.NODEJS_DEV }}
steps:
- name: Checkout
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
with:
fetch-depth: 0
- name: Setup Node
id: setup-node
uses: actions/setup-node@53b83947a5a98c8d113130e565377fae1a50d02f # v6
with:
node-version: ${{ matrix.nodejs }}
- name: Retrieve NPM Cached Dependencies
uses: actions/cache@668228422ae6a00e4ad889ee87cd7109ec5666a7 # v5
id: npm-cache
with:
path: |
assets/node_modules
key: nodejs-${{ steps.setup-node.outputs.node-version }}-${{ hashFiles('assets/package-lock.json') }}
- name: Install NPM dependencies
if: steps.npm-cache.outputs.cache-hit != 'true'
run: cd assets && npm ci
codespell:
name: Check common misspellings
needs: [detect-changes]
runs-on: ubuntu-24.04
defaults:
run:
shell: bash
steps:
- name: Checkout
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
with:
fetch-depth: 0
- name: Install codespell
run: |
sudo apt-get install -y git python3 python3-pip
python3 -m pip install codespell
- name: codespell
run: codespell -S priv*,*package*json,deps*,*node_modules*,*svg,*.git,*.app -L enque,daa,afterall,statics
generate-docs:
name: Generate project documentation
needs: [detect-changes]
runs-on: ubuntu-24.04
if: github.event_name == 'push' && github.ref_name == 'main'
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
- name: Set up Elixir
id: setup-elixir
uses: erlef/setup-beam@fc68ffb90438ef2936bbb3251622353b3dcb2f93 # v1
with:
version-file: .tool-versions
version-type: strict
- name: Retrieve Elixir Cached Dependencies
uses: actions/cache@668228422ae6a00e4ad889ee87cd7109ec5666a7 # v5
id: mix-cache
with:
path: |
deps
_build/${{ env.MIX_ENV }}
priv/plts
key: erlang-${{ steps.setup-elixir.outputs.otp-version }}-elixir-${{ steps.setup-elixir.outputs.elixir-version }}-${{ hashFiles('mix.lock') }}-${{ env.MIX_ENV }}
- name: Build docs
uses: lee-dohm/generate-elixir-docs@a745603eef443621976df401f45aaff4d849056b # v1
- name: Generate openapi.json
run: mix openapi.spec.json --start-app=false --spec TrentoWeb.OpenApi.All.ApiSpec
- name: Generate Swagger UI
uses: Legion2/swagger-ui-action@eff65dc3f193f0a749872be82f74baa35be0797d # v1
with:
output: ./doc/swaggerui
spec-file: openapi.json
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Publish to Pages
uses: peaceiris/actions-gh-pages@4f9cc6602d3f66b9c108549d475ec49e8ef4d45e # v4
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: ./doc
keep_files: true
static-code-analysis-js:
name: Static Code Analysis JS
needs: [setup-matrix-env, npm-deps, detect-changes]
if: needs.detect-changes.outputs.assets-changed == 'true'
runs-on: ubuntu-24.04
strategy:
matrix:
include:
- nodejs: ${{ needs.setup-matrix-env.outputs.NODEJS_BC }}
- nodejs: ${{ needs.setup-matrix-env.outputs.NODEJS_DEV }}
steps:
- name: Checkout
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
with:
fetch-depth: 0
- name: Setup Node
id: setup-node
uses: actions/setup-node@53b83947a5a98c8d113130e565377fae1a50d02f # v6
with:
node-version: ${{ matrix.nodejs }}
- name: Retrieve NPM Cached Dependencies
uses: actions/cache@668228422ae6a00e4ad889ee87cd7109ec5666a7 # v5
id: npm-cache
with:
path: |
assets/node_modules
key: nodejs-${{ steps.setup-node.outputs.node-version }}-${{ hashFiles('assets/package-lock.json') }}
- name: Run Eslint
run: cd assets && npm run lint
- name: Check JS Code Format
run: cd assets && npm run format:check
static-code-analysis-elixir:
name: Static Code Analysis Elixir
needs: [setup-matrix-env, elixir-deps, detect-changes]
if: needs.detect-changes.outputs.elixir-changed == 'true'
runs-on: ubuntu-24.04
strategy:
matrix:
include:
- elixir: ${{ needs.setup-matrix-env.outputs.ELIXIR_BC }}
otp: ${{ needs.setup-matrix-env.outputs.ERLANG_BC }}
- elixir: ${{ needs.setup-matrix-env.outputs.ELIXIR_DEV }}
otp: ${{ needs.setup-matrix-env.outputs.ERLANG_DEV }}
steps:
- name: Checkout
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
with:
fetch-depth: 0
- name: Setup
id: setup-elixir
uses: erlef/setup-beam@fc68ffb90438ef2936bbb3251622353b3dcb2f93 # v1
with:
otp-version: ${{ matrix.otp }}
elixir-version: ${{ matrix.elixir }}
- name: Retrieve Elixir Cached Dependencies
uses: actions/cache@668228422ae6a00e4ad889ee87cd7109ec5666a7 # v5
id: mix-cache
with:
path: |
deps
_build/${{ env.MIX_ENV }}
priv/plts
key: erlang-${{ steps.setup-elixir.outputs.otp-version }}-elixir-${{ steps.setup-elixir.outputs.elixir-version }}-${{ hashFiles('mix.lock') }}-${{ env.MIX_ENV }}
- name: Check for unused dependencies
run: mix deps.unlock --check-unused
- name: Check Code Format
run: mix format --check-formatted
- name: Run Credo
run: mix credo
- name: Run Dialyzer
run: mix dialyzer
test-javascript:
name: Javascript tests
needs: [setup-matrix-env, npm-deps, detect-changes]
if: needs.detect-changes.outputs.assets-changed == 'true'
runs-on: ubuntu-24.04
strategy:
matrix:
include:
- nodejs: ${{ needs.setup-matrix-env.outputs.NODEJS_BC }}
- nodejs: ${{ needs.setup-matrix-env.outputs.NODEJS_DEV }}
steps:
- name: Checkout
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
with:
fetch-depth: 0
- name: Setup Node
id: setup-node
uses: actions/setup-node@53b83947a5a98c8d113130e565377fae1a50d02f # v6
with:
node-version: ${{ matrix.nodejs }}
- name: Retrieve NPM Cached Dependencies
uses: actions/cache@668228422ae6a00e4ad889ee87cd7109ec5666a7 # v5
id: npm-cache
with:
path: |
assets/node_modules
key: nodejs-${{ steps.setup-node.outputs.node-version }}-${{ hashFiles('assets/package-lock.json') }}
- name: Run JS tests
run: cd assets && npm test
test-elixir:
name: Elixir tests
needs: [setup-matrix-env, elixir-deps, detect-changes]
if: needs.detect-changes.outputs.elixir-changed == 'true'
runs-on: ubuntu-24.04
strategy:
matrix:
include:
- elixir: ${{ needs.setup-matrix-env.outputs.ELIXIR_BC }}
otp: ${{ needs.setup-matrix-env.outputs.ERLANG_BC }}
- elixir: ${{ needs.setup-matrix-env.outputs.ELIXIR_DEV }}
otp: ${{ needs.setup-matrix-env.outputs.ERLANG_DEV }}
steps:
- name: Checkout
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
with:
fetch-depth: 0
- name: Setup
id: setup-elixir
uses: erlef/setup-beam@fc68ffb90438ef2936bbb3251622353b3dcb2f93 # v1
with:
otp-version: ${{ matrix.otp }}
elixir-version: ${{ matrix.elixir }}
- name: Retrieve Elixir Cached Dependencies
uses: actions/cache@668228422ae6a00e4ad889ee87cd7109ec5666a7 # v5
id: mix-cache
with:
path: |
deps
_build/${{ env.MIX_ENV }}
priv/plts
key: erlang-${{ steps.setup-elixir.outputs.otp-version }}-elixir-${{ steps.setup-elixir.outputs.elixir-version }}-${{ hashFiles('mix.lock') }}-${{ env.MIX_ENV }}
- name: Compile
run: mix compile --warnings-as-errors
- name: "Docker compose dependencies"
uses: isbang/compose-action@4894d2492015c1774ee5a13a95b1072093087ec3 # v2.5.0
with:
compose-file: "./docker-compose.yaml"
down-flags: "--volumes"
- name: Run test
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: mix coveralls.github --warnings-as-errors --trace
test-release:
name: Test release build
needs: [setup-matrix-env, elixir-deps, detect-changes]
if: needs.detect-changes.outputs.elixir-changed == 'true'
runs-on: ubuntu-24.04
strategy:
matrix:
include:
- elixir: ${{ needs.setup-matrix-env.outputs.ELIXIR_BC }}
otp: ${{ needs.setup-matrix-env.outputs.ERLANG_BC }}
- elixir: ${{ needs.setup-matrix-env.outputs.ELIXIR_DEV }}
otp: ${{ needs.setup-matrix-env.outputs.ERLANG_DEV }}
env:
MIX_ENV: prod
steps:
- name: Checkout
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
with:
fetch-depth: 0
- name: Setup
id: setup-elixir
uses: erlef/setup-beam@fc68ffb90438ef2936bbb3251622353b3dcb2f93 # v1
with:
otp-version: ${{ matrix.otp }}
elixir-version: ${{ matrix.elixir }}
- name: Retrieve Elixir Cached Dependencies
uses: actions/cache@668228422ae6a00e4ad889ee87cd7109ec5666a7 # v5
id: mix-cache
with:
path: |
deps
_build/${{ env.MIX_ENV }}
priv/plts
key: erlang-${{ steps.setup-elixir.outputs.otp-version }}-elixir-${{ steps.setup-elixir.outputs.elixir-version }}-${{ hashFiles('mix.lock') }}-${{ env.MIX_ENV }}
- name: Build release
run: mix release
- name: Start release
run: |
export DATABASE_URL=ecto://postgres:postgres@localhost/trento_dev
export EVENTSTORE_URL=ecto://postgres:postgres@localhost/trento_event_store_dev
export DATABASE_POOL_SIZE=10
export EVENTSTORE_POOL_SIZE=10
export PORT=4000
export SECRET_KEY_BASE=OxpmZytAd3dCb8heWykxY02zDQaNeDINbYK0ZCYxVn/xd+Vawc3JFiOLv5kwVBfARp3OT8mWqal0F45AiNP2QA==
export TRENTO_WEB_ORIGIN=localhost
export ACCESS_TOKEN_ENC_SECRET=Zk9Wm3Qr7Xt1Jv5Hn8Bl2Yp6Uf0Sd4Cg7Ei9Ao3Lw1Nx5Rk8Tj2Mq6Vh0Dp4Fa
export REFRESH_TOKEN_ENC_SECRET=Gx2Ym8Kp4Rn0Wj6Ct3Hs9Lv1Bf5Dq7Uo0Ei2Ak4Nz8Mw6Xr1Jl3Tf9Sg5Vh7Py
export AMQP_URL=amqp://guest:guest@localhost
export ADMIN_USER=admin
export CHECKS_SERVICE_BASE_URL=http://localhost:8081
export CHECKS_INTERVAL=5
export PROMETHEUS_URL=http://localhost:9090
export CHARTS_ENABLED=false
export HOST_HEARTBEAT_INTERVAL=5
export HOST_HEARTBEAT_ALLOWED_MISSED=0
export ENABLE_API_KEY=true
export ENABLE_OIDC=false
export ENABLE_OAUTH2=false
export ENABLE_SAML=false
export ENABLE_ALERTING=false
_build/prod/rel/trento/bin/trento eval "IO.puts(:ok)"
chromatic:
name: Chromatic deployment
needs: [setup-matrix-env, elixir-deps, npm-deps, detect-changes]
runs-on: ubuntu-24.04
if: github.event_name != 'repository_dispatch' && github.secret_source != 'None' && vars.CHROMATIC_ENABLED == 'true' && needs.detect-changes.outputs.assets-changed == 'true'
steps:
- name: Checkout
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
with:
fetch-depth: 0
- name: Setup
id: setup-elixir
uses: erlef/setup-beam@fc68ffb90438ef2936bbb3251622353b3dcb2f93 # v1
with:
otp-version: ${{ needs.setup-matrix-env.outputs.ERLANG_DEV }}
elixir-version: ${{ needs.setup-matrix-env.outputs.ELIXIR_DEV }}
- name: Setup Node
id: setup-node
uses: actions/setup-node@53b83947a5a98c8d113130e565377fae1a50d02f # v6
with:
node-version: ${{ needs.setup-matrix-env.outputs.NODEJS_DEV }}
- name: Retrieve Elixir Cached Dependencies
uses: actions/cache@668228422ae6a00e4ad889ee87cd7109ec5666a7 # v5
id: mix-cache
with:
path: |
deps
_build/${{ env.MIX_ENV }}
priv/plts
key: erlang-${{ steps.setup-elixir.outputs.otp-version }}-elixir-${{ steps.setup-elixir.outputs.elixir-version }}-${{ hashFiles('mix.lock') }}-${{ env.MIX_ENV }}
- name: Retrieve NPM Cached Dependencies
uses: actions/cache@668228422ae6a00e4ad889ee87cd7109ec5666a7 # v5
id: npm-cache
with:
path: |
assets/node_modules
key: nodejs-${{ steps.setup-node.outputs.node-version }}-${{ hashFiles('assets/package-lock.json') }}
- name: Build CSS
run: npx tailwindcss --input=css/app.css --output=../priv/static/assets/app.css --postcss
working-directory: assets
- name: Build Frontend
run: npm run build
working-directory: assets
- name: Publish to Chromatic
uses: chromaui/action@f191a0224b10e1a38b2091cefb7b7a2337009116 # v16.0.0
with:
workingDir: assets
projectToken: ${{ secrets.CHROMATIC_PROJECT_TOKEN }}
autoAcceptChanges: true
skip: dependabot/**
npm-e2e-deps:
name: Npm E2E dependencies
needs: [setup-matrix-env, detect-changes]
runs-on: ubuntu-24.04
steps:
- name: Checkout
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
with:
fetch-depth: 0
- name: Setup Node
id: setup-node
uses: actions/setup-node@53b83947a5a98c8d113130e565377fae1a50d02f # v6
with:
node-version: ${{ needs.setup-matrix-env.outputs.NODEJS_DEV }}
- name: Retrieve E2E NPM Cached Dependencies
uses: actions/cache@668228422ae6a00e4ad889ee87cd7109ec5666a7 # v5
id: npm-e2e-cache
with:
path: |
test/e2e/node_modules
key: nodejs-${{ steps.setup-node.outputs.node-version }}-${{ hashFiles('test/e2e/package-lock.json') }}
- name: Install E2E NPM dependencies
if: steps.npm-e2e-cache.outputs.cache-hit != 'true'
run: cd test/e2e && npm ci
test-e2e:
name: E2E Tests
needs:
[setup-matrix-env, elixir-deps, npm-deps, npm-e2e-deps, detect-changes]
runs-on: ubuntu-24.04
strategy:
fail-fast: false
matrix:
containers: [1, 2, 3, 4, 5, 6, 7, 8]
include:
- elixir: ${{ needs.setup-matrix-env.outputs.ELIXIR_DEV }}
otp: ${{ needs.setup-matrix-env.outputs.ERLANG_DEV }}
env:
MIX_ENV: dev
steps:
- name: Checkout
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
with:
fetch-depth: 0
- name: Setup
id: setup-elixir
uses: erlef/setup-beam@fc68ffb90438ef2936bbb3251622353b3dcb2f93 # v1
with:
otp-version: ${{ matrix.otp }}
elixir-version: ${{ matrix.elixir }}
- name: Setup Node
id: setup-node
uses: actions/setup-node@53b83947a5a98c8d113130e565377fae1a50d02f # v6
with:
node-version: ${{ needs.setup-matrix-env.outputs.NODEJS_DEV }}
- name: Retrieve Elixir Cached Dependencies
uses: actions/cache@668228422ae6a00e4ad889ee87cd7109ec5666a7 # v5
id: mix-cache
with:
path: |
deps
_build/${{ env.MIX_ENV }}
priv/plts
key: erlang-${{ steps.setup-elixir.outputs.otp-version }}-elixir-${{ steps.setup-elixir.outputs.elixir-version }}-${{ hashFiles('mix.lock') }}-${{ env.MIX_ENV }}
- name: Retrieve NPM Cached Dependencies
uses: actions/cache@668228422ae6a00e4ad889ee87cd7109ec5666a7 # v5
id: npm-cache
with:
path: |
assets/node_modules
key: nodejs-${{ steps.setup-node.outputs.node-version }}-${{ hashFiles('assets/package-lock.json') }}
- name: Retrieve E2E NPM Cached Dependencies
uses: actions/cache@668228422ae6a00e4ad889ee87cd7109ec5666a7 # v5
id: npm-e2e-cache
with:
path: |
test/e2e/node_modules
key: nodejs-${{ steps.setup-node.outputs.node-version }}-${{ hashFiles('test/e2e/package-lock.json') }}
- name: Check Eslint and JS Code Format
run: cd test/e2e && npm run lint && npm run format:check
- name: "Docker compose dependencies"
uses: isbang/compose-action@4894d2492015c1774ee5a13a95b1072093087ec3 # v2.5.0
with:
compose-file: "./docker-compose.yaml"
compose-flags: "--profile wanda"
down-flags: "--volumes"
- name: Mix setup
run: mix setup
- name: Run trento detached
run: mix phx.server &
- name: Install photofinish
uses: jaxxstorm/action-install-gh-release@25e24d2d23ae098373794ef1d6faecb48ee52da8 # v3.0.0
with:
repo: trento-project/photofinish
tag: v1.4.2
cache: enable
chmod: 0755
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Cypress run
uses: cypress-io/github-action@783cb3f07983868532cabaedaa1e6c00ff4786a8 # v7.1.9
env:
SPLIT: ${{ strategy.job-total }}
SPLIT_INDEX: ${{ strategy.job-index }}
cypress_video: false
cypress_photofinish_binary: $(whereis photofinish | cut -d" " -f2)
with:
working-directory: test/e2e
wait-on-timeout: 30
config: baseUrl=http://localhost:4000
- name: Upload cypress test screenshots
uses: actions/upload-artifact@bbbca2ddaa5d8feaa63e36b76fdaad77386f024f # v7
if: failure()
with:
name: e2e-screenshots-${{ matrix.containers }}
path: test/e2e/cypress/screenshots/
test-regression:
name: Regression tests
needs:
[setup-matrix-env, elixir-deps, npm-deps, npm-e2e-deps, detect-changes]
runs-on: ubuntu-22.04
strategy:
matrix:
include:
- test: sap_system_split
cypress_spec: |
cypress/e2e/databases_overview.cy.js
cypress/e2e/sap_systems_overview.cy.js
- test: process_manager_rename
cypress_spec: |
cypress/e2e/host_details.cy.js
env:
MIX_ENV: dev
steps:
- name: Checkout
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
with:
fetch-depth: 0
- name: Setup
id: setup-elixir
uses: erlef/setup-beam@fc68ffb90438ef2936bbb3251622353b3dcb2f93 # v1
with:
version-file: .tool-versions
version-type: strict
- name: Setup Node
id: setup-node
uses: actions/setup-node@53b83947a5a98c8d113130e565377fae1a50d02f # v6
with:
node-version: ${{ needs.setup-matrix-env.outputs.NODEJS_DEV }}
- name: Retrieve Elixir Cached Dependencies
uses: actions/cache@668228422ae6a00e4ad889ee87cd7109ec5666a7 # v5
id: mix-cache
with:
path: |
deps
_build/${{ env.MIX_ENV }}
priv/plts
key: erlang-${{ steps.setup-elixir.outputs.otp-version }}-elixir-${{ steps.setup-elixir.outputs.elixir-version }}-${{ hashFiles('mix.lock') }}-${{ env.MIX_ENV }}
- name: Retrieve NPM Cached Dependencies
uses: actions/cache@668228422ae6a00e4ad889ee87cd7109ec5666a7 # v5
id: npm-cache
with:
path: |
assets/node_modules
key: nodejs-${{ steps.setup-node.outputs.node-version }}-${{ hashFiles('assets/package-lock.json') }}
- name: Retrieve E2E NPM Cached Dependencies
uses: actions/cache@668228422ae6a00e4ad889ee87cd7109ec5666a7 # v5
id: npm-e2e-cache
with:
path: |
test/e2e/node_modules
key: nodejs-${{ steps.setup-node.outputs.node-version }}-${{ hashFiles('test/e2e/package-lock.json') }}
- name: "Docker compose dependencies"
uses: isbang/compose-action@4894d2492015c1774ee5a13a95b1072093087ec3 # v2.5.0
with:
compose-file: "./docker-compose.yaml"
down-flags: "--volumes"
- name: Postgres trento_dev restore
uses: tj-actions/pg-restore@7ac93da67774277a23b67c31b415760f5bee7441 # v6
with:
database_url: "postgresql://postgres:postgres@localhost:5433/postgres"
backup_file: "test/fixtures/regression/${{ matrix.test }}/trento_dev.sql"
postgresql_version: "15"
- name: Postgres trento_eventstore_dev restore
uses: tj-actions/pg-restore@7ac93da67774277a23b67c31b415760f5bee7441 # v6
with:
database_url: "postgresql://postgres:postgres@localhost:5433/postgres"
backup_file: "test/fixtures/regression/${{ matrix.test }}/trento_eventstore_dev.sql"
postgresql_version: "15"
- name: Run DB migrations
run: mix ecto.migrate
- name: Run DB seed
run: mix run priv/repo/seeds.exs
- name: Run trento detached
run: mix phx.server &
- name: Install photofinish
uses: jaxxstorm/action-install-gh-release@25e24d2d23ae098373794ef1d6faecb48ee52da8 # v3.0.0
with:
repo: trento-project/photofinish
tag: v1.4.2
cache: enable
chmod: 0755
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Cypress run
uses: cypress-io/github-action@783cb3f07983868532cabaedaa1e6c00ff4786a8 # v7.1.9
env:
cypress_video: false
cypress_photofinish_binary: $(whereis photofinish | cut -d" " -f2)
with:
working-directory: test/e2e
spec: ${{ matrix.cypress_spec }}
wait-on-timeout: 30
config: baseUrl=http://localhost:4000
- name: Upload cypress test screenshots
uses: actions/upload-artifact@bbbca2ddaa5d8feaa63e36b76fdaad77386f024f # v7
if: failure()
with:
name: regression-${{ matrix.test }}-e2e-screenshots
path: test/e2e/cypress/screenshots/
test-integration:
name: Integration tests
needs:
[setup-matrix-env, elixir-deps, npm-deps, npm-e2e-deps, detect-changes]
runs-on: ubuntu-22.04
strategy:
matrix:
include:
- test: oidc
cypress_spec: |
cypress/e2e/sso_integration.cy.js
config_file_content: |
import Config
config :trento, :oidc, enabled: true
env:
MIX_ENV: dev
CYPRESS_SSO_INTEGRATION_TESTS: true
CYPRESS_SSO_TYPE: oidc
NODEJS_VERSION: ${{ needs.setup-matrix-env.outputs.NODEJS_DEV }}
- test: oauth2
cypress_spec: |
cypress/e2e/sso_integration.cy.js
config_file_content: |
import Config
config :trento, :oauth2, enabled: true
env:
MIX_ENV: dev
CYPRESS_SSO_INTEGRATION_TESTS: true
CYPRESS_SSO_TYPE: oauth2
NODEJS_VERSION: ${{ needs.setup-matrix-env.outputs.NODEJS_DEV }}
- test: saml
cypress_spec: |
cypress/e2e/sso_integration.cy.js
config_file_content: |
import Config
config :trento, :saml, enabled: true
env:
MIX_ENV: dev
CYPRESS_SSO_INTEGRATION_TESTS: true
CYPRESS_SSO_TYPE: saml
NODEJS_VERSION: ${{ needs.setup-matrix-env.outputs.NODEJS_DEV }}
- test: alerting_db
cypress_spec: |
cypress/e2e/settings_integration.cy.js
cypress/e2e/alerting.cy.js
config_file_content: |
import Config
config :trento, :alerting,
enabled: nil,
smtp_server: nil,
smtp_port: nil,
smtp_username: nil,
smtp_password: nil
env:
MIX_ENV: dev
CYPRESS_ALERTING_DB_TESTS: true
CYPRESS_ALERTING_TESTS: true
NODEJS_VERSION: ${{ needs.setup-matrix-env.outputs.NODEJS_DEV }}
- test: alerting_from_env
cypress_spec: |
cypress/e2e/alerting.cy.js
env:
MIX_ENV: dev
CYPRESS_ALERTING_TESTS: true
NODEJS_VERSION: ${{ needs.setup-matrix-env.outputs.NODEJS_DEV }}
env: ${{ matrix.env }}
steps:
- name: Checkout
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
with:
fetch-depth: 0
- name: Setup
id: setup-elixir
uses: erlef/setup-beam@fc68ffb90438ef2936bbb3251622353b3dcb2f93 # v1
with:
version-file: .tool-versions
version-type: strict
- name: Setup Node
id: setup-node
uses: actions/setup-node@53b83947a5a98c8d113130e565377fae1a50d02f # v6
with:
node-version: ${{ env.NODEJS_VERSION }}
- name: Retrieve Elixir Cached Dependencies
uses: actions/cache@668228422ae6a00e4ad889ee87cd7109ec5666a7 # v5
id: mix-cache
with:
path: |
deps
_build/${{ env.MIX_ENV }}
priv/plts
key: erlang-${{ steps.setup-elixir.outputs.otp-version }}-elixir-${{ steps.setup-elixir.outputs.elixir-version }}-${{ hashFiles('mix.lock') }}-${{ env.MIX_ENV }}
- name: Retrieve NPM Cached Dependencies
uses: actions/cache@668228422ae6a00e4ad889ee87cd7109ec5666a7 # v5
id: npm-cache
with:
path: |
assets/node_modules
key: nodejs-${{ steps.setup-node.outputs.node-version }}-${{ hashFiles('assets/package-lock.json') }}
- name: Retrieve E2E NPM Cached Dependencies
uses: actions/cache@668228422ae6a00e4ad889ee87cd7109ec5666a7 # v5
id: npm-e2e-cache
with:
path: |
test/e2e/node_modules
key: nodejs-${{steps.setup-node.outputs.node-version }}-${{ hashFiles('test/e2e/package-lock.json') }}
- name: Install photofinish
uses: jaxxstorm/action-install-gh-release@25e24d2d23ae098373794ef1d6faecb48ee52da8 # v3.0.0
with:
repo: trento-project/photofinish
tag: v1.4.2
cache: enable
chmod: 0755
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: "Docker compose dependencies"
uses: isbang/compose-action@4894d2492015c1774ee5a13a95b1072093087ec3 # v2.5.0
with:
compose-file: "./docker-compose.yaml"
compose-flags: "--profile idp"
down-flags: "--volumes"
- name: Create dev.local.exs file
run: echo "${{ matrix.config_file_content }}" > config/dev.local.exs
- name: Mix setup
run: mix setup
- name: Run trento detached
run: mix phx.server &
- name: Cypress run
uses: cypress-io/github-action@783cb3f07983868532cabaedaa1e6c00ff4786a8 # v7.1.9
env:
cypress_video: false
cypress_photofinish_binary: $(whereis photofinish | cut -d" " -f2)
with:
working-directory: test/e2e
spec: ${{ matrix.cypress_spec }}
wait-on-timeout: 30
config: baseUrl=http://localhost:4000
- name: Upload cypress test screenshots
uses: actions/upload-artifact@bbbca2ddaa5d8feaa63e36b76fdaad77386f024f # v7
if: failure()
with:
name: integration-${{ matrix.test }}-e2e-screenshots
path: test/e2e/cypress/screenshots/
target-branch-deps:
name: Rebuild target branch dependencies
needs: [setup-matrix-env, detect-changes]
runs-on: ubuntu-24.04
strategy:
matrix:
include:
- elixir: ${{ needs.setup-matrix-env.outputs.ELIXIR_BC }}
otp: ${{ needs.setup-matrix-env.outputs.ERLANG_BC }}
- elixir: ${{ needs.setup-matrix-env.outputs.ELIXIR_DEV }}
otp: ${{ needs.setup-matrix-env.outputs.ERLANG_DEV }}
if: github.event_name == 'pull_request'
steps:
- name: Checkout target branch
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
with:
ref: ${{ github.event.pull_request.base.ref }}
- name: Set up Elixir
id: setup-elixir
uses: erlef/setup-beam@fc68ffb90438ef2936bbb3251622353b3dcb2f93 # v1
with:
otp-version: ${{ matrix.otp }}
elixir-version: ${{ matrix.elixir }}
- name: Retrieve Elixir Cached Dependencies - target branch
uses: actions/cache@668228422ae6a00e4ad889ee87cd7109ec5666a7 # v5
id: mix-cache-target
with:
path: |
deps
_build/${{ env.MIX_ENV }}
priv/plts
key: erlang-${{ steps.setup-elixir.outputs.otp-version }}-elixir-${{ steps.setup-elixir.outputs.elixir-version }}-${{ hashFiles('mix.lock') }}-${{ env.MIX_ENV }}
- name: Install missing dependencies
if: steps.mix-cache-target.outputs.cache-hit != 'true'
run: |
mkdir -p priv/plts
mix local.rebar --force
mix local.hex --force
mix deps.get
mix deps.compile --warnings-as-errors
mix dialyzer --plt
api-docs-check:
name: API docs check
needs: [setup-matrix-env, elixir-deps, detect-changes]
if: github.event_name == 'pull_request' && !failure() && !cancelled() && needs.detect-changes.outputs.elixir-changed == 'true'
runs-on: ubuntu-24.04
strategy:
matrix:
include:
- elixir: ${{ needs.setup-matrix-env.outputs.ELIXIR_BC }}
otp: ${{ needs.setup-matrix-env.outputs.ERLANG_BC }}
- elixir: ${{ needs.setup-matrix-env.outputs.ELIXIR_DEV }}
otp: ${{ needs.setup-matrix-env.outputs.ERLANG_DEV }}
steps:
- name: Checkout
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
with:
fetch-depth: 0
- name: Set up Elixir
id: setup-elixir
uses: erlef/setup-beam@fc68ffb90438ef2936bbb3251622353b3dcb2f93 # v1
with:
otp-version: ${{ matrix.otp }}
elixir-version: ${{ matrix.elixir }}
- name: Retrieve Elixir Cached Dependencies - current branch
uses: actions/cache@668228422ae6a00e4ad889ee87cd7109ec5666a7 # v5
id: mix-cache-current
with:
path: |
deps
_build/${{ env.MIX_ENV }}
priv/plts
key: erlang-${{ steps.setup-elixir.outputs.otp-version }}-elixir-${{ steps.setup-elixir.outputs.elixir-version }}-${{ hashFiles('mix.lock') }}-${{ env.MIX_ENV }}
- name: Setup Node.js
id: setup-node
uses: actions/setup-node@53b83947a5a98c8d113130e565377fae1a50d02f # v6
with:
node-version: ${{ needs.setup-matrix-env.outputs.NODEJS_DEV }}
- name: Install API linting tools
run: |
npm install -g @redocly/cli@latest
npm install -g @quobix/vacuum@latest
npm install -g @stoplight/spectral-cli
- name: Run API docs check
run: ./hack/api_docs_check.sh
api-bc-check:
name: API bc check
needs: [setup-matrix-env, elixir-deps, target-branch-deps, detect-changes]
if: github.event_name == 'pull_request' && !failure() && !cancelled() && needs.detect-changes.outputs.elixir-changed == 'true'
runs-on: ubuntu-24.04
strategy:
matrix:
include:
- version: Unversioned
elixir: ${{ needs.setup-matrix-env.outputs.ELIXIR_BC }}
otp: ${{ needs.setup-matrix-env.outputs.ERLANG_BC }}
- version: Unversioned
elixir: ${{ needs.setup-matrix-env.outputs.ELIXIR_DEV }}
otp: ${{ needs.setup-matrix-env.outputs.ERLANG_DEV }}
- version: V1
elixir: ${{ needs.setup-matrix-env.outputs.ELIXIR_BC }}