diff --git a/.github/workflows/polkadot.yml b/.github/workflows/polkadot.yml new file mode 100644 index 0000000..00a6492 --- /dev/null +++ b/.github/workflows/polkadot.yml @@ -0,0 +1,20 @@ +on: + workflow_dispatch: + +jobs: + run-polkadot: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v3 + - name: Polkadot + uses: ../.. + with: + runtime-package: "polkadot-runtime" + extra-args: "--disable-idempotency-check --no-weight-warnings" + node-uri: "wss://polkadot-try-runtime-node.parity-chains.parity.io:443" + repository: "polkadot-fellows/runtimes" + # ref: + # description: "The branch, tag or SHA to checkout. When checking out the repository that triggered a workflow, this defaults to the reference or SHA for that event. Otherwise, uses the default branch." + # token: + # description: "Personal access token (PAT) used to fetch the repository." diff --git a/action.yml b/action.yml new file mode 100644 index 0000000..5e6272d --- /dev/null +++ b/action.yml @@ -0,0 +1,98 @@ +name: "Try Runtime GHA" +description: "Easily check runtime migrations for a Substrate-based blockchain using try-runtime-cli" +author: "Parity Tech" +branding: + icon: "shield" + color: "green" + +inputs: + runtime-package: + 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"' + required: true + default: "" + node-uri: + description: "URI of a node to scrape state" + required: true + shared-cache-key: + description: "The shared cache key" + required: true + default: "try-runtime-gha" + repository: + description: 'Repository name with owner. For example, "paritytech/polkadot-sdk". Default: ${{ github.repository }}' + ref: + description: "The branch, tag or SHA to checkout. When checking out the repository that triggered a workflow, this defaults to the reference or SHA for that event. Otherwise, uses the default branch." + token: + description: "Personal access token (PAT) used to fetch the repository." + +runs: + using: "composite" + steps: + - name: Checkout sources + uses: actions/checkout@v3 + with: + repository: ${{ inputs.repository }} + ref: ${{ inputs.ref }} + token: ${{ inputs.token }} + + - name: Download try-runtime-cli + run: | + curl -sL https://github.com/paritytech/try-runtime-cli/releases/download/v0.6.1/try-runtime-x86_64-unknown-linux-musl -o try-runtime + chmod +x ./try-runtime + shell: bash + + - name: Install Protoc + uses: arduino/setup-protoc@v1.3.0 + 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: Fetch cache + uses: Swatinem/rust-cache@v2.7.0 + with: + shared-key: ${{ inputs.shared-cache-key }} + + - name: Build ${{ inputs.runtime-name }} + run: | + cargo build --profile production -p ${{ inputs.runtime-package }} --features try-runtime -q --locked + shell: bash + + - name: Check migrations + run: | + PACKAGE_NAME=${{ inputs.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 + + 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 \ + $EXTRA_FLAGS \ + live --uri ${{ inputs.runtime-uri }}" + + # Echo the command + echo "Running command:" + echo "$COMMAND" + + # Run the command + eval "$COMMAND" + + shell: bash