Skip to content

Commit

Permalink
feat: add gas diff to CI workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
fedealconada committed Jan 5, 2024
1 parent d7f3462 commit 50904e5
Show file tree
Hide file tree
Showing 2 changed files with 64 additions and 1 deletion.
57 changes: 57 additions & 0 deletions .github/workflows/gas-diff.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
name: Report gas diff

on:
workflow_call:
# on:
# push:
# branches:
# - main
# pull_request:
# # Optionally configure to run only for changes in specific files. For example:
# # paths:
# # - src/**
# # - test/**
# # - foundry.toml
# # - remappings.txt
# # - .github/workflows/foundry-gas-diff.yml

jobs:
compare_gas_reports:
name: Compare
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
submodules: recursive

- uses: ./.github/actions/install

- name: Build contracts
run: forge build --sizes

- name: Check gas snapshots
run: forge snapshot --diff

- name: Run tests
run: forge test --gas-report > gasreport.ansi
env:
# make fuzzing semi-deterministic to avoid noisy gas cost estimation
# due to non-deterministic fuzzing (but still use pseudo-random fuzzing seeds)
FOUNDRY_FUZZ_SEED: 0x${{ github.event.pull_request.base.sha || github.sha }}

- name: Compare gas reports
uses: Rubilmax/[email protected]
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 }}
8 changes: 7 additions & 1 deletion .github/workflows/pull_request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,10 @@ jobs:
analyse:
name: Slither analysis
uses: ./.github/workflows/slither.yml
secrets: inherit
secrets: inherit

gas-diff:
name: Gas diff
uses: ./.github/workflows/gas-diff.yml
secrets: inherit

0 comments on commit 50904e5

Please sign in to comment.