check-runtime-migration #46
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | |
jobs: | |
set-image: | |
# GitHub Actions allows using 'env' in a container context. | |
# However, env variables don't work for forks: https://github.com/orgs/community/discussions/44322 | |
# This workaround sets the container image for each job using 'set-image' job output. | |
runs-on: ubuntu-latest | |
outputs: | |
IMAGE: ${{ steps.set_image.outputs.IMAGE }} | |
RUNNER: ${{ steps.set_runner.outputs.RUNNER }} | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- id: set_image | |
run: cat .github/env >> $GITHUB_OUTPUT | |
# By default we use spot machines that can be terminated at any time. | |
# Merge queues use persistent runners to avoid kicking off from queue when the runner is terminated. | |
- id: set_runner | |
run: | | |
# Run merge queues on persistent runners | |
if [[ $GITHUB_REF_NAME == *"gh-readonly-queue"* ]]; then | |
echo "RUNNER=arc-runners-polkadot-sdk-beefy-persistent" >> $GITHUB_OUTPUT | |
else | |
echo "RUNNER=arc-runners-polkadot-sdk-beefy" >> $GITHUB_OUTPUT | |
fi | |
# More info can be found here: https://github.com/paritytech/polkadot/pull/5865 | |
check-runtime-migration: | |
runs-on: ${{ needs.set-image.outputs.RUNNER }} | |
# We need to set this to rather long to allow the snapshot to be created, but the average time | |
# should be much lower. | |
timeout-minutes: 60 | |
needs: [set-image] | |
container: | |
image: ${{ needs.set-image.outputs.IMAGE }} | |
strategy: | |
fail-fast: false | |
matrix: | |
network: | |
[ | |
westend, | |
rococo, | |
asset-hub-westend, | |
asset-hub-rococo, | |
bridge-hub-westend, | |
bridge-hub-rococo, | |
contracts-rococo, | |
collectives-westend, | |
coretime-rococo, | |
] | |
include: | |
- network: westend | |
package: westend-runtime | |
wasm: westend_runtime.compact.compressed.wasm | |
uri: "wss://try-runtime-westend.polkadot.io:443" | |
subcommand_extra_args: "--no-weight-warnings" | |
command_extra_args: "" | |
- network: rococo | |
package: rococo-runtime | |
wasm: rococo_runtime.compact.compressed.wasm | |
uri: "wss://try-runtime-rococo.polkadot.io:443" | |
subcommand_extra_args: "--no-weight-warnings" | |
command_extra_args: "" | |
- network: asset-hub-westend | |
package: asset-hub-westend-runtime | |
wasm: asset_hub_westend_runtime.compact.compressed.wasm | |
uri: "wss://westend-asset-hub-rpc.polkadot.io:443" | |
subcommand_extra_args: "" | |
command_extra_args: "" | |
- network: "asset-hub-rococo" | |
package: "asset-hub-rococo-runtime" | |
wasm: "asset_hub_rococo_runtime.compact.compressed.wasm" | |
uri: "wss://rococo-asset-hub-rpc.polkadot.io:443" | |
subcommand_extra_args: "" | |
command_extra_args: "" | |
- network: "bridge-hub-westend" | |
package: "bridge-hub-westend-runtime" | |
wasm: "bridge_hub_westend_runtime.compact.compressed.wasm" | |
uri: "wss://westend-bridge-hub-rpc.polkadot.io:443" | |
- network: "bridge-hub-rococo" | |
package: "bridge-hub-rococo-runtime" | |
wasm: "bridge_hub_rococo_runtime.compact.compressed.wasm" | |
uri: "wss://rococo-bridge-hub-rpc.polkadot.io:443" | |
- network: "contracts-rococo" | |
package: "contracts-rococo-runtime" | |
wasm: "contracts_rococo_runtime.compact.compressed.wasm" | |
uri: "wss://rococo-contracts-rpc.polkadot.io:443" | |
- network: "collectives-westend" | |
package: "collectives-westend-runtime" | |
wasm: "collectives_westend_runtime.compact.compressed.wasm" | |
uri: "wss://westend-collectives-rpc.polkadot.io:443" | |
command_extra_args: "--disable-spec-name-check" | |
- network: "coretime-rococo" | |
package: "coretime-rococo-runtime" | |
wasm: "coretime_rococo_runtime.compact.compressed.wasm" | |
uri: "wss://rococo-coretime-rpc.polkadot.io:443" | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Download CLI | |
run: | | |
curl -sL https://github.com/paritytech/try-runtime-cli/releases/download/v0.7.0/try-runtime-x86_64-unknown-linux-musl -o try-runtime | |
chmod +x ./try-runtime | |
echo "Using try-runtime-cli version:" | |
./try-runtime --version | |
- name: Get Date | |
id: get-date | |
run: | | |
echo "today=$(/bin/date -u "+%Y%m%d")" >> $GITHUB_OUTPUT | |
shell: bash | |
- name: Download Snapshot | |
uses: actions/cache@v4 | |
with: | |
path: snapshot.raw | |
key: try-runtime-snapshot-${{ matrix.network }}-${{ steps.get-date.outputs.today }} | |
save-always: true | |
- name: Create Snapshot If Stale | |
if: ${{ hashFiles('snapshot.raw') == '' }} | |
run: | | |
echo "Creating new snapshot for today (${{ steps.get-date.outputs.today }})" | |
./try-runtime create-snapshot --uri ${{ matrix.uri }} snapshot.raw | |
- name: Build Runtime | |
run: | | |
echo "---------- Building ${{ matrix.package }} runtime ----------" | |
time forklift cargo build --release --locked -p ${{ matrix.package }} --features try-runtime -q | |
- name: Run Check | |
run: | | |
echo "Running ${{ matrix.network }} runtime migration check" | |
export RUST_LOG=remote-ext=debug,runtime=debug | |
echo "---------- Executing on-runtime-upgrade for ${{ matrix.network }} ----------" | |
time ./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 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() | |
steps: | |
- run: | | |
tee resultfile <<< '${{ toJSON(needs) }}' | |
FAILURES=$(cat resultfile | grep '"result": "failure"' | 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 |