-
-
Notifications
You must be signed in to change notification settings - Fork 594
157 lines (138 loc) · 4.95 KB
/
ecosystem-benchmark.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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
name: ecosystem-benchmark
on:
workflow_dispatch:
inputs:
pr:
type: number
description: "Run Benchmark PR number"
required: true
push:
branches:
- main
paths-ignore:
- "**/*.md"
- "website/**"
tags-ignore:
- "**"
jobs:
get-runner-labels:
name: Get Runner Labels
uses: ./.github/workflows/get-runner-labels.yml
build:
name: Test Linux
needs: [get-runner-labels]
uses: ./.github/workflows/reusable-build.yml
with:
target: x86_64-unknown-linux-gnu
native: ${{ needs.get-runner-labels.outputs.LINUX_RUNNER_LABELS == '"ubuntu-22.04"' }}
runner: ${{ needs.get-runner-labels.outputs.LINUX_RUNNER_LABELS }}
ref: ${{ github.event_name == 'workflow_dispatch' && format('pull/{0}/head', inputs.pr) || github.sha }}
test: false
bench: false
create-comment:
runs-on: ubuntu-latest
outputs:
comment-id: ${{ steps.create-comment.outputs.result }}
steps:
- id: create-comment
uses: actions/github-script@v7
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
result-encoding: string
script: |
const url = `${context.serverUrl}//${context.repo.owner}/${context.repo.repo}/actions/runs/${context.runId}`
const urlLink = `[Open](${url})`
const body = `⏳ Triggered benchmark: ${urlLink}`
if (context.eventName === 'workflow_dispatch') {
const { data: comment } = await github.rest.issues.createComment({
issue_number: context.payload.inputs.pr,
owner: context.repo.owner,
repo: context.repo.repo,
body
})
return comment.id
}
const { data: comment } = await github.rest.repos.createCommitComment({
commit_sha: context.sha,
owner: context.repo.owner,
repo: context.repo.repo,
body
})
return comment.id
bench:
needs: [build]
runs-on: [self-hosted, benchmark]
outputs:
diff-result: ${{ steps.run-benchmark.outputs.diff-result }}
steps:
- name: Checkout
uses: actions/checkout@v4
with:
ref: ${{ github.event_name == 'workflow_dispatch' && format('pull/{0}/head', inputs.pr) || github.sha }}
- name: Clean
uses: ./.github/actions/clean
with:
target: x86_64-unknown-linux-gnu
- name: Download bindings
uses: ./.github/actions/download-artifact
with:
name: bindings-x86_64-unknown-linux-gnu
path: crates/node_binding/
try-local-cache: false
- name: Show restored binding
shell: bash
run: ls -lah crates/node_binding/*.node
- name: Pnpm Cache
uses: ./.github/actions/pnpm-cache
- name: Build JS
run: pnpm run build:js
- name: Run rspack-ecosystem-benchmark
id: run-benchmark
run: |
RSPACK_DIR=$(pwd)
git clone --single-branch --depth 1 https://github.com/web-infra-dev/rspack-ecosystem-benchmark.git
cd rspack-ecosystem-benchmark
pnpm i
RSPACK_DIR="$RSPACK_DIR" node bin/cli.js bench
result=$(node bin/cli.js compare --base latest --current current)
echo "$result"
echo "diff-result=${result//$'\n'/'@@'}" >> $GITHUB_OUTPUT
comment-compare-results:
runs-on: ubuntu-latest
needs: [create-comment, bench]
if: ${{ !cancelled() }}
steps:
- uses: actions/github-script@v7
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
const diffResult = `${{ needs.bench.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}
`
if (context.eventName === 'workflow_dispatch') {
await github.rest.issues.updateComment({
owner: context.repo.owner,
repo: context.repo.repo,
comment_id: `${{ needs.create-comment.outputs.comment-id }}`,
body
})
} else {
await github.rest.repos.updateCommitComment({
owner: context.repo.owner,
repo: context.repo.repo,
comment_id: `${{ needs.create-comment.outputs.comment-id }}`,
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);
}