Feat/improve gas report #1
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 | |
jobs: | |
generate-gas-report: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 # Fetch all history for git diff | |
- 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 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 | |
uses: actions/download-artifact@v4 | |
with: | |
name: gas-report-${{ github.event.pull_request.base.sha }} | |
path: previous_gas_report | |
- name: Download current gas report | |
uses: actions/download-artifact@v4 | |
with: | |
name: gas-report-${{ github.sha }} | |
path: current_gas_report | |
- name: Compare gas reports | |
run: | | |
node compareGasReports.js previous_gas_report/GAS_REPORT.md current_gas_report/GAS_REPORT.md > gas_report_diff.md | |
id: compare-gas-reports | |
- name: Upload gas report comparison | |
uses: actions/upload-artifact@v4 | |
with: | |
name: gas-report-comparison-${{ github.sha }} | |
path: gas_report_diff.md | |
- name: Create pull request comment | |
uses: marocchino/sticky-pull-request-comment@v2 | |
with: | |
token: ${{ secrets.GITHUB_TOKEN }} | |
header: Gas Report Comparison | |
message: | | |
```diff | |
${{ steps.compare-gas-reports.outputs.gas_report_diff }} | |
``` |