-
Notifications
You must be signed in to change notification settings - Fork 3
65 lines (60 loc) · 2 KB
/
bench_rspack_commit.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
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
})