Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(devnet): add ismp #270

Merged
merged 9 commits into from
Sep 20, 2024
29 changes: 29 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,16 @@ jobs:
run: |
cargo check --release --locked --features=runtime-benchmarks,try-runtime

check-ismp:
needs: lint
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: "./.github/actions/init"
- name: Check Build with ISMP
run: |
cargo check --release --locked --features=ismp,runtime-benchmarks,try-runtime

clippy:
needs: lint
runs-on: ubuntu-latest
Expand All @@ -63,6 +73,25 @@ jobs:
token: ${{ secrets.GITHUB_TOKEN }}
args: --release --locked --features=runtime-benchmarks

clippy-ismp:
needs: lint
runs-on: ubuntu-latest
permissions:
checks: write
env:
RUSTFLAGS: "-Wmissing_docs"
SKIP_WASM_BUILD: 1
steps:
- uses: actions/checkout@v4

- uses: "./.github/actions/init"

- name: Annotate with Clippy warnings
uses: actions-rs/clippy-check@v1
with:
token: ${{ secrets.GITHUB_TOKEN }}
args: --release --locked --features=runtime-benchmarks,ismp

test:
needs: lint
runs-on: ubuntu-latest
Expand Down
87 changes: 58 additions & 29 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,45 +16,74 @@ on:
description: Build node
default: true
runtime:
type: boolean
description: Build runtimes deterministically
default: true
description: 'Runtime to build (devnet, testnet, mainnet)'
default: ''
type: choice
options:
- ''
- devnet
- testnet
- mainnet

jobs:
srtool:
runs-on: ubuntu-latest
if: github.event_name != 'workflow_dispatch' && 'true' || inputs.runtime
if: |
startsWith(github.event.release.tag_name, 'testnet') ||
startsWith(github.event.release.tag_name, 'devnet') ||
startsWith(github.event.release.tag_name, 'mainnet') ||
github.event_name == 'workflow_dispatch' &&
github.event.inputs.runtime != ''
permissions:
contents: write
strategy:
matrix:
runtime: [ "devnet", "testnet", "mainnet" ]
steps:
- name: Checkout sources
uses: actions/checkout@v4
- name: Determine Runtime and Set Node Build Opts
id: determine_runtime
run: |
if [ "${{ github.event_name }}" == "workflow_dispatch" ]; then
echo "RUNTIME=${{ github.event.inputs.runtime }}" >> $GITHUB_ENV
elif [[ "${{ github.event.release.tag_name }}" == devnet* ]]; then
echo "RUNTIME=devnet" >> $GITHUB_ENV
elif [[ "${{ github.event.release.tag_name }}" == testnet* ]]; then
echo "RUNTIME=testnet" >> $GITHUB_ENV
elif [[ "${{ github.event.release.tag_name }}" == mainnet* ]]; then
echo "RUNTIME=mainnet" >> $GITHUB_ENV
else
echo "RUNTIME=devnet" >> $GITHUB_ENV # Default to devnet if no tag matches
fi

# if devnet, build the node with ismp feature
if [ "$RUNTIME" == "devnet" ]; then
echo "NODE_BUILD_OPTS=--features on-chain-release-build,ismp" >> $GITHUB_ENV
else
echo "NODE_BUILD_OPTS=--features on-chain-release-build" >> $GITHUB_ENV
fi

- name: Cache runtime target dir
uses: actions/cache@v4
with:
path: "${{ github.workspace }}/runtime/${{ matrix.runtime }}/target"
key: srtool-target-${{ matrix.runtime }}-${{ github.sha }}
path: "${{ github.workspace }}/runtime/${{ env.RUNTIME }}/target"
key: srtool-target-${{ env.RUNTIME }}-${{ github.sha }}
restore-keys: |
srtool-target-${{ matrix.runtime }}-
srtool-target-${{ env.RUNTIME }}-
srtool-target-

- name: Build ${{ matrix.runtime }} runtime
- name: Build ${{ env.RUNTIME }} runtime
id: srtool_build
uses: chevdor/[email protected]
env:
BUILD_OPTS: "--features on-chain-release-build"
# runtimes do not have ismp feature
BUILD_OPTS: '--features on-chain-release-build'
with:
chain: ${{ matrix.runtime }}
package: "pop-runtime-${{ matrix.runtime }}"
runtime_dir: "runtime/${{ matrix.runtime }}"
chain: ${{ env.RUNTIME }}
package: "pop-runtime-${{ env.RUNTIME }}"
runtime_dir: "runtime/${{ env.RUNTIME }}"

