From 385dce7a387d503890fd617da1b09641ede5af33 Mon Sep 17 00:00:00 2001 From: Antonio Antonino Date: Mon, 16 Sep 2024 16:26:31 +0200 Subject: [PATCH 01/11] First test --- .github/workflows/check-code.yml | 522 ++++++++++++++++------------- scripts/run_benches_for_runtime.sh | 18 +- 2 files changed, 295 insertions(+), 245 deletions(-) diff --git a/.github/workflows/check-code.yml b/.github/workflows/check-code.yml index ec041c42d..64b8b5907 100644 --- a/.github/workflows/check-code.yml +++ b/.github/workflows/check-code.yml @@ -13,192 +13,288 @@ concurrency: cancel-in-progress: true jobs: - get-commit-head: - name: Get HEAD commit message + # get-commit-head: + # name: Get HEAD commit message + # runs-on: ubuntu-latest + # outputs: + # headCommitMsg: ${{ steps.get-head-commit-message.outputs.headCommitMsg }} + + # steps: + # - name: Checkout repository + # uses: actions/checkout@v4 + # with: + # # We use different payloads depending on whether this is a `push` or a `pull_request` event + # ref: ${{ github.event.head_commit.id || github.event.pull_request.head.sha }} + + # - name: Get HEAD commit message + # id: get-head-commit-message + # run: echo "headCommitMsg=$(git show -s --format=%s)" >> "$GITHUB_OUTPUT" + + # cargo-clippy: + # name: Run Clippy checks + # runs-on: ubuntu-latest + # needs: get-commit-head + # if: ${{ !contains(needs.get-commit-head.outputs.headCommitMsg, 'ci-skip-rust') }} + + # strategy: + # matrix: + # features: + # - + # - --all-features + # fail-fast: false + + # steps: + # - name: Checkout repository + # uses: actions/checkout@v4 + + # - name: Free Disk Space + # uses: jlumbroso/free-disk-space@main + # with: + # tool-cache: true + + # - name: Set up Cargo cache + # uses: actions/cache@v4 + # with: + # path: | + # ~/.cargo/bin/ + # ~/.cargo/registry/index/ + # ~/.cargo/registry/cache/ + # ~/.cargo/git/db/ + # key: ${{ github.job }}-${{ github.ref }}-${{ matrix.features }}-${{ hashFiles('**/Cargo.lock') }} + + # - name: Run `cargo clippy` + # run: | + # docker run --rm \ + # -v "${GITHUB_WORKSPACE}:/workspace" \ + # -v "${HOME}/.cargo:/root/.cargo" \ + # -w /workspace \ + # -e SKIP_WASM_BUILD=1 \ + # paritytech/ci-unified:bullseye-1.74.0 \ + # bash -c "cargo clippy --all-targets --locked ${{ matrix.features }} -- -D warnings" + + # cargo-fmt: + # name: Check formatting + # runs-on: ubuntu-latest + # container: + # image: paritytech/ci-unified:bullseye-1.74.0 + # env: + # RUSTUP_NIGHTLY_VERSION: nightly-2023-10-02 + # needs: get-commit-head + # if: ${{ !contains(needs.get-commit-head.outputs.headCommitMsg, 'ci-skip-rust') }} + + # steps: + # - name: Checkout repository + # uses: actions/checkout@v4 + + # - name: Install nightly toolchain + # run: rustup toolchain add ${{ env.RUSTUP_NIGHTLY_VERSION }} + + # - name: Run `cargo fmt` + # # Latest nightly version matching the base rustc version (1.74.0) + # run: cargo +${{ env.RUSTUP_NIGHTLY_VERSION }} fmt -- --check + + # - name: Run `taplo` + # run: taplo fmt --check + + # integration-tests: + # name: Run Chopsticks tests + # runs-on: ubuntu-latest + # env: + # working-dir: ./integration-tests/chopsticks + # CI: true + # PEREGRINE_WASM_OVERRIDE: ../../target/debug/wbuild/peregrine-runtime/peregrine_runtime.wasm + # defaults: + # run: + # working-directory: ${{ env.working-dir }} + # needs: + # - get-commit-head + # if: ${{ !contains(needs.get-commit-head.outputs.headCommitMsg, 'ci-skip-integration-tests') }} + + # steps: + # - name: Checkout repository + # uses: actions/checkout@v4 + + # - name: Free Disk Space + # uses: jlumbroso/free-disk-space@main + # with: + # tool-cache: true + + # - name: Setup environment + # uses: actions/setup-node@v4 + # with: + # node-version-file: "${{ env.working-dir }}/.nvmrc" + + # - name: Install dependencies + # run: yarn --immutable + + # - name: Check TS + # run: yarn ts-check + + # - name: Check lints + # run: yarn lint + + # - name: Set up Cargo cache + # uses: actions/cache@v4 + # with: + # path: | + # ~/.cargo/bin/ + # ~/.cargo/registry/index/ + # ~/.cargo/registry/cache/ + # ~/.cargo/git/db/ + # key: ${{ github.job }}-${{ github.ref }}-${{ hashFiles('**/Cargo.lock') }} + + # - name: Build Peregrine runtime + # run: cargo build -p peregrine-runtime + + # - name: Run Chopsticks tests + # run: yarn test:CI + + # cargo-test: + # name: Run Cargo tests + # runs-on: ubuntu-latest + # needs: cargo-clippy + + # strategy: + # matrix: + # features: + # - + # - --all-features + # fail-fast: false + + # steps: + # - name: Checkout repository + # uses: actions/checkout@v4 + + # - name: Free Disk Space + # uses: jlumbroso/free-disk-space@main + # with: + # tool-cache: true + + # - name: Set up Cargo cache + # uses: actions/cache@v4 + # with: + # path: | + # ~/.cargo/bin/ + # ~/.cargo/registry/index/ + # ~/.cargo/registry/cache/ + # ~/.cargo/git/db/ + # key: ${{ github.job }}-${{ github.ref }}-${{ matrix.features }}-${{ hashFiles('**/Cargo.lock') }} + + # - name: Run `cargo test` + # run: | + # docker run --rm \ + # -v "${GITHUB_WORKSPACE}:/workspace" \ + # -v "${HOME}/.cargo:/root/.cargo" \ + # -w /workspace \ + # paritytech/ci-unified:bullseye-1.74.0 \ + # bash -c "cargo test --all-targets --locked ${{ matrix.features }}" + + # cargo-doc: + # name: Check Rustdoc + # runs-on: ubuntu-latest + # needs: cargo-clippy + + # strategy: + # matrix: + # features: + # - + # - --all-features + # fail-fast: false + + # steps: + # - name: Checkout repository + # uses: actions/checkout@v4 + + # - name: Free Disk Space + # uses: jlumbroso/free-disk-space@main + # with: + # tool-cache: true + + # - name: Set up Cargo cache + # uses: actions/cache@v4 + # with: + # path: | + # ~/.cargo/bin/ + # ~/.cargo/registry/index/ + # ~/.cargo/registry/cache/ + # ~/.cargo/git/db/ + # key: ${{ github.job }}-${{ github.ref }}-${{ hashFiles('**/Cargo.lock') }} + + # - name: Run `cargo doc` + # run: | + # docker run --rm \ + # -v "${GITHUB_WORKSPACE}:/workspace" \ + # -v "${HOME}/.cargo:/root/.cargo" \ + # -w /workspace \ + # -e RUSTDOCFLAGS='-D warnings' \ + # -e SKIP_WASM_BUILD=1 \ + # paritytech/ci-unified:bullseye-1.74.0 \ + # bash -c "cargo doc --no-deps --locked ${{ matrix.features }}" + + # try-runtime: + # name: Run try-runtime + # runs-on: ubuntu-latest + # needs: cargo-clippy + # env: + # TRY_RUNTIME_CLI_VERSION_TAG: v0.7.0 + # container: + # image: paritytech/ci-unified:bullseye-1.74.0 + + # strategy: + # matrix: + # runtime: + # - peregrine + # - spiritnet + # fail-fast: false + + # steps: + # - name: Checkout repository + # uses: actions/checkout@v4 + + # - name: Free Disk Space + # uses: jlumbroso/free-disk-space@main + # with: + # tool-cache: true + + # - name: Install try-runtime + # run: | + # curl -sL https://github.com/paritytech/try-runtime-cli/releases/download/${{ env.TRY_RUNTIME_CLI_VERSION_TAG }}/try-runtime-x86_64-unknown-linux-musl -o try-runtime + # chmod +x ./try-runtime + # ./try-runtime --version + + # - name: Set up Cargo cache + # uses: actions/cache@v4 + # with: + # path: | + # ~/.cargo/bin/ + # ~/.cargo/registry/index/ + # ~/.cargo/registry/cache/ + # ~/.cargo/git/db/ + # key: ${{ github.job }}-${{ github.ref }}-${{ hashFiles('**/Cargo.lock') }} + + # - name: Build runtime + # run: cargo build --release --locked -p ${{ matrix.runtime }}-runtime --features try-runtime + + # - name: Run `try-runtime` + # run: | + # ./try-runtime \ + # --runtime=./target/release/wbuild/${{ matrix.runtime }}-runtime/${{ matrix.runtime }}_runtime.compact.compressed.wasm \ + # on-runtime-upgrade \ + # --disable-spec-version-check \ + # --checks=all \ + # live \ + # --uri=wss://${{ matrix.runtime }}.kilt.io + + runtime-benchmarks: + name: Test benchmarks runs-on: ubuntu-latest - outputs: - headCommitMsg: ${{ steps.get-head-commit-message.outputs.headCommitMsg }} - - steps: - - name: Checkout repository - uses: actions/checkout@v4 - with: - # We use different payloads depending on whether this is a `push` or a `pull_request` event - ref: ${{ github.event.head_commit.id || github.event.pull_request.head.sha }} - - - name: Get HEAD commit message - id: get-head-commit-message - run: echo "headCommitMsg=$(git show -s --format=%s)" >> "$GITHUB_OUTPUT" - - cargo-clippy: - name: Run Clippy checks - runs-on: ubuntu-latest - needs: get-commit-head - if: ${{ !contains(needs.get-commit-head.outputs.headCommitMsg, 'ci-skip-rust') }} + # needs: cargo-clippy strategy: matrix: - features: - - - - --all-features - fail-fast: false - - steps: - - name: Checkout repository - uses: actions/checkout@v4 - - - name: Free Disk Space - uses: jlumbroso/free-disk-space@main - with: - tool-cache: true - - - name: Set up Cargo cache - uses: actions/cache@v4 - with: - path: | - ~/.cargo/bin/ - ~/.cargo/registry/index/ - ~/.cargo/registry/cache/ - ~/.cargo/git/db/ - key: ${{ github.job }}-${{ github.ref }}-${{ matrix.features }}-${{ hashFiles('**/Cargo.lock') }} - - - name: Run `cargo clippy` - run: | - docker run --rm \ - -v "${GITHUB_WORKSPACE}:/workspace" \ - -v "${HOME}/.cargo:/root/.cargo" \ - -w /workspace \ - -e SKIP_WASM_BUILD=1 \ - paritytech/ci-unified:bullseye-1.74.0 \ - bash -c "cargo clippy --all-targets --locked ${{ matrix.features }} -- -D warnings" - - cargo-fmt: - name: Check formatting - runs-on: ubuntu-latest - container: - image: paritytech/ci-unified:bullseye-1.74.0 - env: - RUSTUP_NIGHTLY_VERSION: nightly-2023-10-02 - needs: get-commit-head - if: ${{ !contains(needs.get-commit-head.outputs.headCommitMsg, 'ci-skip-rust') }} - - steps: - - name: Checkout repository - uses: actions/checkout@v4 - - - name: Install nightly toolchain - run: rustup toolchain add ${{ env.RUSTUP_NIGHTLY_VERSION }} - - - name: Run `cargo fmt` - # Latest nightly version matching the base rustc version (1.74.0) - run: cargo +${{ env.RUSTUP_NIGHTLY_VERSION }} fmt -- --check - - - name: Run `taplo` - run: taplo fmt --check - - integration-tests: - name: Run Chopsticks tests - runs-on: ubuntu-latest - env: - working-dir: ./integration-tests/chopsticks - CI: true - PEREGRINE_WASM_OVERRIDE: ../../target/debug/wbuild/peregrine-runtime/peregrine_runtime.wasm - defaults: - run: - working-directory: ${{ env.working-dir }} - needs: - - get-commit-head - if: ${{ !contains(needs.get-commit-head.outputs.headCommitMsg, 'ci-skip-integration-tests') }} - - steps: - - name: Checkout repository - uses: actions/checkout@v4 - - - name: Free Disk Space - uses: jlumbroso/free-disk-space@main - with: - tool-cache: true - - - name: Setup environment - uses: actions/setup-node@v4 - with: - node-version-file: "${{ env.working-dir }}/.nvmrc" - - - name: Install dependencies - run: yarn --immutable - - - name: Check TS - run: yarn ts-check - - - name: Check lints - run: yarn lint - - - name: Set up Cargo cache - uses: actions/cache@v4 - with: - path: | - ~/.cargo/bin/ - ~/.cargo/registry/index/ - ~/.cargo/registry/cache/ - ~/.cargo/git/db/ - key: ${{ github.job }}-${{ github.ref }}-${{ hashFiles('**/Cargo.lock') }} - - - name: Build Peregrine runtime - run: cargo build -p peregrine-runtime - - - name: Run Chopsticks tests - run: yarn test:CI - - cargo-test: - name: Run Cargo tests - runs-on: ubuntu-latest - needs: cargo-clippy - - strategy: - matrix: - features: - - - - --all-features - fail-fast: false - - steps: - - name: Checkout repository - uses: actions/checkout@v4 - - - name: Free Disk Space - uses: jlumbroso/free-disk-space@main - with: - tool-cache: true - - - name: Set up Cargo cache - uses: actions/cache@v4 - with: - path: | - ~/.cargo/bin/ - ~/.cargo/registry/index/ - ~/.cargo/registry/cache/ - ~/.cargo/git/db/ - key: ${{ github.job }}-${{ github.ref }}-${{ matrix.features }}-${{ hashFiles('**/Cargo.lock') }} - - - name: Run `cargo test` - run: | - docker run --rm \ - -v "${GITHUB_WORKSPACE}:/workspace" \ - -v "${HOME}/.cargo:/root/.cargo" \ - -w /workspace \ - paritytech/ci-unified:bullseye-1.74.0 \ - bash -c "cargo test --all-targets --locked ${{ matrix.features }}" - - cargo-doc: - name: Check Rustdoc - runs-on: ubuntu-latest - needs: cargo-clippy - - strategy: - matrix: - features: - - - - --all-features + runtime: + - peregrine + - spiritnet fail-fast: false steps: @@ -218,69 +314,13 @@ jobs: ~/.cargo/registry/index/ ~/.cargo/registry/cache/ ~/.cargo/git/db/ - key: ${{ github.job }}-${{ github.ref }}-${{ hashFiles('**/Cargo.lock') }} + key: ${{ github.job }}-${{ github.ref }}-${{ matrix.runtime }}-${{ hashFiles('**/Cargo.lock') }} - - name: Run `cargo doc` + - name: Run benchmarks for runtime run: | docker run --rm \ -v "${GITHUB_WORKSPACE}:/workspace" \ -v "${HOME}/.cargo:/root/.cargo" \ -w /workspace \ - -e RUSTDOCFLAGS='-D warnings' \ - -e SKIP_WASM_BUILD=1 \ paritytech/ci-unified:bullseye-1.74.0 \ - bash -c "cargo doc --no-deps --locked ${{ matrix.features }}" - - try-runtime: - name: Run try-runtime - runs-on: ubuntu-latest - needs: cargo-clippy - env: - TRY_RUNTIME_CLI_VERSION_TAG: v0.7.0 - container: - image: paritytech/ci-unified:bullseye-1.74.0 - - strategy: - matrix: - runtime: - - peregrine - - spiritnet - fail-fast: false - - steps: - - name: Checkout repository - uses: actions/checkout@v4 - - - name: Free Disk Space - uses: jlumbroso/free-disk-space@main - with: - tool-cache: true - - - name: Install try-runtime - run: | - curl -sL https://github.com/paritytech/try-runtime-cli/releases/download/${{ env.TRY_RUNTIME_CLI_VERSION_TAG }}/try-runtime-x86_64-unknown-linux-musl -o try-runtime - chmod +x ./try-runtime - ./try-runtime --version - - - name: Set up Cargo cache - uses: actions/cache@v4 - with: - path: | - ~/.cargo/bin/ - ~/.cargo/registry/index/ - ~/.cargo/registry/cache/ - ~/.cargo/git/db/ - key: ${{ github.job }}-${{ github.ref }}-${{ hashFiles('**/Cargo.lock') }} - - - name: Build runtime - run: cargo build --release --locked -p ${{ matrix.runtime }}-runtime --features try-runtime - - - name: Run `try-runtime` - run: | - ./try-runtime \ - --runtime=./target/release/wbuild/${{ matrix.runtime }}-runtime/${{ matrix.runtime }}_runtime.compact.compressed.wasm \ - on-runtime-upgrade \ - --disable-spec-version-check \ - --checks=all \ - live \ - --uri=wss://${{ matrix.runtime }}.kilt.io + bash -c "bash scripts/run_benches_for_runtime.sh ${{ matrix.runtime }} dev" diff --git a/scripts/run_benches_for_runtime.sh b/scripts/run_benches_for_runtime.sh index 86a9c13f2..3e6574daa 100755 --- a/scripts/run_benches_for_runtime.sh +++ b/scripts/run_benches_for_runtime.sh @@ -6,7 +6,13 @@ runtime=${1-"peregrine"} chain=$([ "$1" == "spiritnet" ] && echo "spiritnet-dev" || echo "dev") -standard_args="--release --locked --features=runtime-benchmarks --bin=kilt-parachain" +# Dev profile is the debug target +profile=${2-"dev"} +standard_args="--profile $2 --locked --features=runtime-benchmarks --bin=kilt-parachain" + +echo $target_folder + +exit 0 pallets=( pallet-migration @@ -44,8 +50,6 @@ pallets=( pallet-asset-switch ) - - # Add Peregrine-only pallets here! if [ "$runtime" = "peregrine" ]; then pallets+=( @@ -57,10 +61,16 @@ echo "[+] Running all runtime benchmarks for $runtime --chain=$chain" cargo build $standard_args +if [ $profile == "dev" ]; then + target_folder="debug" +else + target_folder=$profile +fi + for pallet in "${pallets[@]}"; do echo "Runtime: $runtime. Pallet: $pallet" # shellcheck disable=SC2086 - ./target/release/kilt-parachain benchmark pallet \ + ./target/$target_folder/kilt-parachain benchmark pallet \ --template=".maintain/runtime-weight-template.hbs" \ --header="HEADER-GPL" \ --wasm-execution=compiled \ From e38005e20b5cc34fa46f6ee50d2ca681bef52619 Mon Sep 17 00:00:00 2001 From: Antonio Antonino Date: Mon, 16 Sep 2024 16:31:25 +0200 Subject: [PATCH 02/11] Fix bench command --- .github/workflows/check-code.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/check-code.yml b/.github/workflows/check-code.yml index 64b8b5907..d15daf14c 100644 --- a/.github/workflows/check-code.yml +++ b/.github/workflows/check-code.yml @@ -323,4 +323,4 @@ jobs: -v "${HOME}/.cargo:/root/.cargo" \ -w /workspace \ paritytech/ci-unified:bullseye-1.74.0 \ - bash -c "bash scripts/run_benches_for_runtime.sh ${{ matrix.runtime }} dev" + bash -c "bash scripts/run_benches_for_runtime.sh ${{ matrix.runtime }}-dev dev > /dev/null" From 4ee8527757c94abe08fbab569130ec22753959c5 Mon Sep 17 00:00:00 2001 From: Antonio Antonino Date: Mon, 16 Sep 2024 16:36:53 +0200 Subject: [PATCH 03/11] Last fixes --- .github/workflows/check-code.yml | 3 ++- scripts/run_benches_for_runtime.sh | 2 -- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/.github/workflows/check-code.yml b/.github/workflows/check-code.yml index d15daf14c..1d09503c4 100644 --- a/.github/workflows/check-code.yml +++ b/.github/workflows/check-code.yml @@ -316,7 +316,8 @@ jobs: ~/.cargo/git/db/ key: ${{ github.job }}-${{ github.ref }}-${{ matrix.runtime }}-${{ hashFiles('**/Cargo.lock') }} - - name: Run benchmarks for runtime + # We don't care if the weight files are updated. + - name: Run runtime benchmarks run: | docker run --rm \ -v "${GITHUB_WORKSPACE}:/workspace" \ diff --git a/scripts/run_benches_for_runtime.sh b/scripts/run_benches_for_runtime.sh index 3e6574daa..a51ebc697 100755 --- a/scripts/run_benches_for_runtime.sh +++ b/scripts/run_benches_for_runtime.sh @@ -12,8 +12,6 @@ standard_args="--profile $2 --locked --features=runtime-benchmarks --bin=kilt-pa echo $target_folder -exit 0 - pallets=( pallet-migration attestation From aa727020051c374f171b1558e01b43099a785f67 Mon Sep 17 00:00:00 2001 From: Antonio Antonino Date: Tue, 17 Sep 2024 07:57:52 +0200 Subject: [PATCH 04/11] Use 1 step and 1 repeat for debug benchmarks --- scripts/run_benches_for_runtime.sh | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/scripts/run_benches_for_runtime.sh b/scripts/run_benches_for_runtime.sh index a51ebc697..5e3b4044c 100755 --- a/scripts/run_benches_for_runtime.sh +++ b/scripts/run_benches_for_runtime.sh @@ -5,9 +5,10 @@ # current Substrate reference machine: https://github.com/paritytech/substrate/pull/5848 runtime=${1-"peregrine"} +profile=${2-"dev"} + chain=$([ "$1" == "spiritnet" ] && echo "spiritnet-dev" || echo "dev") # Dev profile is the debug target -profile=${2-"dev"} standard_args="--profile $2 --locked --features=runtime-benchmarks --bin=kilt-parachain" echo $target_folder @@ -61,8 +62,14 @@ cargo build $standard_args if [ $profile == "dev" ]; then target_folder="debug" + # We care about benchmark correctness, not accuracy. + steps=1 + repeat=1 else target_folder=$profile + # Defaults for the benchmark command + steps=50 + repeat=20 fi for pallet in "${pallets[@]}"; do @@ -73,8 +80,8 @@ for pallet in "${pallets[@]}"; do --header="HEADER-GPL" \ --wasm-execution=compiled \ --heap-pages=4096 \ - --steps=50 \ - --repeat=20 \ + --steps=$steps \ + --repeat=$repeat \ --chain="${chain}" \ --pallet="$pallet" \ --extrinsic="*" \ From 1ae20b3c5ad8f2844d404cf029a048c22c61f892 Mon Sep 17 00:00:00 2001 From: Antonio Antonino Date: Tue, 17 Sep 2024 09:14:20 +0200 Subject: [PATCH 05/11] Optimiziations for debug run --- .github/workflows/check-code.yml | 2 +- scripts/run_benches_for_runtime.sh | 16 +++++----------- 2 files changed, 6 insertions(+), 12 deletions(-) diff --git a/.github/workflows/check-code.yml b/.github/workflows/check-code.yml index 1d09503c4..040886420 100644 --- a/.github/workflows/check-code.yml +++ b/.github/workflows/check-code.yml @@ -324,4 +324,4 @@ jobs: -v "${HOME}/.cargo:/root/.cargo" \ -w /workspace \ paritytech/ci-unified:bullseye-1.74.0 \ - bash -c "bash scripts/run_benches_for_runtime.sh ${{ matrix.runtime }}-dev dev > /dev/null" + bash -c "bash -x scripts/run_benches_for_runtime.sh ${{ matrix.runtime }}-dev dev" diff --git a/scripts/run_benches_for_runtime.sh b/scripts/run_benches_for_runtime.sh index 5e3b4044c..3a34f8181 100755 --- a/scripts/run_benches_for_runtime.sh +++ b/scripts/run_benches_for_runtime.sh @@ -11,8 +11,6 @@ chain=$([ "$1" == "spiritnet" ] && echo "spiritnet-dev" || echo "dev") # Dev profile is the debug target standard_args="--profile $2 --locked --features=runtime-benchmarks --bin=kilt-parachain" -echo $target_folder - pallets=( pallet-migration attestation @@ -56,20 +54,17 @@ if [ "$runtime" = "peregrine" ]; then ) fi -echo "[+] Running all runtime benchmarks for $runtime --chain=$chain" +echo "[+] Running all runtime benchmarks for \"$runtime\", \"--chain=$chain\" and profile \"$profile\"" cargo build $standard_args if [ $profile == "dev" ]; then target_folder="debug" # We care about benchmark correctness, not accuracy. - steps=1 - repeat=1 + additional_args="--steps=1 --repeat=1 --default-pov-mode=ignored --no-verify" else target_folder=$profile - # Defaults for the benchmark command - steps=50 - repeat=20 + additional_args="" fi for pallet in "${pallets[@]}"; do @@ -80,11 +75,10 @@ for pallet in "${pallets[@]}"; do --header="HEADER-GPL" \ --wasm-execution=compiled \ --heap-pages=4096 \ - --steps=$steps \ - --repeat=$repeat \ --chain="${chain}" \ --pallet="$pallet" \ --extrinsic="*" \ - --output="./runtimes/${runtime}/src/weights/" + --output="./runtimes/${runtime}/src/weights/" \ + $additional_args done From 708eb33b7a428ff2c4e2f9efdb39d23557f77596 Mon Sep 17 00:00:00 2001 From: Antonio Antonino Date: Tue, 17 Sep 2024 10:06:56 +0200 Subject: [PATCH 06/11] Adjust flags --- scripts/run_benches_for_runtime.sh | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/scripts/run_benches_for_runtime.sh b/scripts/run_benches_for_runtime.sh index 3a34f8181..1944c757d 100755 --- a/scripts/run_benches_for_runtime.sh +++ b/scripts/run_benches_for_runtime.sh @@ -61,24 +61,21 @@ cargo build $standard_args if [ $profile == "dev" ]; then target_folder="debug" # We care about benchmark correctness, not accuracy. - additional_args="--steps=1 --repeat=1 --default-pov-mode=ignored --no-verify" + additional_args="--steps=2 --repeat=1 --default-pov-mode=ignored --no-verify" else target_folder=$profile - additional_args="" + additional_args="--header=\"HEADER-GPL\" --template=\".maintain/runtime-weight-template.hbs\" --output=\"./runtimes/${runtime}/src/weights/\"" fi for pallet in "${pallets[@]}"; do echo "Runtime: $runtime. Pallet: $pallet" # shellcheck disable=SC2086 ./target/$target_folder/kilt-parachain benchmark pallet \ - --template=".maintain/runtime-weight-template.hbs" \ - --header="HEADER-GPL" \ --wasm-execution=compiled \ --heap-pages=4096 \ --chain="${chain}" \ --pallet="$pallet" \ --extrinsic="*" \ - --output="./runtimes/${runtime}/src/weights/" \ $additional_args done From 7f3ce4130d72858e008f815d15e25f07ee03c23e Mon Sep 17 00:00:00 2001 From: Antonio Antonino Date: Tue, 17 Sep 2024 13:29:39 +0200 Subject: [PATCH 07/11] Fix workflow file --- .github/workflows/check-code.yml | 552 +++++++++++++++---------------- 1 file changed, 276 insertions(+), 276 deletions(-) diff --git a/.github/workflows/check-code.yml b/.github/workflows/check-code.yml index 040886420..892a2db80 100644 --- a/.github/workflows/check-code.yml +++ b/.github/workflows/check-code.yml @@ -13,282 +13,283 @@ concurrency: cancel-in-progress: true jobs: - # get-commit-head: - # name: Get HEAD commit message - # runs-on: ubuntu-latest - # outputs: - # headCommitMsg: ${{ steps.get-head-commit-message.outputs.headCommitMsg }} - - # steps: - # - name: Checkout repository - # uses: actions/checkout@v4 - # with: - # # We use different payloads depending on whether this is a `push` or a `pull_request` event - # ref: ${{ github.event.head_commit.id || github.event.pull_request.head.sha }} - - # - name: Get HEAD commit message - # id: get-head-commit-message - # run: echo "headCommitMsg=$(git show -s --format=%s)" >> "$GITHUB_OUTPUT" - - # cargo-clippy: - # name: Run Clippy checks - # runs-on: ubuntu-latest - # needs: get-commit-head - # if: ${{ !contains(needs.get-commit-head.outputs.headCommitMsg, 'ci-skip-rust') }} - - # strategy: - # matrix: - # features: - # - - # - --all-features - # fail-fast: false - - # steps: - # - name: Checkout repository - # uses: actions/checkout@v4 - - # - name: Free Disk Space - # uses: jlumbroso/free-disk-space@main - # with: - # tool-cache: true - - # - name: Set up Cargo cache - # uses: actions/cache@v4 - # with: - # path: | - # ~/.cargo/bin/ - # ~/.cargo/registry/index/ - # ~/.cargo/registry/cache/ - # ~/.cargo/git/db/ - # key: ${{ github.job }}-${{ github.ref }}-${{ matrix.features }}-${{ hashFiles('**/Cargo.lock') }} - - # - name: Run `cargo clippy` - # run: | - # docker run --rm \ - # -v "${GITHUB_WORKSPACE}:/workspace" \ - # -v "${HOME}/.cargo:/root/.cargo" \ - # -w /workspace \ - # -e SKIP_WASM_BUILD=1 \ - # paritytech/ci-unified:bullseye-1.74.0 \ - # bash -c "cargo clippy --all-targets --locked ${{ matrix.features }} -- -D warnings" - - # cargo-fmt: - # name: Check formatting - # runs-on: ubuntu-latest - # container: - # image: paritytech/ci-unified:bullseye-1.74.0 - # env: - # RUSTUP_NIGHTLY_VERSION: nightly-2023-10-02 - # needs: get-commit-head - # if: ${{ !contains(needs.get-commit-head.outputs.headCommitMsg, 'ci-skip-rust') }} - - # steps: - # - name: Checkout repository - # uses: actions/checkout@v4 - - # - name: Install nightly toolchain - # run: rustup toolchain add ${{ env.RUSTUP_NIGHTLY_VERSION }} - - # - name: Run `cargo fmt` - # # Latest nightly version matching the base rustc version (1.74.0) - # run: cargo +${{ env.RUSTUP_NIGHTLY_VERSION }} fmt -- --check - - # - name: Run `taplo` - # run: taplo fmt --check - - # integration-tests: - # name: Run Chopsticks tests - # runs-on: ubuntu-latest - # env: - # working-dir: ./integration-tests/chopsticks - # CI: true - # PEREGRINE_WASM_OVERRIDE: ../../target/debug/wbuild/peregrine-runtime/peregrine_runtime.wasm - # defaults: - # run: - # working-directory: ${{ env.working-dir }} - # needs: - # - get-commit-head - # if: ${{ !contains(needs.get-commit-head.outputs.headCommitMsg, 'ci-skip-integration-tests') }} - - # steps: - # - name: Checkout repository - # uses: actions/checkout@v4 - - # - name: Free Disk Space - # uses: jlumbroso/free-disk-space@main - # with: - # tool-cache: true - - # - name: Setup environment - # uses: actions/setup-node@v4 - # with: - # node-version-file: "${{ env.working-dir }}/.nvmrc" - - # - name: Install dependencies - # run: yarn --immutable - - # - name: Check TS - # run: yarn ts-check - - # - name: Check lints - # run: yarn lint - - # - name: Set up Cargo cache - # uses: actions/cache@v4 - # with: - # path: | - # ~/.cargo/bin/ - # ~/.cargo/registry/index/ - # ~/.cargo/registry/cache/ - # ~/.cargo/git/db/ - # key: ${{ github.job }}-${{ github.ref }}-${{ hashFiles('**/Cargo.lock') }} - - # - name: Build Peregrine runtime - # run: cargo build -p peregrine-runtime - - # - name: Run Chopsticks tests - # run: yarn test:CI - - # cargo-test: - # name: Run Cargo tests - # runs-on: ubuntu-latest - # needs: cargo-clippy - - # strategy: - # matrix: - # features: - # - - # - --all-features - # fail-fast: false - - # steps: - # - name: Checkout repository - # uses: actions/checkout@v4 - - # - name: Free Disk Space - # uses: jlumbroso/free-disk-space@main - # with: - # tool-cache: true - - # - name: Set up Cargo cache - # uses: actions/cache@v4 - # with: - # path: | - # ~/.cargo/bin/ - # ~/.cargo/registry/index/ - # ~/.cargo/registry/cache/ - # ~/.cargo/git/db/ - # key: ${{ github.job }}-${{ github.ref }}-${{ matrix.features }}-${{ hashFiles('**/Cargo.lock') }} - - # - name: Run `cargo test` - # run: | - # docker run --rm \ - # -v "${GITHUB_WORKSPACE}:/workspace" \ - # -v "${HOME}/.cargo:/root/.cargo" \ - # -w /workspace \ - # paritytech/ci-unified:bullseye-1.74.0 \ - # bash -c "cargo test --all-targets --locked ${{ matrix.features }}" - - # cargo-doc: - # name: Check Rustdoc - # runs-on: ubuntu-latest - # needs: cargo-clippy - - # strategy: - # matrix: - # features: - # - - # - --all-features - # fail-fast: false - - # steps: - # - name: Checkout repository - # uses: actions/checkout@v4 - - # - name: Free Disk Space - # uses: jlumbroso/free-disk-space@main - # with: - # tool-cache: true - - # - name: Set up Cargo cache - # uses: actions/cache@v4 - # with: - # path: | - # ~/.cargo/bin/ - # ~/.cargo/registry/index/ - # ~/.cargo/registry/cache/ - # ~/.cargo/git/db/ - # key: ${{ github.job }}-${{ github.ref }}-${{ hashFiles('**/Cargo.lock') }} - - # - name: Run `cargo doc` - # run: | - # docker run --rm \ - # -v "${GITHUB_WORKSPACE}:/workspace" \ - # -v "${HOME}/.cargo:/root/.cargo" \ - # -w /workspace \ - # -e RUSTDOCFLAGS='-D warnings' \ - # -e SKIP_WASM_BUILD=1 \ - # paritytech/ci-unified:bullseye-1.74.0 \ - # bash -c "cargo doc --no-deps --locked ${{ matrix.features }}" - - # try-runtime: - # name: Run try-runtime - # runs-on: ubuntu-latest - # needs: cargo-clippy - # env: - # TRY_RUNTIME_CLI_VERSION_TAG: v0.7.0 - # container: - # image: paritytech/ci-unified:bullseye-1.74.0 - - # strategy: - # matrix: - # runtime: - # - peregrine - # - spiritnet - # fail-fast: false - - # steps: - # - name: Checkout repository - # uses: actions/checkout@v4 - - # - name: Free Disk Space - # uses: jlumbroso/free-disk-space@main - # with: - # tool-cache: true - - # - name: Install try-runtime - # run: | - # curl -sL https://github.com/paritytech/try-runtime-cli/releases/download/${{ env.TRY_RUNTIME_CLI_VERSION_TAG }}/try-runtime-x86_64-unknown-linux-musl -o try-runtime - # chmod +x ./try-runtime - # ./try-runtime --version - - # - name: Set up Cargo cache - # uses: actions/cache@v4 - # with: - # path: | - # ~/.cargo/bin/ - # ~/.cargo/registry/index/ - # ~/.cargo/registry/cache/ - # ~/.cargo/git/db/ - # key: ${{ github.job }}-${{ github.ref }}-${{ hashFiles('**/Cargo.lock') }} - - # - name: Build runtime - # run: cargo build --release --locked -p ${{ matrix.runtime }}-runtime --features try-runtime - - # - name: Run `try-runtime` - # run: | - # ./try-runtime \ - # --runtime=./target/release/wbuild/${{ matrix.runtime }}-runtime/${{ matrix.runtime }}_runtime.compact.compressed.wasm \ - # on-runtime-upgrade \ - # --disable-spec-version-check \ - # --checks=all \ - # live \ - # --uri=wss://${{ matrix.runtime }}.kilt.io - - runtime-benchmarks: - name: Test benchmarks + get-commit-head: + name: Get HEAD commit message runs-on: ubuntu-latest - # needs: cargo-clippy + outputs: + headCommitMsg: ${{ steps.get-head-commit-message.outputs.headCommitMsg }} + + steps: + - name: Checkout repository + uses: actions/checkout@v4 + with: + # We use different payloads depending on whether this is a `push` or a `pull_request` event + ref: ${{ github.event.head_commit.id || github.event.pull_request.head.sha }} + + - name: Get HEAD commit message + id: get-head-commit-message + run: echo "headCommitMsg=$(git show -s --format=%s)" >> "$GITHUB_OUTPUT" + + cargo-clippy: + name: Run Clippy checks + runs-on: ubuntu-latest + needs: get-commit-head + if: ${{ !contains(needs.get-commit-head.outputs.headCommitMsg, 'ci-skip-rust') }} + + strategy: + matrix: + features: + - + - --all-features + fail-fast: false + + steps: + - name: Checkout repository + uses: actions/checkout@v4 + + - name: Free Disk Space + uses: jlumbroso/free-disk-space@main + with: + tool-cache: true + + - name: Set up Cargo cache + uses: actions/cache@v4 + with: + path: | + ~/.cargo/bin/ + ~/.cargo/registry/index/ + ~/.cargo/registry/cache/ + ~/.cargo/git/db/ + key: ${{ github.job }}-${{ github.ref }}-${{ matrix.features }}-${{ hashFiles('**/Cargo.lock') }} + + - name: Run `cargo clippy` + run: | + docker run --rm \ + -v "${GITHUB_WORKSPACE}:/workspace" \ + -v "${HOME}/.cargo:/root/.cargo" \ + -w /workspace \ + -e SKIP_WASM_BUILD=1 \ + paritytech/ci-unified:bullseye-1.74.0 \ + bash -c "cargo clippy --all-targets --locked ${{ matrix.features }} -- -D warnings" + + cargo-fmt: + name: Check formatting + runs-on: ubuntu-latest + container: + image: paritytech/ci-unified:bullseye-1.74.0 + env: + RUSTUP_NIGHTLY_VERSION: nightly-2023-10-02 + needs: get-commit-head + if: ${{ !contains(needs.get-commit-head.outputs.headCommitMsg, 'ci-skip-rust') }} + + steps: + - name: Checkout repository + uses: actions/checkout@v4 + + - name: Install nightly toolchain + run: rustup toolchain add ${{ env.RUSTUP_NIGHTLY_VERSION }} + + - name: Run `cargo fmt` + # Latest nightly version matching the base rustc version (1.74.0) + run: cargo +${{ env.RUSTUP_NIGHTLY_VERSION }} fmt -- --check + + - name: Run `taplo` + run: taplo fmt --check + + integration-tests: + name: Run Chopsticks tests + runs-on: ubuntu-latest + env: + working-dir: ./integration-tests/chopsticks + CI: true + PEREGRINE_WASM_OVERRIDE: ../../target/debug/wbuild/peregrine-runtime/peregrine_runtime.wasm + defaults: + run: + working-directory: ${{ env.working-dir }} + needs: + - get-commit-head + if: ${{ !contains(needs.get-commit-head.outputs.headCommitMsg, 'ci-skip-integration-tests') }} + + steps: + - name: Checkout repository + uses: actions/checkout@v4 + + - name: Free Disk Space + uses: jlumbroso/free-disk-space@main + with: + tool-cache: true + + - name: Setup environment + uses: actions/setup-node@v4 + with: + node-version-file: "${{ env.working-dir }}/.nvmrc" + + - name: Install dependencies + run: yarn --immutable + + - name: Check TS + run: yarn ts-check + + - name: Check lints + run: yarn lint + + - name: Set up Cargo cache + uses: actions/cache@v4 + with: + path: | + ~/.cargo/bin/ + ~/.cargo/registry/index/ + ~/.cargo/registry/cache/ + ~/.cargo/git/db/ + key: ${{ github.job }}-${{ github.ref }}-${{ hashFiles('**/Cargo.lock') }} + + - name: Build Peregrine runtime + run: cargo build -p peregrine-runtime + + - name: Run Chopsticks tests + run: yarn test:CI + + cargo-test: + name: Run Cargo tests + runs-on: ubuntu-latest + needs: cargo-clippy + + strategy: + matrix: + features: + - + - --all-features + fail-fast: false + + steps: + - name: Checkout repository + uses: actions/checkout@v4 + + - name: Free Disk Space + uses: jlumbroso/free-disk-space@main + with: + tool-cache: true + + - name: Set up Cargo cache + uses: actions/cache@v4 + with: + path: | + ~/.cargo/bin/ + ~/.cargo/registry/index/ + ~/.cargo/registry/cache/ + ~/.cargo/git/db/ + key: ${{ github.job }}-${{ github.ref }}-${{ matrix.features }}-${{ hashFiles('**/Cargo.lock') }} + + - name: Run `cargo test` + run: | + docker run --rm \ + -v "${GITHUB_WORKSPACE}:/workspace" \ + -v "${HOME}/.cargo:/root/.cargo" \ + -w /workspace \ + paritytech/ci-unified:bullseye-1.74.0 \ + bash -c "cargo test --all-targets --locked ${{ matrix.features }}" + + cargo-doc: + name: Check Rustdoc + runs-on: ubuntu-latest + needs: cargo-clippy + + strategy: + matrix: + features: + - + - --all-features + fail-fast: false + + steps: + - name: Checkout repository + uses: actions/checkout@v4 + + - name: Free Disk Space + uses: jlumbroso/free-disk-space@main + with: + tool-cache: true + + - name: Set up Cargo cache + uses: actions/cache@v4 + with: + path: | + ~/.cargo/bin/ + ~/.cargo/registry/index/ + ~/.cargo/registry/cache/ + ~/.cargo/git/db/ + key: ${{ github.job }}-${{ github.ref }}-${{ hashFiles('**/Cargo.lock') }} + + - name: Run `cargo doc` + run: | + docker run --rm \ + -v "${GITHUB_WORKSPACE}:/workspace" \ + -v "${HOME}/.cargo:/root/.cargo" \ + -w /workspace \ + -e RUSTDOCFLAGS='-D warnings' \ + -e SKIP_WASM_BUILD=1 \ + paritytech/ci-unified:bullseye-1.74.0 \ + bash -c "cargo doc --no-deps --locked ${{ matrix.features }}" + + try-runtime: + name: Run try-runtime + runs-on: ubuntu-latest + needs: cargo-clippy + env: + TRY_RUNTIME_CLI_VERSION_TAG: v0.7.0 + container: + image: paritytech/ci-unified:bullseye-1.74.0 + + strategy: + matrix: + runtime: + - peregrine + - spiritnet + fail-fast: false + + steps: + - name: Checkout repository + uses: actions/checkout@v4 + + - name: Free Disk Space + uses: jlumbroso/free-disk-space@main + with: + tool-cache: true + + - name: Install try-runtime + run: | + curl -sL https://github.com/paritytech/try-runtime-cli/releases/download/${{ env.TRY_RUNTIME_CLI_VERSION_TAG }}/try-runtime-x86_64-unknown-linux-musl -o try-runtime + chmod +x ./try-runtime + ./try-runtime --version + + - name: Set up Cargo cache + uses: actions/cache@v4 + with: + path: | + ~/.cargo/bin/ + ~/.cargo/registry/index/ + ~/.cargo/registry/cache/ + ~/.cargo/git/db/ + key: ${{ github.job }}-${{ github.ref }}-${{ hashFiles('**/Cargo.lock') }} + + - name: Build runtime + run: cargo build --release --locked -p ${{ matrix.runtime }}-runtime --features try-runtime + + - name: Run `try-runtime` + run: | + ./try-runtime \ + --runtime=./target/release/wbuild/${{ matrix.runtime }}-runtime/${{ matrix.runtime }}_runtime.compact.compressed.wasm \ + on-runtime-upgrade \ + --disable-spec-version-check \ + --checks=all \ + live \ + --uri=wss://${{ matrix.runtime }}.kilt.io + + test-runtime-benchmarks: + name: Test runtime benchmarks + runs-on: ubuntu-latest + needs: cargo-clippy + if: ${{ github.event_name == 'push'}} strategy: matrix: @@ -316,7 +317,6 @@ jobs: ~/.cargo/git/db/ key: ${{ github.job }}-${{ github.ref }}-${{ matrix.runtime }}-${{ hashFiles('**/Cargo.lock') }} - # We don't care if the weight files are updated. - name: Run runtime benchmarks run: | docker run --rm \ From 53252610b25f2c3ec34e534149f5359f5b1367ac Mon Sep 17 00:00:00 2001 From: Antonio Antonino Date: Tue, 17 Sep 2024 13:54:09 +0200 Subject: [PATCH 08/11] Bail early if a benchmark fails --- .github/workflows/check-code.yml | 2 +- scripts/run_benches_for_runtime.sh | 7 +++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/.github/workflows/check-code.yml b/.github/workflows/check-code.yml index 892a2db80..4699e54e5 100644 --- a/.github/workflows/check-code.yml +++ b/.github/workflows/check-code.yml @@ -324,4 +324,4 @@ jobs: -v "${HOME}/.cargo:/root/.cargo" \ -w /workspace \ paritytech/ci-unified:bullseye-1.74.0 \ - bash -c "bash -x scripts/run_benches_for_runtime.sh ${{ matrix.runtime }}-dev dev" + bash -c "bash -x scripts/run_benches_for_runtime.sh ${{ matrix.runtime }} dev" diff --git a/scripts/run_benches_for_runtime.sh b/scripts/run_benches_for_runtime.sh index 1944c757d..650ab27c8 100755 --- a/scripts/run_benches_for_runtime.sh +++ b/scripts/run_benches_for_runtime.sh @@ -78,4 +78,11 @@ for pallet in "${pallets[@]}"; do --extrinsic="*" \ $additional_args + bench_status=$? + + # Exit with error as soon as one benchmark fails + if [ $bench_status -ne 0 ]; then + exit $bench_status + fi + done From 040d3c330941be7fe2ec10c32f9586e1c82bb02a Mon Sep 17 00:00:00 2001 From: Antonio Antonino Date: Tue, 17 Sep 2024 14:00:42 +0200 Subject: [PATCH 09/11] Use release as the default profile --- scripts/run_benches_for_runtime.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/run_benches_for_runtime.sh b/scripts/run_benches_for_runtime.sh index 650ab27c8..d9d1112ce 100755 --- a/scripts/run_benches_for_runtime.sh +++ b/scripts/run_benches_for_runtime.sh @@ -5,7 +5,7 @@ # current Substrate reference machine: https://github.com/paritytech/substrate/pull/5848 runtime=${1-"peregrine"} -profile=${2-"dev"} +profile=${2-"release"} chain=$([ "$1" == "spiritnet" ] && echo "spiritnet-dev" || echo "dev") # Dev profile is the debug target From d8a43d450837b99ae27072ecfc8b2662c1d36042 Mon Sep 17 00:00:00 2001 From: Antonio Antonino Date: Fri, 20 Sep 2024 10:08:56 +0200 Subject: [PATCH 10/11] Clean up unused flags --- scripts/run_benches_for_pallets.sh | 4 ---- scripts/run_benches_for_runtime.sh | 1 - 2 files changed, 5 deletions(-) diff --git a/scripts/run_benches_for_pallets.sh b/scripts/run_benches_for_pallets.sh index 4c1915d45..aedf395d9 100755 --- a/scripts/run_benches_for_pallets.sh +++ b/scripts/run_benches_for_pallets.sh @@ -38,11 +38,7 @@ for pallet in "${pallets[@]}"; do ./target/release/kilt-parachain benchmark pallet \ --template=".maintain/weight-template.hbs" \ --header="HEADER-GPL" \ - --execution=wasm \ - --wasm-execution=compiled \ --heap-pages=4096 \ - --steps=50 \ - --repeat=20 \ --chain="${chain}" \ --pallet="$pallet" \ --extrinsic="*" \ diff --git a/scripts/run_benches_for_runtime.sh b/scripts/run_benches_for_runtime.sh index d9d1112ce..7e18e9eb5 100755 --- a/scripts/run_benches_for_runtime.sh +++ b/scripts/run_benches_for_runtime.sh @@ -71,7 +71,6 @@ for pallet in "${pallets[@]}"; do echo "Runtime: $runtime. Pallet: $pallet" # shellcheck disable=SC2086 ./target/$target_folder/kilt-parachain benchmark pallet \ - --wasm-execution=compiled \ --heap-pages=4096 \ --chain="${chain}" \ --pallet="$pallet" \ From 07c4d249fc2377aaf7c4a4e54cb17cf5546b3e6e Mon Sep 17 00:00:00 2001 From: Antonio Antonino Date: Fri, 20 Sep 2024 11:05:29 +0200 Subject: [PATCH 11/11] Adapted workflow after CI refactor merge --- .github/workflows/check-code.yml | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/.github/workflows/check-code.yml b/.github/workflows/check-code.yml index 1d83d5710..8b289a5d0 100644 --- a/.github/workflows/check-code.yml +++ b/.github/workflows/check-code.yml @@ -315,6 +315,11 @@ jobs: test-runtime-benchmarks: name: Test runtime benchmarks runs-on: ubuntu-latest + container: + image: paritytech/ci-unified:bullseye-1.74.0 + env: + # Configured by the Docker image. We can't change this unless the image does it. + CARGO_HOME: /usr/local/cargo needs: cargo-clippy if: ${{ github.event_name == 'push'}} @@ -338,17 +343,11 @@ jobs: uses: actions/cache@v4 with: path: | - ~/.cargo/bin/ - ~/.cargo/registry/index/ - ~/.cargo/registry/cache/ - ~/.cargo/git/db/ + ${{ env.CARGO_HOME }}/bin/ + ${{ env.CARGO_HOME }}/registry/index/ + ${{ env.CARGO_HOME }}/registry/cache/ + ${{ env.CARGO_HOME }}/git/db/ key: ${{ github.job }}-${{ github.ref }}-${{ matrix.runtime }}-${{ hashFiles('**/Cargo.lock') }} - name: Run runtime benchmarks - run: | - docker run --rm \ - -v "${GITHUB_WORKSPACE}:/workspace" \ - -v "${HOME}/.cargo:/root/.cargo" \ - -w /workspace \ - paritytech/ci-unified:bullseye-1.74.0 \ - bash -c "bash -x scripts/run_benches_for_runtime.sh ${{ matrix.runtime }} dev" + run: bash -x scripts/run_benches_for_runtime.sh ${{ matrix.runtime }} dev