fix(cli): Fix Windows bindings for Electron/MSYS2 and refresh MSYS2 CI #3636
Workflow file for this run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Test & Release | |
| env: | |
| DEBUG: 'napi:*' | |
| RUST_BACKTRACE: 1 | |
| # https://github.com/nodejs/node/issues/51555#issuecomment-2290742072 | |
| DISABLE_V8_COMPILE_CACHE: 1 | |
| permissions: {} | |
| concurrency: | |
| group: ${{ github.workflow }}-${{ github.ref }} | |
| cancel-in-progress: true | |
| on: | |
| push: | |
| branches: | |
| - main | |
| pull_request: | |
| jobs: | |
| lint: | |
| name: Lint SourceCode | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v6 | |
| - name: Setup node | |
| uses: actions/setup-node@v6 | |
| with: | |
| node-version: 24 | |
| cache: 'yarn' | |
| - name: Install | |
| uses: dtolnay/rust-toolchain@stable | |
| with: | |
| toolchain: stable | |
| components: rustfmt, clippy | |
| - name: Cache cargo | |
| uses: actions/cache@v5 | |
| 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: | |
| permissions: | |
| contents: read | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| node: ['20', '22', '24'] | |
| settings: | |
| - host: ubuntu-latest | |
| target: x86_64-unknown-linux-gnu | |
| build: yarn build:test | |
| test: | | |
| yarn test:cli | |
| yarn test | |
| yarn workspace @examples/napi test:leak | |
| yarn tsc -p examples/napi/tsconfig.json --noEmit --skipLibCheck | |
| yarn test:macro | |
| cargo test | |
| toolchain: stable | |
| - host: ubuntu-latest | |
| target: x86_64-unknown-linux-gnu | |
| build: yarn build:test | |
| test: | | |
| yarn test:cli | |
| yarn test | |
| yarn tsc -p examples/napi/tsconfig.json --noEmit --skipLibCheck | |
| yarn test:macro | |
| toolchain: 1.88.0 | |
| - host: macos-latest | |
| target: aarch64-apple-darwin | |
| build: yarn build:test | |
| test: | | |
| yarn test:cli | |
| yarn test | |
| yarn workspace @examples/napi test:leak | |
| yarn tsc -p examples/napi/tsconfig.json --noEmit --skipLibCheck | |
| RUSTFLAGS="-C link-args=-Wl,-undefined,dynamic_lookup,-no_fixup_chains" | |
| cargo test | |
| toolchain: stable | |
| - host: windows-latest | |
| target: x86_64-pc-windows-msvc | |
| build: yarn workspace @examples/napi build | |
| test: | | |
| yarn test:cli | |
| yarn workspace @examples/napi test | |
| yarn workspace @examples/napi test:leak | |
| yarn tsc -p examples/napi/tsconfig.json --noEmit --skipLibCheck | |
| yarn test:macro | |
| cargo test | |
| toolchain: stable | |
| - host: windows-11-arm | |
| target: aarch64-pc-windows-msvc | |
| build: yarn build:test | |
| test: | | |
| yarn test:cli | |
| yarn test | |
| 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: | | |
| export NODE_OPTIONS="--max-old-space-size=3072" | |
| yarn workspace @examples/napi test -s | |
| node ./node_modules/electron/install.js | |
| yarn test:electron | |
| toolchain: stable | |
| exclude: | |
| - settings: | |
| toolchain: 1.88.0 | |
| node: 20 | |
| - settings: | |
| target: i686-pc-windows-msvc | |
| node: 20 | |
| - settings: | |
| target: aarch64-pc-windows-msvc | |
| node: 20 | |
| name: ${{ matrix.settings.target }} - node@${{ matrix.node }} - toolchain@ ${{ matrix.settings.toolchain }} | |
| runs-on: ${{ matrix.settings.host }} | |
| steps: | |
| - uses: actions/checkout@v6 | |
| - name: Setup node | |
| uses: actions/setup-node@v6 | |
| with: | |
| node-version: ${{ matrix.node }} | |
| cache: 'yarn' | |
| - name: Install rustup (Windows 11 ARM) | |
| if: matrix.settings.host == 'windows-11-arm' | |
| shell: pwsh | |
| run: | | |
| Invoke-WebRequest -Uri "https://static.rust-lang.org/rustup/dist/aarch64-pc-windows-msvc/rustup-init.exe" -OutFile rustup-init.exe | |
| .\rustup-init.exe --default-toolchain none -y | |
| "$env:USERPROFILE\.cargo\bin" | Out-File -Append -Encoding ascii $env:GITHUB_PATH | |
| "CARGO_HOME=$env:USERPROFILE\.cargo" | Out-File -Append -Encoding ascii $env:GITHUB_ENV | |
| - name: Install Rust (Windows 11 ARM) | |
| if: matrix.settings.host == 'windows-11-arm' | |
| shell: pwsh | |
| run: | | |
| rustup install stable | |
| rustup target add ${{ matrix.settings.target }} | |
| cargo --version | |
| - name: Install | |
| uses: dtolnay/rust-toolchain@stable | |
| if: matrix.settings.host != 'windows-11-arm' | |
| with: | |
| toolchain: ${{ matrix.settings.toolchain }} | |
| targets: ${{ matrix.settings.target }} | |
| - name: Cache cargo | |
| uses: actions/cache@v5 | |
| 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", "ia32", "wasm32"]' | |
| 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 }} | |
| env: | |
| CARGO_PROFILE_DEV_OPT_LEVEL: 1 | |
| - name: Setup node | |
| uses: actions/setup-node@v6 | |
| if: matrix.settings.target == 'i686-pc-windows-msvc' | |
| with: | |
| node-version: 22 | |
| architecture: 'x86' | |
| - name: Unit tests | |
| if: matrix.settings.test | |
| run: ${{ matrix.settings.test }} | |
| shell: bash | |
| timeout-minutes: 10 | |
| env: | |
| NODE_OPTIONS: '--max-old-space-size=8192' | |
| DISABLE_V8_COMPILE_CACHE: 1 | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| - 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: | | |
| sudo sysctl -w kernel.apparmor_restrict_unprivileged_userns=0 | |
| 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-and-test-msys2: | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| settings: | |
| - sys: UCRT64 | |
| target: x86_64-pc-windows-gnu | |
| - sys: MINGW64 | |
| target: x86_64-pc-windows-gnu | |
| - sys: CLANG64 | |
| target: x86_64-pc-windows-gnullvm | |
| - sys: CLANGARM64 | |
| target: aarch64-pc-windows-gnullvm | |
| name: ${{ matrix.settings.target }} - msys2/${{ matrix.settings.sys }} | |
| runs-on: ${{ matrix.settings.sys == 'CLANGARM64' && 'windows-11-arm' || 'windows-latest' }} | |
| steps: | |
| - uses: actions/checkout@v6 | |
| with: | |
| path: napi-rs | |
| # NOTE: The patch should be applied to the upstream | |
| # repo of oxc-node, and once the oxc-node gnu/gnullvm | |
| # bindings are publish, this part should be removed. | |
| - uses: actions/checkout@v6 | |
| with: | |
| repository: oxc-project/oxc-node | |
| ref: v0.0.35 | |
| path: oxc-node | |
| - name: Patch oxc-node | |
| working-directory: oxc-node | |
| shell: bash | |
| run: | | |
| git apply <<'PATCH' | |
| diff --git a/.cargo/config.toml b/.cargo/config.toml | |
| index dda5ea5..3e8417f 100644 | |
| --- a/.cargo/config.toml | |
| +++ b/.cargo/config.toml | |
| @@ -1,4 +1,4 @@ | |
| -[target.'cfg(target_env = "gnu")'] | |
| +[target.'cfg(all(target_env = "gnu", target_os = "linux"))'] | |
| rustflags = ["-C", "link-args=-Wl,-z,nodelete"] | |
| [target.x86_64-pc-windows-msvc] | |
| @@ -10,7 +10,7 @@ rustflags = ["-C", "target-feature=+crt-static"] | |
| [target.aarch64-pc-windows-msvc] | |
| rustflags = ["-C", "target-feature=+crt-static"] | |
| -[target.'cfg(target_os = "windows")'] | |
| +[target.'cfg(all(target_os = "windows", target_env = "msvc"))'] | |
| rustflags = [ | |
| # Disables linking against the default Universal C Runtime (libucrt.lib). This prevents conflicts if another CRT library is linked manually. | |
| "-C", | |
| @@ -21,6 +21,9 @@ rustflags = [ | |
| "link-args=/DEFAULTLIB:ucrt.lib", | |
| ] | |
| +[target.x86_64-pc-windows-gnu] | |
| +rustflags = [ "-C", "link-arg=-ladvapi32" ] | |
| + | |
| # LLD linker is currently broken for us, opt out. | |
| # https://blog.rust-lang.org/2025/09/18/Rust-1.90.0/#what-s-in-1-90-0-stable | |
| [target.x86_64-unknown-linux-gnu] | |
| PATCH | |
| - uses: actions/checkout@v6 | |
| with: | |
| repository: rolldown/rolldown | |
| ref: v1.0.0-rc.1 | |
| path: rolldown | |
| - name: Patch rolldown | |
| working-directory: rolldown | |
| shell: bash | |
| run: | | |
| mkdir -p dummy/rolldown-binding-builder | |
| cp packages/rolldown/build-binding.ts dummy/rolldown-binding-builder/build-binding.mjs | |
| cat > dummy/rolldown-binding-builder/package.json <<'JSON' | |
| { | |
| "name": "rolldown-binding-builder", | |
| "private": true, | |
| "type": "module", | |
| "scripts": { | |
| "build": "node ./build-binding.mjs" | |
| }, | |
| "napi": { | |
| "binaryName": "rolldown-binding", | |
| "packageName": "@rolldown/binding", | |
| "targets": [ | |
| "x86_64-apple-darwin", | |
| "x86_64-pc-windows-msvc", | |
| "x86_64-unknown-linux-gnu", | |
| "x86_64-unknown-linux-musl", | |
| "x86_64-unknown-freebsd", | |
| "i686-pc-windows-msvc", | |
| "armv7-unknown-linux-gnueabihf", | |
| "aarch64-unknown-linux-gnu", | |
| "aarch64-apple-darwin", | |
| "aarch64-unknown-linux-musl", | |
| "aarch64-unknown-linux-ohos", | |
| "aarch64-pc-windows-msvc", | |
| "aarch64-linux-android", | |
| "wasm32-wasip1-threads" | |
| ], | |
| "wasm": { | |
| "initialMemory": 16384, | |
| "browser": { | |
| "fs": true, | |
| "asyncInit": true | |
| } | |
| }, | |
| "dtsHeader": "type MaybePromise<T> = T | Promise<T>\ntype Nullable<T> = T | null | undefined\ntype VoidNullable<T = void> = T | null | undefined | void\nexport type BindingStringOrRegex = string | RegExp\ntype BindingResult<T> = { errors: BindingError[], isBindingErrors: boolean } | T\n\n" | |
| }, | |
| "dependencies": { | |
| "@napi-rs/cli": "3.5.1", | |
| "glob": "11.0.3" | |
| } | |
| } | |
| JSON | |
| git apply <<'PATCH' | |
| diff --git a/.cargo/config.toml b/.cargo/config.toml | |
| index 7b46f90..72f7e0d 100644 | |
| --- a/.cargo/config.toml | |
| +++ b/.cargo/config.toml | |
| @@ -13,8 +13,8 @@ rustflags = ["-C", "target-feature=+crt-static"] | |
| [target.aarch64-pc-windows-msvc] | |
| rustflags = ["-C", "target-feature=+crt-static"] | |
| -[target.'cfg(target_os = "windows")'] | |
| -rustflags = [ | |
| +[target.'cfg(all(target_os = "windows", target_env = "msvc"))'] | |
| +rustfgags = [ | |
| # Disables linking against the default Universal C Runtime (libucrt.lib). This prevents conflicts if another CRT library is linked manually. | |
| "-C", | |
| "link-args=/NODEFAULTLIB:libucrt.lib", | |
| PATCH | |
| - name: Setup MSYS2 | |
| uses: msys2/setup-msys2@v2 | |
| with: | |
| msystem: ${{ matrix.settings.sys }} | |
| update: true | |
| install: >- | |
| git | |
| pacboy: >- | |
| toolchain:p | |
| cmake:p | |
| rust:p | |
| yarn:p | |
| ${{ (matrix.settings.sys == 'CLANG64' || matrix.settings.sys == 'CLANGARM64') && 'gcc-compat:p' || '' }} | |
| - name: Build oxc-node | |
| shell: msys2 {0} | |
| working-directory: oxc-node | |
| run: | | |
| cargo build --release --target ${{ matrix.settings.target }} | |
| - name: Build rolldown | |
| shell: msys2 {0} | |
| working-directory: rolldown | |
| run: | | |
| cd dummy/rolldown-binding-builder | |
| npm install | |
| npm run build | |
| - name: Install dependencies (napi-rs) | |
| shell: msys2 {0} | |
| working-directory: napi-rs | |
| run: | | |
| corepack enable | |
| yarn install --immutable --mode=skip-build | |
| # HACK: replace the msvc version | |
| - name: Use local build oxc-node and rolldown | |
| shell: msys2 {0} | |
| run: | | |
| # NOTE: oxc-node | |
| if [ "$MSYSTEM" = "CLANGARM64" ]; then | |
| # NOTE: this should be win32-arm64-gnullvm but the binding of oxc-node hasn't been updated, it depends on this PR | |
| NODE_ARTIFACT=node_modules/@oxc-node/core/oxc-node.win32-arm64-msvc.node | |
| elif [ "MSYSTEM" = "CLANG64" ]; then | |
| # NOTE: this should be win32-x64-gnullvm | |
| NODE_ARTIFACT=node_modules/@oxc-node/core/oxc-node.win32-x64-gnu.node | |
| else | |
| NODE_ARTIFACT=node_modules/@oxc-node/core/oxc-node.win32-x64-gnu.node | |
| fi | |
| cp oxc-node/target/${{matrix.settings.target}}/release/oxc_node.dll napi-rs/$NODE_ARTIFACT | |
| # NOTE: rolldown | |
| NODE_ARTIFACT=node_modules/rolldown/dist/shared/rolldown-binding.win32-x64-gnu.node | |
| if [ "$MSYSTEM" = "CLANGARM64" ]; then | |
| NODE_ARTIFACT=node_modules/rolldown/dist/shared/rolldown-binding.win32-arm64-msvc.node | |
| fi | |
| cp rolldown/dummy/rolldown-binding-builder/src/rolldown-binding.*.node napi-rs/$NODE_ARTIFACT | |
| - name: Build tests | |
| shell: msys2 {0} | |
| working-directory: napi-rs | |
| run: | | |
| yarn workspace @examples/napi build | |
| - name: Run tests | |
| shell: msys2 {0} | |
| working-directory: napi-rs | |
| run: | | |
| yarn test:cli | |
| # NOTE: skip `yarn workspace @examples/compat-mode test`, binary | |
| # can be built but cannot be loaded | |
| yarn workspace @examples/napi test | |
| yarn workspace @napi-rs/wasm-runtime test | |
| yarn workspace @examples/napi test:leak | |
| yarn tsc -p examples/napi/tsconfig.json --noEmit --skipLibCheck | |
| yarn test:macro | |
| cargo test | |
| - name: Electron tests | |
| shell: msys2 {0} | |
| working-directory: napi-rs | |
| run: | | |
| node ./node_modules/electron/install.js | |
| yarn test:electron | |
| - name: Test build with profile | |
| shell: msys2 {0} | |
| working-directory: napi-rs | |
| 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-24.04 | |
| target: aarch64-unknown-linux-ohos | |
| - host: ubuntu-latest | |
| target: riscv64gc-unknown-linux-gnu | |
| setup: | | |
| sudo apt-get update | |
| sudo apt-get install -y gcc-riscv64-linux-gnu | |
| - host: ubuntu-latest | |
| target: loongarch64-unknown-linux-gnu | |
| # TODO: Switch to gcc-loongarch64-linux when available | |
| setup: | | |
| sudo apt-get update | |
| sudo apt-get install -y gcc-13-loongarch64-linux-gnu | |
| steps: | |
| - uses: actions/checkout@v6 | |
| - name: Setup node | |
| uses: actions/setup-node@v6 | |
| with: | |
| node-version: 24 | |
| cache: 'yarn' | |
| - name: Setup OpenHarmony SDK | |
| if: ${{ contains(matrix.settings.target, 'ohos') }} | |
| uses: openharmony-rs/[email protected] | |
| - name: Install | |
| uses: dtolnay/rust-toolchain@stable | |
| with: | |
| toolchain: stable | |
| targets: ${{ matrix.settings.target }} | |
| - name: Cache cargo | |
| uses: actions/cache@v5 | |
| 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 | |
| env: | |
| TARGET_CC: clang | |
| 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 | |
| - target: s390x-unknown-linux-gnu | |
| - target: x86_64-unknown-linux-gnu | |
| - target: aarch64-unknown-linux-gnu | |
| steps: | |
| - uses: actions/checkout@v6 | |
| - name: Setup node | |
| uses: actions/setup-node@v6 | |
| with: | |
| node-version: 24 | |
| cache: 'yarn' | |
| - name: Install | |
| uses: dtolnay/rust-toolchain@stable | |
| with: | |
| toolchain: stable | |
| targets: ${{ matrix.settings.target }} | |
| - name: Cache cargo | |
| uses: actions/cache@v5 | |
| with: | |
| path: | | |
| ~/.cargo/registry | |
| ~/.cargo/git | |
| target | |
| ~/.napi-rs | |
| key: stable-ubuntu-latest-${{ matrix.settings.target }}-cargo-cache | |
| - name: Install dependencies | |
| run: yarn install --immutable --mode=skip-build | |
| - name: Cross build native tests | |
| run: yarn build:test -- --target ${{ matrix.settings.target }} --release --use-napi-cross | |
| shell: bash | |
| env: | |
| CARGO_PROFILE_DEV_OPT_LEVEL: 1 | |
| TARGET_CC: clang | |
| - uses: actions/upload-artifact@v6 | |
| with: | |
| name: ${{ matrix.settings.target }}-example | |
| path: examples/napi/*.node | |
| - uses: actions/upload-artifact@v6 | |
| with: | |
| name: ${{ matrix.settings.target }}-example-compat | |
| path: examples/napi-compat-mode/index.node | |
| build_musl: | |
| name: build - ${{ matrix.settings.target }} | |
| runs-on: ubuntu-latest | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| settings: | |
| - target: x86_64-unknown-linux-musl | |
| - target: aarch64-unknown-linux-musl | |
| steps: | |
| - uses: actions/checkout@v6 | |
| - name: Setup node | |
| uses: actions/setup-node@v6 | |
| with: | |
| node-version: 24 | |
| cache: 'yarn' | |
| - name: Install | |
| uses: dtolnay/rust-toolchain@stable | |
| with: | |
| targets: ${{ matrix.settings.target }} | |
| - name: Install dependencies | |
| run: yarn install --immutable --mode=skip-build | |
| - name: Install ziglang | |
| uses: mlugg/setup-zig@v2 | |
| with: | |
| version: 0.15.2 | |
| - name: Install cargo-zigbuild | |
| uses: taiki-e/install-action@v2 | |
| env: | |
| GITHUB_TOKEN: ${{ github.token }} | |
| with: | |
| tool: cargo-zigbuild | |
| - name: Cache cargo | |
| uses: actions/cache@v5 | |
| with: | |
| path: | | |
| .cargo-cache/registry | |
| .cargo-cache/git | |
| target | |
| key: stable-${{ matrix.settings.target }}-cargo-cache | |
| - name: Cross build musl | |
| run: yarn build:test -- --target ${{ matrix.settings.target }} -x | |
| - uses: actions/upload-artifact@v6 | |
| with: | |
| name: ${{ matrix.settings.target }}-example | |
| path: examples/napi/*.node | |
| if-no-files-found: error | |
| - uses: actions/upload-artifact@v6 | |
| with: | |
| name: ${{ matrix.settings.target }}-example-compat | |
| path: examples/napi-compat-mode/index.node | |
| if-no-files-found: error | |
| test_in_docker: | |
| name: Test - ${{ matrix.settings.target }} - ${{ matrix.node }} | |
| # Node.js on qemu segfaults on s390x and arm64v8 when using 24.04 | |
| # See also https://github.com/actions/runner-images/issues/11471 | |
| runs-on: ${{ contains(matrix.settings.target, 'aarch64') && 'ubuntu-24.04-arm' || 'ubuntu-22.04' }} | |
| permissions: | |
| contents: read | |
| needs: | |
| - build_musl | |
| - build_for_test_in_docker | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| node: [20, 22] | |
| 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' | |
| steps: | |
| - uses: actions/checkout@v6 | |
| - name: Setup node | |
| uses: actions/setup-node@v6 | |
| with: | |
| node-version: 24 | |
| cache: 'yarn' | |
| - uses: actions/download-artifact@v7 | |
| with: | |
| name: ${{ matrix.settings.target }}-example | |
| path: examples/napi/ | |
| - uses: actions/download-artifact@v7 | |
| with: | |
| name: ${{ matrix.settings.target }}-example-compat | |
| path: examples/napi-compat-mode/index.node | |
| - name: Install dependencies | |
| if: ${{ matrix.settings.arch != 's390x' }} | |
| 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: Install dependencies | |
| if: ${{ matrix.settings.arch == 's390x' }} | |
| run: | | |
| yarn config set --json supportedArchitectures.cpu '["current", "wasm32"]' | |
| yarn install --immutable --mode=skip-build | |
| yarn workspace @napi-rs/wasm-runtime build | |
| - name: Set up QEMU | |
| uses: docker/setup-qemu-action@v3 | |
| if: ${{ !contains(matrix.settings.target, 'aarch64') }} | |
| with: | |
| platforms: all | |
| image: tonistiigi/binfmt:qemu-v8.1.5 | |
| - run: docker run --rm --privileged multiarch/qemu-user-static --reset -p yes | |
| if: ${{ !contains(matrix.settings.target, 'aarch64') }} | |
| - 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 | |
| # Node.js on qemu randomly segfaults on powerpc64le | |
| continue-on-error: ${{ matrix.settings.target == 'powerpc64le-unknown-linux-gnu' || matrix.settings.target == 's390x-unknown-linux-gnu' }} | |
| with: | |
| image: ${{ steps.image-name.outputs.docker-image }} | |
| options: ${{ matrix.settings.args }} -v ${{ github.workspace }}:/build -w /build | |
| run: | | |
| export NODE_OPTIONS=--max-old-space-size=8192 | |
| export DISABLE_V8_COMPILE_CACHE=1 | |
| yarn workspace @examples/napi test | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| build-and-test-linux-armv7: | |
| name: stable - armv7-unknown-linux-gnueabihf - node@22 | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v6 | |
| - name: Setup node | |
| uses: actions/setup-node@v6 | |
| with: | |
| node-version: 22 | |
| cache: 'yarn' | |
| - name: Install | |
| uses: dtolnay/rust-toolchain@stable | |
| with: | |
| toolchain: stable | |
| targets: armv7-unknown-linux-gnueabihf | |
| - name: Cache cargo | |
| uses: actions/cache@v5 | |
| with: | |
| path: | | |
| ~/.cargo/registry | |
| ~/.cargo/git | |
| target | |
| key: stable-linux-armv7-gnueabihf-node@22-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 | |
| env: | |
| TARGET_CC: clang | |
| - 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:22-slim | |
| options: --platform linux/arm/v7 -v ${{ github.workspace }}:/build -w /build | |
| run: yarn test | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| build_binary_crate: | |
| runs-on: ubuntu-latest | |
| name: Test cli build binary | |
| steps: | |
| - uses: actions/checkout@v6 | |
| - name: Setup node | |
| uses: actions/setup-node@v6 | |
| with: | |
| node-version: 24 | |
| cache: 'yarn' | |
| - name: Install | |
| uses: dtolnay/rust-toolchain@stable | |
| with: | |
| toolchain: stable | |
| - name: Cache cargo | |
| uses: actions/cache@v5 | |
| 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,napi9,experimental,async,chrono_date,latin1,full' | |
| package: 'napi' | |
| - features: 'napi3' | |
| package: 'napi' | |
| - features: 'napi3,compat-mode' | |
| package: 'napi' | |
| - features: 'napi9' | |
| package: 'napi' | |
| - features: 'napi3,serde-json' | |
| package: 'napi' | |
| - features: 'napi9,serde-json' | |
| package: 'napi' | |
| - features: 'async,compat-mode' | |
| package: 'napi' | |
| - features: 'compat-mode,strict,type-def,noop,full,default' | |
| package: 'napi-derive' | |
| - features: 'noop' | |
| package: 'napi-examples' | |
| - features: 'snmalloc' | |
| package: 'napi-examples' | |
| name: stable - ubuntu-latest | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v6 | |
| - 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-freebsd: | |
| runs-on: ubuntu-latest | |
| name: Test freebsd target | |
| permissions: | |
| contents: read | |
| steps: | |
| - uses: actions/checkout@v6 | |
| - name: Install ziglang | |
| uses: mlugg/setup-zig@v2 | |
| with: | |
| version: 0.15.2 | |
| - uses: jaxxstorm/action-install-gh-release@v1 | |
| with: | |
| repo: rust-cross/cargo-zigbuild | |
| - name: Setup node | |
| uses: actions/setup-node@v6 | |
| with: | |
| node-version: 24 | |
| cache: 'yarn' | |
| - name: Install | |
| uses: dtolnay/rust-toolchain@stable | |
| with: | |
| toolchain: stable | |
| targets: x86_64-unknown-freebsd | |
| - name: Cache cargo | |
| uses: actions/cache@v5 | |
| with: | |
| path: | | |
| ~/.cargo/registry | |
| ~/.cargo/git | |
| target | |
| key: stable-cargo-cache-build-freebsd | |
| - name: 'Install dependencies' | |
| run: | | |
| yarn config set supportedArchitectures.cpu --json '["current", "x64", "arm64", "wasm32"]' | |
| yarn config set supportedArchitectures.os --json '["current", "freebsd"]' | |
| yarn install --mode=skip-build --immutable | |
| - name: Build | |
| run: | | |
| yarn workspace @examples/napi build --target x86_64-unknown-freebsd -x | |
| yarn tsc -p examples/napi/tsconfig.json | |
| rm -rf examples/napi/__tests__ | |
| mv examples/napi/dist/__tests__ examples/napi/ | |
| - name: Test | |
| id: build | |
| uses: cross-platform-actions/[email protected] | |
| env: | |
| DEBUG: 'napi:*' | |
| RUSTUP_HOME: /home/runner/rustup | |
| CARGO_HOME: /home/runner/cargo | |
| RUSTUP_IO_THREADS: 1 | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| with: | |
| operating_system: freebsd | |
| version: '15.0' | |
| memory: 12G | |
| cpu_count: 3 | |
| environment_variables: 'DEBUG RUSTUP_IO_THREADS GITHUB_TOKEN' | |
| shell: bash | |
| run: | | |
| env | sort | |
| sudo pkg install -y -f curl node libnghttp2 npm | |
| sudo npm install -g corepack | |
| sudo corepack enable | |
| echo "~~~~ node -v ~~~~" | |
| node -v | |
| echo "~~~~ yarn --version ~~~~" | |
| yarn --version | |
| pwd | |
| ls -lah | |
| whoami | |
| env | |
| freebsd-version | |
| export NODE_OPTIONS="--max-old-space-size=8192" | |
| yarn workspace @examples/napi test-js -s | |
| test-node-wasi: | |
| runs-on: ubuntu-latest | |
| name: Test node wasi target | |
| timeout-minutes: 10 | |
| steps: | |
| - uses: actions/checkout@v6 | |
| - name: Setup node | |
| uses: actions/setup-node@v6 | |
| with: | |
| node-version: 24 | |
| cache: 'yarn' | |
| cache-dependency-path: 'yarn.lock' | |
| - name: Install | |
| uses: dtolnay/rust-toolchain@stable | |
| with: | |
| toolchain: stable | |
| targets: wasm32-wasip1-threads | |
| - name: Install dependencies | |
| run: yarn install --immutable --mode=skip-build | |
| - name: Check | |
| run: cargo check -p napi --all-features --target wasm32-wasip1-threads | |
| env: | |
| RUSTFLAGS: '--cfg tokio_unstable' | |
| - name: Build | |
| run: | | |
| yarn build | |
| yarn workspace @examples/napi build --target wasm32-wasip1-threads --profile wasi | |
| env: | |
| RUSTFLAGS: '--cfg tokio_unstable' | |
| - 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 playwright install chromium | |
| yarn workspace @examples/napi vitest | |
| test-latest-bun: | |
| runs-on: ubuntu-latest | |
| name: Test latest bun | |
| timeout-minutes: 10 | |
| permissions: | |
| contents: read | |
| steps: | |
| - uses: actions/checkout@v6 | |
| - uses: oven-sh/setup-bun@v2 | |
| with: | |
| bun-version: latest | |
| - name: Setup node | |
| uses: actions/setup-node@v6 | |
| with: | |
| node-version: 24 | |
| cache: 'yarn' | |
| - name: Install | |
| uses: dtolnay/rust-toolchain@stable | |
| with: | |
| toolchain: stable | |
| targets: x86_64-unknown-linux-gnu | |
| - name: Cache cargo | |
| uses: actions/cache@v5 | |
| 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 | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| release-npm: | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: write | |
| id-token: write | |
| needs: | |
| - lint | |
| - build_binary_crate | |
| if: "startsWith(github.event.head_commit.message, 'chore(release): publish')" | |
| steps: | |
| - uses: actions/checkout@v6 | |
| - uses: actions/setup-node@v6 | |
| with: | |
| node-version: 24 | |
| cache: 'yarn' | |
| - name: Publish | |
| run: | | |
| yarn install --mode=skip-build | |
| npm install -g npm | |
| yarn build | |
| node ./.github/publish.js | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| done: | |
| runs-on: ubuntu-latest | |
| needs: | |
| - lint | |
| - build_and_test | |
| - build-and-test-msys2 | |
| - build_only | |
| - test_in_docker | |
| - build-and-test-linux-armv7 | |
| - build_binary_crate | |
| - check-all-features | |
| - test-freebsd | |
| - test-node-wasi | |
| - test-latest-bun | |
| steps: | |
| - run: exit 1 | |
| if: ${{ always() && (contains(needs.*.result, 'failure') || contains(needs.*.result, 'cancelled')) }} |