-
Notifications
You must be signed in to change notification settings - Fork 4
1193 lines (1009 loc) · 36.7 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: CI
# Controls when the action will run.
on:
# Triggers the workflow on push or pull request events but only for the master branch
push:
branches: [main, testnet, dev]
pull_request:
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:
permissions: read-all
env:
RUNNER_VM_NAME: "${{ github.event.repository.name }}-$GITHUB_RUN_ID-attempt-$GITHUB_RUN_ATTEMPT"
LINODE_REGION: "nl-ams"
# Shared CPU, Linode 8 GB, 4 vCPU, 96 $/mo
LINODE_VM_SIZE: "g6-standard-4"
# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
docker-build:
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@v4
with:
lfs: true
- name: Build docker image
run: |
docker build -t gluwa/creditcoin3 .
- name: Start a container from image
run: |
# see https://opensource.com/article/18/5/how-find-ip-address-linux
IP_ADDRESS=$(curl https://ifconfig.me)
echo "INFO: IP_ADDRESS=$IP_ADDRESS"
docker run --rm --name creditcoin-validator -d -p 9944:9944 -p 30333:30333 gluwa/creditcoin3 \
--validator --chain testnet \
--name "test-node-$GITHUB_RUN_ID-attempt-$GITHUB_RUN_ATTEMPT" \
--public-addr "/dns4/$IP_ADDRESS/tcp/30333" \
--prometheus-external \
--telemetry-url "wss://telemetry.polkadot.io/submit/ 0" \
--telemetry-url "wss://telemetry.creditcoin.network/submit/ 0" \
--bootnodes "/dns4/cc3-test-bootnode.creditcoin.network/tcp/30333/p2p/12D3KooWAxmsWr6iEjFyLqQBzfLvbCRTAhYBeszyr8UWgQx6Zu7K" \
--port 30333 --unsafe-rpc-external
- name: Healtcheck
run: |
sleep 60
.github/check-health.sh
- name: Sanity test creditcoin-cli inside the container
run: |
docker exec creditcoin-validator which creditcoin
docker exec creditcoin-validator creditcoin wizard --help
- name: Sanity check for chainspecs inside the container
run: |
for f in chainspecs/*.json; do
spec=$(basename "$f")
docker exec creditcoin-validator ls -l "/$spec"
done
- name: Collect docker logs
if: always()
run: |
docker logs creditcoin-validator >docker-creditcoin-validator.log 2>&1
- name: Kill the container
run: |
sudo killall -9 creditcoin3-node
sleep 10
docker rm -f creditcoin-validator
sleep 10
- name: Start container via compose
run: |
docker compose up -d
- name: Sanity check for persistently mounted directory
run: |
sleep 60
docker exec creditcoin-validator ls -ld /creditcoin-node/data
docker exec creditcoin-validator ls -la /creditcoin-node/data
- name: Collect compose logs
if: always()
run: |
docker compose logs --no-color > docker-compose.log
- name: Upload logs
if: always()
uses: actions/upload-artifact@v4
with:
name: docker-logs
path: docker-*.log
- name: Kill the container
run: |
sudo killall -9 creditcoin3-node
sanity-tests:
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@v4
with:
lfs: true
- name: Check for parity between extrinsics, benchmarks and weights
run: |
echo "INFO: active pallets are"
./.github/check-parity-bw-extrinsics-benchmarks-weights.sh --show-pallets
echo "========================"
./.github/check-parity-bw-extrinsics-benchmarks-weights.sh
- name: Check migrations
run: |
./.github/check-usage-of-log-warn.sh
- name: Check if Cargo.toml specifies dependencies from forks
run: |
./.github/check-for-used-forks.sh
- name: Check if all Cargo.toml files are specified inside Dependabot config
run: |
.github/check-for-missing-Cargo-toml-in-Dependabot-config.sh
- name: Check if all package.json files are specified inside Dependabot config
run: |
.github/check-for-missing-package-json-in-Dependabot-config.sh
- name: Check if chainspecs are valid and not contain bootnodes
run: |
./.github/check-bootnodes.sh
sanity-test-cli:
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@v4
with:
lfs: true
- name: Install Node.js
uses: actions/setup-node@v4
with:
node-version: 20
- run: npm install -g yarn
- name: Install creditcoin-cli
working-directory: ./cli
run: |
yarn install
yarn build
npm install -g .
- name: Execute creditcoin cli command
run: |
# this makes sure we have a `creditcoin` entrypoint in the standard PATH
which creditcoin
creditcoin help
creditcoin wizard --help
sanity-test-precompiles:
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@v4
with:
lfs: true
- name: Install Solidity compiler
run: |
sudo add-apt-repository ppa:ethereum/ethereum
sudo apt-get update
sudo apt-get install solc
- name: Generate ABI from source code
working-directory: ./precompiles/metadata
run: |
solc --version
./abi-creator.sh
- name: Prepare ENV for Devnet
id: devnet-env
if: github.base_ref == 'dev'
run: |
echo "target_chain=devnet" >> "$GITHUB_OUTPUT"
- name: Prepare ENV for Testnet
id: testnet-env
if: github.base_ref == 'testnet'
run: |
echo "target_chain=testnet" >> "$GITHUB_OUTPUT"
- name: Prepare ENV for Mainnnet
id: mainnet-env
if: github.base_ref == 'main'
run: |
echo "target_chain=mainnet" >> "$GITHUB_OUTPUT"
- name: Check
run: |
export TARGET_CHAIN="${{ steps.devnet-env.outputs.target_chain || steps.testnet-env.outputs.target_chain || steps.mainnet-env.outputs.target_chain }}"
.github/check-solidity-source-vs-metadata.sh
fmt:
name: Rustfmt
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@v4
with:
lfs: true
- name: Configure rustc version
run: |
RUSTC_VERSION=$(grep channel rust-toolchain.toml | tail -n1 | tr -d " " | cut -f2 -d'"')
echo "RUSTC_VERSION=$RUSTC_VERSION" >> "$GITHUB_ENV"
- name: Install Rust toolchain
uses: gluwa/toolchain@dev
with:
toolchain: ${{ env.RUSTC_VERSION }}
profile: minimal
override: true
components: rustfmt
- name: Check formatting
uses: gluwa/cargo@dev
with:
command: fmt
args: -- --check
clippy:
name: Clippy
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@v4
with:
lfs: true
- name: Install protobuf
uses: arduino/setup-protoc@v3
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}
- name: Configure rustc version
run: |
RUSTC_VERSION=$(grep channel rust-toolchain.toml | tail -n1 | tr -d " " | cut -f2 -d'"')
echo "RUSTC_VERSION=$RUSTC_VERSION" >> "$GITHUB_ENV"
- name: Install Rust toolchain
uses: gluwa/toolchain@dev
with:
toolchain: ${{ env.RUSTC_VERSION }}
target: wasm32-unknown-unknown
profile: minimal
override: true
components: clippy
- uses: Swatinem/rust-cache@v2
- name: Run Clippy
uses: gluwa/cargo@dev
with:
command: clippy
args: --all-targets --all-features -- -D warnings -A clippy::too_many_arguments -A clippy::type_complexity
check:
# The type of runner that the job will run on
runs-on: ubuntu-24.04
# Steps represent a sequence of tasks that will be executed as part of the job
steps:
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- uses: actions/checkout@v4
with:
lfs: true
- name: Install protobuf
uses: arduino/setup-protoc@v3
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}
- name: Configure rustc version
run: |
RUSTC_VERSION=$(grep channel rust-toolchain.toml | tail -n1 | tr -d " " | cut -f2 -d'"')
echo "RUSTC_VERSION=$RUSTC_VERSION" >> "$GITHUB_ENV"
- name: Install Rust toolchain
uses: gluwa/toolchain@dev
with:
toolchain: ${{ env.RUSTC_VERSION }}
target: wasm32-unknown-unknown
profile: minimal
override: true
- uses: Swatinem/rust-cache@v2
- name: Check Build
run: |
SKIP_WASM_BUILD=1 cargo check --release
- name: Check Build for Benchmarking
run: |
SKIP_WASM_BUILD=1 cargo check --features=runtime-benchmarks --release
unit-test-creditcoin:
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@v4
with:
lfs: true
- name: Install protobuf
uses: arduino/setup-protoc@v3
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}
- name: Configure rustc version
run: |
RUSTC_VERSION=$(grep channel rust-toolchain.toml | tail -n1 | tr -d " " | cut -f2 -d'"')
echo "RUSTC_VERSION=$RUSTC_VERSION" >> "$GITHUB_ENV"
- name: Install Rust toolchain
uses: gluwa/toolchain@dev
with:
toolchain: ${{ env.RUSTC_VERSION }}
target: wasm32-unknown-unknown
profile: minimal
override: true
- uses: Swatinem/rust-cache@v2
- name: Run tests
uses: gluwa/cargo@dev
with:
command: test
args: --features=runtime-benchmarks -- --test-threads 1
build-creditcoin-node:
strategy:
fail-fast: false
matrix:
target: [devnet, testnet]
name: build-creditcoin-node-for-${{ matrix.target }}
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@v4
with:
lfs: true
- name: Set-Up
run: |
sudo apt-get update
sudo apt install -y curl
- name: Install protobuf
uses: arduino/setup-protoc@v3
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}
- name: Configure rustc version
run: |
RUSTC_VERSION=$(grep channel rust-toolchain.toml | tail -n1 | tr -d " " | cut -f2 -d'"')
echo "RUSTC_VERSION=$RUSTC_VERSION" >> "$GITHUB_ENV"
- name: Install Rust toolchain
uses: gluwa/toolchain@dev
with:
toolchain: ${{ env.RUSTC_VERSION }}
target: wasm32-unknown-unknown
profile: minimal
override: true
- uses: Swatinem/rust-cache@v2
with:
shared-key: build-creditcoin-node
- name: Extra compiler flags
if: matrix.target == 'devnet'
id: compiler-flags
run: |
echo "extra=--features=fast-runtime --features=devnet" >> "$GITHUB_OUTPUT"
- name: Build SUT
uses: gluwa/cargo@dev
with:
command: build
args: --release ${{ steps.compiler-flags.outputs.extra }}
- name: Upload creditcoin-node binary
uses: actions/upload-artifact@v4
with:
name: creditcoin-node-${{ matrix.target }}
path: target/release/creditcoin3-node
- name: Upload WASM runtime
uses: actions/upload-artifact@v4
with:
name: creditcoin_node_runtime.compact.compressed.wasm-${{ matrix.target }}
path: target/release/wbuild/creditcoin3-runtime/creditcoin_next_runtime.compact.compressed.wasm
build-creditcoin-node-for-testing:
needs:
- build-creditcoin-node
strategy:
fail-fast: false
matrix:
target: [devnet, ci]
name: build-creditcoin-node-for-testing-${{ matrix.target }}
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@v4
with:
lfs: true
- name: Set-Up
run: |
sudo apt-get update
sudo apt install -y curl
- name: Install protobuf
uses: arduino/setup-protoc@v3
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}
- name: Configure rustc version
run: |
RUSTC_VERSION=$(grep channel rust-toolchain.toml | tail -n1 | tr -d " " | cut -f2 -d'"')
echo "RUSTC_VERSION=$RUSTC_VERSION" >> "$GITHUB_ENV"
- name: Install Rust toolchain
uses: gluwa/toolchain@dev
with:
toolchain: ${{ env.RUSTC_VERSION }}
target: wasm32-unknown-unknown
profile: minimal
override: true
- uses: Swatinem/rust-cache@v2
with:
shared-key: build-creditcoin-node
- name: Extra compiler flags
if: matrix.target == 'devnet'
id: compiler-flags
run: |
echo "extra=--features=devnet" >> "$GITHUB_OUTPUT"
- name: Build SUT
uses: gluwa/cargo@dev
with:
command: build
args: --release --features=fast-runtime ${{ steps.compiler-flags.outputs.extra }}
- name: Upload creditcoin-node binary
uses: actions/upload-artifact@v4
with:
name: creditcoin-node-for-testing-${{ matrix.target }}
path: target/release/creditcoin3-node
- name: Upload WASM runtime
uses: actions/upload-artifact@v4
with:
name: creditcoin_node_runtime.compact.compressed.wasm-for-${{ matrix.target }}
path: target/release/wbuild/creditcoin3-runtime/creditcoin_next_runtime.compact.compressed.wasm
integration-test-smart-contract:
needs:
- build-creditcoin-node-for-testing
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@v4
with:
lfs: true
- name: Download creditcoin-node binary
uses: actions/download-artifact@v4
with:
name: creditcoin-node-for-testing-ci
path: target/release
- name: Install Node.js
uses: actions/setup-node@v4
with:
node-version: 20
- name: Start Node 1 - Alice
run: |
chmod a+x ./target/release/creditcoin3-node
./target/release/creditcoin3-node \
--dev --validator --pruning archive \
--node-key d182d503b7dd97e7c055f33438c7717145840fd66b2a055284ee8d768241a463 \
--base-path ./alice-data &
- name: Wait for node(s) to start
run: |
./.github/wait-for-creditcoin.sh 'http://127.0.0.1:9944'
- name: Configure testing environment
id: test-env
working-directory: ./cli
run: |
yarn install
EVM_PRIVATE_KEY=$(node dist/test/blockchainSetup.js)
echo "url=http://127.0.0.1:9944" >> "$GITHUB_OUTPUT"
echo "private_key=$EVM_PRIVATE_KEY" >> "$GITHUB_OUTPUT"
- name: Execute smart contract test tool
working-directory: ./testing
run: |
./evm-network-test.sh ${{ steps.test-env.outputs.url }} ${{ steps.test-env.outputs.private_key }}
integration-test-check-extrinsics:
needs:
- build-creditcoin-node-for-testing
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@v4
with:
lfs: true
- name: Install Node Dependencies
uses: actions/setup-node@v4
with:
node-version: 20
- run: npm install --ignore-scripts -g @polkadot/metadata-cmp
- name: Download creditcoin-node binary
uses: actions/download-artifact@v4
with:
name: creditcoin-node-for-testing-ci
path: target/release
- name: Run Extrinsics Ordering
shell: bash
run: |
chmod a+x ./target/release/creditcoin3-node
./.github/check-extrinsics.sh
env:
GITHUB_TOKEN: ${{ secrets.PAT || secrets.GITHUB_TOKEN }}
#Upload logs if nodes are not connecting.
#head-node.log and release-node.log are created in ./scripts/check-extrinsics.sh
- name: Upload logs
uses: actions/upload-artifact@v4
if: always()
with:
if-no-files-found: warn
name: "extrinsic-logs"
path: |
head-node.log
release-node.log
metadata-cmp-with-mainnet.txt
metadata-cmp-with-testnet.txt
unit-test-cli:
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@v4
with:
lfs: true
- name: Install Node.js
uses: actions/setup-node@v4
with:
node-version: 20
- run: npm install -g yarn
- name: Execute tests
working-directory: ./cli
run: |
yarn install
yarn test:unit
- uses: codecov/codecov-action@v5
with:
files: cli/coverage/lcov.info
fail_ci_if_error: false
verbose: true
deploy-github-runner:
# WARNING: same matrix as integration-test-cli job
strategy:
fail-fast: false
matrix:
include:
- proxy: no
- proxy: yes
secret: no-funds
- proxy: yes
secret: not-a-proxy
- proxy: yes
secret: valid-proxy
proxy_type: Staking
- proxy: yes
secret: valid-proxy
proxy_type: NonTransfer
- proxy: yes
secret: valid-proxy
proxy_type: All
name: deploy-github-runner / proxy=${{ matrix.proxy }} / ${{ matrix.secret }} / type=${{ matrix.proxy_type }}
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@v4
with:
lfs: true
# See /~https://github.com/actions/runner/issues/1879#issuecomment-1123196869
- name: Create matrix.txt
run: |
echo "proxy=${{ matrix.proxy }} / ${{ matrix.secret }} / type=${{ matrix.proxy_type }}" > matrix.txt
- name: Evaluate env vars
id: get-env
run: |
HASH_VALUE=$(echo "${{ hashFiles('matrix.txt') }}" | cut -c1-7)
rm matrix.txt
# WARNING: using env.RUNNER_VM_NAME directly in job outputs above
# doesn't evaluate the $GITHUB_RUN_ID reference
echo "runner_vm_name=${{ env.RUNNER_VM_NAME }}-$HASH_VALUE" >> "$GITHUB_OUTPUT"
- name: Provision VM
if: env.LC_GITHUB_REPO_ADMIN_TOKEN
run: |
.github/provision-linode-vm.sh
env:
LC_OWNER_REPO_SLUG: ${{ github.repository }}
LC_GITHUB_REPO_ADMIN_TOKEN: ${{ secrets.GH_REPO_ADMIN_TOKEN }}
LC_RUNNER_EPHEMERAL: false
LC_RUNNER_VM_NAME: ${{ steps.get-env.outputs.runner_vm_name }}
LC_PROXY_ENABLED: ${{ matrix.proxy }}
LC_PROXY_SECRET_VARIANT: ${{ matrix.secret }}
LC_PROXY_TYPE: ${{ matrix.proxy_type }}
LC_WORKFLOW_ID: ${{ github.run_id }}
LINODE_CLI_TOKEN: ${{ secrets.LINODE_CLI_TOKEN }}
remove-github-runner:
runs-on: ubuntu-24.04
needs:
- integration-test-cli
if: ${{ always() }}
# WARNING: same matrix as integration-test-cli job
strategy:
fail-fast: false
matrix:
include:
- proxy: no
- proxy: yes
secret: no-funds
- proxy: yes
secret: not-a-proxy
- proxy: yes
secret: valid-proxy
proxy_type: Staking
- proxy: yes
secret: valid-proxy
proxy_type: NonTransfer
- proxy: yes
secret: valid-proxy
proxy_type: All
name: remove-github-runner / proxy=${{ matrix.proxy }} / ${{ matrix.secret }} / type=${{ matrix.proxy_type }}
steps:
- uses: actions/checkout@v4
with:
lfs: true
# See /~https://github.com/actions/runner/issues/1879#issuecomment-1123196869
- name: Create matrix.txt
run: |
echo "proxy=${{ matrix.proxy }} / ${{ matrix.secret }} / type=${{ matrix.proxy_type }}" > matrix.txt
- name: Evaluate env vars
id: get-env
run: |
HASH_VALUE=$(echo "${{ hashFiles('matrix.txt') }}" | cut -c1-7)
rm matrix.txt
echo "runner_vm_name=${{ env.RUNNER_VM_NAME }}-$HASH_VALUE" >> "$GITHUB_OUTPUT"
- name: Remove VM
run: |
.github/remove-linode-vm.sh
env:
LINODE_CLI_TOKEN: ${{ secrets.LINODE_CLI_TOKEN }}
LC_RUNNER_VM_NAME: ${{ steps.get-env.outputs.runner_vm_name }}
integration-test-cli:
strategy:
fail-fast: false
matrix:
include:
- proxy: no
- proxy: yes
secret: no-funds
- proxy: yes
secret: not-a-proxy
- proxy: yes
secret: valid-proxy
proxy_type: Staking
- proxy: yes
secret: valid-proxy
proxy_type: NonTransfer
- proxy: yes
secret: valid-proxy
proxy_type: All
name: integration-test-cli / proxy=${{ matrix.proxy }} / ${{ matrix.secret }} / type=${{ matrix.proxy_type }}
needs:
- build-creditcoin-node-for-testing
- deploy-github-runner
runs-on:
[
self-hosted,
"workflow-${{ github.run_id }}",
"proxy-${{ matrix.proxy }}",
"secret-${{ matrix.secret }}",
"type-${{ matrix.proxy_type }}",
]
# checkov:skip=CKV2_GHA_1:We need this for typedefs auto-commit
permissions: write-all
steps:
- uses: actions/checkout@v4
with:
lfs: true
repository: ${{ github.event.pull_request.head.repo.full_name }}
ref: ${{ github.event.pull_request.head.ref }}
- name: Download creditcoin-node binary
uses: actions/download-artifact@v4
with:
name: creditcoin-node-for-testing-ci
path: target/release
- name: Install Node.js
uses: actions/setup-node@v4
with:
node-version: 20
- run: npm install -g yarn
- name: Start creditcoin3-node in order to update typedefs
run: |
chmod a+x ./target/release/creditcoin3-node
./target/release/creditcoin3-node \
--chain dev \
--validator --alice --pruning archive \
--node-key d182d503b7dd97e7c055f33438c7717145840fd66b2a055284ee8d768241a463 \
--base-path ./alice-data &
- name: Wait for nodes to start
run: |
./.github/wait-for-creditcoin.sh 'http://127.0.0.1:9944'
- name: Install creditcoin-cli dependencies
working-directory: ./cli
run: |
yarn install
- name: Auto-update typedefs
id: update_typedefs
working-directory: ./cli
run: |
./get-metadata.sh
# kill the node b/c the tests will launch their own processes
killall -9 creditcoin3-node
yarn build:types
yarn format
echo "========== DEBUG DEBUG DEBUG =========="
git status --short --untracked-files=no
git diff
echo "======================================="
# do not update if only creditcoin.json has changed,
# usually happens on version bump without any real metadata change
# shellcheck disable=SC2143
if [ -n "$(git status --short --untracked-files=no | grep -v yarn.lock | grep -v creditcoin.json)" ]; then
git diff
echo "git_diff=true" >> "$GITHUB_OUTPUT"
else
echo "git_diff=false" >> "$GITHUB_OUTPUT"
fi
- name: Extra ENV for PRs towards dev branch
if: github.base_ref == 'dev'
id: for-dev-prs
run: |
echo "========== DEBUG DEBUG DEBUG =========="
echo "${{ github.base_ref }}"
echo "======================================="
echo "validator_cycle=no" >> "$GITHUB_OUTPUT"
- name: Extra ENV for other PRs and commits
if: github.base_ref != 'dev'
id: non-dev-prs
run: |
echo "========== DEBUG DEBUG DEBUG =========="
echo "${{ github.base_ref }}"
echo "======================================="
echo "validator_cycle=yes" >> "$GITHUB_OUTPUT"
- name: Build creditcoin-cli
working-directory: ./cli
run: |
yarn build
- name: Run integration tests
working-directory: ./cli
run: |
yarn test:integration
env:
PROXY_ENABLED: ${{ matrix.proxy }}
PROXY_SECRET_VARIANT: ${{ matrix.secret }}
PROXY_TYPE: ${{ matrix.proxy_type }}
EXECUTE_VALIDATOR_CYCLE_TEST_SCENARIO: ${{ steps.for-dev-prs.outputs.validator_cycle || steps.non-dev-prs.outputs.validator_cycle }}
- name: Kill nodes
if: always()
continue-on-error: true
run: |
# if all went well kill the node. Otherwise GitHub Actions would exit on the
# previous step killing everything and we don't have to worry about
# dangling processes
killall -9 creditcoin3-node
- name: Upload logs from Alice and Bob
if: always()
uses: actions/upload-artifact@v4
with:
name: Alice-and-Bob-logs-for-run-proxy-${{ matrix.proxy }}-${{ matrix.secret }}-type-${{ matrix.proxy_type }}
path: /tmp/creditcoin3-node-*.std*
- name: Commit changes for typedefs
if: ${{ env.GITHUB_TOKEN && success() && steps.update_typedefs.outputs.git_diff == 'true' && matrix.proxy == 'no' }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
uses: EndBug/add-and-commit@v9
with:
add: "cli/creditcoin.json cli/src/lib/interfaces/"
author_name: gluwa-bot
author_email: creditcoin@gluwa.com
message: "Auto-update TypeScript type definitions"
github_token: ${{ secrets.GITHUB_TOKEN }}
- name: Upload code coverage
uses: codecov/codecov-action@v5
with:
files: cli/coverage/lcov.info
fail_ci_if_error: false
verbose: true
integration-test-blockchain:
needs:
- build-creditcoin-node-for-testing
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@v4
with:
lfs: true
- name: Download creditcoin-node binary
uses: actions/download-artifact@v4
with:
name: creditcoin-node-for-testing-ci
path: target/release
- name: Install Node.js
uses: actions/setup-node@v4
with:
node-version: 20
- run: npm install -g yarn
- name: Start Node 1
run: |
chmod a+x ./target/release/creditcoin3-node
./target/release/creditcoin3-node \
--chain dev \
--validator --alice --pruning archive \
--node-key d182d503b7dd97e7c055f33438c7717145840fd66b2a055284ee8d768241a463 \
--ethapi=debug,trace,txpool \
--base-path ./alice-data &
- name: Wait for node(s)s to start
run: |
./.github/wait-for-creditcoin.sh 'http://127.0.0.1:9944'
- name: Install creditcoin-cli dependencies
working-directory: ./cli
run: |
yarn install
- name: Run blockchain tests
working-directory: ./cli
run: |
yarn test:blockchain
- name: Kill nodes
if: always()
continue-on-error: true
run: |
# if all went well kill the node. Otherwise GitHub Actions would exit on the
# previous step killing everything and we don't have to worry about
# dangling processes
killall -9 creditcoin3-node
integration-test-chainspec:
needs:
- build-creditcoin-node
strategy:
fail-fast: false
matrix:
chainspec: [devnet, testnet]
name: integration-test-chainspec-${{ matrix.chainspec }}
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@v4
with:
lfs: true
- name: Download creditcoin-node binary
uses: actions/download-artifact@v4
with:
name: creditcoin-node-${{ matrix.chainspec }}
path: target/release
- name: Install Node.js
uses: actions/setup-node@v4
with:
node-version: 20
- run: npm install -g yarn
- name: Start Node 1
run: |
chmod a+x ./target/release/creditcoin3-node
./target/release/creditcoin3-node \
--chain ${{ matrix.chainspec }} \
--validator --alice --pruning archive \
--node-key d182d503b7dd97e7c055f33438c7717145840fd66b2a055284ee8d768241a463 \
--base-path ./alice-data-${{ matrix.chainspec }} &
- name: Wait for node(s)s to start
run: |
./.github/wait-for-creditcoin.sh 'http://127.0.0.1:9944'
- name: Install creditcoin-cli dependencies
working-directory: ./cli
run: |
yarn install
- name: Run blockchain tests
working-directory: ./cli
run: |
# TODO: maybe we can make a chainspec-tests directory which symlinks to selected test files
yarn jest --config src/test/blockchain-tests.config.ts --silent --verbose --runInBand --forceExit src/test/blockchain-tests/danger-will-brick-the-blockchain.test.ts
env:
BLOCKCHAIN_TESTS_GLOBAL_SETUP: "./${{ matrix.chainspec }}ChainspecSetup.ts"
- name: Kill nodes
if: always()
continue-on-error: true
run: |
# if all went well kill the node. Otherwise GitHub Actions would exit on the
# previous step killing everything and we don't have to worry about
# dangling processes
killall -9 creditcoin3-node
audit:
name: cargo audit
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@v4
with:
lfs: true
- name: Install protobuf
uses: arduino/setup-protoc@v3
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}
- name: Configure rustc version