Skip to content

Commit

Permalink
ci(github): Update CI to report gas difference (#34)
Browse files Browse the repository at this point in the history
Using Rubilmax/foundry-gas-diff
  • Loading branch information
parv3213 authored Jan 29, 2024
1 parent 0f6dd03 commit 778bdc8
Showing 1 changed file with 31 additions and 6 deletions.
37 changes: 31 additions & 6 deletions .github/workflows/PR-CI.yml
Original file line number Diff line number Diff line change
@@ -1,16 +1,20 @@
name: Forge Test
name: Forge Test and Gas Difference

on:
pull_request:
push:
branches:
- main
- staging
- dev
push:
pull_request:
branches:
- main
- staging
- dev
# Optionally configure to run only for changes in specific files. For example:
paths:
- contracts/**
- test/**
- foundry.toml
- .github/workflows/PR-CI.yml

jobs:
check:
Expand Down Expand Up @@ -39,10 +43,31 @@ jobs:
- name: Check formatting
run: npm run prettier-check

# Generate a gas report to a temporary file named gasreport.ansi.
- name: Run tests
run: forge test -vvv
run: forge test --gas-report 2>&1 | tee >(cat) > gasreport.ansi # <- this file name should be unique in your repository!
env:
# make fuzzing semi-deterministic to avoid noisy gas cost estimation
# due to non-deterministic fuzzing (but still use pseudo-random fuzzing seeds)
FOUNDRY_PROFILE: ci
FOUNDRY_FUZZ_SEED: 0x${{ github.event.pull_request.base.sha || github.sha }}
TEST_MNEMONIC: ${{ secrets.TEST_MNEMONIC }}
ARB_URL: ${{ secrets.ARB_URL }}
FORK_BLOCK: ${{secrets.FORK_BLOCK}}

- name: Compare gas reports
uses: Rubilmax/foundry-gas-diff@v3.16
with:
summaryQuantile: 0.9 # only display the 10% most significant gas diffs in the summary (defaults to 20%)
sortCriteria: avg,max # sort diff rows by criteria
sortOrders: desc,asc # and directions
ignore: test-foundry/**/* # filter out gas reports from specific paths (test/ is included by default)
id: gas_diff

- name: Add gas diff to sticky comment
if: github.event_name == 'pull_request' || github.event_name == 'pull_request_target'
uses: marocchino/sticky-pull-request-comment@v2
with:
# delete the comment in case changes no longer impact gas costs
delete: ${{ !steps.gas_diff.outputs.markdown }}
message: ${{ steps.gas_diff.outputs.markdown }}

0 comments on commit 778bdc8

Please sign in to comment.