-
Notifications
You must be signed in to change notification settings - Fork 1
527 lines (458 loc) · 17.3 KB
/
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
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
name: CI
on:
push:
branches: [main]
pull_request:
types: [opened, synchronize]
concurrency:
group: ${{ github.workflow }}-${{ github.event.number || github.ref }}
cancel-in-progress: true
env:
NX_CLOUD_DISTRIBUTED_EXECUTION_AGENT_COUNT: 3
NX_CLOUD_DISTRIBUTED_EXECUTION: true
NX_REJECT_UNKNOWN_LOCAL_CACHE: 0
CI: true
jobs:
deps:
strategy:
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
name: Deps [${{ matrix.os }}]
permissions:
contents: read
actions: read
runs-on: ${{ matrix.os }}
defaults:
run:
shell: bash
steps:
- name: Checkout [Pull Request]
uses: actions/checkout@v4
if: github.event_name == 'pull_request'
with:
ref: ${{ github.event.pull_request.head.sha }}
fetch-depth: 0
- name: Checkout [Main]
uses: actions/checkout@v4
if: github.event_name != 'pull_request'
with:
fetch-depth: 0
- name: Derive SHAs
uses: nrwl/nx-set-shas@v4
- name: Install Node
uses: actions/setup-node@v4
with:
node-version: lts/*
- name: Install pnpm
uses: pnpm/action-setup@v3
id: pnpm-install
with:
version: latest
run_install: false
- name: Get pnpm store directory
id: pnpm-cache
run: echo "STORE_PATH=$(pnpm store path)" >> $GITHUB_OUTPUT
- name: Setup pnpm cache
uses: actions/cache@v4
id: cache
with:
path: |
${{ steps.pnpm-cache.outputs.STORE_PATH }}
node_modules/
key: ${{ matrix.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
restore-keys: ${{ matrix.os }}-pnpm-store-
- name: Install dependencies
if: steps.cache.outputs.cache-hit != 'true'
run: pnpm install --no-frozen-lockfile
- name: Check format
run: pnpm nx format:check --all
set-agents:
name: Set Agent Matrix
runs-on: ubuntu-latest
outputs:
matrix: ${{ steps.set-matrix.outputs.matrix }}
steps:
- name: Calculate Matrix
id: set-matrix
run: |
AGENTS_JSON_ARRAY=$(node -e "
const agents = Array.from(new Array($NX_CLOUD_DISTRIBUTED_EXECUTION_AGENT_COUNT)).map((_, i) => i + 1);
console.log(JSON.stringify(agents));
")
echo $AGENTS_JSON_ARRAY
echo "matrix=$AGENTS_JSON_ARRAY" >> $GITHUB_OUTPUT
agents:
name: Agent ${{ matrix.agent }} [${{ matrix.os }}]
needs: [set-agents, deps]
runs-on: ${{ matrix.os }}
permissions:
contents: read
actions: read
defaults:
run:
shell: bash
strategy:
matrix:
os:
- ubuntu-latest
- macos-latest
agent:
- ${{ fromJson(needs.set-agents.outputs.matrix) }}
steps:
- name: Checkout [Pull Request]
uses: actions/checkout@v4
if: github.event_name == 'pull_request'
with:
ref: ${{ github.event.pull_request.head.sha }}
fetch-depth: 0
- name: Checkout [Main]
uses: actions/checkout@v4
if: github.event_name != 'pull_request'
with:
fetch-depth: 0
- name: Derive SHAs
uses: nrwl/nx-set-shas@v4
- name: Install Node
uses: actions/setup-node@v4
with:
node-version: lts/*
- name: Install pnpm
uses: pnpm/action-setup@v3
id: pnpm-install
with:
version: latest
run_install: false
- name: Get pnpm store directory
id: pnpm-cache
run: echo "STORE_PATH=$(pnpm store path)" >> $GITHUB_OUTPUT
- name: Restore pnpm cache
uses: actions/cache/restore@v4
id: cache
with:
path: |
${{ steps.pnpm-cache.outputs.STORE_PATH }}
node_modules/
key: ${{ matrix.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
restore-keys: ${{ matrix.os }}-pnpm-store-
- name: Install dependencies
if: steps.cache.outputs.cache-hit != 'true'
run: pnpm install --no-frozen-lockfile
- name: Install linux dependencies (ubuntu-latest)
if: matrix.os == 'ubuntu-latest'
run: |
sudo apt-get update -y
sudo apt-get install gdb nasm -y
- name: Install macos dependencies (macos-latest)
if: matrix.os == 'macos-latest'
run: |
brew install llvm gdb nasm
ln -s "$(brew --prefix llvm)/bin/clang-format" "/usr/local/bin/clang-format"
ln -s "$(brew --prefix llvm)/bin/clang-tidy" "/usr/local/bin/clang-tidy"
- name: Run Agent (unix)
run: npx nx-cloud start-agent
main:
strategy:
matrix:
os: [windows-latest, ubuntu-latest, macos-latest]
fail-fast: false
name: Main Job [${{ matrix.os }}]
env:
NX_CACHE_DIRECTORY: tmp/${{ matrix.os }}
permissions:
contents: read
actions: read
defaults:
run:
shell: bash
runs-on: ${{ matrix.os }}
needs: [set-agents, deps]
steps:
- name: Checkout [Pull Request]
uses: actions/checkout@v4
if: github.event_name == 'pull_request'
with:
ref: ${{ github.event.pull_request.head.sha }}
fetch-depth: 0
- name: Checkout [Main]
uses: actions/checkout@v4
if: github.event_name != 'pull_request'
with:
fetch-depth: 0
- name: Derive SHAs
uses: nrwl/nx-set-shas@v4
- name: Install Node
uses: actions/setup-node@v4
with:
node-version: lts/*
- name: Install pnpm
uses: pnpm/action-setup@v3
id: pnpm-install
with:
version: latest
run_install: false
- name: Get pnpm store directory
id: pnpm-cache
run: echo "STORE_PATH=$(pnpm store path)" >> $GITHUB_OUTPUT
- name: Restore pnpm cache
uses: actions/cache/restore@v4
id: cache
with:
path: |
${{ steps.pnpm-cache.outputs.STORE_PATH }}
node_modules/
key: ${{ matrix.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
restore-keys: ${{ matrix.os }}-pnpm-store-
- name: Nx cache
uses: actions/cache@v4
id: nx_cache
with:
path: ${{ env.NX_CACHE_DIRECTORY }}
key: ${{ matrix.os }}-nx-cache-${{ hashFiles('tmp/**') }}
restore-keys: ${{ matrix.os }}-nx-cache
- name: Install dependencies
if: steps.cache.outputs.cache-hit != 'true'
run: pnpm install --no-frozen-lockfile
- name: Start Agents (unix)
if: needs.agents.result != 'failure' &&
needs.agents.result != 'cancelled' &&
needs.agents.result != 'skipped' &&
matrix.os != 'windows-latest'
run: npx nx-cloud start-ci-run --stop-agents-after=e2e
- name: Run Test Agents (unix)
id: agents
run: |
pnpm nx affected \
--nx-bail \
--base=$NX_BASE \
--head=$NX_HEAD \
--configuration=ci \
--output-style=stream \
--parallel=$NX_CLOUD_DISTRIBUTED_EXECUTION_AGENT_COUNT \
--no-cloud \
-t lint build test
- name: Stop Agents
if: always()
run: npx nx-cloud stop-all-agents
- name: Upload coverage reports to Codecov
if: matrix.os == 'ubuntu-latest'
uses: codecov/codecov-action@v4
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
- name: Tar dist
if: matrix.os == 'ubuntu-latest'
run: |
if [ -d "dist" ]; then
tar -cvf dist.tar dist
else
mkdir dist
tar -cvf dist.tar dist
fi
- name: Upload dist
if: matrix.os == 'ubuntu-latest'
uses: actions/upload-artifact@v4
with:
name: dist
path: dist.tar
e2e:
name: E2E [${{ matrix.os }}]
needs: [main, agents]
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [windows-latest, ubuntu-latest, macos-latest]
fail-fast: false
env:
NX_CLOUD_DISTRIBUTED_EXECUTION: false
NX_CACHE_DIRECTORY: tmp/${{ matrix.os }}
permissions:
contents: read
actions: read
defaults:
run:
shell: bash
steps:
- name: Checkout [Pull Request]
uses: actions/checkout@v4
if: github.event_name == 'pull_request'
with:
ref: ${{ github.event.pull_request.head.sha }}
fetch-depth: 0
- name: Checkout [Main]
uses: actions/checkout@v4
if: github.event_name != 'pull_request'
with:
fetch-depth: 0
- name: Derive SHAs
uses: nrwl/nx-set-shas@v4
- name: Install Node
uses: actions/setup-node@v4
with:
node-version: lts/*
- name: Install pnpm
uses: pnpm/action-setup@v3
id: pnpm-install
with:
version: latest
run_install: false
- name: Get pnpm store directory
id: pnpm-cache
run: echo "STORE_PATH=$(pnpm store path)" >> $GITHUB_OUTPUT
- name: Restore pnpm cache
uses: actions/cache/restore@v4
id: cache
with:
path: |
${{ steps.pnpm-cache.outputs.STORE_PATH }}
node_modules/
key: ${{ matrix.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
restore-keys: ${{ matrix.os }}-pnpm-store-
- name: Nx cache
uses: actions/cache@v4
id: nx_cache
with:
path: ${{ env.NX_CACHE_DIRECTORY }}
key: ${{ matrix.os }}-nx-cache-${{ hashFiles('tmp/**') }}
restore-keys: ${{ matrix.os }}-nx-cache
- name: Install dependencies
if: steps.cache.outputs.cache-hit != 'true'
run: pnpm install --no-frozen-lockfile
- name: Install linux dependencies (ubuntu-latest)
if: matrix.os == 'ubuntu-latest'
run: |
sudo apt-get update -y
sudo apt-get install gdb -y
- name: Install macos dependencies (macos-latest)
if: matrix.os == 'macos-latest'
run: |
brew install llvm gdb
ln -s "$(brew --prefix llvm)/bin/clang-format" "/usr/local/bin/clang-format"
ln -s "$(brew --prefix llvm)/bin/clang-tidy" "/usr/local/bin/clang-tidy"
- name: Install MSYS2 (windows-latest)
if: matrix.os == 'windows-latest'
shell: pwsh
run: |
Add-Content $env:GITHUB_PATH "C:\msys64"
Add-Content $env:GITHUB_PATH "C:\msys64\usr\bin"
Add-Content $env:GITHUB_PATH "C:\msys64\ucrt64\bin"
- name: Install windows dependencies (windows-latest)
if: matrix.os == 'windows-latest'
uses: msys2/setup-msys2@v2
with:
msystem: UCRT64
update: true
release: false
pacboy: >-
gcc:u
make:u
cmake:u
clang:u
clang-tools-extra:u
gdb:u
- name: Start registry
env:
NX_NO_CLOUD: true
run: pnpm nx local-registry &
- name: Run e2e
env:
NX_NO_CLOUD: true
SKIP: true
run: pnpm nx affected-e2e
- name: Stop registry
env:
NX_NO_CLOUD: true
run: pnpm nx stop-local-registry
publish:
name: Publish
runs-on: ubuntu-latest
needs: [e2e]
env:
NX_CLOUD_DISTRIBUTED_EXECUTION: false
NX_SKIP_NX_CACHE: true
GITHUB_TOKEN: ${{ secrets.PAT }}
permissions:
contents: write
actions: write
id-token: write
steps:
- name: Checkout [Pull Request]
uses: actions/checkout@v4
if: github.event_name == 'pull_request' && startsWith(github.ref, 'refs/heads/main')
with:
ref: ${{ github.event.pull_request.head.sha }}
fetch-depth: 0
- name: Checkout [Main]
uses: actions/checkout@v4
if: github.event_name != 'pull_request' && startsWith(github.ref, 'refs/heads/main')
with:
fetch-depth: 0
token: ${{ secrets.PAT }}
- name: Derive SHAs
if: startsWith(github.ref, 'refs/heads/main')
uses: nrwl/nx-set-shas@v4
- name: Install Node
if: startsWith(github.ref, 'refs/heads/main')
uses: actions/setup-node@v4
with:
node-version: lts/*
registry-url: 'https://registry.npmjs.org'
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
- name: Install pnpm
if: startsWith(github.ref, 'refs/heads/main')
uses: pnpm/action-setup@v3
id: pnpm-install
with:
version: latest
run_install: false
- name: Get pnpm store directory
if: startsWith(github.ref, 'refs/heads/main')
id: pnpm-cache
run: echo "STORE_PATH=$(pnpm store path)" >> $GITHUB_OUTPUT
- name: Restore pnpm cache
uses: actions/cache/restore@v4
if: startsWith(github.ref, 'refs/heads/main')
id: cache
with:
path: |
${{ steps.pnpm-cache.outputs.STORE_PATH }}
node_modules/
key: ubuntu-latest-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
restore-keys: ubuntu-latest-pnpm-store-
- name: Install dependencies
if: startsWith(github.ref, 'refs/heads/main') && steps.cache.outputs.cache-hit != 'true'
run: pnpm install --no-frozen-lockfile
- name: Build packages
if: startsWith(github.ref, 'refs/heads/main')
run: |
pnpm nx run-many \
--nx-bail \
--configuration=ci \
--output-style=stream \
--no-dte \
--no-cloud \
--skip-nx-cache \
--projects=plugins/* \
-t build
- name: Check npm auth
if: startsWith(github.ref, 'refs/heads/main')
run: npm whoami
- name: Setup Git
if: startsWith(github.ref, 'refs/heads/main')
uses: fregante/setup-git-user@v2
- name: Semantic Versioning
if: startsWith(github.ref, 'refs/heads/main')
run: pnpm nx release --skip-publish
shell: bash
env:
SKIP_TESTS: true
- name: Publish
if: startsWith(github.ref, 'refs/heads/main')
run: pnpm nx release publish
shell: bash
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
NPM_CONFIG_PROVENANCE: true
- name: Delete Artifacts
uses: geekyeggo/delete-artifact@v4
with:
name: '*'