-
Notifications
You must be signed in to change notification settings - Fork 15
818 lines (674 loc) · 25.1 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
---
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
# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
docker-build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Build docker image
run: |
docker build -t gluwa/creditcoin .
- 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 9933:9933 -p 30333:30333 gluwa/creditcoin \
--validator --chain mainnet \
--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/bootnode.creditcoin.network/tcp/30333/p2p/12D3KooWAEgDL126EUFxFfdQKiUhmx3BJPdszQHu9PsYsLCuavhb" "/dns4/bootnode2.creditcoin.network/tcp/30333/p2p/12D3KooWSQye3uN3bZQRRC4oZbpiAZXkP2o5UZh6S8pqyh24bF3k" "/dns4/bootnode3.creditcoin.network/tcp/30333/p2p/12D3KooWFrsEZ2aSfiigAxs6ir2kU6en4BewotyCXPhrJ7T1AzjN" \
--port 30333 --unsafe-rpc-external
- name: Healtcheck
run: |
sleep 60
./scripts/check-health.sh
- name: Sanity test creditcoin-cli inside the container
run: |
docker exec creditcoin-validator which creditcoin-cli
docker exec creditcoin-validator creditcoin-cli wizard --help
- name: Kill the container
run: |
# this will also kill the parent container
sudo killall -9 creditcoin-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: Kill the container
run: |
# this will also kill the parent container
sudo killall -9 creditcoin-node
sanity-tests:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Check for parity between extrinsics, benchmarks and weights
run: |
echo "INFO: active pallets are"
./scripts/check-parity-bw-extrinsics-benchmarks-weights.sh --show-pallets
echo "========================"
./scripts/check-parity-bw-extrinsics-benchmarks-weights.sh
- name: Check migrations
run: |
./scripts/check-usage-of-log-warn.sh
- name: Check if Cargo.toml specifies dependencies from forks
run: |
./scripts/check-for-used-forks.sh
sanity-test-cli:
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v4
- name: Install Node.js
uses: actions/setup-node@v4
with:
node-version: 20
- run: npm install -g yarn
- name: Install creditcoin-js & creditcoin-cli
run: |
pushd creditcoin-js/ && yarn install && yarn pack && popd
pushd scripts/cc-cli && yarn upgrade 'creditcoin-js' && yarn build && npm install -g . && popd
- name: Execute creditcoin-cli command
run: |
# this makes sure we have a creditcoin-cli entrypoint in the standard PATH
creditcoin-cli help
audit:
name: cargo audit
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set-Up
run: |
sudo apt-get update
sudo apt install -y protobuf-compiler
- 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: Install cargo audit
run: |
cargo install cargo-audit --features=fix
- name: Run cargo audit
run: |
cargo audit --ignore RUSTSEC-2020-0071
CC_MATCH=$(cargo audit --ignore RUSTSEC-2020-0071 --color never | grep -E "^.── creditcoin" || true)
# fail for anything which is a 1st level dependency of Creditcoin
if [ -n "$CC_MATCH" ]; then
echo "FAIL: Direct dependencies of Creditcoin found in audit report"
echo "INFO: Inspect the output above for more information"
exit 1
else
echo "INFO: No direct dependencies of Creditcoin found in audit report"
exit 0
fi
fmt:
name: Rustfmt
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- 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-latest
steps:
- uses: actions/checkout@v4
- name: Set-Up
run: |
sudo apt-get update
sudo apt install -y protobuf-compiler
- 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-22.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
- name: Set-Up
run: |
sudo apt-get update
sudo apt install -y cmake pkg-config libssl-dev git build-essential clang libclang-dev curl protobuf-compiler
- 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: macos-13
steps:
- uses: actions/checkout@v4
- name: Set-Up
env:
HOMEBREW_NO_INSTALL_CLEANUP: true
HOMEBREW_NO_INSTALLED_DEPENDENTS_CHECK: true
run: |
brew update
brew install cmake openssl protobuf
- 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: Configure flags for collecting coverage
run: |
# shellcheck disable=SC2129
echo "CARGO_INCREMENTAL=0" >> "$GITHUB_ENV"
echo "RUSTFLAGS=-Zprofile -Ccodegen-units=1 -Cinline-threshold=0 -Clink-dead-code -Coverflow-checks=off -Cpanic=abort -Zpanic_abort_tests" >> "$GITHUB_ENV"
echo "RUSTDOCFLAGS=-Zprofile -Ccodegen-units=1 -Cinline-threshold=0 -Clink-dead-code -Coverflow-checks=off -Cpanic=abort -Zpanic_abort_tests" >> "$GITHUB_ENV"
- name: Run tests
uses: gluwa/cargo@dev
with:
command: test
args: --features=try-runtime -- --test-threads 1
env:
CARGO_INCREMENTAL: ${{ env.CARGO_INCREMENTAL }}
RUSTFLAGS: ${{ env.RUSTFLAGS }}
RUSTDOCFLAGS: ${{ env.RUSTDOCFLAGS }}
- id: coverage
continue-on-error: true
uses: actions-rs/grcov@v0.1
with:
config: .grcov.yml
- uses: codecov/codecov-action@v4
with:
files: ${{ steps.coverage.outputs.report }}
fail_ci_if_error: false
verbose: true
unit-test-cli:
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v4
- name: Install Node.js
uses: actions/setup-node@v4
with:
node-version: 20
- run: npm install -g yarn
- name: Execute tests
run: |
pushd creditcoin-js/ && yarn install && yarn pack && popd
pushd scripts/cc-cli
yarn upgrade 'creditcoin-js'
yarn test:unit
popd
- uses: codecov/codecov-action@v4
with:
files: scripts/cc-cli/coverage/lcov.info
fail_ci_if_error: false
verbose: true
build-creditcoin-node:
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v4
- name: Set-Up
run: |
sudo apt-get update
sudo apt install -y cmake pkg-config libssl-dev git build-essential clang libclang-dev curl protobuf-compiler
- 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: Build SUT
uses: gluwa/cargo@dev
with:
command: build
args: --release --features fast-runtime
- name: Upload creditcoin-node binary
uses: actions/upload-artifact@v4
with:
name: creditcoin-node
path: target/release/creditcoin-node
- name: Upload WASM runtime
uses: actions/upload-artifact@v4
with:
name: creditcoin_node_runtime.compact.compressed.wasm
path: target/release/wbuild/creditcoin-node-runtime/creditcoin_node_runtime.compact.compressed.wasm
integration-test-cli:
needs:
- build-creditcoin-node
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v4
- name: Start local Ethereum node
run: |
docker run --rm -p 8545:8545 -d gluwa/hardhat-dev
- name: Download creditcoin-node binary
uses: actions/download-artifact@v4
with:
name: creditcoin-node
path: target/release
- name: Install Node.js
uses: actions/setup-node@v4
with:
node-version: 20
- run: npm install -g yarn
- name: Install creditcoin-js & creditcoin-cli
run: |
pushd creditcoin-js/ && yarn install && yarn pack && popd
pushd scripts/cc-cli && yarn upgrade 'creditcoin-js' && yarn build && popd
- name: Start Node 1
run: |
chmod a+x ./target/release/creditcoin-node
./target/release/creditcoin-node \
--chain local \
--validator --alice --pruning archive \
--node-key d182d503b7dd97e7c055f33438c7717145840fd66b2a055284ee8d768241a463 \
--base-path ./alice-data &
- name: Start Node 2
run: |
./target/release/creditcoin-node \
--chain local \
--validator --bob --pruning archive \
--bootnodes /ip4/127.0.0.1/tcp/30333/p2p/12D3KooWKEKymnBDKfa8MkMWiLE6DYbC4aAUciqmYucm7xFKK3Au \
--port 30335 --ws-port 9945 --rpc-port 9935 \
--base-path ./bob-data &
- name: Wait for nodes to start
run: |
./integration-tests/wait-for-creditcoin.sh 'http://127.0.0.1:9933'
./integration-tests/wait-for-creditcoin.sh 'http://127.0.0.1:9935'
- name: Run integration tests
run: |
pushd scripts/cc-cli
yarn test:integration
popd
- name: Upload code coverage
uses: codecov/codecov-action@v4
with:
files: scripts/cc-cli/coverage/lcov.info
fail_ci_if_error: false
verbose: true
- 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 creditcoin-node
build-creditcoin-transaction-producer:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
token: ${{ secrets.CREDITCOIN_GITHUB_API_TOKEN }}
repository: gluwa/creditcoin-transaction-producer
path: creditcoin-transaction-producer
- name: Configure rustc version
run: |
source creditcoin-transaction-producer/ci/env
echo "RUSTC_VERSION=$RUSTC_VERSION" >> "$GITHUB_ENV"
- name: Install Node.js
uses: actions/setup-node@v4
with:
node-version: 20
- 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: Build creditcoin-transaction-producer
run: |
pushd creditcoin-transaction-producer/
cargo install just
just install
just build
popd
# archive the entire directory, together with binary artifacts and FE artifacts
tar -czvf creditcoin-transaction-producer.tar.gz creditcoin-transaction-producer/
- name: Upload creditcoin-transaction-producer archive
uses: actions/upload-artifact@v4
with:
path: creditcoin-transaction-producer.tar.gz
name: creditcoin-transaction-producer.tar.gz
tools-creditcoin-transaction-producer:
runs-on: ubuntu-latest
needs:
- build-creditcoin-node
- build-creditcoin-transaction-producer
steps:
- name: Start local Ethereum node
run: |
docker run --rm -p 8545:8545 -d gluwa/hardhat-dev
- name: Download creditcoin-node binary
uses: actions/download-artifact@v4
with:
name: creditcoin-node
path: target/release
- name: Start creditcoin-node
run: |
chmod a+x ./target/release/creditcoin-node
./target/release/creditcoin-node --dev --monitor-nonce auto >~/creditcoin-node.log 2>&1 &
- uses: actions/checkout@v4
- name: Wait for creditcoin-node to start
run: |
./integration-tests/wait-for-creditcoin.sh
- name: Download creditcoin-transaction-producer archive
uses: actions/download-artifact@v4
with:
name: creditcoin-transaction-producer.tar.gz
- name: Start creditcoin-transaction-producer
run: |
tar -xzvf creditcoin-transaction-producer.tar.gz
pushd creditcoin-transaction-producer/
# Deployer Seed is Private Key for Account #0 in hardhat
# Funded Account Seed is Alice
./target/release/creditcoin-transaction-producer --max-accounts 20 --max-chain-apis 25 \
--funded-account-seed '0xe5be9a5092b81bca64be81d212e7f2f9eba183bb7a90954f7b76361f6edb5c0a' \
--deployer-seed '0xabf82ff96b463e9d82b83cb9bb450fe87e6166d4db6d7021d0c71d7e960d5abe' \
--setup --frontend ./dist >~/creditcoin-transaction-producer.log 2>&1 &
popd
- name: Sanity check that creditcoin-transaction-producer started
run: |
sleep 20
./scripts/check-transaction-producer.sh
- name: Upload logs
uses: actions/upload-artifact@v4
if: always()
with:
name: transaction-producer-logs
path: ~/creditcoin-*.log
- name: Kill SUT
if: always()
continue-on-error: true
run: |
killall -9 creditcoin-node
killall -9 creditcoin-transaction-producer
integration-test-loan-cycle:
needs:
- build-creditcoin-node
runs-on: ubuntu-22.04
# checkov:skip=CKV2_GHA_1:We need this for creditcoin-js typedefs auto-commit
permissions: write-all
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 10
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
path: target/release
- name: Start SUT
run: |
chmod a+x ./target/release/creditcoin-node
./target/release/creditcoin-node --dev --monitor-nonce auto >~/creditcoin-node.log 2>&1 &
- name: Start local Ethereum node
run: |
docker run --rm -p 8545:8545 -d gluwa/hardhat-dev
- name: Install Node.js
uses: actions/setup-node@v4
with:
node-version: 20
- run: npm install -g yarn
- name: Prepare for integration tests
run: |
pushd integration-tests/
# wait for creditcoin-node to initialize
./yarn-install-and-wait-for-creditcoin.sh
git checkout yarn.lock
popd
- name: Auto-update typedefs
id: update_typedefs
run: |
pushd creditcoin-js/
./get-metadata.sh
yarn build:types
yarn format
echo "========== DEBUG DEBUG DEBUG =========="
git status --short
git diff
echo "======================================="
if [ -n "$(git status --short)" ]; then
git diff
echo "git_diff=true" >> "$GITHUB_OUTPUT"
fi
popd
- name: Execute integration tests
run: |
pushd integration-tests/
yarn test
popd
- name: Git diff in case of failure
if: failure()
run: |
git diff
- name: Commit changes for typedefs
if: ${{ success() && steps.update_typedefs.outputs.git_diff == 'true' }}
uses: EndBug/add-and-commit@v9
with:
author_name: gluwa-bot
author_email: creditcoin@gluwa.com
message: "Auto-update creditcoin-js type definitions"
github_token: ${{ secrets.CREDITCOIN_GITHUB_API_TOKEN }}
- name: Upload logs
uses: actions/upload-artifact@v4
if: always()
with:
name: logs
path: ~/creditcoin-node.log
- name: Kill SUT
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 creditcoin-node
javascript-lint:
name: javascript-lint / ${{ matrix.directory }}
runs-on: ubuntu-22.04
strategy:
matrix:
directory:
[creditcoin-js, integration-tests, scripts/js, scripts/cc-cli]
steps:
- uses: actions/checkout@v4
- name: Install Node.js
uses: actions/setup-node@v4
with:
node-version: 20
- run: npm install -g yarn
- name: Run tools
run: |
pushd creditcoin-js/ && yarn install && yarn pack && popd
pushd ${{ matrix.directory }}
yarn upgrade 'creditcoin-js'
yarn lint
popd
javascript-typecheck:
name: javascript-typecheck / ${{ matrix.directory }}
runs-on: ubuntu-22.04
strategy:
matrix:
directory:
[creditcoin-js, integration-tests, scripts/js, scripts/cc-cli]
steps:
- uses: actions/checkout@v4
- name: Install Node.js
uses: actions/setup-node@v4
with:
node-version: 20
- run: npm install -g yarn
- name: Run tools
run: |
pushd creditcoin-js/ && yarn install && yarn pack && popd
pushd ${{ matrix.directory }}
yarn upgrade 'creditcoin-js'
yarn typecheck
popd
javascript-format:
name: javascript-format / ${{ matrix.directory }}
runs-on: ubuntu-22.04
strategy:
matrix:
directory:
[creditcoin-js, integration-tests, scripts/js, scripts/cc-cli]
steps:
- uses: actions/checkout@v4
- name: Install Node.js
uses: actions/setup-node@v4
with:
node-version: 20
- run: npm install -g yarn
- name: Run tools
run: |
pushd creditcoin-js/ && yarn install && yarn pack && popd
pushd ${{ matrix.directory }}
yarn upgrade 'creditcoin-js'
if ! yarn check-format; then
echo "FAIL: JavaScript is not formatted properly!"
echo "HELP: Execute 'yarn format' and commit the changes to fix this"
exit 1
fi
popd
benchmark:
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v4
- name: Inspect benchmark CI config
run: |
# WARNING: Command below may differ depending on which workflow config file
# your job is defined in !!! Don't copy&paste it blindly !!!
PALLETS_IN_CI_CONFIG=$(grep "./scripts/bench.sh -p" .github/workflows/ci.yml | grep -v PALLETS_IN_CI_CONFIG | tr -s ' ' | cut -d' ' -f4 | sort | xargs)
PALLETS_IN_SOURCE=$(./scripts/check-parity-bw-extrinsics-benchmarks-weights.sh --show-pallets)
if [ "$PALLETS_IN_CI_CONFIG" != "$PALLETS_IN_SOURCE" ]; then
echo "FAIL: Pallet mismatch between source code and benchmark CI config"
echo "INFO: in source: '$PALLETS_IN_SOURCE'"
echo "INFO: CI config: '$PALLETS_IN_CI_CONFIG'"
exit 1
fi
- name: Set-Up
run: |
sudo apt-get update
sudo apt install -y cmake pkg-config libssl-dev git build-essential clang libclang-dev curl protobuf-compiler
- 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: Build benchmarks
uses: gluwa/cargo@dev
with:
command: build
args: --release --features runtime-benchmarks
- name: Check if runner machine meets chain's requirements
continue-on-error: true
run: |
./scripts/check-hardware.sh
- name: Run benchmarks to generate dummy weights
run: |
./scripts/bench.sh -p creditcoin -b -r 1 -s 2
./scripts/bench.sh -p offchain_task_scheduler -b -r 1 -s 2
./scripts/bench.sh -p rewards -b -r 1 -s 2
# check if automatically generated weights compile
- name: Rebuild SUT with newly generated weights
uses: gluwa/cargo@dev
with:
command: build
args: --release
shellcheck:
name: "🐚 Shellcheck"
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v4
- name: Run ShellCheck
uses: ludeeus/action-shellcheck@2.0.0
env:
SHELLCHECK_OPTS: -e SC2002 # allow useless cat commands