@@ -25,14 +25,93 @@ jobs:
2525 needs : isdraft
2626 uses : ./.github/workflows/reusable-preflight.yml
2727
28+ # Prepare snapshots for all networks. Runs before the actual migration checks.
29+ # For scheduled runs: always create fresh snapshots.
30+ # For PRs: use cached snapshots if available, create if not.
31+ prepare-snapshots :
32+ runs-on : ubuntu-latest
33+ needs : [preflight]
34+ if : ${{ needs.preflight.outputs.changes_rust }}
35+ strategy :
36+ fail-fast : false
37+ matrix :
38+ network :
39+ [
40+ westend,
41+ asset-hub-westend,
42+ bridge-hub-westend,
43+ collectives-westend,
44+ coretime-westend,
45+ ]
46+ include :
47+ - network : westend
48+ uri : " wss://try-runtime-westend.polkadot.io:443"
49+ - network : asset-hub-westend
50+ uri : " wss://westend-asset-hub-rpc.polkadot.io:443"
51+ - network : bridge-hub-westend
52+ uri : " wss://westend-bridge-hub-rpc.polkadot.io:443"
53+ - network : collectives-westend
54+ uri : " wss://westend-collectives-rpc.polkadot.io:443"
55+ - network : coretime-westend
56+ uri : " wss://westend-coretime-rpc.polkadot.io:443"
57+ steps :
58+ - name : Check if snapshot exists in cache
59+ id : cache-restore
60+ if : ${{ github.event_name != 'schedule' }}
61+ uses : actions/cache/restore@8b402f58fbc84540c8b491a91e594a4576fec3d7 # v5.0.2
62+ with :
63+ lookup-only : true
64+ path : snapshot.raw
65+ key : try-runtime-snapshot-${{ matrix.network }}-
66+ fail-on-cache-miss : false
67+
68+ - name : Download CLI
69+ if : ${{ steps.cache-restore.outputs.cache-matched-key == '' }}
70+ run : |
71+ curl -sL https://github.com/paritytech/try-runtime-cli/releases/download/v0.10.1/try-runtime-x86_64-unknown-linux-musl -o try-runtime
72+ chmod +x ./try-runtime
73+ ./try-runtime --version
74+
75+ - name : Generate snapshot for ${{ matrix.network }}
76+ if : ${{ steps.cache-restore.outputs.cache-matched-key == '' }}
77+ run : |
78+ echo "Generating snapshot for ${{ matrix.network }}..."
79+ for i in {1..10}; do
80+ echo "Snapshot creation attempt $i/10"
81+ if ./try-runtime create-snapshot --uri ${{ matrix.uri }} -- snapshot.raw; then
82+ if [ -f "snapshot.raw" ] && [ -s "snapshot.raw" ]; then
83+ echo "Snapshot created successfully"
84+ break
85+ fi
86+ fi
87+ echo "Snapshot creation failed, attempt $i/10"
88+ rm -f snapshot.raw
89+ if [ $i -eq 10 ]; then
90+ echo "All snapshot creation attempts failed"
91+ exit 1
92+ fi
93+ sleep 10
94+ done
95+
96+ - name : Get Date
97+ id : get-date
98+ if : ${{ steps.cache-restore.outputs.cache-matched-key == '' }}
99+ run : |
100+ echo "today=$(/bin/date -u "+%Y%m%d")" >> $GITHUB_OUTPUT
101+
102+ - name : Save snapshot to cache
103+ if : ${{ steps.cache-restore.outputs.cache-matched-key == '' }}
104+ uses : actions/cache/save@8b402f58fbc84540c8b491a91e594a4576fec3d7 # v5.0.2
105+ with :
106+ path : snapshot.raw
107+ key : try-runtime-snapshot-${{ matrix.network }}-${{ steps.get-date.outputs.today }}
108+
28109 # More info can be found here: https://github.com/paritytech/polkadot/pull/5865
29110 check-runtime-migration :
30111 runs-on : ${{ needs.preflight.outputs.RUNNER }}
31- if : ${{ needs.preflight.outputs.changes_rust }}
32- # We need to set this to rather long to allow the snapshot to be created, but the average time
33- # should be much lower.
112+ if : ${{ needs.preflight.outputs.changes_rust && github.event_name != 'schedule' }}
34113 timeout-minutes : 120
35- needs : [preflight]
114+ needs : [preflight, prepare-snapshots ]
36115 container :
37116 image : ${{ needs.preflight.outputs.IMAGE }}
38117 strategy :
@@ -50,78 +129,55 @@ jobs:
50129 - network : westend
51130 package : westend-runtime
52131 wasm : westend_runtime.compact.compressed.wasm
53- uri : " wss://try-runtime-westend.polkadot.io:443"
54132 subcommand_extra_args : " --no-weight-warnings --blocktime 6000"
55133 command_extra_args : " "
56134 - network : asset-hub-westend
57135 package : asset-hub-westend-runtime
58136 wasm : asset_hub_westend_runtime.compact.compressed.wasm
59- uri : " wss://westend-asset-hub-rpc.polkadot.io:443"
60137 subcommand_extra_args : " --blocktime 6000"
61138 command_extra_args : " "
62139 - network : bridge-hub-westend
63140 package : bridge-hub-westend-runtime
64141 wasm : bridge_hub_westend_runtime.compact.compressed.wasm
65- uri : " wss://westend-bridge-hub-rpc.polkadot.io:443"
66142 subcommand_extra_args : " --blocktime 6000"
143+ command_extra_args : " "
67144 - network : collectives-westend
68145 package : collectives-westend-runtime
69146 wasm : collectives_westend_runtime.compact.compressed.wasm
70- uri : " wss://westend-collectives-rpc.polkadot.io:443"
71147 command_extra_args : " --disable-spec-name-check"
72148 subcommand_extra_args : " --blocktime 6000"
73149 - network : coretime-westend
74150 package : coretime-westend-runtime
75151 wasm : coretime_westend_runtime.compact.compressed.wasm
76- uri : " wss://westend-coretime-rpc.polkadot.io:443"
77152 subcommand_extra_args : " --blocktime 6000"
153+ command_extra_args : " "
78154 steps :
79155 - name : Checkout
80156 uses : actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
81157
82158 - name : Download CLI
83159 run : |
84- curl -sL https://github.com/paritytech/try-runtime-cli/releases/download/v0.8.0 /try-runtime-x86_64-unknown-linux-musl -o try-runtime
160+ curl -sL https://github.com/paritytech/try-runtime-cli/releases/download/v0.10.1 /try-runtime-x86_64-unknown-linux-musl -o try-runtime
85161 chmod +x ./try-runtime
86162 echo "Using try-runtime-cli version:"
87163 ./try-runtime --version
88164
89- - name : Get Date
90- id : get-date
91- run : |
92- echo "today=$(/bin/date -u "+%Y%m%d")" >> $GITHUB_OUTPUT
93- shell : bash
94-
95- - name : Download Snapshot
96- uses : actions/cache@9255dc7a253b0ccc959486e2bca901246202afeb # v5.0.1
165+ - name : Restore snapshot from cache
166+ uses : actions/cache/restore@8b402f58fbc84540c8b491a91e594a4576fec3d7 # v5.0.2
97167 with :
98168 path : snapshot.raw
99- key : try-runtime-snapshot-${{ matrix.network }}-${{ steps.get-date.outputs.today }}
100- save-always : true
101-
102- - name : Create Snapshot If Stale
103- if : ${{ hashFiles('snapshot.raw') == '' }}
104- run : |
105- echo "Creating new snapshot for today (${{ steps.get-date.outputs.today }})"
106- ./try-runtime create-snapshot --uri ${{ matrix.uri }} snapshot.raw
169+ key : try-runtime-snapshot-${{ matrix.network }}-
170+ fail-on-cache-miss : true
107171
108172 - name : Build Runtime
109- if : ${{ github.event_name != 'schedule' }}
110173 id : required1
111174 run : |
112175 echo "---------- Building ${{ matrix.package }} runtime ----------"
113176 forklift cargo build --release --locked -p ${{ matrix.package }} --features try-runtime -q
114177
115178 - name : Run Check
116- if : ${{ github.event_name != 'schedule' }}
117179 id : required2
118180 run : |
119- # Disable the check for asset-hub-westend temporarily due to frequent failures.
120- if [ "${{ matrix.network }}" = "asset-hub-westend" ]; then
121- echo "Skipping runtime migration check for asset-hub-westend due to frequent failures."
122- exit 0
123- fi
124-
125181 echo "Running ${{ matrix.network }} runtime migration check"
126182 export RUST_LOG=remote-ext=debug,runtime=debug
127183
@@ -132,7 +188,7 @@ jobs:
132188 sleep 5
133189
134190 - name : Stop all workflows if failed
135- if : ${{ failure() && github.event_name != 'schedule' && (steps.required1.conclusion == 'failure' || steps.required2.conclusion == 'failure') }}
191+ if : ${{ failure() && (steps.required1.conclusion == 'failure' || steps.required2.conclusion == 'failure') }}
136192 uses : ./.github/actions/workflow-stopper
137193 with :
138194 app-id : ${{ secrets.WORKFLOW_STOPPER_RUNNER_APP_ID }}
0 commit comments