Repository navigation
568 lines (553 loc) · 25.9 KB
/
Copy pathbuild-native.yml
File metadata and controls
568 lines (553 loc) · 25.9 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
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
# Reusable workflow that builds every native artifact the npm packages ship:
#
# artifact name contents destination in the repo
# --------------------- ------------------------------------ ---------------------------------------------
# canvas-android canvas-release.aar packages/canvas/platforms/android/
# canvas-ios CanvasNative.xcframework (tar.gz) packages/canvas/platforms/ios/CanvasNativeBinary/
# canvas-svg-android canvassvg-release.aar packages/canvas-svg/platforms/android/
# canvas-svg-ios CanvasSVG.xcframework (tar.gz) packages/canvas-svg/platforms/ios/CanvasSVGBinary/
# audio-context-android audiocontext-release.aar packages/audio-context/platforms/android/
# audio-context-ios AudioContextNative.xcframework packages/audio-context/platforms/ios/AudioContextNativeBinary/
# (tar.gz)
# canvas-windows-<arch> canvasnative.node + ANGLE DLLs packages/canvas/platforms/windows/<arch>/
# <module>-windows- canvassvg.node, audiocontext.node, packages/<module>/platforms/windows/<arch>/
# <arch> canvasmedia.node, canvasgamepad.node
# linux-<arch> every package's .node packages/<package>/platforms/linux/lib/<arch>/
# (tree rooted at packages/)
#
# tools/scripts/place-native-artifacts.sh copies a download of all of them into the tree.
#
# Not built here: the <plugin>.aar files under platforms/android (canvas_gamepad.aar,
# canvas_media.aar, canvas_polyfill.aar) are gitignored. The NativeScript CLI builds them from
# platforms/android/java during the app build. canvas-polyfill's async-release.aar ships as committed.
#
# xcframeworks are tarred before upload because upload-artifact does not
# preserve file permissions.
#
# The canvas build mirrors the local flow:
# Apple: one runner per platform (ios, visionos, tvos, catalyst) runs `make <platform>` and
# `canvas-build.sh <platform>` for its framework slices; canvas-ios joins them with
# `canvas-build.sh --xcframework`. Locally, `npm run build.canvas.ios.framework.release`
# does all of it on one machine. canvas-svg is split the same way.
# Android: make android, then gradle :canvas:assembleRelease and copy the aar
#
# Linux: tools/scripts/build-linux.sh on Ubuntu 22.04 (glibc 2.35, GTK 4.6), natively on
# x64 and arm64 runners, then the Node-API tests on Mesa (surfaceless EGL, lavapipe).
#
# Windows: tools/scripts/build-napi.sh <triple> release-napi [<crate>] (`make windows`,
# `make windows-svg`, `make windows-audio`, `make windows-media`); the modules other
# than canvasnative.node share one matrix job (napi-windows). Skia builds from source
# with the runner's LLVM and ninja, as locally with .tools/env.sh
# (.github/actions/setup-windows-native). arm64 is cross-compiled; the x64 jobs also
# run the Node-API test suites on the shipped modules (on WARP: runners have no GPU;
# audio renders offline and on the 'none' sink: they have no audio device either).
#
# The napi-windows modules and the canvas-svg / audio-context mobile builds change rarely, so
# their jobs cache the final artifact keyed on a hash of their sources and skip the whole build
# on a hit. The other jobs that build Skia keep its built libraries per target in
# .github/actions/skia-cache, saved only by pushes to master.
name: Build Native
permissions:
contents: read
on:
workflow_call:
env:
# bump to invalidate the canvas-svg / audio-context / canvas-media artifact caches
NATIVE_CACHE_VERSION: v1
jobs:
canvas-android:
name: Canvas Android
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v4
- uses: ./.github/actions/setup-android-native
- uses: ./.github/actions/skia-cache
with:
name: canvas-android
- name: Fetch V8 + NativeScript runtime headers
run: ./tools/scripts/download-v8.sh
- name: Build libNativeScript.so stub for linking
run: ./tools/scripts/build-android-v8-stub.sh
- name: Build Rust libraries
run: make android
# Saved right after the Rust build, so a later failing step cannot drop the cache.
- uses: ./.github/actions/skia-cache
with:
name: canvas-android
save: 'true'
- name: Build canvas AAR
working-directory: packages/canvas/src-native/canvas-android
run: ./gradlew :canvas:assembleRelease
- name: Copy AAR into platforms/android
run: cp packages/canvas/src-native/canvas-android/canvas/build/outputs/aar/canvas-release.aar packages/canvas/platforms/android/canvas-release.aar
- uses: actions/upload-artifact@v4
with:
name: canvas-android
path: packages/canvas/platforms/android/canvas-release.aar
if-no-files-found: error
# One runner per platform: its Rust targets, then its framework slices. The Xcode pre-build
# phase reruns cargo for each slice, so the slices are built in the job that owns the target dir.
canvas-apple:
name: Canvas ${{ matrix.platform }}
runs-on: macos-15
strategy:
fail-fast: false
matrix:
platform: [ios, visionos, tvos, catalyst]
steps:
- uses: actions/checkout@v4
- uses: ./.github/actions/setup-apple-native
- uses: ./.github/actions/skia-cache
with:
name: canvas-${{ matrix.platform }}
- name: Fetch V8 + NativeScript runtime headers
run: ./tools/scripts/download-v8.sh
- name: Build Rust libraries
run: make ${{ matrix.platform }}
# Saved right after the Rust build, so a later failing step cannot drop the cache.
- uses: ./.github/actions/skia-cache
with:
name: canvas-${{ matrix.platform }}
save: 'true'
- name: Build CanvasNative.framework slices
working-directory: tools/scripts
run: sh canvas-build.sh ${{ matrix.platform }}
# tar keeps the Catalyst framework's symlinks and the file modes
- name: Pack slices
working-directory: packages/canvas/src-native/canvas-ios/dist
run: tar -czf "$GITHUB_WORKSPACE/canvas-apple-${{ matrix.platform }}.tar.gz" Release-*/CanvasNative.framework Release-*/CanvasNative.framework.dSYM
- uses: actions/upload-artifact@v4
with:
name: canvas-apple-${{ matrix.platform }}
path: canvas-apple-${{ matrix.platform }}.tar.gz
if-no-files-found: error
retention-days: 1
canvas-ios:
name: Canvas xcframework
needs: canvas-apple
runs-on: macos-15
steps:
- uses: actions/checkout@v4
- uses: maxim-lobanov/setup-xcode@v1
with:
xcode-version: '^16.0'
- uses: actions/download-artifact@v4
with:
pattern: canvas-apple-*
merge-multiple: true
path: slices
- name: Unpack slices
run: |
mkdir -p packages/canvas/src-native/canvas-ios/dist
for f in slices/*.tar.gz; do tar -xzf "$f" -C packages/canvas/src-native/canvas-ios/dist; done
- name: Build CanvasNative.xcframework
working-directory: tools/scripts
run: sh canvas-build.sh --xcframework
- name: Pack xcframework
run: tar -czf canvas-ios.tar.gz -C packages/canvas/platforms/ios/CanvasNativeBinary CanvasNative.xcframework
- uses: actions/upload-artifact@v4
with:
name: canvas-ios
path: canvas-ios.tar.gz
if-no-files-found: error
canvas-svg-android:
name: Canvas SVG Android
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v4
- name: Restore cached AAR
id: svg-aar
uses: actions/cache@v4
with:
path: packages/canvas-svg/platforms/android/canvassvg-release.aar
key: ${{ env.NATIVE_CACHE_VERSION }}-canvas-svg-android-${{ hashFiles('crates/canvas-svg/**', 'crates/canvas-svg-c/**', 'crates/canvas-svg-android/**', 'crates/canvas-utils/**', 'crates/canvas-core/**', 'crates/gl-bindings/**', 'packages/canvas-svg/src-native/android/**', '!packages/canvas-svg/src-native/android/**/build/**', '!packages/canvas-svg/src-native/android/**/jniLibs/**', 'Cargo.lock', 'tools/scripts/build-svg-android.sh', 'tools/scripts/copy-svg-android.sh', 'Makefile') }}
- uses: ./.github/actions/setup-android-native
if: steps.svg-aar.outputs.cache-hit != 'true'
- uses: ./.github/actions/skia-cache
if: steps.svg-aar.outputs.cache-hit != 'true'
with:
name: canvas-svg-android
# canvassvg's CMake borrows both from packages/canvas (see its CMakeLists.txt)
- name: Fetch V8 + NativeScript runtime headers
if: steps.svg-aar.outputs.cache-hit != 'true'
run: ./tools/scripts/download-v8.sh
- name: Build libNativeScript.so stub for linking
if: steps.svg-aar.outputs.cache-hit != 'true'
run: ./tools/scripts/build-android-v8-stub.sh
- name: Build Rust libraries
if: steps.svg-aar.outputs.cache-hit != 'true'
run: make android-svg
# Saved right after the Rust build, so a later failing step cannot drop the cache.
- uses: ./.github/actions/skia-cache
if: steps.svg-aar.outputs.cache-hit != 'true'
with:
name: canvas-svg-android
save: 'true'
- name: Copy .so files into jniLibs
if: steps.svg-aar.outputs.cache-hit != 'true'
run: sh tools/scripts/copy-svg-android.sh
- name: Build canvassvg AAR
if: steps.svg-aar.outputs.cache-hit != 'true'
working-directory: packages/canvas-svg/src-native/android
run: ./gradlew :canvassvg:assembleRelease
- name: Copy AAR into platforms/android
if: steps.svg-aar.outputs.cache-hit != 'true'
run: cp packages/canvas-svg/src-native/android/canvassvg/build/outputs/aar/canvassvg-release.aar packages/canvas-svg/platforms/android/canvassvg-release.aar
- uses: actions/upload-artifact@v4
with:
name: canvas-svg-android
path: packages/canvas-svg/platforms/android/canvassvg-release.aar
if-no-files-found: error
# canvas-svg changes rarely: on a hit for its xcframework the per-platform jobs never start.
# The lookup runs on macOS like the restore, so both compute the same cache version.
canvas-svg-cache:
name: Canvas SVG cache lookup
runs-on: macos-15
outputs:
key: ${{ steps.key.outputs.key }}
hit: ${{ steps.lookup.outputs.cache-hit }}
steps:
- uses: actions/checkout@v4
- id: key
run: echo "key=${{ env.NATIVE_CACHE_VERSION }}-canvas-svg-ios-${{ hashFiles('crates/canvas-svg/**', 'crates/canvas-svg-c/**', 'crates/canvas-svg-ios/**', 'crates/canvas-utils/**', 'crates/canvas-core/**', 'packages/canvas-svg/src-native/ios/**', '!packages/canvas-svg/src-native/ios/dist/**', 'Cargo.lock', 'tools/scripts/canvas-svg-build.sh', 'Makefile') }}" >> "$GITHUB_OUTPUT"
- id: lookup
uses: actions/cache/restore@v4
with:
path: canvas-svg-ios.tar.gz
key: ${{ steps.key.outputs.key }}
lookup-only: true
canvas-svg-apple:
name: Canvas SVG ${{ matrix.platform }}
needs: canvas-svg-cache
if: needs.canvas-svg-cache.outputs.hit != 'true'
runs-on: macos-15
strategy:
fail-fast: false
matrix:
platform: [ios, visionos, tvos, catalyst]
steps:
- uses: actions/checkout@v4
- uses: ./.github/actions/setup-apple-native
- uses: ./.github/actions/skia-cache
with:
name: canvas-svg-${{ matrix.platform }}
- name: Build Rust libraries
run: make ${{ matrix.platform }}-svg
# Saved right after the Rust build, so a later failing step cannot drop the cache.
- uses: ./.github/actions/skia-cache
with:
name: canvas-svg-${{ matrix.platform }}
save: 'true'
- name: Build CanvasSVG.framework slices
working-directory: tools/scripts
run: sh canvas-svg-build.sh ${{ matrix.platform }}
- name: Pack slices
working-directory: packages/canvas-svg/src-native/ios/dist
run: tar -czf "$GITHUB_WORKSPACE/canvas-svg-apple-${{ matrix.platform }}.tar.gz" Release-*/CanvasSVG.framework Release-*/CanvasSVG.framework.dSYM
- uses: actions/upload-artifact@v4
with:
name: canvas-svg-apple-${{ matrix.platform }}
path: canvas-svg-apple-${{ matrix.platform }}.tar.gz
if-no-files-found: error
retention-days: 1
canvas-svg-ios:
name: Canvas SVG xcframework
needs: [canvas-svg-cache, canvas-svg-apple]
if: ${{ !cancelled() && needs.canvas-svg-cache.result == 'success' && contains(fromJSON('["success","skipped"]'), needs.canvas-svg-apple.result) }}
runs-on: macos-15
steps:
- uses: actions/checkout@v4
- name: Restore cached xcframework
id: svg-xcframework
uses: actions/cache@v4
with:
path: canvas-svg-ios.tar.gz
key: ${{ needs.canvas-svg-cache.outputs.key }}
- uses: maxim-lobanov/setup-xcode@v1
if: steps.svg-xcframework.outputs.cache-hit != 'true'
with:
xcode-version: '^16.0'
- uses: actions/download-artifact@v4
if: steps.svg-xcframework.outputs.cache-hit != 'true'
with:
pattern: canvas-svg-apple-*
merge-multiple: true
path: slices
- name: Unpack slices
if: steps.svg-xcframework.outputs.cache-hit != 'true'
run: |
mkdir -p packages/canvas-svg/src-native/ios/dist
for f in slices/*.tar.gz; do tar -xzf "$f" -C packages/canvas-svg/src-native/ios/dist; done
- name: Build CanvasSVG.xcframework
if: steps.svg-xcframework.outputs.cache-hit != 'true'
working-directory: tools/scripts
run: sh canvas-svg-build.sh --xcframework
- name: Pack xcframework
if: steps.svg-xcframework.outputs.cache-hit != 'true'
run: tar -czf canvas-svg-ios.tar.gz -C packages/canvas-svg/platforms/ios/CanvasSVGBinary CanvasSVG.xcframework
- uses: actions/upload-artifact@v4
with:
name: canvas-svg-ios
path: canvas-svg-ios.tar.gz
if-no-files-found: error
audio-context-android:
name: AudioContext Android
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v4
with:
# Oboe
submodules: true
- name: Restore cached AAR
id: audio-aar
uses: actions/cache@v4
with:
path: packages/audio-context/platforms/android/audiocontext-release.aar
key: ${{ env.NATIVE_CACHE_VERSION }}-audio-context-android-${{ hashFiles('packages/audio-context/src-native/android/**', '!packages/audio-context/src-native/android/**/build/**') }}
- uses: actions/setup-java@v4
if: steps.audio-aar.outputs.cache-hit != 'true'
with:
distribution: temurin
java-version: '17'
# read-only off master, see setup-android-native
- uses: gradle/actions/setup-gradle@v4
if: steps.audio-aar.outputs.cache-hit != 'true'
- name: Setup Android SDK
if: steps.audio-aar.outputs.cache-hit != 'true'
uses: android-actions/setup-android@v4
- name: Build audiocontext AAR
if: steps.audio-aar.outputs.cache-hit != 'true'
working-directory: packages/audio-context/src-native/android
run: ./gradlew :audiocontext:assembleRelease
- name: Copy AAR into platforms/android
if: steps.audio-aar.outputs.cache-hit != 'true'
run: cp packages/audio-context/src-native/android/audiocontext/build/outputs/aar/audiocontext-release.aar packages/audio-context/platforms/android/audiocontext-release.aar
- uses: actions/upload-artifact@v4
with:
name: audio-context-android
path: packages/audio-context/platforms/android/audiocontext-release.aar
if-no-files-found: error
audio-context-ios:
name: AudioContext iOS + visionOS + tvOS + Catalyst
runs-on: macos-15
steps:
- uses: actions/checkout@v4
- name: Restore cached xcframework
id: audio-xcframework
uses: actions/cache@v4
with:
path: audio-context-ios.tar.gz
key: ${{ env.NATIVE_CACHE_VERSION }}-audio-context-ios-${{ hashFiles('packages/audio-context/src-native/ios/**', 'tools/scripts/audio-context-build.sh') }}
- uses: ./.github/actions/setup-apple-native
if: steps.audio-xcframework.outputs.cache-hit != 'true'
with:
install-rust: 'false'
# libogg / libvorbis / libopus / libopusfile static libs per slice: gitignored, built from
# the xiph release tarballs.
- name: Restore cached opus deps
if: steps.audio-xcframework.outputs.cache-hit != 'true'
id: opus-deps
uses: actions/cache@v4
with:
path: packages/audio-context/src-native/ios/AudioContextNative/AudioContextNative/third_party/build
key: ${{ env.NATIVE_CACHE_VERSION }}-audio-context-opus-deps-${{ hashFiles('packages/audio-context/src-native/ios/AudioContextNative/AudioContextNative/scripts/fetch_opus_deps.sh', 'packages/audio-context/src-native/ios/AudioContextNative/AudioContextNative/scripts/build_opus_deps_ios.sh') }}
- name: Build opus deps
if: steps.audio-xcframework.outputs.cache-hit != 'true' && steps.opus-deps.outputs.cache-hit != 'true'
working-directory: packages/audio-context/src-native/ios/AudioContextNative/AudioContextNative
run: |
# opusfile's configure finds the ogg and opus it builds against through pkg-config
command -v pkg-config || brew install pkgconf
./scripts/build_opus_deps_ios.sh
# same as `npm run build.audiocontext.ios.framework.release`
- name: Build AudioContextNative.xcframework
if: steps.audio-xcframework.outputs.cache-hit != 'true'
working-directory: tools/scripts
run: sh audio-context-build.sh
- name: Pack xcframework
if: steps.audio-xcframework.outputs.cache-hit != 'true'
run: tar -czf audio-context-ios.tar.gz -C packages/audio-context/platforms/ios/AudioContextNativeBinary AudioContextNative.xcframework
- uses: actions/upload-artifact@v4
with:
name: audio-context-ios
path: audio-context-ios.tar.gz
if-no-files-found: error
canvas-windows:
name: Canvas Windows (${{ matrix.arch }})
runs-on: windows-2025
strategy:
fail-fast: false
matrix:
include:
- arch: x64
target: x86_64-pc-windows-msvc
- arch: arm64
target: aarch64-pc-windows-msvc
defaults:
run:
shell: bash
steps:
- uses: actions/checkout@v4
- uses: ./.github/actions/setup-windows-native
with:
target: ${{ matrix.target }}
- uses: ./.github/actions/skia-cache
with:
name: canvas-windows-${{ matrix.arch }}
- uses: actions/setup-node@v4
with:
node-version: '22'
- name: Build canvasnative.node (and fetch ANGLE)
run: ./tools/scripts/build-napi.sh ${{ matrix.target }} release-napi
# arm64 is cross-compiled, so only x64 runs them. The runners have no GPU: D3D12 and ANGLE
# fall back to WARP, and the WebGPU suites skip without an adapter.
# Saved right after the Rust build, so a later failing step cannot drop the cache.
- uses: ./.github/actions/skia-cache
with:
name: canvas-windows-${{ matrix.arch }}
save: 'true'
- name: Node-API tests
if: matrix.arch == 'x64'
env:
CANVAS_NAPI_ADDON: ${{ github.workspace }}\packages\canvas\platforms\windows\x64\canvasnative.node
run: node --expose-gc --test "crates/canvas-napi/__test__/*.test.mjs"
- uses: actions/upload-artifact@v4
with:
name: canvas-windows-${{ matrix.arch }}
path: packages/canvas/platforms/windows/${{ matrix.arch }}/
if-no-files-found: error
# The Node-API modules other than canvasnative.node: one entry per module.
napi-windows:
name: ${{ matrix.module.name }} Windows (${{ matrix.arch }})
runs-on: windows-2025
strategy:
fail-fast: false
matrix:
module:
# `sources`: every tracked directory the module is built from (its cache key).
- name: canvas-svg
crate: canvas-svg-napi
file: canvassvg.node
addon-env: CANVAS_SVG_NAPI_ADDON
sources: crates/canvas-svg crates/canvas-svg-c crates/canvas-svg-napi crates/canvas-utils
skia: true
# Runners have no audio device: its suite renders offline and on the 'none' sink.
- name: audio-context
crate: audio-context-napi
file: audiocontext.node
addon-env: AUDIO_CONTEXT_NAPI_ADDON
sources: crates/audio-context-napi
- name: canvas-media
crate: canvas-media-napi
file: canvasmedia.node
addon-env: CANVAS_MEDIA_NAPI_ADDON
sources: crates/canvas-media-napi
# no Node-API test suite
- name: canvas-gamepad
crate: canvas-gamepad-napi
file: canvasgamepad.node
sources: crates/canvas-gamepad-napi
arch: [x64, arm64]
include:
- arch: x64
target: x86_64-pc-windows-msvc
- arch: arm64
target: aarch64-pc-windows-msvc
defaults:
run:
shell: bash
env:
MODULE_DIR: packages/${{ matrix.module.name }}/platforms/windows/${{ matrix.arch }}
steps:
- uses: actions/checkout@v4
# The tree hashes of what the module is built from: equal hashes, equal module.
- name: Source key
id: sources
run: |
key=$(for path in ${{ matrix.module.sources }} crates/vendor/napi-sys Cargo.toml tools/scripts/build-napi.sh; do git rev-parse "HEAD:$path" || exit 1; done | sha256sum | cut -c1-32)
echo "key=$key" >> "$GITHUB_OUTPUT"
- name: Restore cached module
id: cache
uses: actions/cache@v4
with:
path: ${{ env.MODULE_DIR }}/${{ matrix.module.file }}
key: ${{ env.NATIVE_CACHE_VERSION }}-${{ matrix.module.name }}-windows-${{ matrix.arch }}-${{ steps.sources.outputs.key }}
- uses: ./.github/actions/setup-windows-native
if: steps.cache.outputs.cache-hit != 'true'
with:
target: ${{ matrix.target }}
- uses: ./.github/actions/skia-cache
if: steps.cache.outputs.cache-hit != 'true' && matrix.module.skia
with:
name: ${{ matrix.module.name }}-windows-${{ matrix.arch }}
- uses: actions/setup-node@v4
if: steps.cache.outputs.cache-hit != 'true' && matrix.arch == 'x64' && matrix.module.addon-env
with:
node-version: '22'
- name: Build ${{ matrix.module.file }}
if: steps.cache.outputs.cache-hit != 'true'
run: ./tools/scripts/build-napi.sh ${{ matrix.target }} release-napi ${{ matrix.module.crate }}
# arm64 is cross-compiled, so only x64 runs them. The timeout bounds a test process that
# hangs on exit (an addon releasing Media Foundation / D3D objects during process shutdown).
# Saved right after the Rust build, so a later failing step cannot drop the cache.
- uses: ./.github/actions/skia-cache
if: steps.cache.outputs.cache-hit != 'true' && matrix.module.skia
with:
name: ${{ matrix.module.name }}-windows-${{ matrix.arch }}
save: 'true'
- name: Node-API tests
if: steps.cache.outputs.cache-hit != 'true' && matrix.arch == 'x64' && matrix.module.addon-env
timeout-minutes: 5
run: |
export ${{ matrix.module.addon-env }}="$(cygpath -w "$PWD/$MODULE_DIR/${{ matrix.module.file }}")"
node --expose-gc --test "crates/${{ matrix.module.crate }}/__test__/*.test.mjs"
- uses: actions/upload-artifact@v4
with:
name: ${{ matrix.module.name }}-windows-${{ matrix.arch }}
path: ${{ env.MODULE_DIR }}/
if-no-files-found: error
# Every package's Linux Node-API module in one job: canvasnative.node and canvassvg.node share
# the Skia build. Natively on each arch (no cross sysroot).
linux:
name: Linux (${{ matrix.arch }})
runs-on: ${{ matrix.runner }}
strategy:
fail-fast: false
matrix:
include:
- arch: x64
runner: ubuntu-22.04
- arch: arm64
runner: ubuntu-22.04-arm
steps:
- uses: actions/checkout@v4
- uses: ./.github/actions/setup-linux-native
- uses: ./.github/actions/skia-cache
with:
name: linux-${{ matrix.arch }}
- uses: actions/setup-node@v4
with:
node-version: '22'
- name: Build the Node-API modules
run: ./tools/scripts/build-linux.sh
# Mesa's surfaceless EGL (llvmpipe) for 2D / WebGL and lavapipe for WebGPU: no GPU here.
# canvas-media's suite drives Media Foundation, so it is Windows only.
# Saved right after the Rust build, so a later failing step cannot drop the cache.
- uses: ./.github/actions/skia-cache
with:
name: linux-${{ matrix.arch }}
save: 'true'
- name: Node-API tests
env:
CANVAS_NAPI_ADDON: ${{ github.workspace }}/packages/canvas/platforms/linux/lib/${{ matrix.arch }}/canvasnative.node
CANVAS_SVG_NAPI_ADDON: ${{ github.workspace }}/packages/canvas-svg/platforms/linux/lib/${{ matrix.arch }}/canvassvg.node
AUDIO_CONTEXT_NAPI_ADDON: ${{ github.workspace }}/packages/audio-context/platforms/linux/lib/${{ matrix.arch }}/audiocontext.node
timeout-minutes: 10
run: |
node --expose-gc --test "crates/canvas-napi/__test__/*.test.mjs"
node --expose-gc --test "crates/canvas-svg-napi/__test__/*.test.mjs"
node --expose-gc --test "crates/audio-context-napi/__test__/*.test.mjs"
- uses: actions/upload-artifact@v4
with:
name: linux-${{ matrix.arch }}
path: packages/*/platforms/linux/lib/${{ matrix.arch }}/
if-no-files-found: error