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 3fb3591
Show file tree
Hide file tree
Showing 3 changed files with 72 additions and 58 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
89 changes: 47 additions & 42 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,46 +17,51 @@ concurrency:
cancel-in-progress: ${{ github.ref_name != 'main' }}

jobs:
prepare-binding:
name: Prepare Rspack Binding
runs-on: [self-hosted, benchmark]
steps:
- uses: actions/checkout@v4
- name: Init env
uses: ./.github/actions/env
- uses: ./.github/actions/prepare-rspack-binding
with:
path: ${{ env.RSPACK_DIR }}
test:
uses: ./.github/workflows/bench_rspack_pr.yml
with:
prNumber: 6553

bench:
needs: prepare-binding
runs-on: [self-hosted, benchmark]
timeout-minutes: 30
strategy:
matrix:
shardIndex: [1, 2, 3]
shardTotal: [3]
fail-fast: false
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Init env
uses: ./.github/actions/env
- uses: ./.github/actions/build-rspack
with:
path: ${{ env.RSPACK_DIR }}
- name: Run benchmark
run: node bin/cli.js bench --shard ${{ matrix.shardIndex }}/${{ matrix.shardTotal }}
- id: print-compare-results
name: Print compare results
run: |
result=$(node bin/cli.js compare --base latest --current current)
echo "$result"
echo "diff-result=${result//$'\n'/'@@'}" >> $GITHUB_OUTPUT
- name: Check Threshold
run: |
result='${{ steps.print-compare-results.outputs.diff-result }}';
if [[ $result =~ "Threshold exceeded" ]]; then
echo "Some benchmark cases exceed the threshold, please visit the previous step for more information"
exit 1
fi
# prepare-binding:
# name: Prepare Rspack Binding
# runs-on: [self-hosted, benchmark]
# steps:
# - uses: actions/checkout@v4
# - name: Init env
# uses: ./.github/actions/env
# - uses: ./.github/actions/prepare-rspack-binding
# with:
# path: ${{ env.RSPACK_DIR }}

# bench:
# needs: prepare-binding
# runs-on: [self-hosted, benchmark]
# timeout-minutes: 30
# strategy:
# matrix:
# shardIndex: [1, 2, 3]
# shardTotal: [3]
# fail-fast: false
# steps:
# - name: Checkout
# uses: actions/checkout@v4
# - name: Init env
# uses: ./.github/actions/env
# - uses: ./.github/actions/build-rspack
# with:
# path: ${{ env.RSPACK_DIR }}
# - name: Run benchmark
# run: node bin/cli.js bench --shard ${{ matrix.shardIndex }}/${{ matrix.shardTotal }}
# - id: print-compare-results
# name: Print compare results
# run: |
# result=$(node bin/cli.js compare --base latest --current current)
# echo "$result"
# echo "diff-result=${result//$'\n'/'@@'}" >> $GITHUB_OUTPUT
# - name: Check Threshold
# run: |
# result='${{ steps.print-compare-results.outputs.diff-result }}';
# if [[ $result =~ "Threshold exceeded" ]]; then
# echo "Some benchmark cases exceed the threshold, please visit the previous step for more information"
# exit 1
# fi

0 comments on commit 3fb3591

Please sign in to comment.