-
Notifications
You must be signed in to change notification settings - Fork 10
108 lines (92 loc) · 3.05 KB
/
gas_report.yml
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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
name: Gas Report
on:
pull_request:
branches:
- dev
- main
jobs:
generate-gas-report:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: '20'
- name: Cache Yarn dependencies
uses: actions/cache@v4
with:
path: |
~/.cache/yarn
**/node_modules
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
${{ runner.os }}-yarn-
- name: Install dependencies
run: yarn install
- name: Run gas report script
run: node scripts/foundry/generateGasReport.js
- name: Check gas report file exists
run: |
if [ ! -f GAS_REPORT.md ]; then
echo "GAS_REPORT.md does not exist."
exit 1
fi
- name: Upload gas report artifact
uses: actions/upload-artifact@v4
with:
name: gas-report-${{ github.sha }}
path: GAS_REPORT.md
if-no-files-found: warn
compare-gas-report:
runs-on: ubuntu-latest
needs: generate-gas-report
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Download previous gas report
id: download-previous
uses: actions/download-artifact@v4
with:
name: gas-report-${{ github.event.pull_request.base.sha }}
path: previous_gas_report
continue-on-error: true
- name: Download current gas report
uses: actions/download-artifact@v4
with:
name: gas-report-${{ github.sha }}
path: current_gas_report
- name: Compare gas reports
id: compare-gas-reports
if: steps.download-previous.outcome == 'success'
run: |
node scripts/foundry/compareGasReports.js previous_gas_report/GAS_REPORT.md current_gas_report/GAS_REPORT.md > gas_report_diff.md
- name: Handle no previous report
if: steps.download-previous.outcome != 'success'
run: echo "No previous gas report found. Skipping comparison."
- name: Upload gas report comparison
if: steps.compare-gas-reports.outcome == 'success'
uses: actions/upload-artifact@v4
with:
name: gas-report-comparison-${{ github.sha }}
path: gas_report_diff.md
- name: Read gas report comparison
if: steps.compare-gas-reports.outcome == 'success'
id: read-gas-report-comparison
run: echo "gas_report_diff=$(<gas_report_diff.md)" >> $GITHUB_ENV
- name: Create pull request comment
if: steps.compare-gas-reports.outcome == 'success'
uses: marocchino/sticky-pull-request-comment@v2
with:
token: ${{ secrets.GITHUB_TOKEN }}
header: Gas Report Comparison
message: |
## Gas Report Comparison
```diff
${{ env.gas_report_diff }}
```