-
Notifications
You must be signed in to change notification settings - Fork 19
739 lines (720 loc) · 28.6 KB
/
verify-pr-commit.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
# yaml-language-server: $schema=https://json.schemastore.org/github-workflow.json
name: Verify PR Commit
concurrency:
group: ${{github.workflow}}-${{github.ref}}
cancel-in-progress: true
on:
pull_request:
branches:
- main
- "*-development" # Feature Branches should suffix with -development
env:
BIN_DIR: target/release
PR_LABEL_METADATA_CHANGED: metadata-changed
PR_LABEL_METADATA_VERSION_NOT_INCREMENTED: metadata-version-not-incremented
jobs:
changes:
name: Determine Changed Files
runs-on: ubuntu-22.04
outputs:
rust: ${{steps.filter.outputs.rust}}
build-binary: ${{steps.filter.outputs.build-binary}}
cargo-lock: ${{steps.filter.outputs.cargo-lock}}
run-e2e: ${{steps.filter.outputs.run-e2e}}
ci-docker-image: ${{steps.filter.outputs.ci-docker-image}}
steps:
- name: Check Out Repo
uses: actions/checkout@v4
- name: Check for Changed Files
uses: dorny/paths-filter@de90cc6fb38fc0963ad72b210f1f284cd68cea36
id: filter
with:
filters: |
rust:
- '**/*.rs'
- '**/*.hbs'
- '.rustfmt.toml'
- '**/Cargo.toml'
- '**/Cargo.lock'
build-binary:
- '**/*.rs'
- '**/*.hbs'
- '.rustfmt.toml'
- '**/Cargo.toml'
- '**/Cargo.lock'
- 'js/api-augment/**'
- 'e2e/**/*.{ts,json}'
cargo-lock:
- '**/Cargo.toml'
- '**/Cargo.lock'
run-e2e:
- '**/*.rs'
- '**/Cargo.toml'
- 'e2e/**/*.{ts,json}'
clear-metadata-labels:
name: Clear Metadata Labels
runs-on: ubuntu-22.04
permissions:
pull-requests: write
steps:
- name: Clear Metadata Changed Label
if: contains(github.event.pull_request.labels.*.name, env.PR_LABEL_METADATA_CHANGED)
uses: RobinJesba/GitHub-Labeler-Action@2f69380bbf2ee60b2f0893ef0f40582c9a34a64d
with:
GITHUB_TOKEN: ${{ github.token }}
LABELS_TO_REMOVE: ${{env.PR_LABEL_METADATA_CHANGED}}
- name: Clear Metadata Version Not Incremented Label
if: contains(github.event.pull_request.labels.*.name, env.PR_LABEL_METADATA_VERSION_NOT_INCREMENTED)
uses: RobinJesba/GitHub-Labeler-Action@2f69380bbf2ee60b2f0893ef0f40582c9a34a64d
with:
GITHUB_TOKEN: ${{ github.token }}
LABELS_TO_REMOVE: ${{env.PR_LABEL_METADATA_VERSION_NOT_INCREMENTED}}
# Workaround to handle skipped required check inside matrix
# https://docs.github.com/en/repositories/configuring-branches-and-merges-in-your-repository/defining-the-mergeability-of-pull-requests/troubleshooting-required-status-checks
build-binaries-dummy:
needs: changes
if: needs.changes.outputs.build-binary != 'true'
runs-on: ubuntu-22.04
name: Build ${{matrix.network}} Binary on ${{matrix.branch_alias}} Branch
strategy:
matrix:
# Match this to the real build-binaries job
include:
- network: dev
git_branch: ${{github.head_ref}}
spec: frequency-no-relay
branch_alias: pr
- network: local
git_branch: ${{github.head_ref}}
spec: frequency-local
branch_alias: pr
- network: local
git_branch: main
spec: frequency-local
branch_alias: main
- network: testnet
spec: frequency-testnet
branch_alias: pr
- network: mainnet
spec: frequency
branch_alias: pr
steps:
- run: echo "Just a dummy matrix to satisfy GitHub required checks that were skipped"
build-binaries:
needs: changes
if: needs.changes.outputs.build-binary == 'true'
name: Build ${{matrix.network}} Binary on ${{matrix.branch_alias}} Branch
strategy:
fail-fast: true
matrix:
include:
- network: dev
git_branch: ${{github.head_ref}}
spec: frequency-no-relay
branch_alias: pr
- network: local
git_branch: ${{github.head_ref}}
spec: frequency-local
branch_alias: pr
- network: local
git_branch: main
spec: frequency-local
branch_alias: main
- network: testnet
spec: frequency-testnet
branch_alias: pr
- network: mainnet
spec: frequency
branch_alias: pr
runs-on: ubicloud-standard-16
container: ghcr.io/frequency-chain/frequency/ci-base-image:1.3.1
env:
NETWORK: mainnet
steps:
- name: Check Out Repo
uses: actions/checkout@v4
with:
ref: ${{matrix.git_branch}}
- name: Set Env Vars
run: |
export BUILT_BIN_FILENAME=frequency; echo "BUILT_BIN_FILENAME=$BUILT_BIN_FILENAME" >> $GITHUB_ENV
echo "FINAL_BIN_FILENAME=$BUILT_BIN_FILENAME.${{matrix.network}}.${{matrix.spec}}.${{matrix.branch_alias}}" >> $GITHUB_ENV
# # XXX Keep this step as it lets us skip full binary builds during development/testing
# - name: Cache Binary for Testing
# id: cache-binary
# uses: actions/cache@v3
# with:
# path: ${{env.BIN_DIR}}/${{env.FINAL_BIN_FILENAME}}
# key: binaries-${{runner.os}}-${{env.NETWORK}}-${{github.head_ref}}
- name: Compile Binary
if: steps.cache-binary.outputs.cache-hit != 'true'
run: |
CARGO_INCREMENTAL=0 RUSTFLAGS="-D warnings" cargo build --locked --release \
--features ${{matrix.spec}}
- name: Run Sanity Checks
if: steps.cache-binary.outputs.cache-hit != 'true'
working-directory: ${{env.BIN_DIR}}
run: |
file ${{env.BUILT_BIN_FILENAME}} && \
./${{env.BUILT_BIN_FILENAME}} --version
- name: Rename Reference Binary
if: steps.cache-binary.outputs.cache-hit != 'true'
working-directory: ${{env.BIN_DIR}}
run: cp ${{env.BUILT_BIN_FILENAME}} ${{env.FINAL_BIN_FILENAME}}
- name: Upload Artifact
uses: actions/upload-artifact@v4
with:
name: artifacts-binary-${{matrix.network}}-${{matrix.branch_alias}}-${{github.run_id}}
path: ${{env.BIN_DIR}}/${{env.FINAL_BIN_FILENAME}}*
if-no-files-found: error
check-for-vulnerable-crates:
needs: changes
if: needs.changes.outputs.cargo-lock == 'true'
name: Check for Vulnerable Crates
runs-on: ubuntu-22.04
container: ghcr.io/frequency-chain/frequency/ci-base-image:1.3.1
steps:
- name: Check Out Repo
uses: actions/checkout@v4
- name: Set Up Cargo Deny
run: |
cargo install --force --locked cargo-deny
cargo generate-lockfile
- name: Run Cargo Deny
run: cargo deny check --hide-inclusion-graph -c deny.toml
verify-rust-code-format:
needs: changes
if: needs.changes.outputs.rust == 'true'
name: Verify Rust Code Format
runs-on: ubuntu-22.04
container:
image: ghcr.io/frequency-chain/frequency/ci-base-image:1.3.1
steps:
- name: Check Out Repository
uses: actions/checkout@v4
- name: Install Nightly Toolchain
run: |
rustup toolchain install nightly-2024-08-01
- name: Install Rust Target
run: |
rustup target add wasm32-unknown-unknown --toolchain nightly-2024-08-01
- name: Install Rust Source Component
run: |
rustup component add rust-src --toolchain nightly-2024-08-01
- name: Verify Rust Code Formatting
run: |
cargo +nightly-2024-08-01 fmt --check
lint-rust-code:
needs: changes
if: needs.changes.outputs.rust == 'true'
name: Lint Rust Code
runs-on: ubicloud-standard-4
container: ghcr.io/frequency-chain/frequency/ci-base-image:1.3.1
steps:
- name: Check Out Repo
uses: actions/checkout@v4
- name: Lint
run: |
SKIP_WASM_BUILD=1 env -u RUSTFLAGS cargo clippy \
--features runtime-benchmarks,frequency-lint-check \
-- \
-D warnings
verify-rust-developer-docs:
needs: changes
if: needs.changes.outputs.rust == 'true'
name: Verify Rust Developer Docs
runs-on: ubicloud-standard-4
container: ghcr.io/frequency-chain/frequency/ci-base-image:1.3.1
steps:
- name: Check Out Repo
uses: actions/checkout@v4
- name: Build Docs
run: |
RUSTC_BOOTSTRAP=1 RUSTDOCFLAGS="--enable-index-page --check -Zunstable-options" cargo doc --no-deps --workspace --features frequency
verify-rust-packages-and-deps:
needs: changes
if: needs.changes.outputs.rust == 'true'
name: Verify Rust Packages and Dependencies
runs-on: ubicloud-standard-4
container: ghcr.io/frequency-chain/frequency/ci-base-image:1.3.1
steps:
- name: Check Out Repo
uses: actions/checkout@v4
- name: Check
run: SKIP_WASM_BUILD= cargo check --features runtime-benchmarks,frequency-lint-check
run-rust-tests:
needs: changes
if: needs.changes.outputs.rust == 'true'
name: Run Rust Tests
runs-on: ubicloud-standard-8
container: ghcr.io/frequency-chain/frequency/ci-base-image:1.3.1
steps:
- name: Check Out Repo
uses: actions/checkout@v4
- name: Init Git
run: |
git config --global --add safe.directory /__w/frequency/frequency
- name: Run Tests
run: cargo test --features runtime-benchmarks,frequency-lint-check --workspace --release
calc-code-coverage:
needs: changes
if: needs.changes.outputs.rust == 'true'
name: Calculate Code Coverage
runs-on: ubicloud-standard-8
container: ghcr.io/frequency-chain/frequency/ci-base-image:1.3.1
steps:
- name: Check Out Repo
uses: actions/checkout@v4
- name: Generate and Upload Code Coverage
id: codecov
uses: ./.github/workflows/common/codecov
with:
code-cov-token: ${{ secrets.CODECOV_TOKEN }}
# Workaround to handle skipped required check inside matrix
# https://docs.github.com/en/repositories/configuring-branches-and-merges-in-your-repository/defining-the-mergeability-of-pull-requests/troubleshooting-required-status-checks
verify-build-runtimes-dummy:
needs: changes
if: needs.changes.outputs.rust != 'true'
name: Verify Build Runtime for ${{matrix.network}}
strategy:
matrix:
# Should match `verify-build-runtimes`
network: [dev, paseo, mainnet]
runs-on: ubuntu-22.04
steps:
- run: echo "Just a dummy matrix to satisfy GitHub required checks that were skipped"
verify-build-runtimes:
needs: changes
if: needs.changes.outputs.rust == 'true'
name: Verify Build Runtime for ${{matrix.network}}
strategy:
fail-fast: true
matrix:
# Remember, runtimes are separate for each relay chain
# We do not release frequency-*-local runtimes however
# Also should match `verify-build-runtimes-dummy`
network: [dev, paseo, mainnet]
include:
- network: dev
chain: dev
build-profile: release
package: frequency-runtime
runtime-dir: runtime/frequency
built-wasm-file-name-prefix: frequency_runtime
features: frequency-no-relay
wasm-core-version: frequency-testnet
- network: paseo
chain: frequency-paseo
build-profile: release
package: frequency-runtime
runtime-dir: runtime/frequency
built-wasm-file-name-prefix: frequency_runtime
features: frequency-testnet
wasm-core-version: frequency-testnet
- network: mainnet
chain: frequency
build-profile: release
package: frequency-runtime
runtime-dir: runtime/frequency
built-wasm-file-name-prefix: frequency_runtime
features: frequency
wasm-core-version: frequency
runs-on: ubicloud-standard-8
steps:
- name: Check Out Repo
uses: actions/checkout@v4
- name: Install Rust Toolchain
# Match installation steps to CI base docker image
run: |
curl https://sh.rustup.rs -sSf | bash -s -- -y
echo "PATH=$HOME/.cargo/bin:$PATH" >> $GITHUB_ENV
- name: Extract Runtime Spec Version
run: |
echo "RUNTIME_SPEC_VERSION=$(awk '/spec_version:/ {match($0, /[0-9]+/); print substr($0, RSTART, RLENGTH); exit}' \
${{matrix.runtime-dir}}/src/lib.rs)" >> $GITHUB_ENV
- name: Validate Extracted Version
shell: bash
run: |
echo "Runtime Spec Version: ${{env.RUNTIME_SPEC_VERSION}}"
[[ $RUNTIME_SPEC_VERSION == ?(-)+([0-9]) ]] || \
(echo "ERROR: \"${{env.RUNTIME_SPEC_VERSION}}\" is not a valid integer" && exit 1)
- name: Set Env Vars
run: |
echo "WASM_DIR=${{matrix.runtime-dir}}/target/srtool/${{matrix.build-profile}}/wbuild/${{matrix.package}}" >> $GITHUB_ENV
echo "BUILT_WASM_FILENAME=${{matrix.built-wasm-file-name-prefix}}.compact.compressed.wasm" >> $GITHUB_ENV
# # XXX Keep this step as it lets us skip WASM builds during development/testing
# - name: Cache WASM for Testing
# id: cache-wasm
# uses: actions/cache@v3
# with:
# path: ${{env.WASM_DIR}}/${{env.BUILT_WASM_FILENAME}}
# key: runtimes-${{runner.os}}-${{matrix.network}}-${{github.head_ref}}
- name: Build Deterministic WASM
id: srtool_build
if: steps.cache-wasm.outputs.cache-hit != 'true'
uses: ./.github/workflows/common/srtool
env:
BUILD_OPTS: "--features on-chain-release-build,no-metadata-docs,${{matrix.features}}"
with:
profile: ${{matrix.build-profile}}
package: ${{matrix.package}}
chain: ${{matrix.chain}}
runtime_dir: ${{ matrix.runtime-dir }}
tag: "1.77.0"
- name: Check Deterministic WASM Build Exists
if: steps.cache-wasm.outputs.cache-hit != 'true'
run: |
file ${{ steps.srtool_build.outputs.wasm }}
- name: Install Subwasm
run: |
cargo install --locked --git https://github.com/chevdor/subwasm --tag v0.20.0 --force
subwasm --version
- name: Test WASM file
run: |
subwasm info ${{ steps.srtool_build.outputs.wasm }}
subwasm info ${{ steps.srtool_build.outputs.wasm }} | grep "Core version:.*${{matrix.wasm-core-version}}-${{env.RUNTIME_SPEC_VERSION}}" || \
(echo "ERROR: WASM Core version didn't match ${{matrix.wasm-core-version}}-${{env.RUNTIME_SPEC_VERSION}}" && exit 1)
verify-js-api-augment:
needs: build-binaries
name: Verify JS API Augment
runs-on: ubuntu-22.04
container: ghcr.io/frequency-chain/frequency/ci-base-image:1.3.1
steps:
- name: Check Out Repo
uses: actions/checkout@v4
- name: Set Env Vars
run: |
echo "BIN_FILENAME=frequency.local.frequency-local.pr" >> $GITHUB_ENV
- name: Set up NodeJs
uses: actions/setup-node@v4
with:
node-version: 20
cache: "npm"
cache-dependency-path: js/api-augment/package-lock.json
- name: Install Latest Versions
run: npm install # DO NOT use `npm ci` as we want the latest polkadot/api possible
working-directory: js/api-augment
- name: Lint
run: npm run lint
working-directory: js/api-augment
- name: Download Binaries
id: download-binaries
uses: actions/download-artifact@v4
with:
pattern: artifacts-binary-local-pr-${{github.run_id}}
path: ${{env.BIN_DIR}}
- name: Extract and List Downloaded Binaries
run: |
download_dir=${{steps.download-binaries.outputs.download-path}}
mv "${download_dir}"/artifacts*/* "${download_dir}"
echo "Download dir: $download_dir"
echo "Downloaded binaries: $(ls -l $download_dir)"
- name: Set Binary Permissions
working-directory: ${{env.BIN_DIR}}
run: |
chmod 755 ${{env.BIN_FILENAME}}
- name: Output Metadata
run: ${{env.BIN_DIR}}/${{env.BIN_FILENAME}} export-metadata --chain=frequency-paseo-local --tmp ./js/api-augment/metadata.json
- name: Build
run: npm run build
working-directory: js/api-augment
- name: Test
run: npm test
working-directory: js/api-augment
- name: Build & Publish Dry Run
run: npm publish --dry-run
working-directory: js/api-augment/dist
- name: Generate npm tarball
run: npm pack
working-directory: js/api-augment/dist
- name: Upload Artifact
uses: actions/upload-artifact@v4
with:
name: artifacts-api-augment-${{github.run_id}}
path: js/api-augment/dist/frequency-chain-api-augment-0.0.0.tgz
if-no-files-found: error
verify-node-docker-images:
needs: build-binaries
name: Verify Node Docker Images
runs-on: ubuntu-22.04
steps:
- name: Check Out Repo
uses: actions/checkout@v4
- name: Set Env Vars
run: |
echo "BUILT_BIN_FILENAME=frequency.mainnet.frequency.pr" >> $GITHUB_ENV
echo "DOCKER_BIN_FILENAME=frequency" >> $GITHUB_ENV
- name: Download Binaries
id: download-binaries
uses: actions/download-artifact@v4
with:
pattern: artifacts-binary-*-${{github.run_id}}
path: ${{env.BIN_DIR}}
merge-multiple: true
- name: List Downloaded Binaries
run: |
download_dir=${{steps.download-binaries.outputs.download-path}}
echo "Download dir: $download_dir"
echo "Downloaded binaries: $(ls -l $download_dir)"
- name: Rename Binary
working-directory: ${{env.BIN_DIR}}
run: mv ${{env.BUILT_BIN_FILENAME}} ${{env.DOCKER_BIN_FILENAME}}
- name: Set Binary Permissions
working-directory: ${{env.BIN_DIR}}
run: |
chmod 755 ${{env.DOCKER_BIN_FILENAME}}
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
with:
platforms: "amd64"
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Build collator standalone
env:
IMAGE_NAME: standalone-node
uses: docker/build-push-action@v5
with:
context: .
push: false
file: ./docker/${{env.IMAGE_NAME}}.dockerfile
- name: Build collator image for local relay chain
env:
IMAGE_NAME: collator-node-local
uses: docker/build-push-action@v6
with:
context: .
push: false
file: docker/${{env.IMAGE_NAME}}.dockerfile
execute-binary-checks:
needs: build-binaries
name: Execute Binary Checks
runs-on: ubuntu-22.04
steps:
- name: Check Out Repo
uses: actions/checkout@v4
- name: Set Env Vars
run: |
echo "TEST_BIN_FILENAME=frequency.mainnet.frequency.pr" >> $GITHUB_ENV
- name: Download Binaries
id: download-binaries
uses: actions/download-artifact@v4
with:
pattern: artifacts-binary-mainnet-pr-${{github.run_id}}
path: ${{env.BIN_DIR}}
- name: List Downloaded Binaries
run: |
download_dir=${{steps.download-binaries.outputs.download-path}}
mv "${download_dir}"/artifacts*/* "${download_dir}"
echo "Download dir: $download_dir"
echo "Downloaded binaries: $(ls -l $download_dir)"
- name: Set Binary Permissions
working-directory: ${{env.BIN_DIR}}
run: |
chmod 755 ${{env.TEST_BIN_FILENAME}}
- name: Output Binary Version
working-directory: ${{env.BIN_DIR}}
run: |
file ./${{env.TEST_BIN_FILENAME}} && ./${{env.TEST_BIN_FILENAME}} --version
check-metadata-and-spec-version:
needs: build-binaries
name: Check Metadata and Spec Version
runs-on: ubuntu-22.04
permissions:
pull-requests: write
steps:
- name: Check Out Repo
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set Env Vars
run: |
echo "TEST_BIN_FILENAME=frequency.local.frequency-local.pr" >> $GITHUB_ENV
echo "REF_BIN_FILENAME=frequency.local.frequency-local.main" >> $GITHUB_ENV
- name: Download Binaries
id: download-binaries
uses: actions/download-artifact@v4
with:
pattern: artifacts-binary-local-*-${{github.run_id}}
path: ${{env.BIN_DIR}}
merge-multiple: true
- name: List Downloaded Binaries
run: |
download_dir=${{steps.download-binaries.outputs.download-path}}
echo "Download dir: $download_dir"
echo "Downloaded binaries: $(ls -l $download_dir)"
- name: Set Binary Permissions
working-directory: ${{env.BIN_DIR}}
run: |
chmod 755 $TEST_BIN_FILENAME
chmod 755 $REF_BIN_FILENAME
- name: Compare Metadata
id: compare-metadata
working-directory: ${{env.BIN_DIR}}
run: |
set -x
./$REF_BIN_FILENAME export-metadata --chain=frequency-paseo-local --tmp metadata-ref.json
metadata_ref=$(cat metadata-ref.json | jq -r .result)
./$TEST_BIN_FILENAME export-metadata --chain=frequency-paseo-local --tmp metadata.json
metadata=$(cat metadata.json | jq -r .result)
matches=$([ "$metadata" = "$metadata_ref" ] && echo 'true' || echo 'false')
echo "Metadata matches?: $match"
echo "metadata_matches=$matches" >> $GITHUB_OUTPUT
- name: Assign Metadata Changed Label
if: steps.compare-metadata.outputs.metadata_matches != 'true'
uses: RobinJesba/GitHub-Labeler-Action@2f69380bbf2ee60b2f0893ef0f40582c9a34a64d
with:
GITHUB_TOKEN: ${{ github.token }}
LABELS_TO_ADD: ${{env.PR_LABEL_METADATA_CHANGED}}
- name: Check Spec Version
if: steps.compare-metadata.outputs.metadata_matches != 'true'
id: check-spec-version
working-directory: ${{env.BIN_DIR}}
run: |
set -x
spec_version_ref=$(./$REF_BIN_FILENAME export-runtime-version | jq -r .specVersion)
spec_version=$(./$TEST_BIN_FILENAME export-runtime-version | jq -r .specVersion)
incremented=$([ $spec_version -gt $spec_version_ref ] && echo 'true' || echo 'false')
echo "spec_version_ref=$spec_version_ref" >> $GITHUB_OUTPUT
echo "spec_version=$spec_version" >> $GITHUB_OUTPUT
echo "metadata_version_incremented=$incremented" >> $GITHUB_OUTPUT
- name: Assign Metadata Version Not Incremented Label
if: |
(steps.compare-metadata.outputs.metadata_matches != 'true') &&
(steps.check-spec-version.outputs.metadata_version_incremented != 'true')
uses: RobinJesba/GitHub-Labeler-Action@2f69380bbf2ee60b2f0893ef0f40582c9a34a64d
with:
GITHUB_TOKEN: ${{ github.token }}
LABELS_TO_ADD: ${{env.PR_LABEL_METADATA_VERSION_NOT_INCREMENTED}}
- name: Fail CI
if: |
(steps.compare-metadata.outputs.metadata_matches != 'true') &&
(steps.check-spec-version.outputs.metadata_version_incremented != 'true')
working-directory: ${{env.BIN_DIR}}
run: |
spec_version=${{steps.check-spec-version.outputs.spec_version}}
spec_version_ref=${{steps.check-spec-version.outputs.spec_version_ref}}
echo "ERROR: When metadata is updated, the new spec version ($spec_version)\
must be greater than the latest version on main branch ($spec_version_ref)"
exit 1
run-e2e:
if: needs.changes.outputs.run-e2e == 'true'
needs: [build-binaries, verify-js-api-augment]
name: Run E2E Tests
runs-on: ubuntu-22.04
steps:
- name: Check Out Repo
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set Env Vars
run: |
echo "BIN_FILENAME=frequency.dev.frequency-no-relay.pr" >> $GITHUB_ENV
echo "FREQUENCY_PROCESS_NAME=frequency" >> $GITHUB_ENV
- name: Download Binaries
id: download-binaries
uses: actions/download-artifact@v4
with:
pattern: artifacts-binary-dev-pr-${{github.run_id}}
path: ${{env.BIN_DIR}}
- name: List Downloaded Binaries
run: |
download_dir=${{steps.download-binaries.outputs.download-path}}
mv "${download_dir}"/artifacts*/* "${download_dir}"
echo "Download dir: $download_dir"
echo "Downloaded binaries: $(ls -l $download_dir)"
- name: Download api-augment tarball
uses: actions/download-artifact@v4
with:
name: artifacts-api-augment-${{github.run_id}}
path: js/api-augment/dist
- name: Set Binaries Permissions
working-directory: ${{env.BIN_DIR}}
run: |
chmod 755 $BIN_FILENAME
- name: Start Local Node
working-directory: ${{env.BIN_DIR}}
run: |
./${{env.BIN_FILENAME}} \
-lruntime=debug \
--dev \
--sealing=instant \
--wasm-execution=compiled \
--no-telemetry \
--no-prometheus \
--port $((30333)) \
--rpc-port $((9944)) \
--rpc-external \
--rpc-cors all \
--rpc-methods=Unsafe \
--tmp \
&
- name: Set up NodeJs
uses: actions/setup-node@v4
with:
node-version: 20
cache: "npm"
cache-dependency-path: e2e/package-lock.json
- name: Install Built api-augment
run: npm install ../js/api-augment/dist/frequency-chain-api-augment-0.0.0.tgz
working-directory: e2e
- name: Install NPM Modules
run: npm ci
working-directory: e2e
- name: Lint
run: npm run lint
working-directory: e2e
- name: Run E2E Tests
working-directory: e2e
env:
CHAIN_ENVIRONMENT: dev
WS_PROVIDER_URL: ws://127.0.0.1:9944
run: npm test
- name: Stop Local Node
if: always()
run: pkill ${{env.FREQUENCY_PROCESS_NAME}}
verify-genesis-state:
needs: build-binaries
name: Verify Genesis State
runs-on: ubuntu-22.04
steps:
- name: Set Env Vars
run: |
echo "EXPECTED_GENESIS_STATE_PASEO=0x000000000000000000000000000000000000000000000000000000000000000000805f6ddb6879aa31316a38c149e52ffe4e9f2a193e966ddcf3b6a2cb5846e96903170a2e7597b7b7e3d84c05391d139a62b157e78786d8c082f29dcf4c11131400" >> $GITHUB_ENV
echo "EXPECTED_GENESIS_STATE_MAINNET=0x000000000000000000000000000000000000000000000000000000000000000000393a2a0f7778716d006206c5a4787cbf2ea3b26a67379b7a38ee54519d7fd4be03170a2e7597b7b7e3d84c05391d139a62b157e78786d8c082f29dcf4c11131400" >> $GITHUB_ENV
echo "BIN_FILENAME_TESTNET=frequency.testnet.frequency-testnet.pr" >> $GITHUB_ENV
echo "BIN_FILENAME_MAINNET=frequency.mainnet.frequency.pr" >> $GITHUB_ENV
- name: Download Binaries
id: download-binaries
uses: actions/download-artifact@v4
with:
pattern: artifacts-binary-*-${{github.run_id}}
path: ${{env.BIN_DIR}}
merge-multiple: true
- name: List Downloaded Binaries
run: |
download_dir=${{steps.download-binaries.outputs.download-path}}
echo "Download dir: $download_dir"
echo "Downloaded binaries: $(ls -l $download_dir)"
- name: Set Binary Permissions
working-directory: ${{env.BIN_DIR}}
run: |
chmod 755 $BIN_FILENAME_TESTNET
chmod 755 $BIN_FILENAME_MAINNET
- name: Test Frequency Paseo Genesis State
working-directory: ${{env.BIN_DIR}}
run: |
expected_genesis_state=${{env.EXPECTED_GENESIS_STATE_PASEO}}
echo "Expected genesis state: $expected_genesis_state"
actual_genesis_state=$(./${{env.BIN_FILENAME_TESTNET}} export-genesis-state --chain=frequency-paseo)
echo "Actual genesis state: $actual_genesis_state"
[ $actual_genesis_state = $expected_genesis_state ] || \
(echo "ERROR: The actual genesis state does not match the expected" && exit 1)
- name: Test Frequency Mainnet Genesis State
working-directory: ${{env.BIN_DIR}}
run: |
expected_genesis_state=${{env.EXPECTED_GENESIS_STATE_MAINNET}}
echo "Expected genesis state: $expected_genesis_state"
actual_genesis_state=$(./${{env.BIN_FILENAME_MAINNET}} export-genesis-state)
echo "Actual genesis state: $actual_genesis_state"
[ $actual_genesis_state = $expected_genesis_state ] || \
(echo "ERROR: The actual genesis state does not match the expected" && exit 1)