-
Notifications
You must be signed in to change notification settings - Fork 1.2k
214 lines (197 loc) · 8.08 KB
/
check-runtime-migration.yml
File metadata and controls
214 lines (197 loc) · 8.08 KB
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
name: check-runtime-migration
on:
push:
branches:
- master
pull_request:
types: [opened, synchronize, reopened, ready_for_review]
# Take a snapshot at 5am when most SDK devs are not working.
schedule:
- cron: "0 5 * * *"
merge_group:
workflow_dispatch:
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true
permissions: {}
jobs:
isdraft:
uses: ./.github/workflows/reusable-isdraft.yml
preflight:
needs: isdraft
uses: ./.github/workflows/reusable-preflight.yml
# Prepare snapshots for all networks. Runs before the actual migration checks.
# For scheduled runs: always create fresh snapshots.
# For PRs: use cached snapshots if available, create if not.
prepare-snapshots:
runs-on: ubuntu-latest
needs: [preflight]
if: ${{ needs.preflight.outputs.changes_rust }}
strategy:
fail-fast: false
matrix:
network:
[
westend,
asset-hub-westend,
bridge-hub-westend,
collectives-westend,
coretime-westend,
]
include:
- network: westend
uri: "wss://try-runtime-westend.polkadot.io:443"
- network: asset-hub-westend
uri: "wss://westend-asset-hub-rpc.polkadot.io:443"
- network: bridge-hub-westend
uri: "wss://westend-bridge-hub-rpc.polkadot.io:443"
- network: collectives-westend
uri: "wss://westend-collectives-rpc.polkadot.io:443"
- network: coretime-westend
uri: "wss://westend-coretime-rpc.polkadot.io:443"
steps:
- name: Check if snapshot exists in cache
id: cache-restore
if: ${{ github.event_name != 'schedule' }}
uses: actions/cache/restore@8b402f58fbc84540c8b491a91e594a4576fec3d7 # v5.0.2
with:
lookup-only: true
path: snapshot.raw
key: try-runtime-snapshot-${{ matrix.network }}-
fail-on-cache-miss: false
- name: Download CLI
if: ${{ steps.cache-restore.outputs.cache-matched-key == '' }}
run: |
curl -sL https://github.com/paritytech/try-runtime-cli/releases/download/v0.10.1/try-runtime-x86_64-unknown-linux-musl -o try-runtime
chmod +x ./try-runtime
./try-runtime --version
- name: Generate snapshot for ${{ matrix.network }}
if: ${{ steps.cache-restore.outputs.cache-matched-key == '' }}
run: |
echo "Generating snapshot for ${{ matrix.network }}..."
for i in {1..10}; do
echo "Snapshot creation attempt $i/10"
if ./try-runtime create-snapshot --uri ${{ matrix.uri }} -- snapshot.raw; then
if [ -f "snapshot.raw" ] && [ -s "snapshot.raw" ]; then
echo "Snapshot created successfully"
break
fi
fi
echo "Snapshot creation failed, attempt $i/10"
rm -f snapshot.raw
if [ $i -eq 10 ]; then
echo "All snapshot creation attempts failed"
exit 1
fi
sleep 10
done
- name: Get Date
id: get-date
if: ${{ steps.cache-restore.outputs.cache-matched-key == '' }}
run: |
echo "today=$(/bin/date -u "+%Y%m%d")" >> $GITHUB_OUTPUT
- name: Save snapshot to cache
if: ${{ steps.cache-restore.outputs.cache-matched-key == '' }}
uses: actions/cache/save@8b402f58fbc84540c8b491a91e594a4576fec3d7 # v5.0.2
with:
path: snapshot.raw
key: try-runtime-snapshot-${{ matrix.network }}-${{ steps.get-date.outputs.today }}
# More info can be found here: https://github.com/paritytech/polkadot/pull/5865
check-runtime-migration:
runs-on: ${{ needs.preflight.outputs.RUNNER }}
if: ${{ needs.preflight.outputs.changes_rust && github.event_name != 'schedule' }}
timeout-minutes: 120
needs: [preflight, prepare-snapshots]
container:
image: ${{ needs.preflight.outputs.IMAGE }}
strategy:
fail-fast: false
matrix:
network:
[
westend,
asset-hub-westend,
bridge-hub-westend,
collectives-westend,
coretime-westend,
]
include:
- network: westend
package: westend-runtime
wasm: westend_runtime.compact.compressed.wasm
subcommand_extra_args: "--no-weight-warnings --blocktime 6000"
command_extra_args: ""
- network: asset-hub-westend
package: asset-hub-westend-runtime
wasm: asset_hub_westend_runtime.compact.compressed.wasm
subcommand_extra_args: " --blocktime 6000"
command_extra_args: ""
- network: bridge-hub-westend
package: bridge-hub-westend-runtime
wasm: bridge_hub_westend_runtime.compact.compressed.wasm
subcommand_extra_args: " --blocktime 6000"
command_extra_args: ""
- network: collectives-westend
package: collectives-westend-runtime
wasm: collectives_westend_runtime.compact.compressed.wasm
command_extra_args: "--disable-spec-name-check"
subcommand_extra_args: " --blocktime 6000"
- network: coretime-westend
package: coretime-westend-runtime
wasm: coretime_westend_runtime.compact.compressed.wasm
subcommand_extra_args: " --blocktime 6000"
command_extra_args: ""
steps:
- name: Checkout
uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
- name: Download CLI
run: |
curl -sL https://github.com/paritytech/try-runtime-cli/releases/download/v0.10.1/try-runtime-x86_64-unknown-linux-musl -o try-runtime
chmod +x ./try-runtime
echo "Using try-runtime-cli version:"
./try-runtime --version
- name: Restore snapshot from cache
uses: actions/cache/restore@8b402f58fbc84540c8b491a91e594a4576fec3d7 # v5.0.2
with:
path: snapshot.raw
key: try-runtime-snapshot-${{ matrix.network }}-
fail-on-cache-miss: true
- name: Build Runtime
id: required1
run: |
echo "---------- Building ${{ matrix.package }} runtime ----------"
forklift cargo build --release --locked -p ${{ matrix.package }} --features try-runtime -q
- name: Run Check
id: required2
run: |
echo "Running ${{ matrix.network }} runtime migration check"
export RUST_LOG=remote-ext=debug,runtime=debug
echo "---------- Executing on-runtime-upgrade for ${{ matrix.network }} ----------"
./try-runtime ${{ matrix.command_extra_args }} \
--runtime ./target/release/wbuild/${{ matrix.package }}/${{ matrix.wasm }} \
on-runtime-upgrade --disable-spec-version-check --checks=all ${{ matrix.subcommand_extra_args }} snap -p snapshot.raw
sleep 5
- name: Stop all workflows if failed
if: ${{ failure() && (steps.required1.conclusion == 'failure' || steps.required2.conclusion == 'failure') }}
uses: ./.github/actions/workflow-stopper
with:
app-id: ${{ secrets.WORKFLOW_STOPPER_RUNNER_APP_ID }}
app-key: ${{ secrets.WORKFLOW_STOPPER_RUNNER_APP_KEY }}
# name of this job must be unique across all workflows
# otherwise GitHub will mark all these jobs as required
confirm-required-checks-passed:
runs-on: ubuntu-latest
name: All runtime migrations passed
# If any new job gets added, be sure to add it to this array
needs: [check-runtime-migration]
if: always() && !cancelled() && github.event_name != 'schedule'
steps:
- run: |
tee resultfile <<< '${{ toJSON(needs) }}'
FAILURES=$(cat resultfile | grep -E '"result": "(failure|cancelled)"' | wc -l)
if [ $FAILURES -gt 0 ]; then
echo "### At least one required job failed ❌" >> $GITHUB_STEP_SUMMARY
exit 1
else
echo '### Good job! All the required jobs passed 🚀' >> $GITHUB_STEP_SUMMARY
fi