-
-
Notifications
You must be signed in to change notification settings - Fork 239
651 lines (578 loc) · 19.2 KB
/
test-release.yaml
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
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
name: Test & Release
env:
DEBUG: 'napi:*'
RUST_BACKTRACE: 1
CARGO_TARGET_AARCH64_UNKNOWN_LINUX_MUSL_LINKER: aarch64-linux-gnu-gcc
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
permissions:
contents: write
id-token: write
on:
push:
branches:
- main
pull_request:
jobs:
lint:
name: Lint SourceCode
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Setup node
uses: actions/setup-node@v4
with:
node-version: 20
cache: 'yarn'
- name: Install
uses: dtolnay/rust-toolchain@stable
with:
toolchain: stable
components: rustfmt, clippy
- name: Cache cargo
uses: actions/cache@v4
with:
path: |
~/.cargo/registry
~/.cargo/git
key: lint-cargo-cache
- name: 'Install dependencies'
run: yarn install --immutable --mode=skip-build
- name: 'Lint JS/TS'
run: yarn lint
- name: Cargo fmt
run: cargo fmt -- --check
- name: Clippy
run: cargo clippy
build_and_test:
strategy:
fail-fast: false
matrix:
node: ['18', '20']
settings:
- host: ubuntu-latest
target: x86_64-unknown-linux-gnu
build: yarn build:test
test: |
yarn test:cli
yarn test --verbose
yarn tsc -p examples/napi/tsconfig.json --noEmit --skipLibCheck
yarn test:macro
toolchain: stable
- host: ubuntu-latest
target: x86_64-unknown-linux-gnu
build: yarn build:test
test: |
yarn test:cli
yarn test --verbose
yarn tsc -p examples/napi/tsconfig.json --noEmit --skipLibCheck
yarn test:macro
toolchain: 1.65.0
- host: macos-14
target: aarch64-apple-darwin
build: yarn build:test
test: |
yarn test:cli
yarn test --verbose
yarn tsc -p examples/napi/tsconfig.json --noEmit --skipLibCheck
yarn test:macro
toolchain: stable
- host: windows-latest
target: x86_64-pc-windows-msvc
build: yarn build:test
test: |
yarn test:cli
yarn test --verbose
yarn tsc -p examples/napi/tsconfig.json --noEmit --skipLibCheck
yarn test:macro
toolchain: stable
- host: windows-latest
target: i686-pc-windows-msvc
build: |
yarn workspace @examples/napi build --target i686-pc-windows-msvc --release
yarn workspace @examples/compat-mode build --target i686-pc-windows-msvc --release
test: |
yarn test --verbose
node ./node_modules/electron/install.js
yarn test:electron
toolchain: stable
exclude:
- settings:
toolchain: 1.65.0
node: 18
- settings:
toolchain: 1.65.0
node: 20
- settings:
target: i686-pc-windows-msvc
node: 18
name: ${{ matrix.settings.host }} - node@${{ matrix.node }} - toolchain@ ${{ matrix.settings.toolchain }}
runs-on: ${{ matrix.settings.host }}
steps:
- uses: actions/checkout@v4
- name: Setup node
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node }}
cache: 'yarn'
- name: Install
uses: dtolnay/rust-toolchain@stable
with:
toolchain: ${{ matrix.settings.toolchain }}
targets: ${{ matrix.settings.target }}
- name: Cache cargo
uses: actions/cache@v4
with:
path: |
~/.cargo/registry
~/.cargo/git
target
key: ${{ matrix.settings.host }}-${{ matrix.settings.toolchain }}-${{ matrix.settings.target }}-cargo-cache
- name: 'Install dependencies'
shell: bash
run: |
yarn config set supportedArchitectures.cpu --json '["current", "x64", "x86"]'
yarn install --mode=skip-build --immutable
- name: Check build
run: cargo check --target ${{ matrix.settings.target }} --all --bins --examples --tests -vvv
- name: Build tests
if: matrix.settings.build
run: ${{ matrix.settings.build }}
- name: Setup node
uses: actions/setup-node@v4
if: matrix.settings.target == 'i686-pc-windows-msvc'
with:
node-version: 20
architecture: 'x86'
- name: Unit tests
if: matrix.settings.test
run: ${{ matrix.settings.test }}
- name: Electron tests
if: matrix.settings.target == 'aarch64-apple-darwin' || matrix.settings.target == 'x86_64-pc-windows-msvc'
run: |
node ./node_modules/electron/install.js
yarn test:electron
- name: Electron tests
if: matrix.settings.target == 'x86_64-unknown-linux-gnu'
run: |
node ./node_modules/electron/install.js
xvfb-run --auto-servernum yarn test:electron
- name: Test build with profile
run: yarn workspace @examples/napi build --profile napi-rs-custom
build_only:
name: Build only test - ${{ matrix.settings.target }}
runs-on: ${{ matrix.settings.host }}
strategy:
fail-fast: false
matrix:
settings:
- host: ubuntu-latest
target: aarch64-linux-android
- host: ubuntu-latest
target: armv7-linux-androideabi
- host: ubuntu-latest
target: riscv64gc-unknown-linux-gnu
setup: |
sudo apt-get update
sudo apt-get install -y gcc-riscv64-linux-gnu
- host: windows-latest
target: aarch64-pc-windows-msvc
steps:
- uses: actions/checkout@v4
- name: Setup node
uses: actions/setup-node@v4
with:
node-version: 20
cache: 'yarn'
- name: Install
uses: dtolnay/rust-toolchain@stable
with:
toolchain: stable
targets: ${{ matrix.settings.target }}
- name: Cache cargo
uses: actions/cache@v4
with:
path: |
~/.cargo/registry
~/.cargo/git
target
key: stable-${{ matrix.settings.host }}-${{ matrix.settings.target }}-cargo-cache
- name: Setup toolchain
if: matrix.settings.setup
run: ${{ matrix.settings.setup }}
- name: Install dependencies
run: yarn install --immutable --mode=skip-build
- name: Cross build native tests
run: yarn build:test -- --target ${{ matrix.settings.target }} --release
shell: bash
build_for_test_in_docker:
name: build - ${{ matrix.settings.target }}
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
settings:
- target: powerpc64le-unknown-linux-gnu
setup: |
sudo apt-get update
sudo apt-get install -y gcc-powerpc64le-linux-gnu
- target: s390x-unknown-linux-gnu
setup: |
sudo apt-get update
sudo apt-get install -y gcc-s390x-linux-gnu
steps:
- uses: actions/checkout@v4
- name: Setup node
uses: actions/setup-node@v4
with:
node-version: 20
cache: 'yarn'
- name: Install
uses: dtolnay/rust-toolchain@stable
with:
toolchain: stable
targets: ${{ matrix.settings.target }}
- name: Cache cargo
uses: actions/cache@v4
with:
path: |
~/.cargo/registry
~/.cargo/git
target
key: stable-ubuntu-latest-${{ matrix.settings.target }}-cargo-cache
- name: Setup toolchain
run: ${{ matrix.settings.setup }}
- name: Install dependencies
run: yarn install --immutable --mode=skip-build
- name: Cross build native tests
run: yarn build:test -- --target ${{ matrix.settings.target }} --release
shell: bash
- uses: actions/upload-artifact@v4
with:
name: ${{ matrix.settings.target }}-example
path: examples/napi/*.node
- uses: actions/upload-artifact@v4
with:
name: ${{ matrix.settings.target }}-example-compat
path: examples/napi-compat-mode/index.node
build_in_docker:
name: build - ${{ matrix.settings.target }}
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
settings:
- image: ghcr.io/napi-rs/napi-rs/nodejs-rust:lts-alpine
target: x86_64-unknown-linux-musl
libc: 'musl'
arch: 'x64'
- image: ghcr.io/napi-rs/napi-rs/nodejs-rust:lts-alpine
target: aarch64-unknown-linux-musl
- image: ghcr.io/napi-rs/napi-rs/nodejs-rust:lts-debian-aarch64
target: aarch64-unknown-linux-gnu
arch: 'arm64'
libc: 'gnu'
- image: ghcr.io/napi-rs/napi-rs/nodejs-rust:lts-debian
target: x86_64-unknown-linux-gnu
steps:
- uses: actions/checkout@v4
- name: Setup node
uses: actions/setup-node@v4
with:
node-version: 20
cache: 'yarn'
- name: Install dependencies
run: |
yarn config set supportedArchitectures.cpu --json '["x64", "arm64"]'
yarn config set supportedArchitectures.libc --json '["musl", "glibc"]'
yarn install --immutable --mode=skip-build
- name: Cache cargo
uses: actions/cache@v4
with:
path: |
.cargo-cache/registry
.cargo-cache/git
target
key: stable-${{ matrix.settings.target }}-cargo-cache
- name: Cross build native tests
uses: addnab/docker-run-action@v3
with:
image: ${{ matrix.settings.image }}
options: -v ${{ github.workspace }}/.cargo-cache/registry:/usr/local/cargo/registry -v ${{ github.workspace }}/.cargo-cache/git:/usr/local/cargo/git -v ${{ github.workspace }}:/napi-rs -w /napi-rs
run: |
yarn build:test -- --target ${{ matrix.settings.target }}
chmod 777 -R .cargo-cache
chmod 777 -R target
- uses: actions/upload-artifact@v4
with:
name: ${{ matrix.settings.target }}-example
path: examples/napi/*.node
- uses: actions/upload-artifact@v4
with:
name: ${{ matrix.settings.target }}-example-compat
path: examples/napi-compat-mode/index.node
test_in_docker:
name: Test - ${{ matrix.settings.target }} - ${{ matrix.node }}
runs-on: ubuntu-latest
needs:
- build_in_docker
- build_for_test_in_docker
strategy:
fail-fast: false
matrix:
node: [18, 20]
settings:
- image: 'node:{:version}-slim'
target: x86_64-unknown-linux-gnu
args: ''
arch: 'x64'
libc: 'gnu'
- image: 'node:{:version}-slim'
target: aarch64-unknown-linux-gnu
args: '--platform linux/arm64'
arch: 'arm64'
libc: 'gnu'
- image: 'node:{:version}-slim'
target: powerpc64le-unknown-linux-gnu
args: '--platform linux/ppc64le'
arch: 'ppc64'
libc: 'gnu'
- image: 'node:{:version}-slim'
target: s390x-unknown-linux-gnu
args: '--platform linux/s390x'
arch: 's390x'
libc: 'gnu'
- image: 'node:{:version}-alpine'
target: x86_64-unknown-linux-musl
args: ''
arch: 'x64'
libc: 'musl'
- image: 'node:{:version}-alpine'
target: aarch64-unknown-linux-musl
args: '--platform linux/arm64'
arch: 'arm64'
libc: 'musl'
exclude:
- settings:
target: aarch64-unknown-linux-gnu
node: 18
steps:
- uses: actions/checkout@v4
- name: Setup node
uses: actions/setup-node@v4
with:
node-version: 20
cache: 'yarn'
- uses: actions/download-artifact@v4
with:
name: ${{ matrix.settings.target }}-example
path: examples/napi/
- uses: actions/download-artifact@v4
with:
name: ${{ matrix.settings.target }}-example-compat
path: examples/napi-compat-mode/index.node
- name: Install dependencies
run: |
yarn config set --json supportedArchitectures.cpu '["current", "${{ matrix.settings.arch }}"]'
yarn config set --json supportedArchitectures.libc '["current", "${{ matrix.settings.libc }}"]'
yarn install --immutable --mode=skip-build
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
with:
platforms: all
- run: docker run --rm --privileged multiarch/qemu-user-static --reset -p yes
- name: Setup image name
id: image-name
run: |
node -e "console.info('docker-image=${{ matrix.settings.image }}'.replace('{:version}', ${{ matrix.node }}))" >> "$GITHUB_OUTPUT"
- name: Setup and run tests
uses: addnab/docker-run-action@v3
with:
image: ${{ steps.image-name.outputs.docker-image }}
options: ${{ matrix.settings.args }} -v ${{ github.workspace }}/cores:/cores -v ${{ github.workspace }}:/build -w /build
run: yarn test
- name: List files
run: |
ls -la .
ls -la ./cores
build-and-test-linux-armv7:
name: stable - armv7-unknown-linux-gnueabihf - node@20
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Setup node
uses: actions/setup-node@v4
with:
node-version: 20
cache: 'yarn'
- name: Install
uses: dtolnay/rust-toolchain@stable
with:
toolchain: stable
targets: armv7-unknown-linux-gnueabihf
- name: Cache cargo
uses: actions/cache@v4
with:
path: |
~/.cargo/registry
~/.cargo/git
target
key: stable-linux-armv7-gnueabihf-node@20-cargo-cache
- name: Install dependencies
run: |
yarn config set --json supportedArchitectures.cpu '["arm", "current"]'
yarn install --immutable --mode=skip-build
- name: Cross build native tests
run: yarn build:test -- --target armv7-unknown-linux-gnueabihf --use-napi-cross
- run: docker run --rm --privileged multiarch/qemu-user-static --reset -p yes
- name: Setup and run tests
uses: addnab/docker-run-action@v3
with:
image: node:lts-slim
options: --platform linux/arm/v7 -v ${{ github.workspace }}:/build -w /build
run: yarn test
build_binary_crate:
runs-on: ubuntu-latest
name: Test cli build binary
steps:
- uses: actions/checkout@v4
- name: Setup node
uses: actions/setup-node@v4
with:
node-version: 20
cache: 'yarn'
- name: Install
uses: dtolnay/rust-toolchain@stable
with:
toolchain: stable
- name: Cache cargo
uses: actions/cache@v4
with:
path: |
~/.cargo/registry
~/.cargo/git
target
key: stable-cargo-cache-build-binary
- name: 'Install dependencies'
run: yarn install --mode=skip-build --immutable
- name: Build and run binary
run: |
yarn workspace binary build
./examples/binary/napi-examples-binary
yarn workspace binary build --profile napi-rs-custom
check-all-features:
strategy:
fail-fast: false
matrix:
settings:
- features: 'napi1,napi2,napi3,napi4,napi5,napi6,napi7,napi8,experimental,async,chrono_date,latin1,full'
package: 'napi'
- features: 'compat-mode,strict,type-def,noop,full,default'
package: 'napi-derive'
name: stable - ubuntu-latest
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install
uses: dtolnay/rust-toolchain@stable
with:
toolchain: stable
- name: Check build
run: cargo check -p ${{ matrix.settings.package }} -F ${{ matrix.settings.features }}
test-node-wasi:
runs-on: macos-14
name: Test node wasi target
timeout-minutes: 10
steps:
- uses: actions/checkout@v4
- name: Setup node
uses: actions/setup-node@v4
with:
node-version: 20
cache: 'yarn'
- name: Install
uses: dtolnay/rust-toolchain@stable
with:
toolchain: stable
targets: wasm32-wasi-preview1-threads
- name: Cache cargo
uses: actions/cache@v4
with:
path: |
~/.cargo/registry
~/.cargo/git
target
key: stable-wasm32-wasi-preview1-threads-node@20-cargo-cache
- name: Install dependencies
run: yarn install --immutable --mode=skip-build
- name: Build
run: |
yarn build
yarn workspace @examples/napi build --target wasm32-wasi-preview1-threads --release
- name: Test
run: yarn workspace @examples/napi test -s
env:
WASI_TEST: 'true'
NODE_OPTIONS: '--max-old-space-size=8192'
SKIP_UNWIND_TEST: 1
- name: Browser test
run: yarn workspace @examples/napi vitest
test-latest-bun:
runs-on: ubuntu-latest
name: Test latest bun
timeout-minutes: 10
steps:
- uses: actions/checkout@v4
- uses: oven-sh/setup-bun@v1
with:
bun-version: latest
- name: Setup node
uses: actions/setup-node@v4
with:
node-version: 20
cache: 'yarn'
- name: Install
uses: dtolnay/rust-toolchain@stable
with:
toolchain: stable
targets: x86_64-unknown-linux-gnu
- name: Cache cargo
uses: actions/cache@v4
with:
path: |
~/.cargo/registry
~/.cargo/git
target
key: stable-x86_64-unknown-linux-gnu-node@18-cargo-cache
- name: Install dependencies
run: yarn install --immutable --mode=skip-build
- name: Build
run: |
bun run build
yarn workspace @examples/napi build --features dyn-symbols
- name: Test
continue-on-error: true
run: bun run test:bun
release-npm:
runs-on: ubuntu-latest
needs:
- lint
- build_binary_crate
if: "startsWith(github.event.head_commit.message, 'chore(release): publish')"
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 20
cache: 'yarn'
- name: Publish
run: |
yarn install --mode=skip-build
yarn build
npm config set provenance true
echo "//registry.npmjs.org/:_authToken=$NPM_TOKEN" >> ~/.npmrc
yarn lerna publish from-package --pre-dist-tag canary --yes
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}