GitHub Action
Generate gas diff
Easily generate & compare gas reports automatically generated by Foundry on each of your Pull Requests!
Contract | Method | Avg (+/-) | % |
---|---|---|---|
PositionsManager | supplyLogic borrowLogic |
+849 ❌ +702 ❌ |
+0.25% +0.13% |
Morpho | supply | +809 ❌ | +0.23% |
Full diff report 👇
Contract | Deployment Cost (+/-) | Method | Min (+/-) | % | Avg (+/-) | % | Median (+/-) | % | Max (+/-) | % | # Calls (+/-) |
---|---|---|---|---|---|---|---|---|---|---|---|
PositionsManager | 4,546,050 (+14,617) | supplyLogic borrowLogic |
737 (0) 148,437 (0) |
0.00% 0.00% |
365,894 (+849) 542,977 (+702) |
+0.25% +0.13% |
383,960 (+995) 438,816 (0) |
+0.27% 0.00% |
2,121,294 (+304) 1,090,968 (0) |
+0.01% 0.00% |
500 (0) 292 (0) |
Morpho | 3,150,242 (0) | supply | 3,997 (0) | 0.00% | 371,586 (+809) | +0.23% | 395,247 (+995) | +0.27% | 2,125,764 (+304) | +0.01% | 502 (0) |
Add a workflow (.github/workflows/foundry-gas-diff.yml
):
name: Report gas diff
on:
push:
branches:
- main
pull_request:
# Optionally configure to run only for specific files. For example:
# paths:
# - "src/**"
jobs:
compare_gas_reports:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
# Add any build steps here. For example:
- run: forge test --gas-report > gasreport.ansi
- name: Compare gas reports
uses: Rubilmax/foundry-gas-diff@v3.4
with:
workflowId: foundry-gas-diff.yml # must be the name of the workflow file
ignore: test/**/* # optionally filter out gas reports from specific paths
id: gas_diff
- name: Add gas diff to sticky comment
uses: marocchino/sticky-pull-request-comment@v2
with:
message: ${{ steps.gas_diff.outputs.markdown }}
The workflow ID the reference gas report was uploaded from.
By default, the reference gas report of next workflow runs are uploaded by this action from the previous workflow runs,
thus it should correspond to the ID of the workflow this action is defined in: foundry-gas-diff.yml
in the above example.
The github token allowing the action to upload and download gas reports generated by foundry.
Defaults to: ${{ github.token }}
This should correspond to the path of a file where the output of forge's gas report has been logged. Only necessary when generating multiple gas reports in the same workflow.
Defaults to: gasreport.ansi
The title displayed in the markdown output. Can be used to identify multiple gas diffs in the same PR.
Defaults to: Changes to gas cost
The list of paths from which to ignore gas reports, separated by a comma. This allows to clean out gas diffs from dependency contracts impacted by a change (e.g. Proxies, ERC20, ...).
No default assigned: optional opt-in (Please note that node dependencies are always discarded from gas reports)
The list of paths of which only to keep gas reports, separated by a comma. This allows to only display gas diff of specific contracts.
No default assigned: optional opt-in
This repository is maintained independently from Foundry and may not work as expected with all versions of forge
.