diff --git a/.github/workflows/polkadot.yml b/.github/workflows/examples.yml similarity index 86% rename from .github/workflows/polkadot.yml rename to .github/workflows/examples.yml index f56cac0..c6f3818 100644 --- a/.github/workflows/polkadot.yml +++ b/.github/workflows/examples.yml @@ -4,7 +4,7 @@ on: workflow_dispatch: jobs: - polkadot: + polkadot-relay-chain: runs-on: ubuntu-latest steps: - name: Checkout Runtimes Repo @@ -12,7 +12,7 @@ jobs: 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" @@ -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" diff --git a/action.yml b/action.yml index bf81278..008dd5c 100644 --- a/action.yml +++ b/action.yml @@ -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 @@ -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 diff --git a/readme.md b/readme.md new file mode 100644 index 0000000..dda86eb --- /dev/null +++ b/readme.md @@ -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).