Feat/improve gas report #5
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Gas Report | |
on: | |
pull_request: | |
branches: | |
- dev | |
- main | |
permissions: write-all | |
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: Upload gas report artifact | |
uses: actions/upload-artifact@v4 | |
with: | |
name: gas-report-${{ github.sha }} | |
path: GAS_REPORT.md | |
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 | |
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 | |
id: compare-gas-reports | |
- 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: 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 | |
${{ steps.compare-gas-reports.outputs.gas_report_diff }} | |
``` |