Skip to content

Commit

Permalink
feat: new bench_rspack_pr
Browse files Browse the repository at this point in the history
  • Loading branch information
SyMind committed May 28, 2024
1 parent d5e3a4e commit e659024
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 16 deletions.
6 changes: 2 additions & 4 deletions .github/workflows/bench_rspack_commit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,10 @@ jobs:
with:
path: ${{ env.RSPACK_DIR }}
- name: Run benchmark
run: node bin/cli.js bench --shard ${{ matrix.shardIndex }}/${{ strategy.job-total }}
run: node bin/cli.js bench --shard ${{ matrix.shardIndex }}/${{ smatrix.shardTotal }}
- uses: actions/upload-artifact@v4
with:
name: benchmark-artifacts-${{ matrix.shardIndex }}-${{ strategy.job-total }}
name: benchmark-artifacts-${{ matrix.shardIndex }}-${{ matrix.shardTotal }}
path: output

comment-compare-results:
Expand All @@ -56,8 +56,6 @@ jobs:
pattern: benchmark-artifacts-*
path: output
merge-multiple: true
- shell: bash
run: ls -lah output
- id: print-results
name: Print results
run: |
Expand Down
35 changes: 23 additions & 12 deletions .github/workflows/bench_rspack_pr.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name: Bench Rspack PR

on:
workflow_dispatch:
workflow_call:
inputs:
prNumber:
description: "PR number (e.g. 9887)"
Expand Down Expand Up @@ -62,30 +62,41 @@ jobs:
path: ${{ env.RSPACK_DIR }}
ref: pull/${{ inputs.prNumber }}/head
- name: Run benchmark
run: >-
node bin/cli.js bench --shard ${{ matrix.shardIndex }}/${{ matrix.shardTotal }}
run: node bin/cli.js bench --shard ${{ matrix.shardIndex }}/${{ matrix.shardTotal }}
- uses: actions/upload-artifact@v4
with:
name: benchmark-artifacts-${{ matrix.shardIndex }}-${{ matrix.shardTotal }}
path: output

comment-compare-results:
runs-on: ubuntu-latest
needs: [create-comment, bench]
if: always()
steps:
- uses: actions/checkout@v4
- name: Init env
uses: ./.github/actions/env
- uses: actions/download-artifact@v4
with:
pattern: benchmark-artifacts-*
path: output
merge-multiple: true
- id: print-results
name: Print results
run: |
result=$(node bin/compare-bench.js latest current)
result=$(node bin/cli.js compare --base latest --current current)
echo "$result"
echo "diff-result=${result//$'\n'/'@@'}" >> $GITHUB_OUTPUT
if [[ $result =~ "Threshold exceeded" ]]; then
echo "Some benchmark cases exceed the threshold, please visit the previous step for more information"
exit 1
fi
update-comment:
runs-on: ubuntu-latest
needs: [create-comment, run-bench]
if: always()
steps:
- uses: actions/github-script@v6
with:
github-token: ${{ secrets.RSPACK_BOT_ACCESS_TOKEN }}
script: |
const diffResult = `${{ needs.run-bench.outputs.diff-result }}`
let result = "task ${{ needs.run-bench.result }}"
const diffResult = `${{ steps.print-results.outputs.diff-result }}`
let result = "task ${{ needs.bench.result }}"
if (diffResult) {
result = diffResult.replace(/@@/g, "\n");
}
Expand Down

0 comments on commit e659024

Please sign in to comment.