Bench Rspack PR #4
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: bench-rspack-pr | |
on: | |
workflow_dispatch: | |
inputs: | |
prNumber: | |
description: "PR number (e.g. 9887)" | |
required: true | |
type: string | |
reportComment: | |
description: "Create a comment to display benchmark results" | |
required: false | |
type: string | |
default: "false" | |
jobs: | |
create-comment: | |
runs-on: ubuntu-latest | |
if: "inputs.reportComment == 'true'" | |
outputs: | |
comment-id: ${{ steps.create-comment.outputs.result }} | |
steps: | |
- id: create-comment | |
uses: actions/github-script@v6 | |
with: | |
github-token: ${{ secrets.BENCHMARK_ACCESS_TOKEN }} | |
result-encoding: string | |
script: | | |
const url = `${context.serverUrl}//${context.repo.owner}/${context.repo.repo}/actions/runs/${context.runId}` | |
const urlLink = `[Open](${url})` | |
const { data: comment } = await github.rest.issues.createComment({ | |
issue_number: context.payload.inputs.prNumber, | |
owner: context.repo.owner, | |
repo: 'rspack', | |
body: `⏳ Triggered benchmark: ${urlLink}` | |
}) | |
return comment.id | |
run-bench: | |
runs-on: [self-hosted, rspack-bench] | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v2 | |
- name: Init env | |
uses: ./.github/actions/env | |
- name: Build rspack | |
run: node bin/build-rspack.js origin pull/${{ inputs.prNumber }}/head | |
- name: Run benchmark | |
run: node bin/bench.js | |
- name: Print results | |
run: node bin/compare-bench.js latest current | |
update-comment: | |
runs-on: ubuntu-latest | |
needs: [create-comment, run-bench] | |
if: "inputs.reportComment == 'true'" | |
steps: | |
- uses: actions/github-script@v6 | |
with: | |
github-token: ${{ secrets.ECOSYSTEM_CI_ACCESS_TOKEN }} | |
script: | | |
const { data: { jobs } } = await github.rest.actions.listJobsForWorkflowRun({ | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
run_id: context.runId, | |
per_page: 100 | |
}); | |
const result = jobs.find(job => job.name === "run-bench") | |
const url = `${context.serverUrl}//${context.repo.owner}/${context.repo.repo}/actions/runs/${context.runId}` | |
const urlLink = `[Open](${url})` | |
console.log(result) | |
const body = ` | |
📝 Benchmark detail: ${urlLink} | |
| suite | result | | |
|-------|--------| | |
${result.map(r => `| [${r.suite}](${r.html_url}) | ${r.conclusion} ${r.conclusion} |`).join("\n")} | |
` | |
await github.rest.issues.updateComment({ | |
owner: context.repo.owner, | |
repo: 'rspack', | |
comment_id: ${{ needs.init.outputs.comment-id }}, | |
body | |
}) |