Skip to content

Commit

Permalink
ci: update gas benchmark CI with new diff flow
Browse files Browse the repository at this point in the history
  • Loading branch information
CJ42 committed Sep 26, 2023
1 parent 445be6c commit 9a73464
Showing 1 changed file with 37 additions and 4 deletions.
41 changes: 37 additions & 4 deletions .github/workflows/benchmark.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,32 @@ 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
with:
node-version: "16.15.0"
cache: "npm"

- name: 📦 Install dependencies
run: npm ci

- name: 🏗️ Build contract artifacts
run: npx hardhat compile --force

- name: 🧪 Run Benchmark tests
# 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
Expand All @@ -34,14 +59,22 @@ jobs:
run: npm ci

- name: 🏗️ Build contract artifacts
run: npx hardhat compile
# Clean artifacts to ensure we generate a clean build
run: |
npm run clean
npx hardhat compile --force
- name: 🧪 Run Benchmark tests
run: npm run test:benchmark
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"

0 comments on commit 9a73464

Please sign in to comment.