Skip to content

Bench Rspack Commit

Bench Rspack Commit #2

name: Bench Rspack Commit
on:
workflow_dispatch:
inputs:
commit_sha:
description: "commit sha"
required: true
type: string
jobs:
run-bench:
runs-on: [self-hosted, rspack-bench]
timeout-minutes: 30
outputs:
diff-result: ${{ steps.print-results.outputs.diff-result }}
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Init env
uses: ./.github/actions/env
- name: Build rspack
run: node bin/build-rspack.js origin ${{ inputs.commit_sha }}
- name: Run benchmark
run: node bin/bench.js
- id: print-results
name: Print results
run: |
result=$(node bin/compare-bench.js latest 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
create-comment:
runs-on: ubuntu-latest
needs: [run-bench]
steps:
- id: create-comment
uses: actions/github-script@v6
with:
github-token: ${{ secrets.RSPACK_BOT_ACCESS_TOKEN }}
result-encoding: string
script: |
const diffResult = `${{ needs.run-bench.outputs.diff-result }}`
let result = "task ${{ needs.run-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.commits.createComment({
commit_sha: context.payload.inputs.commit_sha,
owner: context.repo.owner,
repo: 'rspack',
body
})