-
Notifications
You must be signed in to change notification settings - Fork 43
885 lines (776 loc) · 27.7 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
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
name: build
on:
pull_request:
workflow_dispatch:
merge_group:
types: [checks_requested]
push:
branches:
- dev
- staging
- prod
jobs:
build:
runs-on: ubuntu-latest
permissions:
packages: write
outputs:
stable_tags: ${{ steps.bake-metadata.outputs.stable_tags }}
stable_version: ${{ steps.bake-metadata.outputs.stable_version }}
output_method: ${{ steps.bake-metadata.outputs.output_method }}
strategy:
matrix:
targets:
- [core-build, core]
- [editoast, editoast-test]
- [gateway-test, gateway-standalone]
- [front-build, front-tests, front-devel, front-nginx]
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Make bake metadata
id: bake-metadata
env:
GITHUB_CONTEXT: ${{ toJson(github) }}
run: |
set -eo pipefail
echo ::group::Github context
python3 -m json.tool <<< "${GITHUB_CONTEXT}"
echo ::endgroup::
echo ::group::Bake metadata
.github/scripts/bake-metadata.py | tee bake-metadata.json
echo ::endgroup::
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
with:
version: v0.12.0
driver-opts: image=moby/buildkit:v0.12.3
buildkitd-flags: --debug
- name: Login to ghcr.io
uses: docker/login-action@v2
with:
registry: ghcr.io
username: '$' # special user for authenticating as a gh actions worker
password: ${{ secrets.GITHUB_TOKEN }}
# This action happens to randomly fail, so we retry it 3 times.
# Whitelisted messages are:
#
# - `failed to solve: failed to compute cache key`
# full message: `failed to solve: failed to compute cache key: failed to get state for index 0 on XXXXXX`
#
# - `httpReadSeeker: failed open: failed to authorize: no active session`
# full message: `ERROR: failed to solve: DeadlineExceeded: failed to compute cache key: failed to copy: httpReadSeeker: failed open: failed to authorize: no active session for XXXXX: context deadline exceeded`
- name: Build and push
run: |
set -eo pipefail
# disable cache mounts as github cache is slow
find -name Dockerfile -print0 | xargs -0 sed -Ei 's/--mount=type=cache,target=[^[:blank:]]+//g'
TRANSIENT_FAILURES=(
"failed to solve: failed to compute cache key"
"httpReadSeeker: failed open: failed to authorize: no active session"
)
BAKEFILE="--file=docker/docker-bake.hcl"
METADATA="--file=bake-metadata.json"
TARGETS="${{ join(matrix.targets, ' ') }}"
for i in $(seq 1 3); do
echo "::group::Try $i"
if docker buildx bake $BAKEFILE $METADATA $TARGETS 2>&1 | tee docker-build.log; then
echo "::endgroup::"
exit 0
fi
echo "::endgroup::"
for failure_msg in "${TRANSIENT_FAILURES[@]}"; do
if grep -q "$failure_msg" docker-build.log; then
echo "Transient failure detected, retrying..."
continue 2
fi
done
echo "Build failed for non-transient cause, exiting."
exit 1
done
echo "All retries failed, exiting."
exit 1
- name: Upload front-build artifact
uses: actions/upload-artifact@v4
if: steps.bake-metadata.outputs.output_method == 'artifact' && contains(matrix.targets, 'front-build')
with:
name: front-build
path: osrd-front-build.tar
- name: Upload core-build artifact
uses: actions/upload-artifact@v4
if: steps.bake-metadata.outputs.output_method == 'artifact' && contains(matrix.targets, 'core-build')
with:
name: core-build
path: osrd-core-build.tar
- name: Upload editoast-test artifact
uses: actions/upload-artifact@v4
if: steps.bake-metadata.outputs.output_method == 'artifact' && contains(matrix.targets, 'editoast-test')
with:
name: editoast-test
path: osrd-editoast-test.tar
- name: Upload editoast artifact
uses: actions/upload-artifact@v4
if: steps.bake-metadata.outputs.output_method == 'artifact' && contains(matrix.targets, 'editoast')
with:
name: editoast
path: osrd-editoast.tar
- name: Upload gateway-test artifact
uses: actions/upload-artifact@v4
if: steps.bake-metadata.outputs.output_method == 'artifact' && contains(matrix.targets, 'gateway-test')
with:
name: gateway-test
path: osrd-gateway-test.tar
- name: Upload front-tests artifact
uses: actions/upload-artifact@v4
if: steps.bake-metadata.outputs.output_method == 'artifact' && contains(matrix.targets, 'front-tests')
with:
name: front-tests
path: osrd-front-tests.tar
- name: Upload front artifact
uses: actions/upload-artifact@v4
if: steps.bake-metadata.outputs.output_method == 'artifact' && contains(matrix.targets, 'front-devel')
with:
name: front
path: osrd-front.tar
- name: Upload core artifact
uses: actions/upload-artifact@v4
if: steps.bake-metadata.outputs.output_method == 'artifact' && contains(matrix.targets, 'core')
with:
name: core
path: osrd-core.tar
- name: Upload gateway-standalone artifact
uses: actions/upload-artifact@v4
if: steps.bake-metadata.outputs.output_method == 'artifact' && contains(matrix.targets, 'gateway-standalone')
with:
name: gateway-standalone
path: osrd-gateway-standalone.tar
- name: Upload front-nginx artifact
uses: actions/upload-artifact@v4
if: steps.bake-metadata.outputs.output_method == 'artifact' && contains(matrix.targets, 'front-nginx')
with:
name: front-nginx
path: osrd-front-nginx.tar
check_generated_railjson_sync:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install poetry
run: pipx install poetry
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.9"
cache: "poetry"
- name: Install railjson_generator dependencies
run: |
poetry -C python/railjson_generator install
- name: Generate railjson
run: |
mkdir /tmp/generated_infras
poetry -C python/railjson_generator run python -m railjson_generator /tmp/generated_infras tests/infra-scripts/*.py
- name: Ensure generated infrastructures are up to date
run: diff -r -u tests/data/infras /tmp/generated_infras
check_railjson_generator:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install poetry
run: pipx install poetry
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.9"
cache: "poetry"
- name: Install railjson_generator dependencies
run: |
cd python/railjson_generator
poetry install
- name: Flake8
run: |
cd python/railjson_generator
poetry run pflake8 --config ./pyproject.toml --output-file flake8.xml --format junit-xml
- name: Publish flake8 report
uses: mikepenz/action-junit-report@v4
if: failure()
with:
report_paths: flake8.xml
- name: Black
run: |
cd python/railjson_generator
poetry run black . --check
- name: Isort
run: |
cd python/railjson_generator
poetry run isort . --check
- name: Pytype
run: |
cd python/railjson_generator
poetry run pytype -j auto
- name: Pytest
run: |
cd python/railjson_generator
poetry run pytest --cov --cov-report=xml
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v3
with:
name: codecov
flags: railjson_generator
directory: ./python/railjson_generator
token: ${{ secrets.CODECOV_TOKEN }}
fail_ci_if_error: false
verbose: true
files: coverage.xml
check_commits:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0 # Fetch all history for all branches and tags
- name: Check commit names
run: |
# We don't have a base ref to check against if we aren't in a
# pull_request workflow.
BASE=${{ github.base_ref }}
if [[ -z "$BASE" ]]; then
exit 0
fi
commit_titles() {
git log --format=%s origin/"$BASE"..HEAD --skip=1
}
commit_titles | TERM=xterm-color .github/scripts/check-commit-titles.sh
final_newline_lint:
runs-on: ubuntu-latest
name: Check final newline
steps:
- name: Install ripgrep
run: sudo apt-get install -y ripgrep
- name: Checkout
uses: actions/checkout@v4
- name: Check final newline is present
run: |
# search missing final newline
if rg -Ul '[^\n]\z' -g '!*.svg' .; then
echo "Found missing final newline on listed file(s)"
exit 1
fi
# search multiple final newlines
if rg -Ul '\n\n\z' .; then
echo "Found multiple final newlines on listed file(s)"
exit 1
fi
check_integration_tests:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Install poetry
run: pipx install poetry
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.9"
cache: "poetry"
- name: Install dependencies
run: |
cd tests
poetry install
- name: Flake8
run: |
cd tests
poetry run pflake8 --config ./pyproject.toml
- name: Black
run: |
cd tests
poetry run black . --check
- name: Isort
run: |
cd tests
poetry run isort . --check
- name: Pytype
run: |
cd tests
poetry run pytype -j auto
check_osrd_schema:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install poetry
run: pipx install poetry
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.9"
cache: "poetry"
- name: Install dependencies
run: |
cd python/osrd_schemas
poetry install
- name: Flake8
run: |
cd python/osrd_schemas
poetry run pflake8 --config ./pyproject.toml --output-file flake8.xml --format junit-xml
- name: Publish flake8 report
uses: mikepenz/action-junit-report@v4
if: failure()
with:
report_paths: flake8.xml
- name: Black
run: |
cd python/osrd_schemas
poetry run black . --check
- name: Isort
run: |
cd python/osrd_schemas
poetry run isort . --check
- name: Pytype
run: |
cd python/osrd_schemas
poetry run pytype -j auto
check_toml:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Install taplo
uses: baptiste0928/cargo-install@v3
with:
crate: taplo-cli
locked: true
- name: Check TOML format
run: taplo fmt --check --diff
check_infra_schema_sync:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Install poetry
run: pipx install poetry
- uses: actions/setup-python@v5
with:
python-version: "3.11"
cache: "poetry"
- name: Check infra_schema.json sync
run: |
cd python/osrd_schemas
poetry install --no-interaction --no-root
poetry run python -m osrd_schemas.infra_editor > current_infra_schema.json
diff current_infra_schema.json ../../front/src/reducers/osrdconf/infra_schema.json
check_front_rtk_sync:
runs-on: ubuntu-latest
needs:
- build
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Download built images
if: needs.build.outputs.output_method == 'artifact'
uses: actions/download-artifact@v4
with:
name: front-build
path: .
- name: Load built images
if: needs.build.outputs.output_method == 'artifact'
run: |
docker load --input ./osrd-front-build.tar
docker image ls -a
- name: Generate rtk bindings
run: >
docker run --rm --net=host -v $PWD/output:/app/tests/unit
-v $PWD/editoast:/editoast
-v $PWD/gateway:/gateway
-v $PWD/front/src/common/api:/app/src/common/api
${{ fromJSON(needs.build.outputs.stable_tags).front-build }}
yarn generate-types
- name: Check for unexpected changes
run: |
git diff --exit-code front
check_core:
runs-on: ubuntu-latest
needs:
- build
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Download built images
if: needs.build.outputs.output_method == 'artifact'
uses: actions/download-artifact@v4
with:
name: core-build
path: .
- name: Load built images
if: needs.build.outputs.output_method == 'artifact'
run: |
docker load --input ./osrd-core-build.tar
- name: Execute tests within container
run: |
docker run --name core-test \
-v $PWD/core/build:/output ${{ fromJSON(needs.build.outputs.stable_tags).core-build }} \
/bin/bash -c 'gradle -Pspotbugs_report_xml --continue check; status=$?; cp -r build/* /output/; exit $status'
exit $(docker wait core-test)
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v3
with:
name: codecov
flags: core
directory: ./core/build/reports/jacoco/testCodeCoverageReport
files: testCodeCoverageReport.xml
token: ${{ secrets.CODECOV_TOKEN }}
fail_ci_if_error: false
verbose: true
- name: Report JUnit failures
uses: mikepenz/action-junit-report@v4
if: failure()
with:
report_paths: "./core/build/test-results/test/TEST-*.xml"
require_tests: true
- name: Report spotbugs lints
if: failure()
uses: jwgmeligmeyling/[email protected]
with:
path: "./output/reports/spotbugs/*.xml"
check_editoast_tests:
runs-on: ubuntu-latest
needs:
- build
services:
postgres:
image: postgis/postgis
env:
POSTGRES_USER: postgres
POSTGRES_PASSWORD: password
ports:
- 5432:5432
# needed because the postgres container does not provide a healthcheck
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
redis:
image: redis
ports:
- 6379:6379
options: >-
--health-cmd "redis-cli ping"
--health-interval 5s
--health-timeout 5s
--health-retries 5
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Download built front-build image
if: needs.build.outputs.output_method == 'artifact'
uses: actions/download-artifact@v4
with:
name: front-build
path: .
- name: Download built editoast-test image
if: needs.build.outputs.output_method == 'artifact'
uses: actions/download-artifact@v4
with:
name: editoast-test
path: .
- name: Load built images
if: needs.build.outputs.output_method == 'artifact'
run: |
docker load --input ./osrd-front-build.tar
docker load --input ./osrd-editoast-test.tar
- name: Check for i18n missing keys
run: |
docker run --name=front-i18n-checker --net=host \
${{ fromJSON(needs.build.outputs.stable_tags).front-build }} \
yarn i18n-checker
exit $(docker wait front-i18n-checker)
- name: Execute tests within container
run: |
docker run --rm --net=host \
-v $PWD/docker/init_db.sql:/init_db.sql \
postgis/postgis:latest \
psql postgresql://postgres:password@localhost:5432 -f /init_db.sql
docker run --name=editoast-test --net=host -v $PWD/output:/output \
-e DATABASE_URL="postgres://osrd:password@localhost:5432/osrd" \
${{ fromJSON(needs.build.outputs.stable_tags).editoast-test }} \
/bin/bash -c "diesel migration run --locked-schema && cargo test --workspace --verbose -- --test-threads=4 && grcov . --binary-path ./target/debug/ -s . -t lcov --branch --ignore-not-existing --ignore "/*" -o /output/lcov.info"
exit $(docker wait editoast-test)
- name: Upload coverage
uses: codecov/codecov-action@v3
with:
name: codecov
flags: editoast
fail_ci_if_error: false
verbose: true
token: ${{ secrets.CODECOV_TOKEN }}
files: ./output/lcov.info
check_editoast_lints:
# lints runs in a separate job, as it takes about 1m30 for the documentation
# check to complete. As editoast tests take while to run, we don't want this to
# be on the hot path
runs-on: ubuntu-latest
needs:
- build
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Download built images
if: needs.build.outputs.output_method == 'artifact'
uses: actions/download-artifact@v4
with:
name: editoast-test
path: .
- name: Load built images
if: needs.build.outputs.output_method == 'artifact'
run: |
docker load --input ./osrd-editoast-test.tar
- name: Documentation check
run: |
docker run --name=editoast-doc --net=host -v $PWD/output:/output \
-e RUSTDOCFLAGS="-D warnings" \
${{ fromJSON(needs.build.outputs.stable_tags).editoast-test }} \
cargo doc --manifest-path ./Cargo.toml --no-deps
exit $(docker wait editoast-doc)
- name: Format check
run: |
docker run --name=editoast-format --net=host -v $PWD/output:/output \
${{ fromJSON(needs.build.outputs.stable_tags).editoast-test }} \
cargo fmt --check
exit $(docker wait editoast-format)
- name: Clippy check
run: |
docker run --name=editoast-clippy --net=host -v $PWD/output:/output \
${{ fromJSON(needs.build.outputs.stable_tags).editoast-test }} \
cargo clippy --all-features --all-targets -- -D warnings
exit $(docker wait editoast-clippy)
check_editoast_openapi:
# for the same reason as check_editoast_lints, we run this in a separate job
runs-on: ubuntu-latest
needs:
- build
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Download built editoast image
if: needs.build.outputs.output_method == 'artifact'
uses: actions/download-artifact@v4
with:
name: editoast
path: .
- name: Download built front-build image
if: needs.build.outputs.output_method == 'artifact'
uses: actions/download-artifact@v4
with:
name: front-build
path: .
- name: Load built images
if: needs.build.outputs.output_method == 'artifact'
run: |
docker load --input ./osrd-editoast.tar
docker load --input ./osrd-front-build.tar
- name: Generate OpenAPI
run: |
docker run --name=editoast-test --net=host -v $PWD/output:/output \
${{ fromJSON(needs.build.outputs.stable_tags).editoast }} \
/bin/bash -c 'editoast openapi > /output/openapi.yaml'
- name: Check for unexpected changes
run: |
diff $PWD/editoast/openapi.yaml $PWD/output/openapi.yaml
- name: Check for i18n API errors
run: |
docker run --name=front-i18n-api-error --net=host -v $PWD/output/openapi.yaml:/editoast/openapi.yaml \
${{ fromJSON(needs.build.outputs.stable_tags).front-build }} \
yarn i18n-api-errors
exit $(docker wait front-i18n-api-error)
check_gateway:
runs-on: ubuntu-latest
needs:
- build
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Download built images
if: needs.build.outputs.output_method == 'artifact'
uses: actions/download-artifact@v4
with:
name: gateway-test
path: .
- name: Load built images
if: needs.build.outputs.output_method == 'artifact'
run: |
docker load --input ./osrd-gateway-test.tar
- name: Execute tests within container
run: |
docker run --name=gateway-test --net=host -v $PWD/output:/output \
${{ fromJSON(needs.build.outputs.stable_tags).gateway-test }} \
/bin/bash -c "cargo test --verbose && grcov . --binary-path ./target/debug/ -s . -t lcov --branch --ignore-not-existing --ignore "/*" -o /output/lcov.info"
exit $(docker wait gateway-test)
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v3
with:
name: codecov
flags: gateway
fail_ci_if_error: false
verbose: true
token: ${{ secrets.CODECOV_TOKEN }}
files: ./output/lcov.info
- name: Documentation check
run: |
docker run --name=gateway-doc --net=host -v $PWD/output:/output \
-e RUSTDOCFLAGS="-D warnings" \
${{ fromJSON(needs.build.outputs.stable_tags).gateway-test }} \
cargo doc --manifest-path ./Cargo.toml --no-deps
exit $(docker wait gateway-doc)
- name: Format check
run: |
docker run --name=gateway-format --net=host -v $PWD/output:/output \
${{ fromJSON(needs.build.outputs.stable_tags).gateway-test }} \
cargo fmt --check
exit $(docker wait gateway-format)
- name: Clippy check
run: |
docker run --name=gateway-clippy --net=host -v $PWD/output:/output \
${{ fromJSON(needs.build.outputs.stable_tags).gateway-test }} \
cargo clippy --all-features --all-targets -- -D warnings
exit $(docker wait gateway-clippy)
check_front:
runs-on: ubuntu-latest
needs:
- build
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Download built images
if: needs.build.outputs.output_method == 'artifact'
uses: actions/download-artifact@v4
with:
name: front-build
path: .
- name: Load built images
if: needs.build.outputs.output_method == 'artifact'
run: |
docker load --input ./osrd-front-build.tar
- name: Check code formatting
run: |
docker run --name=front-format --net=host \
${{ fromJSON(needs.build.outputs.stable_tags).front-build }} \
yarn prettier . --check
exit $(docker wait front-format)
- name: Execute tests within container
run: |
docker run --name=front-test --net=host -v $PWD/output:/app/tests/unit \
${{ fromJSON(needs.build.outputs.stable_tags).front-build }} \
yarn test-coverage
exit $(docker wait front-test)
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v3
with:
name: codecov
flags: front
fail_ci_if_error: false
verbose: true
token: ${{ secrets.CODECOV_TOKEN }}
files: ./output/coverage/clover.xml
integration_tests:
runs-on: ubuntu-latest
needs:
- build
steps:
# TODO: check if we can deduplicate the base steps from integration_tests_quality
# https://www.jameskerr.blog/posts/sharing-steps-in-github-action-workflows/
- name: Checkout
uses: actions/checkout@v4
- name: Download built front-tests image
if: needs.build.outputs.output_method == 'artifact'
uses: actions/download-artifact@v4
with:
name: front-tests
path: .
- name: Download built editoast image
if: needs.build.outputs.output_method == 'artifact'
uses: actions/download-artifact@v4
with:
name: editoast
path: .
- name: Download built core image
if: needs.build.outputs.output_method == 'artifact'
uses: actions/download-artifact@v4
with:
name: core
path: .
- name: Download built gateway-standalone image
if: needs.build.outputs.output_method == 'artifact'
uses: actions/download-artifact@v4
with:
name: gateway-standalone
path: .
- name: Download built front-nginx image
if: needs.build.outputs.output_method == 'artifact'
uses: actions/download-artifact@v4
with:
name: front-nginx
path: .
- name: Load built images
if: needs.build.outputs.output_method == 'artifact'
run: |
docker load --input ./osrd-front-tests.tar
docker load --input ./osrd-editoast.tar
docker load --input ./osrd-core.tar
docker load --input ./osrd-gateway-standalone.tar
docker load --input ./osrd-front-nginx.tar
- name: Install poetry
run: pipx install poetry
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.9"
cache: "poetry"
- name: Install dependencies
run: |
cd tests
poetry install
- name: Startup the test infrastructure
id: start_playwright_worker
run: |
set -e
export OSRD_FRONT_MODE=nginx
export TAG='${{ needs.build.outputs.stable_version }}'
services='editoast core front gateway'
docker compose pull --policy missing $services
docker compose up --no-build -d $services jaeger
env:
DOCKER_BUILDKIT: 1
COMPOSE_DOCKER_CLI_BUILD: 1
- name: Run pytest
run: |
poetry -C tests run pytest -m "not e2e" --cov --cov-report=xml
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v3
with:
name: codecov
flags: tests
fail_ci_if_error: false
verbose: true
token: ${{ secrets.CODECOV_TOKEN }}
files: coverage.xml
- name: Run Playwright tests
run: |
docker run --init --name=playwright-test --net=host \
-e CI=true \
-v $PWD/front/test-results:/app/test-results \
${{ fromJSON(needs.build.outputs.stable_tags).front-tests }} \
/bin/sh -c "npx playwright install --with-deps && yarn e2e-tests"
exit $(docker wait playwright-test)
- uses: actions/upload-artifact@v3
if: always()
with:
name: integration-videos
path: front/test-results/
retention-days: 30
- name: Save container logs
run: docker compose logs > container-logs
if: always()
- uses: actions/upload-artifact@v3
if: always()
with:
name: integration-container-logs
path: container-logs
retention-days: 30