feat: benchmark suite #20
Workflow file for this run
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: Foundry Benchmarks | |
| on: | |
| pull_request: | |
| types: [opened, synchronize, reopened] | |
| workflow_dispatch: | |
| inputs: | |
| pr_number: | |
| description: "PR number to comment on (optional)" | |
| required: false | |
| type: string | |
| versions: | |
| description: "Comma-separated list of Foundry versions to benchmark (e.g., stable,nightly,v1.0.0)" | |
| required: false | |
| type: string | |
| default: "stable,nightly" | |
| repos: | |
| description: "Comma-separated list of repos to benchmark (e.g., ithacaxyz/account:main,Vectorized/solady)" | |
| required: false | |
| type: string | |
| default: "ithacaxyz/account:v0.3.2,Vectorized/solady:v0.1.22" | |
| permissions: | |
| contents: write | |
| pull-requests: write | |
| env: | |
| ITHACAXYZ_ACCOUNT: "ithacaxyz/account:v0.3.2" | |
| VECTORIZED_SOLADY: "Vectorized/solady:v0.1.22" | |
| DEFAULT_REPOS: "ithacaxyz/account:v0.3.2,Vectorized/solady:v0.1.22" | |
| jobs: | |
| setup: | |
| name: Setup and Build | |
| runs-on: foundry-runner | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| - name: Install build dependencies | |
| run: | | |
| sudo apt-get update | |
| sudo apt-get install -y build-essential pkg-config | |
| - name: Setup Rust toolchain | |
| uses: dtolnay/rust-toolchain@stable | |
| - name: Cache Rust dependencies | |
| uses: Swatinem/rust-cache@v2 | |
| with: | |
| workspaces: | | |
| ./ | |
| - name: Setup Foundry | |
| env: | |
| FOUNDRY_DIR: ${{ github.workspace }}/.foundry | |
| run: | | |
| ./.github/scripts/setup-foundryup.sh | |
| echo "${{ github.workspace }}/.foundry/bin" >> $GITHUB_PATH | |
| - name: Build benchmark binary | |
| run: cargo build --release --bin foundry-bench | |
| - name: Upload benchmark binary | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: foundry-bench | |
| path: target/release/foundry-bench | |
| forge-test-bench: | |
| name: Forge Test Benchmarks | |
| needs: setup | |
| runs-on: foundry-runner | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| - name: Benchmark setup | |
| uses: ./.github/actions/benchmark-setup | |
| - name: Run forge test benchmarks | |
| env: | |
| FOUNDRY_DIR: ${{ github.workspace }}/.foundry | |
| run: | | |
| VERSIONS="${{ github.event.inputs.versions || 'stable,nightly' }}" | |
| REPOS="${{ github.event.inputs.repos || env.DEFAULT_REPOS }}" | |
| ./foundry-bench --output-dir ./benches --force-install \ | |
| --versions $VERSIONS \ | |
| --repos $REPOS \ | |
| --benchmarks forge_test,forge_fuzz_test \ | |
| --output-file forge_test_bench.md | |
| - name: Upload test benchmark results | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: forge-test-results | |
| path: benches/forge_test_bench.md | |
| forge-build-bench: | |
| name: Forge Build Benchmarks | |
| needs: setup | |
| runs-on: foundry-runner | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| - name: Benchmark setup | |
| uses: ./.github/actions/benchmark-setup | |
| - name: Run forge build benchmarks | |
| env: | |
| FOUNDRY_DIR: ${{ github.workspace }}/.foundry | |
| run: | | |
| VERSIONS="${{ github.event.inputs.versions || 'stable,nightly' }}" | |
| REPOS="${{ github.event.inputs.repos || env.DEFAULT_REPOS }}" | |
| ./foundry-bench --output-dir ./benches --force-install \ | |
| --versions $VERSIONS \ | |
| --repos $REPOS \ | |
| --benchmarks forge_build_no_cache,forge_build_with_cache \ | |
| --output-file forge_build_bench.md | |
| - name: Upload build benchmark results | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: forge-build-results | |
| path: benches/forge_build_bench.md | |
| forge-coverage-bench: | |
| name: Forge Coverage Benchmarks | |
| needs: setup | |
| runs-on: foundry-runner | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| - name: Benchmark setup | |
| uses: ./.github/actions/benchmark-setup | |
| - name: Run forge coverage benchmarks | |
| env: | |
| FOUNDRY_DIR: ${{ github.workspace }}/.foundry | |
| run: | | |
| VERSIONS="${{ github.event.inputs.versions || 'stable,nightly' }}" | |
| # Coverage only runs on ithacaxyz/account:v0.3.2 | |
| ./foundry-bench --output-dir ./benches --force-install \ | |
| --versions $VERSIONS \ | |
| --repos ${{ env.ITHACAXYZ_ACCOUNT }} \ | |
| --benchmarks forge_coverage \ | |
| --output-file forge_coverage_bench.md | |
| - name: Upload coverage benchmark results | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: forge-coverage-results | |
| path: benches/forge_coverage_bench.md | |
| combine-results: | |
| name: Combine and Publish Results | |
| needs: [forge-test-bench, forge-build-bench, forge-coverage-bench] | |
| runs-on: foundry-runner | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| - name: Download all benchmark results | |
| uses: actions/download-artifact@v4 | |
| with: | |
| pattern: forge-*-results | |
| path: benches/ | |
| merge-multiple: true | |
| - name: Combine benchmark results | |
| run: ./.github/scripts/combine-benchmarks.sh benches | |
| - name: Commit and read benchmark results | |
| id: benchmark_results | |
| run: ./.github/scripts/commit-and-read-benchmarks.sh benches "${{ github.event_name }}" "${{ github.repository }}" | |
| - name: Comment on PR | |
| if: github.event.inputs.pr_number != '' || github.event_name == 'pull_request' | |
| uses: actions/github-script@v7 | |
| with: | |
| script: | | |
| const prNumber = ${{ github.event.inputs.pr_number || github.event.pull_request.number }}; | |
| const benchmarkResults = `${{ steps.benchmark_results.outputs.results }}`; | |
| const comment = `## 📊 Foundry Benchmark Results | |
| <details> | |
| <summary>Click to view detailed benchmark results</summary> | |
| ${benchmarkResults} | |
| </details> | |
| --- | |
| 🤖 This comment was automatically generated by the [Foundry Benchmarks workflow](https://github.com/${{ github.repository }}/actions). | |
| To run benchmarks manually: Go to [Actions](https://github.com/${{ github.repository }}/actions/workflows/benchmarks.yml) → "Run workflow"`; | |
| github.rest.issues.createComment({ | |
| issue_number: prNumber, | |
| owner: context.repo.owner, | |
| repo: context.repo.repo, | |
| body: comment | |
| }); |