-
Notifications
You must be signed in to change notification settings - Fork 10
57 lines (49 loc) · 1.67 KB
/
Copy pathgas.yml
File metadata and controls
57 lines (49 loc) · 1.67 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
name: Report gas diff
on:
push:
pull_request:
paths:
- src/**
- test/**
- foundry.toml
- .github/workflows/gas.yml
workflow_dispatch:
env:
FOUNDRY_PROFILE: ci
jobs:
compare_gas_reports:
runs-on: ubuntu-latest
permissions:
pull-requests: write
steps:
- uses: actions/checkout@v4
with:
submodules: recursive
- name: Install Foundry
uses: foundry-rs/foundry-toolchain@v1
with:
version: nightly
- name: Show Forge version
run: |
forge --version
# Do not count negative and fuzz tests toward gas calculations since they can add noise
# (https://book.getfoundry.sh/guides/best-practices?highlight=best%20pr#general-test-guidance)
- name: Run Forge tests
run: |
forge test --no-match-test "(RevertWhen|testFuzz)" --gas-report --color never | tee gasreport.ansi
id: test
- name: Compare gas reports
uses: Rubilmax/foundry-gas-diff@v3
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
base: ${{ github.base_ref }}
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 }}