Skip to content

Commit

Permalink
chore: update runtime spec checks ⛓️ (#4349) (#4350)
Browse files Browse the repository at this point in the history
* chore: update runtime spec checks ⛓️

* chore: add checks to berghain release

* chore: add conditional rpc endpoint
  • Loading branch information
ahasna committed Dec 14, 2023
1 parent c9dfe95 commit 2a3137a
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 11 deletions.
6 changes: 5 additions & 1 deletion .github/workflows/_03_release_checks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@ on:
type: string
required: false
default: ${{ github.ref_name }}
network:
type: string
required: false
default: perseverance

env:
FORCE_COLOR: 1
Expand Down Expand Up @@ -77,4 +81,4 @@ jobs:

- name: Check changelog 📝
shell: bash
run: ./ci/scripts/check_runtime_spec_version.sh ${{ inputs.tag }}
run: ./ci/scripts/check_runtime_spec_version.sh ${{ inputs.network }}
5 changes: 5 additions & 0 deletions .github/workflows/release-berghain.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,12 @@ concurrency:
cancel-in-progress: true

jobs:
release-checks:
uses: ./.github/workflows/_03_release_checks.yml
with:
network: "berghain"
build:
needs: [release-checks]
uses: ./.github/workflows/_20_build.yml
secrets: inherit
with:
Expand Down
31 changes: 21 additions & 10 deletions ci/scripts/check_runtime_spec_version.sh
Original file line number Diff line number Diff line change
@@ -1,21 +1,32 @@
#!/bin/bash

version=$1
network=$1

runtime_spec_version_file="state-chain/runtime/src/lib.rs"
numeric_version=$(echo $version | tr -d '.')

# Extract the spec_version from the Rust file
spec_version=$(grep 'spec_version:' $runtime_spec_version_file | awk '{print $2}' | tr -d ',')

runtime_version=$(cargo read-manifest --manifest-path state-chain/runtime/Cargo.toml | jq -r .version)

# Compare versions
if [ "$spec_version" != "$numeric_version" ]; then
echo "Error: spec_version ($spec_version) does not match the expected version ($numeric_version)"
if [ -z $network ]; then
echo "Network not specified"
exit 1
fi

if [ "$runtime_version" != "$version" ]; then
echo "Error: runtime version ($runtime_version) does not match the expected version ($version)"
exit 1
if [ $network == "berghain" ]; then
RPC_ENDPOINT="https://mainnet-archive.chainflip.io"
else
RPC_ENDPOINT="https://perseverance.chainflip.xyz"
fi

live_runtime_version=$(curl -s -H "Content-Type: application/json" -d '{"id":1, "jsonrpc":"2.0", "method": "state_getRuntimeVersion", "params":[]}' $RPC_ENDPOINT | jq .result.specVersion)

echo "Live runtime version: $live_runtime_version, Current Spec version: $spec_version"

# Compare versions
if [ $spec_version -gt $live_runtime_version ]; then
echo "Runtime version has been incremented."
exit 0
else
echo "Runtime version has not been incremented."
exit 2
fi

0 comments on commit 2a3137a

Please sign in to comment.