-
-
Notifications
You must be signed in to change notification settings - Fork 622
256 lines (234 loc) · 8.25 KB
/
ecosystem-ci.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
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
name: Ecosystem CI
on:
workflow_dispatch:
inputs:
pr:
type: number
description: "Run ecosystem ci PR number"
required: true
suite:
description: "testsuite to run. runs all testsuits when `-`."
required: false
type: choice
options:
- "-"
- modernjs
# - nx
- rspress
- rsbuild
- rslib
- examples
- devserver
suiteRef:
description: "suite ref to use"
required: true
type: string
default: "-"
push:
branches:
- main
paths-ignore:
- "**/*.md"
- "website/**"
tags-ignore:
- "**"
permissions:
# Allow commenting on commits
contents: write
# Allow commenting on issues
issues: write
# Allow commenting on pull requests
pull-requests: write
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('refs/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 ecosystem ci: ${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
calculate-eco-ci-suite:
runs-on: ubuntu-latest
outputs:
suites: ${{ steps.calculate.outputs.result }}
steps:
- id: calculate
uses: actions/github-script@v7
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
result-encoding: string
script: |
const suiteName = `${{ github.event_name == 'workflow_dispatch' && inputs.suite || '-' }}`;
let suites = [
"modernjs",
// "nx",
"rspress",
"rslib",
"rsbuild",
"rsdoctor",
"examples",
"devserver",
"nuxt",
]
if (suiteName !== "-") {
suites = suites.filter(suite => suite === suiteName)
}
return JSON.stringify({
include: suites.map(suite => ({ suite }))
})
eco-ci:
needs: [build, calculate-eco-ci-suite]
strategy:
matrix: ${{fromJson(needs.calculate-eco-ci-suite.outputs.suites)}}
fail-fast: false
name: eco-ci (${{ matrix.suite }})
runs-on: ubuntu-22.04
# runs-on: ${{ fromJSON(needs.get-runner-labels.outputs.LINUX_RUNNER_LABELS) }}
steps:
- name: Checkout
uses: actions/checkout@v4
with:
ref: ${{ github.event_name == 'workflow_dispatch' && format('refs/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-ci
run: |
# prepare rspack
cp ./crates/node_binding/*.node ./npm/linux-x64-gnu/
RSPACK_DIR=$(pwd)
cd ..
git clone --single-branch --depth 1 https://github.com/web-infra-dev/rspack-ecosystem-ci.git
cd rspack-ecosystem-ci
pnpm i --frozen-lockfile
mkdir -p ./workspace
ln -s $RSPACK_DIR ./workspace/rspack
SUITE='${{ matrix.suite }}'
SUITE_REF='${{ inputs.suiteRef || '-' }}'
CONCLUSION='success'
if [[ "$SUITE_REF" != "-" ]]; then
# run test suite with suiteRef
pnpm tsx ecosystem-ci.ts run-suites --suite-commit "$SUITE_REF" "$SUITE" || CONCLUSION='failure'
echo "finish run $SUITE with $SUITE_REF"
else
# run test suite
pnpm tsx ecosystem-ci.ts run-suites "$SUITE" || CONCLUSION='failure'
echo "finish run $SUITE"
fi
echo "{\"conclusion\":\"$CONCLUSION\"}" >> "$RSPACK_DIR/$SUITE.json"
- name: Upload Result
uses: actions/upload-artifact@v4
with:
name: eco-ci-result-${{ matrix.suite }}
path: ${{ matrix.suite }}.json
comment-compare-results:
runs-on: ubuntu-latest
needs: [create-comment, eco-ci]
if: ${{ !cancelled() }}
steps:
- name: Download Result
uses: actions/download-artifact@v4
with:
path: results
pattern: eco-ci-result-*
merge-multiple: true
- uses: actions/github-script@v7
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
const { data } = await github.rest.actions.listJobsForWorkflowRunAttempt({
owner: context.repo.owner,
repo: context.repo.repo,
run_id: context.runId,
attempt_number: ${{ github.run_attempt }},
})
const jobs = data?.jobs || []
let result = jobs
.filter(job => job.name.startsWith('eco-ci '))
.filter(job => job.conclusion !== 'skipped')
.map(job => {
const suite = job.name.replace(/^eco-ci \(([^)]+)\)$/, "$1")
let conclusion = job.conclusion
if (conclusion === "success") {
conclusion = require(`./results/${suite}.json`).conclusion;
}
return { suite, conclusion, link: job.html_url }
})
const conclusionEmoji = {
success: ":white_check_mark:",
failure: ":x:",
cancelled: ":stop_button:"
}
const url = `${context.serverUrl}//${context.repo.owner}/${context.repo.repo}/actions/runs/${context.runId}`
const urlLink = `[Open](${url})`
const body = result.length ? ` 📝 Ecosystem CI detail: ${urlLink}
| suite | result |
|-------|--------|
${result.map(r => `| [${r.suite}](${r.link}) | ${conclusionEmoji[r.conclusion]} ${r.conclusion} |`).join("\n")}
` : ` 📝 Ecosystem CI failed: ${urlLink}`
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,
});
}