-
Notifications
You must be signed in to change notification settings - Fork 20
1059 lines (927 loc) · 35 KB
/
ci.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
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: General CI
# This file is a joint CI of parachain and tee-worker, it contains:
# - build (of docker images)
# - format check
# - unit tests
# - integration tests
# Some notes:
#
# [1] the tee-worker part is a modified version of tee-worker/.github/workflows/build_and_test.yml
# with extra triggering control.
#
# [2] the original file (`tee-worker/.github/workflows/build_and_test.yml`) is kept to sync
# upstream changes, therefore we need to manually apply the changes to this file.
# [3] please beware that if a job in `needs` is skipped, its dependent job will also be skipped,
# see https://github.com/actions/runner/issues/491
#
# jobs that will always be executed:
# - fmt
# - set-condition
# - parachain-build-dev
# - identity-build
#
# [4] please note that job-level if `env` is not supported:
# https://github.com/actions/runner/issues/1189
# as a workaround, we need to put it in a step-level or use `needs.outputs`
#
on:
push:
branches:
- dev
paths-ignore:
- "**/dependabot.yml"
- "**/README.md"
pull_request:
branches:
- dev
types:
- opened
- reopened
- synchronize
- ready_for_review
workflow_dispatch:
inputs:
rebuild-parachain-docker:
type: boolean
description: rebuild-parachain-docker
required: true
default: true
rebuild-tee-docker:
type: boolean
description: rebuild-tee-docker
required: true
default: true
rebuild-bitacross-docker:
type: boolean
description: rebuild-bitacross-docker
required: true
default: true
push-docker:
type: boolean
description: push-docker
required: true
default: false
env:
CARGO_TERM_COLOR: always
DOCKER_BUILDKIT: 1
# the branch or tag on which this workflow is triggered
# `head_ref` will only be set if the triggering event is `pull_request`
REF_VERSION: ${{ github.head_ref || github.ref_name }}
concurrency:
# see https://stackoverflow.com/questions/74117321/if-condition-in-concurrency-in-gha
# along with the `sequentialise` job below, it guarantees:
# - for push in dev: all triggered CIs will be run sequentially, none is cancelled
# - for PR: later triggered CIs will cancel previous runs, maximum one CI will be run
group: ${{ github.workflow }}-${{ github.head_ref && github.ref || github.run_id }}
cancel-in-progress: true
jobs:
set-condition:
runs-on: ubuntu-latest
# see https://github.com/orgs/community/discussions/25722
if: ${{ github.event_name == 'push' || !github.event.pull_request.draft }}
outputs:
rebuild_parachain: ${{ steps.env.outputs.rebuild_parachain }}
rebuild_tee: ${{ steps.env.outputs.rebuild_tee }}
rebuild_bitacross: ${{ steps.env.outputs.rebuild_bitacross }}
push_docker: ${{ steps.env.outputs.push_docker }}
run_parachain_test: ${{ steps.env.outputs.run_parachain_test }}
run_tee_test: ${{ steps.env.outputs.run_tee_test }}
run_bitacross_test: ${{ steps.env.outputs.run_bitacross_test }}
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
# Checks to see if any files in the PR/commit match one of the listed file types.
# We can use this filter to decide whether or not to build docker images
- uses: dorny/paths-filter@v3
id: filter
with:
filters: .github/file-filter.yml
list-files: shell
- name: Set condition
id: env
run: |
rebuild_parachain=false
rebuild_tee=false
rebuild_bitacross=false
push_docker=false
run_parachain_test=false
run_tee_test=false
if [ "${{ github.event.inputs.rebuild-parachain-docker }}" = "true" ] || [ "${{ steps.filter.outputs.parachain_src }}" = "true" ]; then
rebuild_parachain=true
fi
if [ "${{ github.event.inputs.rebuild-tee-docker }}" = "true" ] || [ "${{ steps.filter.outputs.tee_src }}" = "true" ]; then
rebuild_tee=true
fi
if [ "${{ github.event.inputs.rebuild-bitacross-docker }}" = "true" ] || [ "${{ steps.filter.outputs.bitacross_src }}" = "true" ]; then
rebuild_bitacross=true
fi
if [ "${{ github.event.inputs.push-docker }}" = "true" ]; then
push_docker=true
elif [ "${{ github.event_name }}" = 'push' ] && [ "${{ github.ref }}" = 'refs/heads/dev' ]; then
push_docker=true
fi
if [ "${{ steps.filter.outputs.parachain_test }}" = "true" ] || [ "$rebuild_parachain" = "true" ]; then
run_parachain_test=true
fi
if [ "${{ steps.filter.outputs.tee_test }}" = "true" ] || [ "$rebuild_parachain" = "true" ] || [ "$rebuild_tee" = "true" ]; then
run_tee_test=true
fi
if [ "${{ steps.filter.outputs.bitacross_test }}" = "true" ] || [ "$rebuild_parachain" = "true" ] || [ "$rebuild_bitacross" = "true" ]; then
run_bitacross_test=true
fi
echo "rebuild_parachain=$rebuild_parachain" | tee -a $GITHUB_OUTPUT
echo "rebuild_tee=$rebuild_tee" | tee -a $GITHUB_OUTPUT
echo "rebuild_bitacross=$rebuild_bitacross" | tee -a $GITHUB_OUTPUT
echo "push_docker=$push_docker" | tee -a $GITHUB_OUTPUT
echo "run_parachain_test=$run_parachain_test" | tee -a $GITHUB_OUTPUT
echo "run_tee_test=$run_tee_test" | tee -a $GITHUB_OUTPUT
echo "run_bitacross_test=$run_bitacross_test" | tee -a $GITHUB_OUTPUT
fmt:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install rust toolchain
run: rustup show
- name: Install pre-built taplo
run: |
mkdir -p $HOME/.local/bin
wget -q https://github.com/tamasfe/taplo/releases/download/0.8.1/taplo-linux-x86_64.gz
gzip -d taplo-linux-x86_64.gz
cp taplo-linux-x86_64 $HOME/.local/bin/taplo
chmod a+x $HOME/.local/bin/taplo
echo "$HOME/.local/bin" >> $GITHUB_PATH
- name: Parachain fmt check
run: |
cargo fmt --all -- --check
taplo fmt --check
- name: Tee-worker fmt check
working-directory: ./tee-worker
run: |
cargo fmt --all -- --check
taplo fmt --check
- name: Tee-worker enclave-runtime fmt check
working-directory: ./tee-worker/enclave-runtime
run: |
cargo fmt --all -- --check
- name: bitacross-worker fmt check
working-directory: ./bitacross-worker
run: |
cargo fmt --all -- --check
taplo fmt --check
- name: bitacross-worker enclave-runtime fmt check
working-directory: ./bitacross-worker/enclave-runtime
run: |
cargo fmt --all -- --check
- name: Enable corepack and pnpm
run: corepack enable && corepack enable pnpm
- name: Tee-worker ts-tests install npm deps
working-directory: ./tee-worker/ts-tests
# We can't update the lockfile here because the client-api hasn't been generated yet.
run: pnpm install --frozen-lockfile
- name: Tee-worker check ts code format
working-directory: ./tee-worker/ts-tests
run: pnpm run check-format
- name: Dynamic-contract install npm deps
working-directory: ./tee-worker/litentry/core/assertion-build/src/dynamic
run: pnpm install
- name: Dynamic-contract check code format
working-directory: ./tee-worker/litentry/core/assertion-build/src/dynamic
run: pnpm run check-format
- name: Fail early
if: failure()
uses: andymckay/cancel-action@0.5
# sequentialise the workflow runs on `dev` branch
# the if condition is applied in step level to make this job always `successful`
sequentialise:
runs-on: ubuntu-latest
steps:
- name: Wait for previous run
if: ${{ !failure() && (github.event_name == 'push') && (github.ref == 'refs/heads/dev') }}
uses: litentry/consecutive-workflow-action@main
with:
token: ${{ secrets.GITHUB_TOKEN }}
interval: 300
branch: dev
parachain-clippy:
runs-on: ubuntu-latest
needs:
- fmt
- set-condition
- sequentialise
if: needs.set-condition.outputs.rebuild_parachain == 'true'
steps:
- uses: actions/checkout@v4
- name: Install rust toolchain
run: rustup show
- name: Install dependencies
run: |
sudo apt-get update
sudo apt-get install -yq openssl clang libclang-dev cmake protobuf-compiler
- name: Run cargo clippy check
run: make clippy
- name: Fail early
if: failure()
uses: andymckay/cancel-action@0.5
tee-check:
runs-on: ubuntu-latest
needs:
- fmt
- set-condition
- sequentialise
container: "litentry/litentry-tee-dev:latest"
strategy:
matrix:
type:
- tee # TODO: switch to identity
- bitacross
name: ${{ matrix.type }}
steps:
- uses: actions/checkout@v4
- name: Install dependencies
run: |
sudo apt-get update && \
sudo apt-get install -yq openssl clang libclang-dev cmake protobuf-compiler
- name: Cargo test
working-directory: ./${{ matrix.type }}-worker
run: |
cargo test --release
- name: Worker common clippy
working-directory: ./${{ matrix.type }}-worker
shell: bash
run: |
for d in . enclave-runtime; do
pushd "$d"
echo "::group::cargo clippy all"
cargo clippy --release -- -D warnings
echo "::endgroup::"
echo "::group::cargo clippy development"
cargo clippy --release --features development -- -D warnings
echo "::endgroup::"
echo "::group::cargo clippy offchain-worker"
cargo clippy --release --features offchain-worker -- -D warnings
echo "::group::cargo clippy offchain-worker,development"
cargo clippy --release --features offchain-worker,development -- -D warnings
echo "::endgroup::"
popd
done
- name: Identity-worker specific clippy
if: matrix.type == 'tee'
working-directory: ./tee-worker
shell: bash
run: |
for d in . enclave-runtime; do
pushd "$d"
echo "::group::cargo clippy sidechain"
cargo clippy --release --features sidechain -- -D warnings
echo "::endgroup::"
echo "::group::cargo clippy evm"
cargo clippy --release --features evm -- -D warnings
echo "::endgroup::"
echo "::group::cargo clippy sidechain development"
cargo clippy --release --features sidechain,development -- -D warnings
echo "::endgroup::"
echo "::group::cargo clippy evm development"
cargo clippy --release --features evm,development -- -D warnings
echo "::endgroup::"
popd
done
- name: Fail early
if: failure()
uses: andymckay/cancel-action@0.5
parachain-build-dev:
runs-on: ubuntu-latest
needs:
- fmt
- set-condition
- sequentialise
steps:
- name: Free up disk space
if: startsWith(runner.name, 'GitHub Actions')
uses: jlumbroso/free-disk-space@main
with:
tool-cache: true
swap-storage: false
large-packages: false
- uses: actions/checkout@v4
- name: Build docker image
if: needs.set-condition.outputs.rebuild_parachain == 'true'
run: |
echo "::group::build docker image"
./scripts/build-docker.sh release latest --features=fast-runtime
echo "::endgroup::"
echo "::group::docker images"
docker images --all
echo "::endgroup::"
- name: Pull docker image optionally
if: needs.set-condition.outputs.rebuild_parachain == 'false'
run: |
docker pull litentry/litentry-parachain:latest
docker pull litentry/litentry-chain-aio:latest
- name: Save docker image
run: |
docker save litentry/litentry-parachain:latest litentry/litentry-chain-aio:latest | gzip > litentry-parachain-dev.tar.gz
- name: Upload parachain docker image
uses: actions/upload-artifact@v4
with:
name: litentry-parachain-dev
path: litentry-parachain-dev.tar.gz
if-no-files-found: error
- name: Fail early
if: failure()
uses: andymckay/cancel-action@0.5
identity-build:
runs-on: ubuntu-latest
needs:
- fmt
- set-condition
- sequentialise
steps:
- name: Free up disk space
if: startsWith(runner.name, 'GitHub Actions')
uses: jlumbroso/free-disk-space@main
with:
tool-cache: true
swap-storage: false
large-packages: false
- uses: actions/checkout@v4
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
with:
# use the docker driver to access the local image
# we don't need external caches or multi platforms here
# see https://docs.docker.com/build/drivers/
driver: docker
- name: Cache worker-cache
if: needs.set-condition.outputs.rebuild_tee == 'true'
uses: actions/cache@v4
with:
path: |
worker-cache
key: worker-cache-${{ env.REF_VERSION }}-${{ hashFiles('tee-worker/**/Cargo.lock', 'tee-worker/**/Cargo.toml') }}
restore-keys: |
worker-cache-${{ env.REF_VERSION }}-
worker-cache-
- name: Create cache folder if not exist
if: needs.set-condition.outputs.rebuild_tee == 'true'
run: |
for i in 'git/db' 'registry/cache' 'registry/index' 'sccache'; do
[ ! -d "worker-cache/$i" ] && mkdir -p "worker-cache/$i" || true
echo "hello" > worker-cache/$i/nix
done
echo "::group::List worker-cache size"
du -sh worker-cache/*
echo "::endgroup::"
echo "::group::Show disk usage"
df -h .
echo "::endgroup::"
# cache mount in buildkit won't be exported as image layers, so it doesn't work well with GHA cache, see
# https://github.com/moby/buildkit/issues/1512
# https://www.reddit.com/r/rust/comments/126xeyx/exploring_the_problem_of_faster_cargo_docker/
# https://hackmd.io/@kobzol/S17NS71bh (a great summary)
#
# the `reproducible-containers/buildkit-cache-dance` seems to be unstable too in my test
# sometimes it works, sometimes it results in empty cache, root cause unclear
#
# thus the persistence of rust cache (w/ sccache) is maintained manually
#
# there's no cache-from/to as the docker image layer is too large and it takes too long to sync
# moreoever, we are not so eager to have layer caches, as the most critical operation(cargo build)
# is "atomic" and can't be broken into layers.
- name: Build local builder
if: needs.set-condition.outputs.rebuild_tee == 'true'
uses: docker/build-push-action@v6
with:
context: .
file: tee-worker/build.Dockerfile
tags: local-builder:latest
target: builder
build-args: |
WORKER_MODE_ARG=sidechain
WORKER_ENV_DATA_PROVIDERS_CONFIG=1
WORKER_MOCK_SERVER=1
ADDITIONAL_FEATURES_ARG=
- name: Copy caches from the built image
if: needs.set-condition.outputs.rebuild_tee == 'true'
run: |
echo "::group::Show disk usage"
df -h .
echo "::endgroup::"
echo "::group::docker images"
docker images --all
echo "::endgroup::"
echo "::group::copy cache out"
for i in 'git/db' 'registry/cache' 'registry/index'; do
b="${i%/*}"
rm -rf worker-cache/$i
docker cp "$(docker create --rm local-builder:latest):/opt/rust/$i" worker-cache/$b
done
rm -rf worker-cache/sccache
docker cp "$(docker create --rm local-builder:latest):/opt/rust/sccache" worker-cache
du -sh worker-cache/*
echo "::endgroup::"
echo "::group::df -h ."
df -h .
echo "::endgroup::"
- name: Build worker
if: needs.set-condition.outputs.rebuild_tee == 'true'
uses: docker/build-push-action@v6
with:
context: .
file: tee-worker/build.Dockerfile
tags: litentry/identity-worker:latest
target: deployed-worker
- name: Build cli
if: needs.set-condition.outputs.rebuild_tee == 'true'
uses: docker/build-push-action@v6
with:
context: .
file: tee-worker/build.Dockerfile
tags: litentry/identity-cli:latest
target: deployed-client
- name: Pull and tag worker and cli image optionally
if: needs.set-condition.outputs.rebuild_tee == 'false'
run: |
docker pull litentry/identity-worker:latest
docker pull litentry/identity-cli:latest
- run: docker images --all
- name: Test enclave
if: needs.set-condition.outputs.rebuild_tee == 'true'
# cargo test is not supported in the enclave
# see https://github.com/apache/incubator-teaclave-sgx-sdk/issues/232
run: docker run litentry/identity-worker:latest test --all
- name: Save docker images
run: docker save litentry/identity-worker:latest litentry/identity-cli:latest | gzip > litentry-identity.tar.gz
- name: Upload docker images
uses: actions/upload-artifact@v4
with:
name: litentry-identity
path: litentry-identity.tar.gz
if-no-files-found: error
- name: Fail early
if: failure()
uses: andymckay/cancel-action@0.5
bitacross-build:
runs-on: ubuntu-latest
needs:
- fmt
- set-condition
- sequentialise
steps:
- name: Free up disk space
if: startsWith(runner.name, 'GitHub Actions')
uses: jlumbroso/free-disk-space@main
with:
tool-cache: true
swap-storage: false
large-packages: false
- uses: actions/checkout@v4
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
with:
# use the docker driver to access the local image
# we don't need external caches or multi platforms here
# see https://docs.docker.com/build/drivers/
driver: docker
- name: Build local builder
if: needs.set-condition.outputs.rebuild_bitacross == 'true'
uses: docker/build-push-action@v6
with:
context: .
file: bitacross-worker/build.Dockerfile
tags: local-builder:latest
target: builder
build-args: |
WORKER_MODE_ARG=offchain-worker
ADDITIONAL_FEATURES_ARG=
- name: Build worker
if: needs.set-condition.outputs.rebuild_bitacross == 'true'
uses: docker/build-push-action@v6
with:
context: .
file: bitacross-worker/build.Dockerfile
tags: litentry/bitacross-worker:latest
target: deployed-worker
- name: Build cli
if: needs.set-condition.outputs.rebuild_bitacross == 'true'
uses: docker/build-push-action@v6
with:
context: .
file: bitacross-worker/build.Dockerfile
tags: litentry/bitacross-cli:latest
target: deployed-client
- name: Pull and tag worker and cli image optionally
if: needs.set-condition.outputs.rebuild_bitacross == 'false'
run: |
docker pull litentry/bitacross-worker:latest
docker pull litentry/bitacross-cli:latest
- run: docker images --all
- name: Test enclave
if: needs.set-condition.outputs.rebuild_bitacross == 'true'
# cargo test is not supported in the enclave
# see https://github.com/apache/incubator-teaclave-sgx-sdk/issues/232
run: docker run litentry/bitacross-worker:latest test --all
- name: Save docker images
run: docker save litentry/bitacross-worker:latest litentry/bitacross-cli:latest | gzip > litentry-bitacross.tar.gz
- name: Upload docker images
uses: actions/upload-artifact@v4
with:
name: litentry-bitacross
path: litentry-bitacross.tar.gz
if-no-files-found: error
- name: Fail early
if: failure()
uses: andymckay/cancel-action@0.5
parachain-ts-test:
runs-on: ubuntu-latest
needs:
- set-condition
- parachain-build-dev
strategy:
matrix:
chain:
- litmus
- litentry
- rococo
name: ${{ matrix.chain }}
steps:
- uses: actions/checkout@v4
- uses: actions/download-artifact@v4
with:
name: litentry-parachain-dev
- name: Load docker image
run: |
docker load < litentry-parachain-dev.tar.gz
- name: Enable corepack and pnpm
run: corepack enable && corepack enable pnpm
- name: Run ts tests for ${{ matrix.chain }}
if: needs.set-condition.outputs.run_parachain_test == 'true'
timeout-minutes: 35
run: |
make test-ts-docker-${{ matrix.chain }}
- name: Collect docker logs if test fails
continue-on-error: true
uses: jwalton/gh-docker-logs@v2
if: failure()
with:
tail: all
dest: docker-logs
- name: Upload docker logs if test fails
uses: actions/upload-artifact@v4
if: failure()
with:
name: ${{ matrix.chain }}-ts-tests-docker-logs
path: docker-logs
if-no-files-found: ignore
retention-days: 3
- name: Archive logs if test fails
uses: actions/upload-artifact@v4
if: failure()
with:
name: ${{ matrix.chain }}-ts-tests-artifact
path: /tmp/parachain_dev/
if-no-files-found: ignore
retention-days: 3
- name: Fail early
if: failure()
uses: andymckay/cancel-action@0.5
parachain-dynamic-contract-test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Enable corepack and pnpm
run: corepack enable && corepack enable pnpm
- name: Install npm deps
working-directory: ./tee-worker/litentry/core/assertion-build/src/dynamic
run: pnpm install
- name: Run all unittests
working-directory: ./tee-worker/litentry/core/assertion-build/src/dynamic
run: pnpm run test
- name: Fail early
if: failure()
uses: andymckay/cancel-action@0.5
parachain-unit-test:
runs-on: ubuntu-latest
needs:
- fmt
- set-condition
- sequentialise
# run_parachain_test is related to ts-tests only
if: needs.set-condition.outputs.rebuild_parachain == 'true'
steps:
- uses: actions/checkout@v4
- name: Run all unittests
run: |
echo "::group::core-primitives unittest"
cargo test --locked --release -p core-primitives --lib
echo "::endgroup::"
echo "::group::all pallets unittest"
cargo test --locked --release -p pallet-* --lib
echo "::endgroup::"
echo "::group::all pallets unittest with runtime-benchmarks feature"
cargo test --locked --release -p pallet-* --lib --features=runtime-benchmarks
echo "::endgroup::"
- name: Fail early
if: failure()
uses: andymckay/cancel-action@0.5
parachain-runtime-test:
runs-on: ubuntu-latest
needs:
- fmt
- set-condition
- sequentialise
if: needs.set-condition.outputs.rebuild_parachain == 'true'
steps:
- uses: actions/checkout@v4
- name: Install toolchain
run: rustup show
- name: Install dependencies
run: |
sudo apt-get update && \
sudo apt-get install -yq openssl clang libclang-dev cmake protobuf-compiler
# We could have used matrix but the runtime tests are executed sequentially for a cleaner GHA visualisation graph.
# It won't take much longer as we run them back to back.
- name: Run runtime tests
run: |
echo "::group::rococo runtime test"
cargo test --locked --release -p rococo-parachain-runtime --lib
echo "::endgroup::"
echo "::group::litmus runtime test"
cargo test --locked --release -p litmus-parachain-runtime --lib
echo "::endgroup::"
echo "::group::litentry runtime test"
cargo test --locked --release -p litentry-parachain-runtime --lib
echo "::endgroup::"
- name: Fail early
if: failure()
uses: andymckay/cancel-action@0.5
identity-single-worker-test:
runs-on: ubuntu-latest
needs:
- set-condition
- parachain-build-dev
- identity-build
strategy:
fail-fast: false
matrix:
include:
# Litentry
- test_name: lit-di-substrate-identity-test
- test_name: lit-di-evm-identity-test
- test_name: lit-di-bitcoin-identity-test
- test_name: lit-di-solana-identity-test
- test_name: lit-di-vc-test
- test_name: lit-dr-vc-test
- test_name: lit-parentchain-nonce
- test_name: lit-test-failed-parentchain-extrinsic
- test_name: lit-twitter-identity-test
- test_name: lit-discord-identity-test
- test_name: lit-assertion-contracts-test
name: ${{ matrix.test_name }}
steps:
- uses: actions/checkout@v4
- name: Pull polkadot image
run: |
docker pull parity/polkadot
- uses: actions/download-artifact@v4
with:
name: litentry-parachain-dev
- uses: actions/download-artifact@v4
with:
name: litentry-identity
- name: Load docker image
run: |
docker load < litentry-parachain-dev.tar.gz
docker load < litentry-identity.tar.gz
docker images
- name: Enable corepack and pnpm
run: corepack enable && corepack enable pnpm
- name: Generate parachain artefacts
run: |
./tee-worker/scripts/litentry/generate_parachain_artefacts.sh
ls -l docker/generated-rococo/
ls -l tee-worker/docker/litentry/
- name: Build litentry parachain docker images
run: |
cd tee-worker/docker
docker compose -f litentry-parachain.build.yml build
- name: Integration single worker test ${{ matrix.test_name }}
if: needs.set-condition.outputs.run_tee_test == 'true'
timeout-minutes: 40
run: |
cd tee-worker/docker
docker compose -f docker-compose.yml -f ${{ matrix.test_name }}.yml up --no-build --exit-code-from ${{ matrix.test_name }} ${{ matrix.test_name }}
- name: Stop integration single worker docker containers
if: needs.set-condition.outputs.run_tee_test == 'true'
run: |
cd tee-worker/docker
docker compose -f docker-compose.yml -f ${{ matrix.test_name }}.yml stop
- name: Collect docker logs if test fails
continue-on-error: true
uses: jwalton/gh-docker-logs@v2
if: failure()
with:
tail: all
dest: docker-logs
- name: Upload docker logs if test fails
uses: actions/upload-artifact@v4
if: failure()
with:
name: ${{ matrix.test_name }}-docker-logs
path: docker-logs
if-no-files-found: ignore
retention-days: 3
identity-multi-worker-test:
runs-on: ubuntu-latest
continue-on-error: true
needs:
- set-condition
- parachain-build-dev
- identity-build
strategy:
fail-fast: false
matrix:
include:
- test_name: lit-di-bitcoin-identity-multiworker-test
- test_name: lit-di-evm-identity-multiworker-test
- test_name: lit-di-solana-identity-multiworker-test
- test_name: lit-di-substrate-identity-multiworker-test
- test_name: lit-di-vc-multiworker-test
- test_name: lit-dr-vc-multiworker-test
- test_name: lit-resume-worker
name: ${{ matrix.test_name }}
steps:
- uses: actions/checkout@v4
- name: Pull polkadot image
run: |
docker pull parity/polkadot
- uses: actions/download-artifact@v4
with:
name: litentry-parachain-dev
- uses: actions/download-artifact@v4
with:
name: litentry-identity
- name: Load docker image
run: |
docker load < litentry-parachain-dev.tar.gz
docker load < litentry-identity.tar.gz
docker images
- name: Enable corepack and pnpm
run: corepack enable && corepack enable pnpm
- name: Generate parachain artefacts
run: |
./tee-worker/scripts/litentry/generate_parachain_artefacts.sh
ls -l docker/generated-rococo/
ls -l tee-worker/docker/litentry/
- name: Build litentry parachain docker images
run: |
cd tee-worker/docker
docker compose -f litentry-parachain.build.yml build
- name: Integration multi worker test ${{ matrix.test_name }}
if: needs.set-condition.outputs.run_tee_test == 'true'
timeout-minutes: 40
run: |
cd tee-worker/docker
docker compose -f multiworker-docker-compose.yml -f ${{ matrix.test_name }}.yml up --no-build --exit-code-from ${{ matrix.test_name }} ${{ matrix.test_name }}
- name: Stop integration multi worker docker containers
if: needs.set-condition.outputs.run_tee_test == 'true'
run: |
cd tee-worker/docker
docker compose -f multiworker-docker-compose.yml -f ${{ matrix.test_name }}.yml stop
- name: Collect docker logs if test fails
continue-on-error: true
uses: jwalton/gh-docker-logs@v2
if: failure()
with:
tail: all
dest: docker-logs
- name: Upload docker logs if test fails
uses: actions/upload-artifact@v4
if: failure()
with:
name: ${{ matrix.test_name }}-docker-logs
path: docker-logs
if-no-files-found: ignore
retention-days: 3
bitacross-worker-test:
runs-on: ubuntu-latest
needs:
- set-condition
- parachain-build-dev
- bitacross-build
strategy:
fail-fast: false
matrix:
include:
- test_name: lit-sign-bitcoin
name: ${{ matrix.test_name }}
steps:
- uses: actions/checkout@v4
- name: Pull polkadot image
run: |
docker pull parity/polkadot
- uses: actions/download-artifact@v4
with:
name: litentry-parachain-dev
- uses: actions/download-artifact@v4
with:
name: litentry-bitacross
- name: Load docker image
run: |
docker load < litentry-parachain-dev.tar.gz
docker load < litentry-bitacross.tar.gz
docker images
- name: Enable corepack and pnpm
run: corepack enable && corepack enable pnpm
- name: Generate parachain artefacts
run: |
./tee-worker/scripts/litentry/generate_parachain_artefacts.sh
ls -l docker/generated-rococo/
ls -l bitacross-worker/docker/litentry/
- name: Build litentry parachain docker images
run: |
cd tee-worker/docker
docker compose -f litentry-parachain.build.yml build
- name: Integration bitacross worker test ${{ matrix.test_name }}
if: needs.set-condition.outputs.run_bitacross_test == 'true'
timeout-minutes: 40
run: |
cd bitacross-worker/docker
docker compose -f multiworker-docker-compose.yml -f ${{ matrix.test_name }}.yml up --no-build --exit-code-from ${{ matrix.test_name }} ${{ matrix.test_name }}
- name: Stop integration multi worker docker containers
if: needs.set-condition.outputs.run_bitacross_test == 'true'
run: |
cd bitacross-worker/docker
docker compose -f multiworker-docker-compose.yml -f ${{ matrix.test_name }}.yml stop
- name: Collect docker logs if test fails
continue-on-error: true
uses: jwalton/gh-docker-logs@v2
if: failure()
with:
tail: all
dest: docker-logs
- name: Upload docker logs if test fails
uses: actions/upload-artifact@v4
if: failure()
with:
name: ${{ matrix.test_name }}-docker-logs
path: docker-logs
if-no-files-found: ignore
retention-days: 3
# Secrets are not passed to the runner when a workflow is triggered from a forked repository,
# see https://docs.github.com/en/actions/security-guides/encrypted-secrets#using-encrypted-secrets-in-a-workflow
#
# Only try to push docker image when
# - parachain-ts-test passes