Skip to content

feat(benches): forge test --isolate #34

feat(benches): forge test --isolate

feat(benches): forge test --isolate #34

Workflow file for this run

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,forge_isolate_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
env:
GITHUB_HEAD_REF: ${{ github.head_ref }}
run: ./.github/scripts/commit-and-read-benchmarks.sh benches "${{ github.event_name }}" "${{ github.repository }}"
- name: Push branch for manual runs
if: github.event_name == 'workflow_dispatch'
run: |
git push origin "${{ steps.benchmark_results.outputs.branch_name }}"
echo "Pushed branch: ${{ steps.benchmark_results.outputs.branch_name }}"
- name: Create PR for manual runs
if: github.event_name == 'workflow_dispatch'
uses: actions/github-script@v7
with:
script: |
const branchName = '${{ steps.benchmark_results.outputs.branch_name }}';
const prComment = `${{ steps.benchmark_results.outputs.pr_comment }}`;
// Create the pull request
const { data: pr } = await github.rest.pulls.create({
owner: context.repo.owner,
repo: context.repo.repo,
title: 'chore(bench): update benchmark results',
head: branchName,
base: 'master',
body: `## Benchmark Results Update
This PR contains the latest benchmark results from a manual workflow run.
${prComment}
---
🤖 This PR was automatically generated by the [Foundry Benchmarks workflow](https://github.com/${{ github.repository }}/actions).`
});
console.log(`Created PR #${pr.number}: ${pr.html_url}`);
- 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 prComment = `${{ steps.benchmark_results.outputs.pr_comment }}`;
const comment = `${prComment}
---
🤖 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
});