name: CI env: DEBUG: 'napi:*' APP_NAME: 'skia' MACOSX_DEPLOYMENT_TARGET: '10.13' on: push: branches: - main tags-ignore: - '**' pull_request: concurrency: group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.sha }} cancel-in-progress: ${{ github.ref_name != 'main' }} jobs: lint: name: Lint SourceCode runs-on: ubuntu-latest container: image: ghcr.io/brooooooklyn/canvas/ubuntu-builder:jammy steps: - uses: actions/checkout@v7 with: submodules: true - name: Setup node uses: actions/setup-node@v7 with: node-version: 26 cache: 'yarn' - name: Install uses: ./.github/actions/setup-rust with: targets: x86_64-apple-darwin components: clippy, rustfmt - name: Install dependencies run: yarn install --immutable --mode=skip-build - name: Download skia binary run: | git config --global --add safe.directory $(pwd) node ./scripts/release-skia-binary.mjs --download - name: 'Lint JS/TS' run: yarn lint - name: Cargo fmt run: cargo fmt -- --check - name: Clippy run: cargo clippy lint-cpp: name: Lint C++ Code runs-on: macos-latest steps: - uses: actions/checkout@v7 - name: Install clang-format run: brew install clang-format - name: Format C++ Code run: clang-format --Werror --style=Chromium --fail-on-incomplete-format --dry-run skia-c/* build: strategy: fail-fast: false matrix: settings: - host: macos-latest target: 'x86_64-apple-darwin' build: | rustc --print target-cpus clang --version yarn build --target x86_64-apple-darwin -- --locked downloadTarget: '' - host: windows-latest setup: | choco upgrade llvm build: yarn build --target x86_64-pc-windows-msvc -- --locked target: 'x86_64-pc-windows-msvc' downloadTarget: '' - host: windows-latest setup: | choco upgrade llvm build: yarn build --target aarch64-pc-windows-msvc -- --locked target: 'aarch64-pc-windows-msvc' downloadTarget: 'aarch64-pc-windows-msvc' - host: ubuntu-latest target: 'x86_64-unknown-linux-gnu' downloadTarget: '' docker: ghcr.io/brooooooklyn/canvas/ubuntu-builder:jammy build: >- rustup install && rustup target add x86_64-unknown-linux-gnu && yarn build --target x86_64-unknown-linux-gnu -- --locked - host: ubuntu-latest downloadTarget: 'x86_64-unknown-linux-musl' target: 'x86_64-unknown-linux-musl' build: yarn build --target x86_64-unknown-linux-musl -x -- --locked - host: macos-latest downloadTarget: 'aarch64-apple-darwin' target: 'aarch64-apple-darwin' build: | export MACOSX_DEPLOYMENT_TARGET='11.0' clang --version yarn build --target aarch64-apple-darwin -- --locked - host: ubuntu-latest downloadTarget: 'aarch64-unknown-linux-gnu' target: 'aarch64-unknown-linux-gnu' docker: ghcr.io/brooooooklyn/canvas/ubuntu-builder:jammy-aarch64 build: >- set -e && rustup install && rustup target add aarch64-unknown-linux-gnu && yarn build --target aarch64-unknown-linux-gnu -- --locked - host: ubuntu-24.04-arm target: 'aarch64-unknown-linux-musl' downloadTarget: 'aarch64-unknown-linux-musl' build: yarn build --target aarch64-unknown-linux-musl -x -- --locked - host: ubuntu-latest target: 'aarch64-linux-android' downloadTarget: 'aarch64-linux-android' build: | export CLANG_VERSION=`ls ${ANDROID_NDK_LATEST_HOME}/toolchains/llvm/prebuilt/linux-x86_64/lib/clang | sed 's/ *$//g'` touch "${ANDROID_NDK_LATEST_HOME}/toolchains/llvm/prebuilt/linux-x86_64/lib/clang/${CLANG_VERSION}/lib/linux/aarch64/libgcc.a" chmod 777 "${ANDROID_NDK_LATEST_HOME}/toolchains/llvm/prebuilt/linux-x86_64/lib/clang/${CLANG_VERSION}/lib/linux/aarch64/libgcc.a" echo "INPUT(-lunwind)" > "${ANDROID_NDK_LATEST_HOME}/toolchains/llvm/prebuilt/linux-x86_64/lib/clang/${CLANG_VERSION}/lib/linux/aarch64/libgcc.a" export LDFLAGS="-fuse-ld=lld" export CC=aarch64-linux-android24-clang export CXX=aarch64-linux-android24-clang++ export CMAKE_TOOLCHAIN_FILE_aarch64_linux_android="$(pwd)/cmake/android-determine.cmake" yarn build --target aarch64-linux-android -- --locked - host: ubuntu-latest target: 'riscv64gc-unknown-linux-gnu' downloadTarget: 'riscv64gc-unknown-linux-gnu' build: | sudo apt-get update sudo apt-get install gcc-riscv64-linux-gnu g++-riscv64-linux-gnu -y export CC=riscv64-linux-gnu-gcc export CXX=riscv64-linux-gnu-g++ yarn build --target riscv64gc-unknown-linux-gnu -- --locked name: stable - ${{ matrix.settings.target }} - node@24 runs-on: ${{ matrix.settings.host }} steps: - uses: actions/checkout@v7 with: submodules: true - name: Setup node uses: actions/setup-node@v7 with: node-version: 26 cache: 'yarn' - name: Set env if: matrix.settings.host == 'windows-latest' run: echo "C:\\msys64\\mingw64\\bin" >> $GITHUB_PATH shell: bash - uses: mlugg/setup-zig@v2 if: ${{ contains(matrix.settings.target, 'musl') }} with: version: 0.15.1 - name: Install cargo-zigbuild uses: taiki-e/install-action@v2 if: ${{ contains(matrix.settings.target, 'musl') }} env: GITHUB_TOKEN: ${{ github.token }} with: tool: cargo-zigbuild - name: Setup nasm uses: ilammy/setup-nasm@v1 if: ${{ matrix.settings.host == 'windows-latest' || matrix.settings.target == 'x86_64-unknown-linux-musl' || matrix.settings.target == 'x86_64-apple-darwin' }} - name: Install uses: ./.github/actions/setup-rust with: targets: ${{ matrix.settings.target }} - name: Install dependencies run: yarn install --immutable --mode=skip-build - name: Setup toolchain run: ${{ matrix.settings.setup }} if: ${{ matrix.settings.setup }} - name: Download skia binary run: node ./scripts/release-skia-binary.mjs --download --target=${{ matrix.settings.downloadTarget }} - name: 'Build' if: ${{ !matrix.settings.docker }} run: ${{ matrix.settings.build }} # Keep the `--` before `--locked` intact. On Windows the default shell # is pwsh, where `yarn` resolves to yarn.ps1. PowerShell drops the first # `--` for scripts and keeps it only for native commands, so napi never # sees the separator and rejects `--locked` as an unknown option. shell: bash - name: Build in docker uses: tj-actions/docker-run@v2 if: ${{ matrix.settings.docker }} with: image: ${{ matrix.settings.docker }} name: build-${{ matrix.settings.target }} options: --user 0:0 -v ${{ github.workspace }}/.cargo-cache/git/db:/usr/local/cargo/git/db -v ${{ github.workspace }}/.cargo/registry/cache:/usr/local/cargo/registry/cache -v ${{ github.workspace }}/.cargo/registry/index:/usr/local/cargo/registry/index -v ${{ github.workspace }}:/build -w /build args: | sh -c "${{ matrix.settings.build }}" # As in the armv7 job: a shared-object link allows undefined symbols, # so a HarfBuzz, ICU or Skia symbol missing from the Skia archives # would only fail at its first call. musl has no symbol versions: what # its libc exports (zig's libc.S, the stub the addon links against) # does not count. riscv64 takes libstdc++ from the host process and # android liblog is unversioned, so those do not count either. - name: Check undefined symbols if: ${{ contains(matrix.settings.target, 'linux') }} shell: bash run: | set -euo pipefail NODES=("${APP_NAME}".*.node) F="${NODES[0]}" readelf --dyn-syms -W "$F" | awk '$7 == "UND" && $5 == "GLOBAL" && $8 != "" && $8 !~ /@/ && $8 !~ /^(napi_|node_api_)/ {print $8}' | sort -u > undefined.txt : > provided.txt case "${{ matrix.settings.target }}" in *-musl) ZIG_LIB=$(zig env | sed -nE 's/.*lib_dir"?[[:space:]]*[:=][[:space:]]*"([^"]+)".*/\1/p') grep -oE '^(\.globl|\.weak|WEAK64|WEAKTIME64)[[:space:]]+[A-Za-z0-9_]+' "$ZIG_LIB/libc/musl/libc.S" | awk '{print $2}' | sort -u > provided.txt ;; riscv64gc-*) LIBSTDCXX=$(riscv64-linux-gnu-g++ -print-file-name=libstdc++.so.6) readelf --dyn-syms -W "$LIBSTDCXX" | awk '$7 != "UND" && $8 != "" {sub(/@.*/, "", $8); print $8}' | sort -u > provided.txt ;; *-android) grep -E '^__android_log_' undefined.txt > provided.txt || true ;; esac comm -23 undefined.txt provided.txt > unresolved.txt if [ -s unresolved.txt ]; then cat unresolved.txt echo '::error::unversioned strong undefined symbols' exit 1 fi # The Windows link fails on a missing symbol; check that none comes # from a DLL instead (Windows ships its own ICU as icu.dll). - name: Check Windows imports if: ${{ contains(matrix.settings.target, 'windows-msvc') }} shell: bash run: | set -euo pipefail # vswhere prints CRLF; $(...) keeps the CR, which breaks the path. VS=$("/c/Program Files (x86)/Microsoft Visual Studio/Installer/vswhere.exe" -latest -products '*' -property installationPath | tr -d '\r') DUMPBINS=("$(cygpath -u "$VS")"/VC/Tools/MSVC/*/bin/Hostx64/x64/dumpbin.exe) DUMPBIN="${DUMPBINS[-1]}" if [ ! -x "$DUMPBIN" ]; then echo "::error::dumpbin not found under $VS" exit 1 fi NODES=("${APP_NAME}".*.node) F="${NODES[0]}" # Dash options: Git Bash rewrites a leading-slash argument such as # /imports into a Windows path before dumpbin sees it. "$DUMPBIN" -nologo -imports "$F" | tr -d '\r' > imports.txt sed -nE 's/^ ([^ ].*\.[dD][lL][lL])$/\1/p' imports.txt | tr '[:upper:]' '[:lower:]' | sort -u | tee dlls.txt # The addon imports GetProcAddress from kernel32 (napi-rs loads # node's functions with it): if either line is missing, the # format is not the one parsed here and the checks below would # pass. if ! grep -qx 'kernel32\.dll' dlls.txt || ! grep -qE '^ +[0-9A-Fa-f]+ +GetProcAddress$' imports.txt; then cat imports.txt echo '::error::could not read the dumpbin -imports output' exit 1 fi if grep -vxE 'advapi32\.dll|api-ms-win-core-synch-l1-2-0\.dll|bcryptprimitives\.dll|kernel32\.dll|ntdll\.dll' dlls.txt; then echo '::error::unexpected imported DLL' exit 1 fi if grep -E '^ +[0-9A-Fa-f]+ +(hb_|u_|ubidi_|ubrk_|ucasemap_|udata_|unorm2_|uscript_)' imports.txt; then echo '::error::HarfBuzz or ICU function imported from a DLL' exit 1 fi - name: Upload artifact uses: actions/upload-artifact@v7 with: name: bindings-${{ matrix.settings.target }} path: ${{ env.APP_NAME }}.*.node build-armv7-linux-gnueabihf: name: Build armv7-unknown-linux-gnueabihf runs-on: ubuntu-latest steps: - name: Install clang run: | sudo apt-get update sudo apt-get install -y clang-19 llvm-19 - uses: actions/checkout@v7 with: submodules: true - name: Setup cmake uses: jwlawson/actions-setup-cmake@v2 with: cmake-version: '4.x' - name: Setup node uses: actions/setup-node@v7 with: node-version: 26 cache: 'yarn' - name: Install uses: ./.github/actions/setup-rust with: targets: 'armv7-unknown-linux-gnueabihf' - name: Install dependencies run: yarn install --immutable --mode=skip-build # The Skia release also carries the libc++ libskia was compiled with, # built against the same glibc 2.17 sysroot napi-cross uses below. - name: Download skia binary run: | node ./scripts/release-skia-binary.mjs --download --target=armv7-unknown-linux-gnueabihf sudo mkdir -p /usr/armv7-unknown-linux-gnueabihf/lib/llvm-19 sudo tar -xzf libc++-linux-armv7-gnueabihf.tar.gz -C /usr/armv7-unknown-linux-gnueabihf/lib/llvm-19 # napi --use-napi-cross sets the GCC 4.8.5 linker, TARGET_SYSROOT and # TARGET_AR, and prefixes TARGET_CFLAGS/TARGET_CXXFLAGS with --sysroot # and --gcc-toolchain because TARGET_CC/TARGET_CXX are clang. Without # -mfpu clang turns on NEON. # cc 1.11 passes --target=arm-unknown-linux-gnueabihf (the rustc LLVM # triple), and clang then misses the napi-cross GCC install under # lib/gcc/armv7-unknown-linux-gnueabihf and links with the host ld. # --gcc-triple keeps that GCC install, and its ld, for every target. - name: Build run: | # libaom-sys forces armv7-linux-gcc.cmake, which runs # arm-linux-gnueabihf-{gcc,g++,as}. # libaom-sys sets AOM_TARGET_CPU=arm. cpu.cmake then compiles the # *_neon.c files, but rtcd.pl only matches armv7/armv8 and declares # the *_c functions only, so the NEON files call undeclared # functions. The NEON code is never called. GCC 10 only warned # about this; clang 16+ makes it an error. mkdir -p "$RUNNER_TEMP/armv7-bin" printf '#!/bin/sh\nexec clang-19 --target=armv7-unknown-linux-gnueabihf -Wno-error=implicit-function-declaration "$@"\n' > "$RUNNER_TEMP/armv7-bin/arm-linux-gnueabihf-gcc" printf '#!/bin/sh\nexec clang++-19 --target=armv7-unknown-linux-gnueabihf "$@"\n' > "$RUNNER_TEMP/armv7-bin/arm-linux-gnueabihf-g++" printf '#!/bin/sh\nexec armv7-unknown-linux-gnueabihf-as "$@"\n' > "$RUNNER_TEMP/armv7-bin/arm-linux-gnueabihf-as" chmod +x "$RUNNER_TEMP"/armv7-bin/* export PATH="$RUNNER_TEMP/armv7-bin:$PATH" yarn build --target armv7-unknown-linux-gnueabihf --use-napi-cross -- --locked env: TARGET_CC: clang-19 TARGET_CXX: clang++-19 TARGET_CFLAGS: --gcc-triple=armv7-unknown-linux-gnueabihf -march=armv7-a -mfpu=vfpv3-d16 -mfloat-abi=hard -mthumb TARGET_CXXFLAGS: --gcc-triple=armv7-unknown-linux-gnueabihf -march=armv7-a -mfpu=vfpv3-d16 -mfloat-abi=hard -mthumb -stdlib=libc++ -nostdinc++ -isystem/usr/armv7-unknown-linux-gnueabihf/lib/llvm-19/include/c++/v1 -L/usr/armv7-unknown-linux-gnueabihf/lib/llvm-19/lib # A shared-object link allows undefined symbols, so a missing libc or # libc++abi symbol would only fail at load time. README promises # glibc 2.18. - name: Check armv7 glibc and C++ runtime needs run: | set -euo pipefail F="${APP_NAME}.linux-arm-gnueabihf.node" llvm-readelf-19 -d "$F" | sed -n 's/.*(NEEDED).*\[\(.*\)\]/\1/p' | tee needed.txt if grep -vxE 'libc\.so\.6|libm\.so\.6|libdl\.so\.2|libpthread\.so\.0|librt\.so\.1|libgcc_s\.so\.1|ld-linux-armhf\.so\.3' needed.txt; then echo '::error::unexpected NEEDED library' exit 1 fi llvm-readelf-19 -V "$F" > versions.txt if grep -E 'GLIBCXX_|CXXABI_' versions.txt; then echo '::error::needs libstdc++' exit 1 fi MAX=$(grep -oE 'GLIBC_2\.[0-9]+' versions.txt | sort -u -t. -k2,2n | tail -1) echo "highest glibc version: $MAX" if [ "${MAX#GLIBC_2.}" -gt 18 ]; then echo "::error::needs $MAX, README promises 2.18" exit 1 fi llvm-readelf-19 --dyn-syms -W "$F" | awk '$7 == "UND" && $5 == "GLOBAL" && $8 != "" && $8 !~ /@/ && $8 !~ /^(napi_|node_api_)/' > unresolved.txt if [ -s unresolved.txt ]; then cat unresolved.txt echo '::error::unversioned strong undefined symbols' exit 1 fi - name: Upload artifact uses: actions/upload-artifact@v7 with: name: bindings-armv7-unknown-linux-gnueabihf path: ${{ env.APP_NAME }}.*.node test-macOS-windows-binding: name: Test bindings on ${{ matrix.settings.target }} - node@${{ matrix.node }} needs: - build strategy: fail-fast: false matrix: settings: - host: macos-latest target: 'x86_64-apple-darwin' - host: macos-latest target: 'aarch64-apple-darwin' - host: windows-latest target: 'x86_64-pc-windows-msvc' node: ['22', '24'] runs-on: ${{ matrix.settings.host }} steps: - uses: actions/checkout@v7 with: submodules: true - name: Download Apple Emoji font uses: robinraju/release-downloader@v1 with: repository: 'PoomSmart/EmojiLibrary' fileName: AppleColorEmoji@2x.ttf tag: '0.15.4' token: ${{ secrets.GITHUB_TOKEN }} out-file-path: __test__/fonts/ - name: Setup node uses: actions/setup-node@v7 if: startsWith(matrix.settings.target, 'x86_64') with: node-version: ${{ matrix.node }} cache: 'yarn' architecture: 'x64' - name: Setup node uses: actions/setup-node@v7 if: startsWith(matrix.settings.target, 'aarch64') with: node-version: ${{ matrix.node }} cache: 'yarn' architecture: 'arm64' - name: Install dependencies run: yarn install --immutable - name: Download artifacts uses: actions/download-artifact@v8 with: name: bindings-${{ matrix.settings.target }} path: . - name: Download icudtl.dat if: matrix.settings.host == 'windows-latest' run: node ./scripts/release-skia-binary.mjs --download-icu - name: Test bindings run: yarn test:ci env: RUN_STRESS_TESTS: 'true' - name: Test failed if: ${{ failure() }} uses: actions/upload-artifact@v7 with: name: failure-images-${{ matrix.settings.target }}-${{ matrix.node }} path: __test__/failure/** test-windows-arm64-binding: name: Test bindings on Windows ARM64 - node@${{ matrix.node }} needs: - build strategy: fail-fast: false matrix: node: ['22', '24'] runs-on: windows-11-arm steps: - uses: actions/checkout@v7 with: submodules: true - name: Download Apple Emoji font uses: robinraju/release-downloader@v1 with: repository: 'PoomSmart/EmojiLibrary' fileName: AppleColorEmoji@2x.ttf tag: '0.15.4' token: ${{ secrets.GITHUB_TOKEN }} out-file-path: __test__/fonts/ - name: Setup node uses: actions/setup-node@v7 with: node-version: ${{ matrix.node }} cache: 'yarn' architecture: 'arm64' - name: Install dependencies run: yarn install --immutable --mode=skip-build - name: Download artifacts uses: actions/download-artifact@v8 with: name: bindings-aarch64-pc-windows-msvc path: . - name: Download icudtl.dat run: node ./scripts/release-skia-binary.mjs --download-icu - name: Test bindings run: yarn test:ci - name: Test failed if: ${{ failure() }} uses: actions/upload-artifact@v7 with: name: failure-images-aarch64-pc-windows-msvc-${{ matrix.node }} path: __test__/failure/** test-linux-x64-gnu-binding: name: Test bindings on Linux-x64-gnu - node@${{ matrix.node }} needs: - build strategy: fail-fast: false matrix: node: ['22', '24'] runs-on: ubuntu-latest steps: - uses: actions/checkout@v7 - name: Download Apple Emoji font uses: robinraju/release-downloader@v1 with: repository: 'PoomSmart/EmojiLibrary' tag: '0.15.4' fileName: AppleColorEmoji@2x.ttf token: ${{ secrets.GITHUB_TOKEN }} out-file-path: __test__/fonts/ - name: Setup node uses: actions/setup-node@v7 with: node-version: ${{ matrix.node }} cache: 'yarn' - name: Install dependencies run: yarn install --immutable --mode=skip-build - name: Download artifacts uses: actions/download-artifact@v8 with: name: bindings-x86_64-unknown-linux-gnu path: . - name: List packages run: ls -R . shell: bash - name: Test bindings # Use the checked-in Yarn bundle; newer Node images omit Yarn/Corepack. run: docker run --rm -v "$(pwd):/canvas" -w /canvas node:${{ matrix.node }}-slim node .yarn/releases/yarn-*.cjs test:ci - name: Test failed if: ${{ failure() }} uses: actions/upload-artifact@v7 with: name: failure-images-x86_64-unknown-linux-gnu-${{ matrix.node }} path: __test__/failure/** test-linux-x64-musl-binding: name: Test bindings on x86_64-unknown-linux-musl - node@${{ matrix.node }} needs: - build strategy: fail-fast: false matrix: node: ['22', '24'] runs-on: ubuntu-latest steps: - uses: actions/checkout@v7 - name: Download Apple Emoji font uses: robinraju/release-downloader@v1 with: repository: 'PoomSmart/EmojiLibrary' fileName: AppleColorEmoji@2x.ttf tag: '0.15.4' token: ${{ secrets.GITHUB_TOKEN }} out-file-path: __test__/fonts/ - name: Setup node uses: actions/setup-node@v7 with: node-version: ${{ matrix.node }} cache: 'yarn' - name: Install dependencies run: | yarn config set supportedArchitectures.libc "musl" yarn install --immutable --mode=skip-build - name: Download artifacts uses: actions/download-artifact@v8 with: name: bindings-x86_64-unknown-linux-musl path: . - name: List packages run: ls -R . shell: bash - name: Test bindings # Use the checked-in Yarn bundle; newer Node images omit Yarn/Corepack. run: docker run --rm -v "$(pwd):/canvas" -w /canvas node:${{ matrix.node }}-alpine node .yarn/releases/yarn-*.cjs test:ci - name: Test failed if: ${{ failure() }} uses: actions/upload-artifact@v7 with: name: failure-images-x86_64-unknown-linux-musl-${{ matrix.node }} path: __test__/failure/** test-linux-aarch64-gnu-binding: name: Test bindings on aarch64-unknown-linux-gnu - node@${{ matrix.node }} needs: - build strategy: fail-fast: false matrix: node: ['22', '24'] runs-on: ubuntu-26.04-arm steps: - uses: actions/checkout@v7 - name: Download Apple Emoji font uses: robinraju/release-downloader@v1 with: repository: 'PoomSmart/EmojiLibrary' tag: '0.15.4' fileName: AppleColorEmoji@2x.ttf token: ${{ secrets.GITHUB_TOKEN }} out-file-path: __test__/fonts/ - name: Download artifacts uses: actions/download-artifact@v8 with: name: bindings-aarch64-unknown-linux-gnu path: . - name: List packages run: ls -R . shell: bash - name: Install dependencies run: yarn install --immutable --mode=skip-build - name: Setup and run tests uses: tj-actions/docker-run@v2 with: image: node:${{ matrix.node }}-slim name: test-aarch64-${{ matrix.node }} options: '--platform linux/arm64 -v ${{ github.workspace }}:/skia -w /skia' args: | sh -c "set -e && node .yarn/releases/yarn-*.cjs test:ci && ls -la" - name: Test failed if: ${{ failure() }} uses: actions/upload-artifact@v7 with: name: failure-images-aarch64-unknown-linux-gnu-${{ matrix.node }} path: __test__/failure/** test-linux-aarch64-musl-binding: name: Test bindings on aarch64-unknown-linux-musl - node@lts needs: - build runs-on: ubuntu-26.04-arm steps: - uses: actions/checkout@v7 - name: Download Apple Emoji font uses: robinraju/release-downloader@v1 with: repository: 'PoomSmart/EmojiLibrary' tag: '0.15.4' fileName: AppleColorEmoji@2x.ttf token: ${{ secrets.GITHUB_TOKEN }} out-file-path: __test__/fonts/ - name: Download artifacts uses: actions/download-artifact@v8 with: name: bindings-aarch64-unknown-linux-musl path: . - name: List packages run: ls -R . shell: bash - name: Install dependencies run: | yarn config set supportedArchitectures.cpu "arm64" yarn config set supportedArchitectures.libc "musl" yarn install --immutable --mode=skip-build - name: Setup and run tests uses: tj-actions/docker-run@v2 with: image: node:lts-alpine name: test-alpine-musl options: '--platform linux/arm64 -v ${{ github.workspace }}:/skia -w /skia' args: | sh -c "set -e && node .yarn/releases/yarn-*.cjs test:ci" - name: Test failed if: ${{ failure() }} uses: actions/upload-artifact@v7 with: name: failure-images-aarch64-unknown-linux-musl-lts path: __test__/failure/** test-linux-electron: name: Test bindings in Electron on ${{ matrix.settings.target }} needs: - build strategy: fail-fast: false matrix: settings: - host: ubuntu-latest target: x86_64-unknown-linux-gnu - host: ubuntu-26.04-arm target: aarch64-unknown-linux-gnu runs-on: ${{ matrix.settings.host }} steps: - uses: actions/checkout@v7 - name: Setup node uses: actions/setup-node@v7 with: node-version: 26 cache: 'yarn' - name: Install dependencies run: yarn install --immutable --mode=skip-build - name: Download artifacts uses: actions/download-artifact@v8 with: name: bindings-${{ matrix.settings.target }} path: . - name: Download Electron run: node node_modules/electron/install.js - name: Install Electron system libraries shell: bash run: | # Electron links GTK, NSS, ALSA and GBM even with ELECTRON_RUN_AS_NODE=1. # Ubuntu 24.04 renamed some of them with a t64 suffix: install whichever # name has a candidate. sudo apt-get update packages=() for names in 'libgtk-3-0t64 libgtk-3-0' 'libasound2t64 libasound2' libnss3 libgbm1 fonts-dejavu-core; do for name in $names; do if apt-cache policy "$name" | grep -q 'Candidate: [^(]'; then packages+=("$name") break fi done done sudo apt-get install -y --no-install-recommends "${packages[@]}" - name: Test bindings in Electron run: yarn e2e:electron rust-test: name: stable - macOS - cargo - test runs-on: macos-latest steps: - uses: actions/checkout@v7 with: submodules: true - name: Install uses: ./.github/actions/setup-rust with: targets: aarch64-apple-darwin - name: Install dependencies run: yarn install --immutable --mode=skip-build - name: Install llvm run: brew install llvm # `macos-latest` is arm64. Without an explicit target the script falls back # to the host-platform name in `scripts/utils.mjs`, which for darwin is # `lib*-darwin-x64.a` -- so this step used to pull x86_64 Skia onto an # arm64 runner and `ld` silently ignored every object in it. The job still # passed only because `-dead_strip` removed the whole FFI surface: no unit # test reached a `skiac_*` symbol, so nothing had to resolve. - name: Download skia binary run: node ./scripts/release-skia-binary.mjs --download --target=aarch64-apple-darwin - name: Test run: | clang --version cargo test -- --nocapture publish: name: Publish runs-on: ubuntu-latest permissions: contents: write id-token: write attestations: write needs: - test-linux-x64-gnu-binding - test-linux-x64-musl-binding - test-linux-aarch64-gnu-binding - test-linux-aarch64-musl-binding - test-linux-electron - build-armv7-linux-gnueabihf - test-macOS-windows-binding - test-windows-arm64-binding steps: - uses: actions/checkout@v7 with: submodules: true - name: Setup node uses: actions/setup-node@v7 with: node-version: 26 cache: 'yarn' - name: Install dependencies run: yarn install --immutable --mode=skip-build - name: Download all artifacts uses: actions/download-artifact@v8 with: path: artifacts - name: Move artifacts run: yarn artifacts - name: Download ICU for Windows run: node ./scripts/release-skia-binary.mjs --download-icu - name: Generate SBOMs run: node ./scripts/generate-sbom.mjs --all # Releases are commits whose message is a bare semver — the same check # npm publish uses below. Attestation needs id-token/attestations write # permissions that pull_request runs cannot get, so it must only run on # commits that actually publish. - name: Check if release id: release run: | if git log -1 --pretty=%B | grep -q "^[0-9]\+\.[0-9]\+\.[0-9]\+"; then echo "is-release=true" >> "$GITHUB_OUTPUT" else echo "is-release=false" >> "$GITHUB_OUTPUT" fi # actions/attest takes one predicate per invocation, so all binaries are # attested in a single call against the merged sbom-all.cdx.json. - name: Attest binaries if: steps.release.outputs.is-release == 'true' uses: actions/attest@v4 with: subject-path: npm/*/skia.*.node sbom-path: sbom/sbom-all.cdx.json - name: List packages run: ls -R ./npm shell: bash - name: Publish run: | npm install -g npm if git log -1 --pretty=%B | grep "^[0-9]\+\.[0-9]\+\.[0-9]\+$"; then npm publish --access public elif git log -1 --pretty=%B | grep "^[0-9]\+\.[0-9]\+\.[0-9]\+"; then npm publish --tag next --access public else echo "Not a release, skipping publish" fi env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # 'napi prepublish' (Publish's prepublishOnly hook) creates the v # release with the .node assets; attach the SBOMs to that same release. - name: Upload SBOMs to GitHub release run: | if ! git log -1 --pretty=%B | grep -q "^[0-9]\+\.[0-9]\+\.[0-9]\+"; then echo "Not a release, skipping SBOM upload" exit 0 fi if ! compgen -G "sbom/sbom-*.cdx.json" > /dev/null; then echo "::warning::no sbom/sbom-*.cdx.json files found, skipping upload" exit 0 fi TAG="v$(node -p 'require("./package.json").version')" if ! gh release view "$TAG" > /dev/null 2>&1; then echo "::warning::release $TAG not found, skipping SBOM upload" exit 0 fi gh release upload "$TAG" sbom/sbom-*.cdx.json --clobber env: GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}