Skip to content

Bench Rspack Commit #1870

Bench Rspack Commit

Bench Rspack Commit #1870

name: Bench Rspack Commit
on:
workflow_dispatch:
inputs:
commit_sha:
description: "commit sha"
required: true
type: string
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 }}
ref: ${{ inputs.commit_sha }}
bench:
runs-on: [self-hosted, benchmark]
needs: prepare-binding
timeout-minutes: 30
strategy:
matrix:
shardIndex: [1]
shardTotal: [1]
fail-fast: false
steps:
- uses: actions/checkout@v4
- name: Init env
uses: ./.github/actions/env
- uses: ./.github/actions/build-rspack
with:
path: ${{ env.RSPACK_DIR }}
ref: ${{ inputs.commit_sha }}
- name: Run benchmark
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: 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/cli.js compare --base latest --current current)
echo "$result"
echo "diff-result=${result//$'\n'/'@@'}" >> $GITHUB_OUTPUT
- uses: actions/github-script@v6
with:
github-token: ${{ secrets.RSPACK_BOT_ACCESS_TOKEN }}
result-encoding: string
script: |
const diffResult = `${{ steps.print-results.outputs.diff-result }}`
let result = "task ${{ needs.bench.result }}"
if (diffResult) {
result = diffResult.replace(/@@/g, "\n");
}
const url = `${context.serverUrl}//${context.repo.owner}/${context.repo.repo}/actions/runs/${context.runId}`
const urlLink = `[Open](${url})`
const body = `
📝 Benchmark detail: ${urlLink}
${result}
`
await github.rest.repos.createCommitComment({
commit_sha: context.payload.inputs.commit_sha,
owner: context.repo.owner,
repo: 'rspack',
body
})
if (result.includes("Threshold exceeded")) {
console.log("Some benchmark cases exceed the threshold, please visit the previous step for more information");
process.exit(1);
}