From 2e69031cc6b7148b5666dc29d4443c559cc6d069 Mon Sep 17 00:00:00 2001 From: rymnc <43716372+rymnc@users.noreply.github.com> Date: Thu, 3 Apr 2025 23:31:45 +0530 Subject: [PATCH 1/3] fix(ci): nightly benchmark --- .github/workflows/nightly-benchmark.yml | 37 +++++++++++++++++++++---- 1 file changed, 32 insertions(+), 5 deletions(-) diff --git a/.github/workflows/nightly-benchmark.yml b/.github/workflows/nightly-benchmark.yml index c2def4c3120..54ecb7b7102 100644 --- a/.github/workflows/nightly-benchmark.yml +++ b/.github/workflows/nightly-benchmark.yml @@ -21,30 +21,58 @@ jobs: benchmark: runs-on: group: fuelcore-benchmark + concurrency: + group: fuelcore-benchmark # only allow one benchmark run at a time + cancel-in-progress: false outputs: benchmark_results: ${{ steps.benchmarks.outputs.benchmark_results }} steps: - name: Checkout uses: actions/checkout@v4 + - name: Install Rust Toolchain uses: dtolnay/rust-toolchain@master with: toolchain: ${{ env.RUST_VERSION }} targets: "wasm32-unknown-unknown" + + - name: Install criterion + run: cargo install cargo-criterion + - name: Cache uses: Swatinem/rust-cache@v2 + - name: Run benchmarks - id: benchmarks + id: run_benchmarks run: | cargo criterion -p fuel-core-benches --message-format json --bench vm > nightly_benchmarks.json cargo run -p fuel-core-benches --bin collect --release -- --input nightly_benchmarks.json --format consensus-parameters --output nightly_benchmarks.json - echo "benchmark_results=$(cat nightly_benchmarks.json | tr -d '\n' | jq '.${{ env.CONSENSUS_PARAMETERS_VERSION }}.gas_costs')" >> "$GITHUB_OUTPUT" # this will fail when consensus parameters version changes + + - name: Archive benchmark results + uses: actions/upload-artifact@v4 + with: + name: nightly_benchmarks.json + path: nightly_benchmarks.json + + - name: Set benchmark result output + id: benchmarks + run: | # this will fail when consensus parameters version changes + echo "benchmark_results=$(cat nightly_benchmarks.json | tr -d '\n' | jq '.${{ env.CONSENSUS_PARAMETERS_VERSION }}.gas_costs')" >> "$GITHUB_OUTPUT" + create_pr: needs: benchmark runs-on: ubuntu-latest - if: ${{ github.event.inputs.create_pr == 'true' }} + permissions: + pull-requests: write + + if: ${{ github.event.inputs.create_pr == 'true' || github.event_name == 'pull_request' }} steps: - - uses: actions/checkout@v4 + - name: Checkout + uses: actions/checkout@v4 + + - name: Install GitHub CLI + uses: actions4gh/setup-gh@v1 + - run: | jq --argjson benchmark_results "$benchmark_results" \ '.consensus_parameters.${{ env.CONSENSUS_PARAMETERS_VERSION }}.gas_costs = $benchmark_results' \ @@ -55,7 +83,6 @@ jobs: branch_name="chore/benchmark-update-$(date +%s)" git checkout -b "$branch_name" git add bin/fuel-core/chainspec/local-testnet/chain_config.json - git config user.name 'github-actions[bot]' git config user.email 'github-actions[bot]@users.noreply.github.com' git commit -m "Update benchmark results" From b71985de3e6858c1509b2df1892017093fa33559 Mon Sep 17 00:00:00 2001 From: rymnc <43716372+rymnc@users.noreply.github.com> Date: Thu, 3 Apr 2025 23:50:39 +0530 Subject: [PATCH 2/3] fix: remove gh cli --- .github/workflows/nightly-benchmark.yml | 3 --- 1 file changed, 3 deletions(-) diff --git a/.github/workflows/nightly-benchmark.yml b/.github/workflows/nightly-benchmark.yml index 54ecb7b7102..6994e9442b6 100644 --- a/.github/workflows/nightly-benchmark.yml +++ b/.github/workflows/nightly-benchmark.yml @@ -70,9 +70,6 @@ jobs: - name: Checkout uses: actions/checkout@v4 - - name: Install GitHub CLI - uses: actions4gh/setup-gh@v1 - - run: | jq --argjson benchmark_results "$benchmark_results" \ '.consensus_parameters.${{ env.CONSENSUS_PARAMETERS_VERSION }}.gas_costs = $benchmark_results' \ From b4767e27904b274d7034f3c402e9c4b7ae7a8c2d Mon Sep 17 00:00:00 2001 From: rymnc <43716372+rymnc@users.noreply.github.com> Date: Fri, 4 Apr 2025 01:36:29 +0530 Subject: [PATCH 3/3] fix: strip newline after jq --- .github/workflows/nightly-benchmark.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/nightly-benchmark.yml b/.github/workflows/nightly-benchmark.yml index 6994e9442b6..c2cdf43e604 100644 --- a/.github/workflows/nightly-benchmark.yml +++ b/.github/workflows/nightly-benchmark.yml @@ -57,7 +57,7 @@ jobs: - name: Set benchmark result output id: benchmarks run: | # this will fail when consensus parameters version changes - echo "benchmark_results=$(cat nightly_benchmarks.json | tr -d '\n' | jq '.${{ env.CONSENSUS_PARAMETERS_VERSION }}.gas_costs')" >> "$GITHUB_OUTPUT" + echo "benchmark_results=$(cat nightly_benchmarks.json | jq '.${{ env.CONSENSUS_PARAMETERS_VERSION }}.gas_costs' | tr -d '\n' )" >> "$GITHUB_OUTPUT" create_pr: needs: benchmark