-
Notifications
You must be signed in to change notification settings - Fork 15
740 lines (621 loc) · 26.5 KB
/
runtime-upgrade.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
---
name: Runtime Upgrade
on:
pull_request:
branches: [main, testnet]
permissions: read-all
env:
RUNNER_VM_NAME: "github-runner-$GITHUB_RUN_ID-attempt-$GITHUB_RUN_ATTEMPT"
RESOURCE_GROUP: "github-runner-$GITHUB_RUN_ID-attempt-$GITHUB_RUN_ATTEMPT"
AZ_LOCATION: "westus3"
jobs:
setup:
runs-on: ubuntu-22.04
outputs:
test_config: ${{ steps.testnet-env.outputs.test_config || steps.mainnet-env.outputs.test_config }}
target_chain: ${{ steps.testnet-env.outputs.target_chain || steps.mainnet-env.outputs.target_chain }}
boot_node: ${{ steps.testnet-env.outputs.boot_node || steps.mainnet-env.outputs.boot_node }}
rpc_url: ${{ steps.testnet-env.outputs.rpc_url || steps.mainnet-env.outputs.rpc_url }}
https_rpc_url: ${{ steps.testnet-env.outputs.https_rpc_url || steps.mainnet-env.outputs.https_rpc_url }}
release_tag: ${{ steps.testnet-env.outputs.release_tag || steps.mainnet-env.outputs.release_tag }}
artifact_name: ${{ steps.testnet-env.outputs.artifact_name || steps.mainnet-env.outputs.artifact_name }}
last_block_hash: ${{ steps.last-block-info.outputs.last_block_hash }}
last_block_number: ${{ steps.last-block-info.outputs.last_block_number }}
steps:
- uses: actions/checkout@v4
- name: Set-Up
run: |
sudo apt-get update
sudo apt install -y jq
- name: Testnet ENV
id: testnet-env
if: github.base_ref == 'testnet'
run: |
# shellcheck disable=SC2129
echo "target_chain=test" >> "$GITHUB_OUTPUT"
echo "test_config=testnet.config.ts" >> "$GITHUB_OUTPUT"
echo "boot_node=/dns4/testnet-bootnode.creditcoin.network/tcp/30333/p2p/12D3KooWG3eEuYxo37LvU1g6SSESu4i9TQ8FrZmJcjvdys7eA3cH" >> "$GITHUB_OUTPUT"
echo "rpc_url=wss://rpc.testnet.creditcoin.network:443/ws" >> "$GITHUB_OUTPUT"
echo "https_rpc_url=https://rpc.testnet.creditcoin.network/rpc" >> "$GITHUB_OUTPUT"
RELEASE_TAG=$(./scripts/extract-release-tag.sh "testnet")
echo "release_tag=$RELEASE_TAG" >> "$GITHUB_OUTPUT"
echo "artifact_name=creditcoin-$RELEASE_TAG-$(uname -m)-unknown-linux-gnu.zip" >> "$GITHUB_OUTPUT"
- name: Mainnet ENV
id: mainnet-env
if: github.base_ref == 'main'
run: |
# shellcheck disable=SC2129
echo "target_chain=main" >> "$GITHUB_OUTPUT"
echo "test_config=mainnet.config.ts" >> "$GITHUB_OUTPUT"
echo "boot_node=/dns4/bootnode.creditcoin.network/tcp/30333/p2p/12D3KooWAEgDL126EUFxFfdQKiUhmx3BJPdszQHu9PsYsLCuavhb" >> "$GITHUB_OUTPUT"
echo "rpc_url=wss://rpc.mainnet.creditcoin.network:443/ws" >> "$GITHUB_OUTPUT"
echo "https_rpc_url=https://rpc.mainnet.creditcoin.network/rpc" >> "$GITHUB_OUTPUT"
RELEASE_TAG=$(./scripts/extract-release-tag.sh "mainnet")
echo "release_tag=$RELEASE_TAG" >> "$GITHUB_OUTPUT"
echo "artifact_name=creditcoin-$RELEASE_TAG-$(uname -m)-unknown-linux-gnu.zip" >> "$GITHUB_OUTPUT"
- name: Store last block info
id: last-block-info
run: |
# store info about the last finalized block before the fork
# WARNING: using getBlockHash() instead of getFinalizedHead() b/c PoW doesn't have finalization
LAST_BLOCK=$(curl --silent -H "Content-Type: application/json" \
-d '{"id": 1, "jsonrpc": "2.0", "method": "chain_getBlockHash", "params": [] }' \
${{ env.HTTPS_RPC_URL }} | jq -r .result)
echo "$LAST_BLOCK" > last-block.hash
echo "last_block_hash=$LAST_BLOCK" >> "$GITHUB_OUTPUT"
while true; do
curl --silent -H "Content-Type: application/json" \
-d "{\"id\": 1, \"jsonrpc\": \"2.0\", \"method\": \"chain_getBlock\", \"params\": [\"$LAST_BLOCK\"] }" \
${{ env.HTTPS_RPC_URL }} | jq -r .result > last-block.json
LAST_BLOCK_NUMBER=$(jq -r .block.header.number last-block.json)
if [ "$LAST_BLOCK_NUMBER" != "null" ]; then
break
else
echo "INFO: retry fetching block infor for $LAST_BLOCK"
sleep 60
fi
done
echo "last_block_number=$LAST_BLOCK_NUMBER" >> "$GITHUB_OUTPUT"
env:
HTTPS_RPC_URL: ${{ steps.testnet-env.outputs.https_rpc_url || steps.mainnet-env.outputs.https_rpc_url }}
- name: Upload last block info
uses: actions/upload-artifact@v4
with:
name: last-block-info
path: "last-block*"
if-no-files-found: error
build-sut:
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
sudo apt install -y unzip jq
- 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 "try-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
setup-self-hosted:
needs:
- setup
- deploy-github-runner
runs-on:
[self-hosted, "${{ needs.deploy-github-runner.outputs.runner_vm_name }}"]
steps:
- name: Grant everyone permissions on /mnt
run: |
sudo chmod a+rwx /mnt
fork-creditcoin:
needs:
- setup
- setup-self-hosted
- live-sync-creditcoin
- deploy-github-runner
runs-on:
[self-hosted, "${{ needs.deploy-github-runner.outputs.runner_vm_name }}"]
steps:
- uses: actions/checkout@v4
- name: Download creditcoin-node for release ${{ needs.setup.outputs.release_tag }}
uses: i3h/download-release-asset@v1
with:
owner: gluwa
repo: creditcoin
tag: ${{ needs.setup.outputs.release_tag }}
file: ${{ needs.setup.outputs.artifact_name }}
- name: Download creditcoin-fork
uses: i3h/download-release-asset@v1
with:
owner: gluwa
repo: creditcoin-fork
tag: latest
file: creditcoin-fork
- name: Start local creditcoin-node for ${{ needs.setup.outputs.target_chain }}
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"
sudo apt-get update
sudo apt install -y unzip
unzip creditcoin-*-unknown-linux-gnu.zip
chmod a+x ./creditcoin-node
./creditcoin-node --version
./creditcoin-node \
--name "test-node-$GITHUB_RUN_ID-attempt-$GITHUB_RUN_ATTEMPT" \
--chain ${{ needs.setup.outputs.target_chain }} \
--bootnodes "${{ needs.setup.outputs.boot_node }}" \
--prometheus-external \
--telemetry-url "wss://telemetry.creditcoin.network/submit/ 0" \
--base-path /mnt \
--public-addr "/dns4/$IP_ADDRESS/tcp/50555" \
--port 50555 >creditcoin-node-used-for-fork.log 2>&1 &
- name: Wait for creditcoin-node to initialize
run: |
./integration-tests/wait-for-creditcoin.sh
- name: Create fork
run: |
chmod a+x ./creditcoin-fork
./creditcoin-fork --bin ./creditcoin-node --orig ${{ needs.setup.outputs.target_chain }} \
--base dev --name Development \
-o creditcoin-fork.json --rpc ws://127.0.0.1:9944 --exclude-pallets PosSwitch
- name: TERM creditcoin-node
continue-on-error: true
run: |
killall -TERM creditcoin-node
sleep 120
- name: KILL creditcoin-node
continue-on-error: true
run: |
killall -KILL creditcoin-node
sleep 120
- name: Upload logs
uses: actions/upload-artifact@v4
if: always()
with:
name: fork-creditcoin-logs
path: "*.log"
- name: Upload creditcoin-fork.json
uses: actions/upload-artifact@v4
with:
name: creditcoin-fork.json
path: creditcoin-fork.json
live-sync-creditcoin:
needs:
- setup
- setup-self-hosted
- deploy-github-runner
runs-on:
[self-hosted, "${{ needs.deploy-github-runner.outputs.runner_vm_name }}"]
steps:
- uses: actions/checkout@v4
- name: Download creditcoin-node for release ${{ needs.setup.outputs.release_tag }}
uses: i3h/download-release-asset@v1
with:
owner: gluwa
repo: creditcoin
tag: ${{ needs.setup.outputs.release_tag }}
file: ${{ needs.setup.outputs.artifact_name }}
- name: Sync with ${{ needs.setup.outputs.target_chain }} past block number ${{ needs.setup.outputs.last_block_number }}
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"
sudo apt-get update
sudo apt install -y unzip
unzip creditcoin-*-unknown-linux-gnu.zip
chmod a+x ./creditcoin-node
./creditcoin-node --version
./creditcoin-node \
--name "test-node-$GITHUB_RUN_ID-attempt-$GITHUB_RUN_ATTEMPT" \
--chain ${{ needs.setup.outputs.target_chain }} \
--bootnodes "${{ needs.setup.outputs.boot_node }}" \
--prometheus-external --pruning archive \
--telemetry-url "wss://telemetry.creditcoin.network/submit/ 0" \
--public-addr "/dns4/$IP_ADDRESS/tcp/50555" \
--base-path /mnt \
--port 50555 >creditcoin-node-initial-live-sync.log 2>&1 &
- name: Wait for creditcoin-node to sync past block number ${{ needs.setup.outputs.last_block_number }}
run: |
./scripts/wait-for-sync.sh ${{ needs.setup.outputs.last_block_number }}
- name: TERM creditcoin-node
continue-on-error: true
run: |
killall -TERM creditcoin-node
sleep 120
- name: KILL creditcoin-node
continue-on-error: true
run: |
killall -KILL creditcoin-node
sleep 120
- name: Upload logs
uses: actions/upload-artifact@v4
if: always()
with:
name: live-sync-creditcoin-logs
path: "*.log"
test-against-fork:
needs:
- setup
- setup-self-hosted
- build-sut
- fork-creditcoin
- deploy-github-runner
runs-on:
[self-hosted, "${{ needs.deploy-github-runner.outputs.runner_vm_name }}"]
steps:
- uses: actions/checkout@v4
- name: Download creditcoin-node from current PR
uses: actions/download-artifact@v4
with:
name: creditcoin-node
path: target/release
- name: Download creditcoin-fork.json
uses: actions/download-artifact@v4
with:
name: creditcoin-fork.json
- name: Start a local creditcoin-node from the fork
run: |
chmod a+x ./target/release/creditcoin-node
./target/release/creditcoin-node --version
./target/release/creditcoin-node --chain ./creditcoin-fork.json --validator --alice --pruning archive \
--base-path /mnt \
--monitor-nonce auto >creditcoin-node-with-forked-chain.log 2>&1 &
- name: Wait for blockchain to start
run: |
./integration-tests/wait-for-creditcoin.sh
- name: Install Docker engine
run: |
./scripts/install-docker-engine-from-upstream.sh
- name: Start local Ethereum node
run: |
sudo docker run --name hardhat-dev --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: 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"
sudo apt install -y gcc
- name: Install Rust toolchain
uses: gluwa/toolchain@dev
with:
toolchain: ${{ env.RUSTC_VERSION }}
profile: minimal
override: true
- name: Install Subwasm
uses: gluwa/cargo@dev
with:
command: install
args: --locked --git https://github.com/chevdor/subwasm --tag v0.17.1
- name: Download WASM runtime from current PR
id: download-wasm
uses: actions/download-artifact@v4
with:
name: creditcoin_node_runtime.compact.compressed.wasm
- name: Upgrade WASM
run: |
yarn --cwd ./scripts/js upgrade 'creditcoin-js'
yarn --cwd ./scripts/js runtimeUpgrade ws://127.0.0.1:9944 ../../creditcoin_node_runtime.compact.compressed.wasm //Alice 0
# TODO: wait & confirm wasm upgrade has finished, incl. migrations
- name: Execute integration tests
run: |
yarn --cwd ./integration-tests/ test --config creditcoin-fork.config.ts
- name: Upload logs
uses: actions/upload-artifact@v4
if: always()
with:
name: test-against-fork-logs
path: "*.log"
- name: Kill hardhat-dev
if: always()
run: |
sudo docker kill hardhat-dev
- name: Kill creditcoin-node
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
test-against-disconnected-live-node:
# execute only against Testnet b/c we don't have sudo key for Mainnet
if: github.base_ref == 'testnet'
needs:
- build-sut
- setup
- setup-self-hosted
- live-sync-creditcoin
- deploy-github-runner
runs-on:
[self-hosted, "${{ needs.deploy-github-runner.outputs.runner_vm_name }}"]
steps:
- uses: actions/checkout@v4
- name: Download creditcoin-node from current PR
uses: actions/download-artifact@v4
with:
name: creditcoin-node
path: target/release
- name: Start a disconnected creditcoin-node
run: |
chmod a+x ./target/release/creditcoin-node
./target/release/creditcoin-node --version
# WARNING: using different port b/c the network remembers there was a node
# at this address previously. We don't want to be connected to the chain !!!
./target/release/creditcoin-node \
--port 44444 \
--name "test-node-disconnected-$GITHUB_RUN_ID-attempt-$GITHUB_RUN_ATTEMPT" \
--chain ${{ needs.setup.outputs.target_chain }} \
--validator --alice --pruning archive \
--prometheus-external \
--telemetry-url "wss://telemetry.creditcoin.network/submit/ 0" \
--base-path /mnt \
--monitor-nonce auto >creditcoin-node-disconnected-live-node.log 2>&1 &
- name: Wait for blockchain to start
run: |
./integration-tests/wait-for-creditcoin.sh
# check this eventhough it should be true unless live-sync screws up!
- name: Check if creditcoin-node is past block number ${{ needs.setup.outputs.last_block_number }}
run: |
./scripts/wait-for-sync.sh ${{ needs.setup.outputs.last_block_number }}
- 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: 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"
sudo apt install -y gcc
- name: Install Rust toolchain
uses: gluwa/toolchain@dev
with:
toolchain: ${{ env.RUSTC_VERSION }}
profile: minimal
override: true
- name: Install Subwasm
uses: gluwa/cargo@dev
with:
command: install
args: --locked --git https://github.com/chevdor/subwasm --tag v0.17.1
- name: Download WASM runtime
id: download-wasm
uses: actions/download-artifact@v4
with:
name: creditcoin_node_runtime.compact.compressed.wasm
- name: Upgrade WASM
if: env.LENDER_PRIVATE_KEY
run: |
yarn --cwd ./scripts/js upgrade 'creditcoin-js'
yarn --cwd ./scripts/js runtimeUpgrade ws://127.0.0.1:9944 ../../creditcoin_node_runtime.compact.compressed.wasm "${{ env.LENDER_PRIVATE_KEY }}" 0
sleep 10
env:
LENDER_PRIVATE_KEY: ${{ secrets.TESTNET_LENDER_PRIVATE_KEY }}
# TODO: wait & confirm wasm upgrade has finished, incl. migrations
- name: Execute integration tests
if: env.ETHEREUM_NODE_URL
run: |
yarn --cwd ./integration-tests/ test --config testnet.config.ts
env:
CREDITCOIN_API_URL: ws://127.0.0.1:9944
ETHEREUM_NODE_URL: ${{ secrets.TESTNET_ETHEREUM_NODE_URL }}
LENDER_PRIVATE_KEY: ${{ secrets.TESTNET_LENDER_PRIVATE_KEY }}
LENDER_SEED: "${{ secrets.TESTNET_LENDER_SEED }}"
BORROWER_PRIVATE_KEY: ${{ secrets.TESTNET_BORROWER_PRIVATE_KEY }}
BORROWER_SEED: "${{ secrets.TESTNET_BORROWER_SEED }}"
- name: Upload logs
uses: actions/upload-artifact@v4
if: always()
with:
name: test-against-disconnected-live-node-logs
path: "*.log"
- name: Kill creditcoin-node
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
deploy-github-runner:
runs-on: ubuntu-22.04
outputs:
runner_vm_name: ${{ steps.get-env.outputs.runner_vm_name }}
resource_group: ${{ steps.get-env.outputs.resource_group }}
steps:
- uses: actions/checkout@v4
- name: Install azure-cli
run: |
sudo apt remove azure-cli -y && sudo apt autoremove -y
curl -sL https://aka.ms/InstallAzureCLIDeb | sudo bash
sudo apt install -y jq
az version
- name: Authorize hosted-runner
run: |
mkdir -p ~/.ssh/
ssh-keygen -q -t rsa -N '' -f ~/.ssh/id_rsa
cat ~/.ssh/id_rsa.pub >> .github/authorized_keys
- name: Evaluate env vars
id: get-env
run: |
# 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 }}" >> "$GITHUB_OUTPUT"
echo "resource_group=${{ env.RESOURCE_GROUP }}" >> "$GITHUB_OUTPUT"
- name: Provision VM
if: env.LC_GITHUB_REPO_ADMIN_TOKEN
run: |
echo "INFO: From ENVs: RUNNER_VM_NAME=${{ env.RUNNER_VM_NAME }}"
echo "INFO: From Step: RUNNER_VM_NAME=${{ steps.get-env.outputs.runner_vm_name }}"
az login --service-principal --username "${{ secrets.AZURE_APP_ID }}" --password "${{ secrets.AZURE_APP_PASSWORD }}" --tenant "${{ secrets.AZURE_TENANT_ID }}"
az account set --subscription "Playground Subscription"
## az account set -s "${{ secrets.AZURE_SUBSCRIPTION_ID }}"
# create resource group
echo "INFO: ${{ steps.get-env.outputs.resource_group }}"
az group create -n "${{ steps.get-env.outputs.resource_group }}" --location "${{ env.AZ_LOCATION }}"
# RG Creditcoin-Test is in WestUS and the CPU quota is already full
# that's why specify a different region here
az deployment group create -g "${{ steps.get-env.outputs.resource_group }}" -f .github/runner.bicep \
--parameters location="${{ env.AZ_LOCATION }}" \
--parameters vmName="${{ steps.get-env.outputs.runner_vm_name }}" \
--parameters adminPasswordOrKey="$(cat .github/authorized_keys)" > output.json
# provision the GitHub Runner binary on the VM
# passing additional ENV values
SSH_USER_AT_HOSTNAME=$(jq -r '.properties.outputs.sshUserAtHostname.value' < output.json)
echo "INFO: $SSH_USER_AT_HOSTNAME"
export LC_RUNNER_VM_NAME="${{ env.RUNNER_VM_NAME }}"
until ssh -i ~/.ssh/id_rsa \
-o SendEnv=LC_GITHUB_REPO_ADMIN_TOKEN,LC_RUNNER_VM_NAME \
-o StrictHostKeyChecking=no "$SSH_USER_AT_HOSTNAME" < ./scripts/provision-github-runner.sh; do
echo "DEBUG: retrying ssh connection ..."
sleep 30
done
env:
LC_GITHUB_REPO_ADMIN_TOKEN: ${{ secrets.GH_REPO_ADMIN_TOKEN }}
LC_RUNNER_EPHEMERAL: false
test-migrations-via-try-runtime:
# see https://gist.github.com/jonico/a94d03cac7a858e0613926d9f1bc7f2b
runs-on:
[self-hosted, "${{ needs.deploy-github-runner.outputs.runner_vm_name }}"]
needs:
- build-sut
- setup
- setup-self-hosted
- live-sync-creditcoin
- deploy-github-runner
steps:
- uses: actions/checkout@v4
- name: Download creditcoin-node binary from current PR
uses: actions/download-artifact@v4
with:
name: creditcoin-node
path: target/release
- name: Download WASM runtime
uses: actions/download-artifact@v4
with:
name: creditcoin_node_runtime.compact.compressed.wasm
path: target/release
- name: Restore executable permissions
run: |
chmod a+x ./target/release/creditcoin-node
- name: Check if runner machine meets chain's requirements
continue-on-error: true
run: |
./scripts/check-hardware.sh
- name: Start local creditcoin-node for ${{ needs.setup.outputs.target_chain }}
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"
./target/release/creditcoin-node --version
# node should be reusing the database from the
# live-sync-creditcoin CI job listed as dependency above
./target/release/creditcoin-node \
--name "test-node-$GITHUB_RUN_ID-attempt-$GITHUB_RUN_ATTEMPT" \
--chain ${{ needs.setup.outputs.target_chain }} \
--bootnodes "${{ needs.setup.outputs.boot_node }}" \
--rpc-max-request-size 200000 \
--rpc-max-response-size 200000 \
--prometheus-external --pruning archive \
--telemetry-url "wss://telemetry.creditcoin.network/submit/ 0" \
--base-path /mnt \
--public-addr "/dns4/$IP_ADDRESS/tcp/30333" >creditcoin-node-used-for-try-runtime.log 2>&1 &
- name: Wait for creditcoin-node to initialize
run: |
./integration-tests/wait-for-creditcoin.sh
./scripts/wait-for-sync.sh ${{ needs.setup.outputs.last_block_number }}
- name: Try-runtime migrations
run: |
./target/release/creditcoin-node try-runtime \
--runtime ./target/release/creditcoin_node_runtime.compact.compressed.wasm \
--dev on-runtime-upgrade live --uri ws://127.0.0.1:9944 \
--pallet Creditcoin \
--at ${{ needs.setup.outputs.last_block_hash }}
- name: TERM creditcoin-node
continue-on-error: true
run: |
killall -TERM creditcoin-node
sleep 60
- name: KILL creditcoin-node
if: always()
continue-on-error: true
run: |
killall -KILL creditcoin-node
sleep 600
- name: Upload logs
uses: actions/upload-artifact@v4
if: always()
with:
name: test-migrations-via-try-runtime-logs
path: "*.log"
remove-github-runner:
runs-on: ubuntu-22.04
needs:
- deploy-github-runner
- test-migrations-via-try-runtime
- test-against-fork
- test-against-disconnected-live-node
if: ${{ always() && needs.deploy-github-runner.result != 'skipped' }}
steps:
- uses: actions/checkout@v4
- name: Evaluate env vars
id: get-env
run: |
# WARNING: using env.RUNNER_VM_NAME directly in job outputs above
# doesn't evaluate the $GITHUB_RUN_ID reference
echo "resource_group=${{ env.RESOURCE_GROUP }}" >> "$GITHUB_OUTPUT"
- name: Install azure-cli
run: |
sudo apt remove azure-cli -y && sudo apt autoremove -y
curl -sL https://aka.ms/InstallAzureCLIDeb | sudo bash
az version
- name: Remove VM
run: |
echo "INFO: RUNNER_VM_NAME=${{ env.RUNNER_VM_NAME }}"
az login --service-principal --username "${{ secrets.AZURE_APP_ID }}" --password "${{ secrets.AZURE_APP_PASSWORD }}" --tenant "${{ secrets.AZURE_TENANT_ID }}"
az account set --subscription "Playground Subscription"
az group delete --yes -n "${{ steps.get-env.outputs.resource_group }}"
- name: Upload logs
uses: actions/upload-artifact@v4
if: always()
with:
name: "Azure resources"
path: azure_resource_list.json