- name: Store srtool digest to disk
run: |
echo '${{ steps.srtool_build.outputs.json }}' | jq . > ${{ matrix.runtime }}-srtool-digest.json
echo '${{ steps.srtool_build.outputs.json }}' | jq . > ${{ env.RUNTIME }}-srtool-digest.json

# Manual trigger: add artifacts to run
- name: Copy artifacts
Expand All @@ -65,10 +94,10 @@ jobs:
if: github.event_name != 'release'
uses: actions/upload-artifact@v4
with:
name: ${{ matrix.runtime }}-runtime-${{ github.sha }}
name: ${{ env.RUNTIME }}-runtime-${{ github.sha }}
path: |
pop_runtime_${{ matrix.runtime }}*.wasm
${{ matrix.runtime }}-srtool-digest.json
pop_runtime_${{ env.RUNTIME }}*.wasm
${{ env.RUNTIME }}-srtool-digest.json

# We now get extra information thanks to subwasm,
- name: Install subwasm ${{ env.SUBWASM_VERSION }}
Expand All @@ -81,23 +110,23 @@ jobs:
run: |
subwasm info ${{ steps.srtool_build.outputs.wasm }}
subwasm info ${{ steps.srtool_build.outputs.wasm_compressed }}
subwasm --json info ${{ steps.srtool_build.outputs.wasm }} > ${{ matrix.runtime }}-info.json
subwasm --json info ${{ steps.srtool_build.outputs.wasm_compressed }} > ${{ matrix.runtime }}-info_compressed.json
subwasm --json info ${{ steps.srtool_build.outputs.wasm }} > ${{ env.RUNTIME }}-info.json
subwasm --json info ${{ steps.srtool_build.outputs.wasm_compressed }} > ${{ env.RUNTIME }}-info_compressed.json

- name: Extract the metadata
run: |
subwasm meta ${{ steps.srtool_build.outputs.wasm }}
subwasm --json meta ${{ steps.srtool_build.outputs.wasm }} > ${{ matrix.runtime }}-metadata.json
subwasm --json meta ${{ steps.srtool_build.outputs.wasm }} > ${{ env.RUNTIME }}-metadata.json

- name: Archive Subwasm results
if: github.event_name != 'release'
uses: actions/upload-artifact@v4
with:
name: ${{ matrix.runtime }}-info
name: ${{ env.RUNTIME }}-info
path: |
${{ matrix.runtime }}-info.json
${{ matrix.runtime }}-info_compressed.json
${{ matrix.runtime }}-metadata.json
${{ env.RUNTIME }}-info.json
${{ env.RUNTIME }}-info_compressed.json
${{ env.RUNTIME }}-metadata.json

# Release published: add artifacts to release
- name: Add artifacts to release
Expand All @@ -106,7 +135,7 @@ jobs:
with:
append_body: true
body: |
## Runtime: `${{ matrix.runtime }}`
## Runtime: `${{ env.RUNTIME }}`
```
🏋️ Runtime Size: ${{ fromJSON(steps.srtool_build.outputs.json).runtimes.compressed.subwasm.size }} bytes
🔥 Core Version: ${{ fromJSON(steps.srtool_build.outputs.json).runtimes.compressed.subwasm.core_version.specName }}-${{ fromJSON(steps.srtool_build.outputs.json).runtimes.compressed.subwasm.core_version.specVersion }}
Expand All @@ -118,7 +147,7 @@ jobs:
```
files: |
${{ steps.srtool_build.outputs.wasm_compressed }}
${{ matrix.runtime }}-srtool-digest.json
${{ env.RUNTIME }}-srtool-digest.json

build-node:
runs-on: ${{ matrix.platform.os }}
Expand Down Expand Up @@ -168,7 +197,7 @@ jobs:
run: rustup target add ${{ matrix.platform.target }}

- name: Build node
run: cargo build --profile=production -p pop-node --features on-chain-release-build --target ${{ matrix.platform.target }}
run: cargo build --profile=production -p pop-node $NODE_BUILD_OPTS --target ${{ matrix.platform.target }}

- name: Package binary (Linux)
if: contains(matrix.platform.target, 'linux')
Expand Down
Loading
Loading