diff --git a/.github/workflows/benchmark.yml b/.github/workflows/benchmark.yml index 09ffd2b..01e91cc 100644 --- a/.github/workflows/benchmark.yml +++ b/.github/workflows/benchmark.yml @@ -1,3 +1,5 @@ +# This workflow will run on the default branch when triggered by a `workflow_run` event. + name: Benchmark on: @@ -8,13 +10,14 @@ on: jobs: benchmark: runs-on: ubuntu-24.04 - # TODO: Add condition that the base branch in the PR is main. if: ${{ github.event.workflow_run.conclusion == 'success' && github.event.workflow_run.event == 'pull_request' }} permissions: pull-requests: write steps: - - name: Checkout + - name: Checkout PR Branch uses: actions/checkout@v4 + with: + ref: ${{ github.event.workflow_run.head_sha }} - name: Set Up Rust Toolchain uses: actions-rust-lang/setup-rust-toolchain@v1 @@ -36,76 +39,81 @@ jobs: - name: Install Benchmarking Tools run: | - cargo install cargo-criterion critcmp + cargo install critcmp - name: Checkout and Compile Main Branch run: | - git fetch origin "$GITHUB_DEFAULT_BRANCH":"$GITHUB_DEFAULT_BRANCH" - git checkout -f "$GITHUB_DEFAULT_BRANCH" + git fetch origin main + git checkout -f main make install - name: Run Benchmarks on Main Branch run: | - cargo bench --package resolc --bench compile -- --save-baseline main-resolc - cargo bench --package revive-yul --bench parse -- --save-baseline main-yul-parse - cargo bench --package revive-yul --bench lower -- --save-baseline main-yul-lower + cargo bench --package resolc --bench compile -- --save-baseline main_branch_resolc + cargo bench --package revive-yul --bench parse -- --save-baseline main_branch_yul_parse + cargo bench --package revive-yul --bench lower -- --save-baseline main_branch_yul_lower timeout-minutes: 20 - name: Checkout and Compile PR Branch run: | - git checkout -f ${{ github.sha }} + git checkout -f ${{ github.event.workflow_run.head_sha }} make install - name: Run Benchmarks on PR Branch run: | - cargo bench --package resolc --bench compile -- --save-baseline pr-resolc - cargo bench --package revive-yul --bench parse -- --save-baseline pr-yul-parse - cargo bench --package revive-yul --bench lower -- --save-baseline pr-yul-lower + cargo bench --package resolc --bench compile -- --save-baseline pr_branch_resolc + cargo bench --package revive-yul --bench parse -- --save-baseline pr_branch_yul_parse + cargo bench --package revive-yul --bench lower -- --save-baseline pr_branch_yul_lower timeout-minutes: 20 - name: Compare Benchmarks run: | - critcmp main-resolc pr-resolc > benchmarks-resolc - critcmp main-yul-parse pr-yul-parse > benchmarks-yul-parse - critcmp main-yul-lower pr-yul-lower > benchmarks-yul-lower + critcmp main_branch_resolc pr_branch_resolc > benchmarks_resolc + critcmp main_branch_yul_parse pr_branch_yul_parse > benchmarks_yul_parse + critcmp main_branch_yul_lower pr_branch_yul_lower > benchmarks_yul_lower - - name: Post PR Comment with Benchmark Results + - name: Create Report + run: | + cat > BENCHMARK_REPORT.md << EOF + # Benchmarks + + ## Compile E2E + +
+ Details + + \`\`\` + $(cat benchmarks_resolc) + \`\`\` + +
+ + ## Parse Yul + +
+ Details + + \`\`\` + $(cat benchmarks_yul_parse) + \`\`\` + +
+ + ## Lower Yul + +
+ Details + + \`\`\` + $(cat benchmarks_yul_lower) + \`\`\` + +
+ EOF + + - name: Post PR Comment with Benchmark Report uses: marocchino/sticky-pull-request-comment@v2 with: header: benchmark number: ${{ github.event.workflow_run.pull_requests[0].number }} - message: | - # Benchmarks - - ## Compile E2E - -
- Details - - ``` - $(cat benchmarks-resolc) - ``` - -
- - ## Parse Yul - -
- Details - - ``` - $(cat benchmarks-yul-parse) - ``` - -
- - ## Lower Yul - -
- Details - - ``` - $(cat benchmarks-yul-lower) - ``` - -
+ path: BENCHMARK_REPORT.md