From ec58bd949a0f76887a94c5240a0556d44ce94b72 Mon Sep 17 00:00:00 2001 From: CJ42 Date: Tue, 26 Sep 2023 16:37:57 +0100 Subject: [PATCH] ci: update gas benchmark CI with new diff flow --- .github/workflows/benchmark.yml | 36 ++++++++++++++++++++++++++++++--- 1 file changed, 33 insertions(+), 3 deletions(-) diff --git a/.github/workflows/benchmark.yml b/.github/workflows/benchmark.yml index 0fb243e1f..e9bb36b25 100644 --- a/.github/workflows/benchmark.yml +++ b/.github/workflows/benchmark.yml @@ -22,7 +22,11 @@ jobs: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 + - name: Checkout base branch + uses: actions/checkout@v3 + with: + ref: ${{ github.event.pull_request.base.sha }} + fetch-depth: 0 - name: Use Node.js '16.15.0' uses: actions/setup-node@v2 @@ -37,11 +41,37 @@ jobs: run: npx hardhat compile - name: ๐Ÿงช Run Benchmark tests - run: npm run test:benchmark + # Rename the file to be able to generate benchmark JSON report + run: | + npm run test:benchmark + mv gas_benchmark_result.json gas_benchmark_before.json + + - name: Checkout current branch + uses: actions/checkout@v3 + + - name: Use Node.js '16.15.0' + uses: actions/setup-node@v2 + with: + node-version: "16.15.0" + cache: "npm" + + - name: ๐Ÿ“ฆ Install dependencies + run: npm ci + + - name: ๐Ÿ—๏ธ Build contract artifacts + run: npx hardhat compile + + - name: ๐Ÿงช Run Benchmark tests + run: | + npm run test:benchmark + mv gas_benchmark_result.json gas_benchmark_after.json - name: ๐Ÿ“Š Generate Benchmark Report + run: npx hardhat gas-benchmark --compare gas_benchmark_after.json --against gas_benchmark_before.json + + - name: ๐Ÿ’ฌ Add Gas Report as comment in PR uses: peter-evans/create-or-update-comment@v2 with: token: ${{ secrets.GITHUB_TOKEN }} issue-number: ${{ github.event.pull_request.number }} - body-file: "./benchmark.md" + body-file: "./gas_benchmark.md"