[DOCS] Auto-gen doc pages based on codebase #232
This file contains hidden or 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: | |
| paths-ignore: | |
| - '**.md' | |
| - 'website/**' | |
| workflow_dispatch: | |
| env: | |
| FOUNDRY_PROFILE: ci | |
| permissions: | |
| contents: read | |
| jobs: | |
| generate-report: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout PR branch | |
| uses: actions/checkout@v4 | |
| with: | |
| submodules: recursive | |
| - name: Install Foundry | |
| uses: foundry-rs/foundry-toolchain@v1 | |
| - name: Generate gas snapshot for PR | |
| run: forge snapshot --snap .gas-snapshot-pr | |
| - name: Checkout base branch | |
| uses: actions/checkout@v4 | |
| with: | |
| ref: ${{ github.event.pull_request.base.sha }} | |
| submodules: recursive | |
| - name: Generate gas snapshot for base | |
| run: | | |
| forge snapshot --snap .gas-snapshot-base | |
| # Copy base snapshot to temp location so it survives checkout | |
| cp .gas-snapshot-base /tmp/gas-snapshot-base | |
| - name: Checkout PR branch again | |
| uses: actions/checkout@v4 | |
| with: | |
| submodules: recursive | |
| - name: Restore base snapshot | |
| run: cp /tmp/gas-snapshot-base .gas-snapshot-base | |
| - name: Generate gas report | |
| env: | |
| BASE_BRANCH: ${{ github.event.pull_request.base.ref }} | |
| HEAD_BRANCH: ${{ github.event.pull_request.head.ref }} | |
| HEAD_SHA: ${{ github.event.pull_request.head.sha }} | |
| GITHUB_REPOSITORY: ${{ github.repository }} | |
| run: | | |
| # Run diff and capture output (compares current PR state to base snapshot) | |
| forge snapshot --diff .gas-snapshot-base > gas-diff.txt 2>&1 || true | |
| # Generate the formatted report | |
| node .github/scripts/gas-report.js generate | |
| # Create metadata file for the comment workflow | |
| echo "PR_NUMBER=${{ github.event.pull_request.number }}" > gas-report-data.txt | |
| echo "BASE_BRANCH=${{ github.event.pull_request.base.ref }}" >> gas-report-data.txt | |
| echo "HEAD_BRANCH=${{ github.event.pull_request.head.ref }}" >> gas-report-data.txt | |
| echo "HEAD_SHA=${{ github.event.pull_request.head.sha }}" >> gas-report-data.txt | |
| echo "Generated gas report for PR #${{ github.event.pull_request.number }}" | |
| - name: Upload gas report | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: gas-report-data | |
| path: | | |
| gas-report.md | |
| gas-report-data.txt | |
| gas-diff.txt | |
| retention-days: 1 | |
| - name: Upload debug artifacts | |
| if: failure() | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: gas-snapshots-debug | |
| path: | | |
| .gas-snapshot* | |
| gas-diff.txt |