-
Notifications
You must be signed in to change notification settings - Fork 103
143 lines (119 loc) · 5.29 KB
/
check-migrations.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
name: Check Migrations
# If you modify more jobs, ensure that you add them as required to the job "confirmMigrationsPassed"
# which is located at the end of this file (more info in the job)
on:
push:
branches: ["main", "release-*"]
pull_request:
workflow_dispatch:
# Cancel a currently running workflow from the same PR, branch or tag when a new workflow is
# triggered (ref https://stackoverflow.com/a/72408109)
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true
# drop permissions for default token
permissions: {}
jobs:
# This generates a matrix with all the required jobs which will be run in the next step
runtime-matrix:
runs-on: ubuntu-latest
outputs:
runtime: ${{ steps.runtime.outputs.runtime }}
name: Extract tasks from matrix
steps:
- uses: actions/checkout@v4
- id: runtime
run: |
# Filter out runtimes that don't have a URI
TASKS=$(jq '[.[] | select(.uri != null)]' .github/workflows/runtimes-matrix.json)
SKIPPED_TASKS=$(jq '[.[] | select(.uri == null)]' .github/workflows/runtimes-matrix.json)
echo --- Running the following tasks ---
echo $TASKS
echo --- Skipping the following tasks due to not having a uri field ---
echo $SKIPPED_TASKS
# Strip whitespace from Tasks now that we've logged it
TASKS=$(echo $TASKS | jq -c .)
echo "runtime=$TASKS" >> $GITHUB_OUTPUT
# This runs all the jobs in the matrix. It is required by the "confirmMigrationsPassed" job, so
# if they all pass, that job will pass too.
check-migrations:
needs: [runtime-matrix]
continue-on-error: true
runs-on: ubuntu-latest
strategy:
matrix:
runtime: ${{ fromJSON(needs.runtime-matrix.outputs.runtime) }}
steps:
- name: Checkout sources
uses: actions/checkout@v4
- name: Build EXTRA_FLAGS
run: |
# When running on relay, we don't need weight checks.
EXTRA_FLAGS="${{ matrix.runtime.extra_args }}"
if [[ "${{ matrix.runtime.is_relay }}" == "true" ]]; then
EXTRA_FLAGS+="--no-weight-warnings"
echo "Disabling weight checks since we are on a relay"
echo "Disabling try-state checks on the relay"
CHECKS="pre-and-post"
else
echo "Enabling weight checks since we are not on a relay"
echo "Enabling try-state checks on the non-relay"
CHECKS="all"
fi
EXTRA_FLAGS+=" --blocktime ${{ matrix.runtime.blocktime }} "
# Disable the spec version check when we dont want to release.
# The program prints either `1` or `0`.
if [ "$(.github/changelog-processor.py CHANGELOG.md --should-release)" = "0" ]; then
EXTRA_FLAGS+=" --disable-spec-version-check"
echo "Disabling the spec version check since we are not releasing"
else
echo "Enabling the spec version check since we are releasing"
fi
echo "Flags: $EXTRA_FLAGS"
echo "Checks: $CHECKS"
echo "EXTRA_FLAGS=$EXTRA_FLAGS" >> $GITHUB_ENV
echo "CHECKS=$CHECKS" >> $GITHUB_ENV
- name: Install Protoc
uses: arduino/[email protected]
with:
version: "3.6.1"
- name: Add wasm32-unknown-unknown target
run: rustup target add wasm32-unknown-unknown
shell: bash
- name: Add rust-src component
run: rustup component add rust-src
shell: bash
- name: Run ${{ matrix.runtime.name }} Runtime Checks
#uses: "paritytech/[email protected]"
env:
EXTRA_FLAGS: ${{ env.EXTRA_FLAGS }}
CHECKS: ${{ env.CHECKS }}
run: |
cargo install -q --git https://github.com/paritytech/try-runtime-cli --tag v0.8.0 --locked && try-runtime --version
cargo build --profile production -p ${{ matrix.runtime.package }} --features try-runtime -q --locked
PACKAGE_NAME=${{ matrix.runtime.package }}
RUNTIME_BLOB_NAME=$(echo $PACKAGE_NAME | sed 's/-/_/g').compact.compressed.wasm
RUNTIME_BLOB_PATH=./target/production/wbuild/$PACKAGE_NAME/$RUNTIME_BLOB_NAME
export RUST_LOG=remote-ext=debug,runtime=debug
echo "Extra args: $EXTRA_FLAGS"
# Store the command in a variable so we can log it
COMMAND="try-runtime \
--runtime $RUNTIME_BLOB_PATH \
on-runtime-upgrade --checks=$CHECKS \
$EXTRA_FLAGS \
live --uri ${{ matrix.runtime.uri }}"
# Echo the command before running it, for debugging purposes
echo "Running command:"
echo "$COMMAND"
eval "$COMMAND"
# This will only run if all the tests in its "needs" array passed.
# Add this as your required job, becuase if the matrix changes size (new things get added)
# it will still require all the steps to succeed.
# If you add more jobs, remember to add them to the "needs" array.
confirmMigrationsPassed:
runs-on: ubuntu-latest
name: All migrations passed
# If any new job gets added, be sure to add it to this array
needs: [check-migrations]
steps:
- run: echo '### Good job! All the migrations passed 🚀' >> $GITHUB_STEP_SUMMARY