From 7694478912d38109efe0b560f0d22ab893cd9a5f Mon Sep 17 00:00:00 2001 From: alexfertel Date: Thu, 18 Jul 2024 13:36:15 +0200 Subject: [PATCH] feat(ci): add gas-benching workflow (#204) Resolves #169 --- .github/workflows/gas-bench.yml | 45 +++++++++++++++++++++++++++++++++ scripts/bench.sh | 13 ++++++++++ 2 files changed, 58 insertions(+) create mode 100644 .github/workflows/gas-bench.yml create mode 100755 scripts/bench.sh diff --git a/.github/workflows/gas-bench.yml b/.github/workflows/gas-bench.yml new file mode 100644 index 00000000..3c787e8e --- /dev/null +++ b/.github/workflows/gas-bench.yml @@ -0,0 +1,45 @@ +name: gas-bench +# This workflow checks that the compiled wasm binary of every example contract +# can be deployed to Arbitrum Stylus. +permissions: + contents: read +on: + push: + branches: [ main ] + pull_request: +concurrency: + group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }} + cancel-in-progress: true +env: + CARGO_TERM_COLOR: always +jobs: + required: + name: gas usage report + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + + - name: set up rust + uses: dtolnay/rust-toolchain@master + id: toolchain + with: + target: wasm32-unknown-unknown + components: rust-src + toolchain: nightly-2024-01-01 + + - uses: Swatinem/rust-cache@v2 + with: + cache-on-failure: true + + - name: install solc + run: | + curl -LO https://github.com/ethereum/solidity/releases/download/v0.8.21/solc-static-linux + sudo mv solc-static-linux /usr/bin/solc + sudo chmod a+x /usr/bin/solc + + - name: setup nitro node + run: ./scripts/nitro-testnode.sh -d -i + - name: run benches + run: | + export NIGHTLY_TOOLCHAIN=${{steps.toolchain.outputs.name}} + ./scripts/bench.sh diff --git a/scripts/bench.sh b/scripts/bench.sh new file mode 100755 index 00000000..8878daec --- /dev/null +++ b/scripts/bench.sh @@ -0,0 +1,13 @@ +#!/bin/bash +set -e + +MYDIR=$(realpath "$(dirname "$0")") +cd "$MYDIR" +cd .. + +NIGHTLY_TOOLCHAIN=${NIGHTLY_TOOLCHAIN:-nightly} +cargo +"$NIGHTLY_TOOLCHAIN" build --release --target wasm32-unknown-unknown -Z build-std=std,panic_abort -Z build-std-features=panic_immediate_abort + +export RPC_URL=http://localhost:8547 +cargo run --release -p benches +echo "Finished running benches!"