-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
276 lines (227 loc) · 8.51 KB
/
ci.yml
File metadata and controls
276 lines (227 loc) · 8.51 KB
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
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
name: CI
on:
push:
paths-ignore:
- '**/*.md'
branches: [next]
pull_request:
types: [opened, synchronize]
paths-ignore:
- '**/*.md'
branches: [next]
merge_group:
permissions:
id-token: write
actions: write
jobs:
typecheck:
runs-on: ubuntu-latest
concurrency:
group: typecheck-${{ github.workflow }}-#${{ github.event.pull_request.number || github.head_ref || github.ref }}
cancel-in-progress: true
steps:
- name: Checkout repository
uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6
- name: Install pnpm
uses: pnpm/action-setup@41ff72655975bd51cab0327fa583b6e92b6d3061 # v4
- name: Set up Node.js
uses: actions/setup-node@6044e13b5dc448c55e2357c09f80417699197238 # v6
with:
node-version: '24'
cache: 'pnpm'
- name: Install dependencies
run: pnpm install --frozen-lockfile
- name: Run lint
run: pnpm run lint
- name: Check dedupe
run: pnpm dedupe --check
- name: Run typecheck
run: pnpm run typecheck
- name: Run format check
run: pnpm run fmtcheck
- name: Run build
run: pnpm run build
- name: Run site build
run: pnpm run site:build
test:
strategy:
fail-fast: false
matrix:
os: ['ubuntu-latest', 'macos-latest', 'windows-latest']
node: ['20', '22', '24']
name: Test (${{ matrix.os }}, ${{ matrix.node }})
runs-on: ${{ matrix.os }}
concurrency:
group: test-${{ github.workflow }}-#${{ github.event.pull_request.number || github.head_ref || github.ref }}-(${{ matrix.os }}, ${{ matrix.node }})
cancel-in-progress: true
steps:
- name: Checkout repository
uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6
- name: Start Redis (MacOS or Linux)
if: ${{ matrix.os == 'macos-latest' || matrix.os == 'ubuntu-latest' }}
uses: shogo82148/actions-setup-redis@cff708d63a30aebc0bfaa7276fb709d173f36cb6 # v1
with:
redis-version: '7'
auto-start: 'true'
- name: Start Redis (Windows via Memurai)
if: ${{ matrix.os == 'windows-latest' }}
shell: pwsh
run: |
# retry up to 3 times to handle Chocolatey feed flakiness
for ($i = 1; $i -le 3; $i++) {
choco install -y memurai-developer.install
if ($LASTEXITCODE -eq 0) { break }
if ($i -lt 3) {
Write-Host "choco install failed (attempt $i/3), retrying in 15s..."
Start-Sleep -Seconds 15
} else {
Write-Error "choco install failed after 3 attempts"
exit 1
}
}
# ensure service exists and running (avoid non-zero return code of net start)
$svc = Get-Service -Name Memurai -ErrorAction SilentlyContinue
if (-not $svc) {
Write-Error "Memurai service not found after install"
exit 1
}
if ($svc.Status -ne 'Running') {
Start-Service -Name Memurai -ErrorAction Stop
# wait for 20s until Running
$svc.WaitForStatus('Running', '00:00:20')
} else {
Write-Host "Memurai already running."
}
# wait for 6379 port ready (max ~60s)
$deadline = (Get-Date).AddSeconds(60)
$ready = $false
while ((Get-Date) -lt $deadline -and -not $ready) {
try {
$client = New-Object System.Net.Sockets.TcpClient
$async = $client.BeginConnect('127.0.0.1', 6379, $null, $null)
$ok = $async.AsyncWaitHandle.WaitOne(2000)
if ($ok -and $client.Connected) { $ready = $true }
$client.Close()
} catch { }
}
if (-not $ready) {
Write-Error "Memurai (Redis) not ready on 127.0.0.1:6379"
exit 1
}
Write-Host "Memurai is ready on 127.0.0.1:6379"
# install and start MySQL (will automatically start mysqld)
- name: Start MySQL (macOS or Linux)
if: ${{ matrix.os == 'macos-latest' || matrix.os == 'ubuntu-latest' }}
uses: shogo82148/actions-setup-mysql@27e74fac04c136a9f4c2dc2ed457df57331b3e0c # v1
with:
mysql-version: '8'
auto-start: 'true'
- name: Init DB (macOS or Linux)
if: ${{ matrix.os == 'macos-latest' || matrix.os == 'ubuntu-latest' }}
run: |
mysql -uroot -e "CREATE DATABASE IF NOT EXISTS test;"
- name: Start MySQL (Windows)
if: ${{ matrix.os == 'windows-latest' }}
shell: pwsh
run: |
choco install -y mysql
refreshenv
# MySQL default root has no password, set a password and create database/user
# & mysqladmin -u root password root
& mysql -uroot -e "CREATE DATABASE IF NOT EXISTS test;"
- name: Install pnpm
uses: pnpm/action-setup@41ff72655975bd51cab0327fa583b6e92b6d3061 # v4
- name: Set up Node.js
uses: actions/setup-node@6044e13b5dc448c55e2357c09f80417699197238 # v6
with:
node-version: ${{ matrix.node }}
cache: 'pnpm'
- name: Install dependencies
run: pnpm install --frozen-lockfile
- name: Run tests
run: pnpm run ci
- name: Run example tests
if: ${{ matrix.node != '20' && matrix.os != 'windows-latest' }}
run: |
pnpm run example:test:all
- name: Code Coverage
# skip on windows, it will hangup on codecov
if: ${{ matrix.os != 'windows-latest' }}
uses: codecov/codecov-action@671740ac38dd9b0130fbe1cec585b89eea48d3de # v5
with:
use_oidc: true
test-egg-bin:
strategy:
fail-fast: false
matrix:
os: ['ubuntu-latest', 'windows-latest']
node: ['24']
name: Test bin (${{ matrix.os }}, ${{ matrix.node }})
runs-on: ${{ matrix.os }}
concurrency:
group: test-egg-bin-${{ github.workflow }}-#${{ github.event.pull_request.number || github.head_ref || github.ref }}-(${{ matrix.os }}, ${{ matrix.node }})
cancel-in-progress: true
steps:
- name: Checkout repository
uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6
- name: Install pnpm
uses: pnpm/action-setup@41ff72655975bd51cab0327fa583b6e92b6d3061 # v4
- name: Set up Node.js
uses: actions/setup-node@6044e13b5dc448c55e2357c09f80417699197238 # v6
with:
node-version: ${{ matrix.node }}
cache: 'pnpm'
- name: Install dependencies
run: pnpm install --frozen-lockfile
- name: Run tests
run: |
pnpm build --workspace ./tools/egg-bin
pnpm run --filter ./tools/egg-bin ci
- name: Code Coverage
# skip on windows, it will hangup on codecov https://github.com/codecov/codecov-action/issues/1787
if: ${{ matrix.os != 'windows-latest' }}
uses: codecov/codecov-action@671740ac38dd9b0130fbe1cec585b89eea48d3de # v5
with:
use_oidc: true
test-egg-scripts:
strategy:
fail-fast: false
matrix:
os: ['ubuntu-latest']
node: ['22', '24']
name: Test scripts (${{ matrix.os }}, ${{ matrix.node }})
runs-on: ${{ matrix.os }}
concurrency:
group: test-egg-scripts-${{ github.workflow }}-#${{ github.event.pull_request.number || github.head_ref || github.ref }}-(${{ matrix.os }}, ${{ matrix.node }})
cancel-in-progress: true
steps:
- name: Checkout repository
uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6
- name: Install pnpm
uses: pnpm/action-setup@41ff72655975bd51cab0327fa583b6e92b6d3061 # v4
- name: Set up Node.js
uses: actions/setup-node@6044e13b5dc448c55e2357c09f80417699197238 # v6
with:
node-version: ${{ matrix.node }}
cache: 'pnpm'
- name: Install dependencies
run: pnpm install --frozen-lockfile
- name: Run tests
run: |
pnpm build
pnpm run --filter=./tools/scripts ci
- name: Code Coverage
if: ${{ matrix.os != 'windows-latest' }}
uses: codecov/codecov-action@671740ac38dd9b0130fbe1cec585b89eea48d3de # v5
with:
use_oidc: true
done:
runs-on: ubuntu-latest
needs:
- test
- test-egg-bin
- test-egg-scripts
- typecheck
steps:
- run: exit 1
if: ${{ always() && (contains(needs.*.result, 'failure') || contains(needs.*.result, 'cancelled')) }}