Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
liamaharon committed Mar 18, 2024
1 parent 2b7a4c9 commit 893dd19
Show file tree
Hide file tree
Showing 3 changed files with 61 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@ on:
workflow_dispatch:

jobs:
polkadot:
polkadot-relay-chain:
runs-on: ubuntu-latest
steps:
- name: Checkout Runtimes Repo
uses: actions/checkout@v3
with:
repository: "polkadot-fellows/runtimes"

- name: Run Polkadot Try State Checks
- name: Run Polkadot Try Runtime Checks
uses: "paritytech/try-runtime-gha@main"
with:
runtime-package: "polkadot-runtime"
Expand All @@ -22,15 +22,15 @@ jobs:
extra-args: "--no-weight-warnings --disable-spec-version-check"
node-uri: "wss://polkadot-try-runtime-node.parity-chains.parity.io:443"

rococo-asset-hub:
rococo-asset-hub-para-chain:
runs-on: ubuntu-latest
steps:
- name: Checkout Runtimes Repo
- name: Checkout Polkadot SDK
uses: actions/checkout@v3
with:
repository: "paritytech/polkadot-sdk"

- name: Run Polkadot Try State Checks
- name: Run Rococo Asset Hub Try Runtime Checks
uses: "paritytech/try-runtime-gha@main"
with:
runtime-package: "asset-hub-rococo-runtime"
Expand Down
20 changes: 5 additions & 15 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,12 @@ inputs:
description: "The runtime package name"
required: true
extra-args:
description: 'Extra args to pass to the ''on-runtime-upgrade'' subcommand. For example, "--disable-idempotency-check --no-weight-warnings"'
description: 'Extra args to pass to the ''on-runtime-upgrade'' subcommand. For example, "--disable-idempotency-check --no-weight-warnings". See all options at https://paritytech.github.io/try-runtime-cli/try_runtime_core/commands/on_runtime_upgrade/struct.Command.html.'
required: true
default: ""
checks:
description: "Types of checks to run"
description: 'Types of checks to run. For example, "pre-and-post". See all options at https://paritytech.github.io/try-runtime-cli/frame_support/traits/enum.UpgradeCheckSelect.html.'
default: "all"
node-uri:
description: "URI of a node to scrape state"
required: true
Expand Down Expand Up @@ -61,27 +62,16 @@ runs:
RUNTIME_BLOB_NAME=$(echo $PACKAGE_NAME | sed 's/-/_/g').compact.compressed.wasm
RUNTIME_BLOB_PATH=./target/production/wbuild/$PACKAGE_NAME/$RUNTIME_BLOB_NAME
EXTRA_FLAGS="${{ inputs.extra-flags }}"
if [[ "${{ inputs.runtime-is-relay }}" == "true" ]]; then
EXTRA_FLAGS+="--no-weight-warnings"
echo "Disabling weight checks since we are on a relay chain"
fi
echo "Extra flags: $EXTRA_FLAGS"
# Store the command in a variable so we can log it
COMMAND="./try-runtime \
--runtime $RUNTIME_BLOB_PATH \
on-runtime-upgrade --checks=pre-and-post \
on-runtime-upgrade --checks=${{ inputs.checks }} \
$EXTRA_FLAGS \
live --uri ${{ inputs.node-uri }}"
# Echo the command
# Echo the command before running it, for debugging purposes
echo "Running command:"
echo "$COMMAND"
# Run the command
eval "$COMMAND"
shell: bash
51 changes: 51 additions & 0 deletions readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
# Try Runtime GHA

Try Runtime GHA makes it easy to add [try-runtime](https://paritytech.github.io/try-runtime-cli/try_runtime/) checks to your CI.

## Motivation

`try-runtime` enforces critical invariants such as:

- Migrations execute correctly, including `pre_upgrade` and `post_upgrade` hooks
- Migration execution does not exceed the block weight limit
- Migrations are idempotent
- Try State invariants pass
- Post-Migration, all runtime state is decodable

Given that code changes can break any of the above invariants, running `try-runtime` checks is as important as regularly running cargo tests in your PR CI, to prevent accidental regressions.

## Usage

Create a new [Github Action Workflow](https://docs.github.com/en/actions/using-workflows).

The simplest usage only requires two parameters `runtime-package`, and `node-uri`:

```yaml
name: Check Migrations

on:
push:
branches: ["main"]
pull_request:
jobs:
check-migrations:
steps:
- name: Checkout sources
uses: actions/checkout@v3

- name: Run Polkadot Try Runtime Checks
uses: "paritytech/try-runtime-gha@main"
with:
runtime-package: "my-runtime"
node-uri: "wss://my-runtime-uri:443"
```
When triggered, the GHA will
1. Build the `runtime-package` with flags `--production` and `--features try-runtime`
2. Download [try-runtime-cli](https://github.com/paritytech/try-runtime-cli)
3. Exec `try-runtime on-runtime-upgrade --checks [checks] [extra-args] live [node-uri]

If there is an error, you can check the logs for the exact command that failed to help reproduce the issue in your local environment.

See more examples at [`.github/workflows/examples.yml`](https://github.com/paritytech/try-runtime-gha/blob/main/.github/workflows/examples.yml).

0 comments on commit 893dd19

Please sign in to comment.