diff --git a/.github/workflows/test-release.yaml b/.github/workflows/test-release.yaml index a9477221..b0eec774 100644 --- a/.github/workflows/test-release.yaml +++ b/.github/workflows/test-release.yaml @@ -376,7 +376,7 @@ jobs: ls -la ./cores build-and-test-linux-armv7: - name: stable - armv7-unknown-linux-gnu - node@18 + name: stable - armv7-unknown-linux-gnueabihf - node@20 runs-on: ubuntu-latest steps: @@ -401,7 +401,7 @@ jobs: ~/.cargo/registry ~/.cargo/git target - key: stable-linux-armv7-gnu-node@18-cargo-cache + key: stable-linux-armv7-gnueabihf-node@20-cargo-cache - name: Install dependencies run: | diff --git a/.github/workflows/zig.yaml b/.github/workflows/zig.yaml index 69af356a..4a90f216 100644 --- a/.github/workflows/zig.yaml +++ b/.github/workflows/zig.yaml @@ -26,6 +26,7 @@ jobs: 'x86_64-apple-darwin', 'x86_64-unknown-linux-musl', 'aarch64-unknown-linux-musl', + 'armv7-unknown-linux-musleabihf', ] steps: @@ -49,8 +50,6 @@ jobs: ~/.cargo/git target key: stable-zig-${{ matrix.target }}-cargo-cache - - name: Install aarch64 toolchain - run: rustup target add aarch64-unknown-linux-gnu - name: Install ziglang uses: goto-bus-stop/setup-zig@v2 with: @@ -94,6 +93,10 @@ jobs: target: x86_64-apple-darwin - host: ubuntu-latest target: aarch64-unknown-linux-musl + docker-platform: arm64 + - host: ubuntu-latest + target: armv7-unknown-linux-musleabihf + docker-platform: arm/v7 steps: - uses: actions/checkout@v4 @@ -105,7 +108,7 @@ jobs: - name: Install dependencies run: | yarn config set --json supportedArchitectures.libc '["current", "musl"]' - yarn config set --json supportedArchitectures.cpu '["current", "arm64"]' + yarn config set --json supportedArchitectures.cpu '["current", "arm64", "arm"]' yarn install --immutable --mode=skip-build - name: Download artifacts uses: actions/download-artifact@v4 @@ -130,13 +133,23 @@ jobs: if: matrix.settings.host == 'ubuntu-latest' - name: Test uses: addnab/docker-run-action@v3 - if: matrix.settings.target == 'aarch64-unknown-linux-musl' + if: matrix.settings.host == 'ubuntu-latest' && matrix.settings.target != 'x86_64-unknown-linux-musl' && matrix.settings.target != 'armv7-unknown-linux-musleabihf' with: image: node:lts-alpine - options: --platform linux/arm64 -v ${{ github.workspace }}:/build -w /build + options: --platform linux/${{ matrix.settings.docker-platform }} -v ${{ github.workspace }}:/build -w /build run: | set -e yarn test + - name: Test + uses: addnab/docker-run-action@v3 + if: matrix.settings.target == 'armv7-unknown-linux-musleabihf' + with: + # https://github.com/nodejs/docker-node/issues/1798 + image: node:18-alpine + options: --platform linux/${{ matrix.settings.docker-platform }} -v ${{ github.workspace }}:/build -w /build + run: | + set -e + yarn test:without-lerna - name: Test uses: addnab/docker-run-action@v3 if: matrix.settings.target == 'x86_64-unknown-linux-musl' diff --git a/cli/src/api/templates/ci-template.ts b/cli/src/api/templates/ci-template.ts index b04d3bc2..40a8fc96 100644 --- a/cli/src/api/templates/ci-template.ts +++ b/cli/src/api/templates/ci-template.ts @@ -58,6 +58,9 @@ jobs: - host: ubuntu-latest target: 'armv7-unknown-linux-gnueabihf' build: ${packageManager} build --platform --target armv7-unknown-linux-gnueabihf --use-napi-cross + - host: ubuntu-latest + target: 'armv7-unknown-linux-musleabihf' + build: ${packageManager} build --platform --target armv7-unknown-linux-musleabihf -x - host: ubuntu-latest target: 'aarch64-linux-android' build: ${packageManager} build --platform --target aarch64-linux-android diff --git a/cli/src/api/templates/js-binding.ts b/cli/src/api/templates/js-binding.ts index aeb141c1..1cb2ec3c 100644 --- a/cli/src/api/templates/js-binding.ts +++ b/cli/src/api/templates/js-binding.ts @@ -125,7 +125,11 @@ function requireNative() { ${requireTuple('linux-arm64-gnu')} } } else if (process.arch === 'arm') { - ${requireTuple('linux-arm-gnueabihf')} + if (isMusl()) { + ${requireTuple('linux-arm-musleabihf')} + } else { + ${requireTuple('linux-arm-gnueabihf')} + } } else if (process.arch === 'riscv64') { if (isMusl()) { ${requireTuple('linux-riscv64-musl')} diff --git a/cli/src/utils/__tests__/__snapshots__/config.spec.ts.snap b/cli/src/utils/__tests__/__snapshots__/config.spec.ts.snap index 38093d05..d542d762 100644 Binary files a/cli/src/utils/__tests__/__snapshots__/config.spec.ts.snap and b/cli/src/utils/__tests__/__snapshots__/config.spec.ts.snap differ diff --git a/cli/src/utils/__tests__/__snapshots__/target.spec.ts.md b/cli/src/utils/__tests__/__snapshots__/target.spec.ts.md index ec16fbae..b022c3b5 100644 --- a/cli/src/utils/__tests__/__snapshots__/target.spec.ts.md +++ b/cli/src/utils/__tests__/__snapshots__/target.spec.ts.md @@ -93,6 +93,13 @@ Generated by [AVA](https://avajs.dev). platformArchABI: 'linux-arm-gnueabihf', triple: 'armv7-unknown-linux-gnueabihf', }, + { + abi: 'musleabihf', + arch: 'arm', + platform: 'linux', + platformArchABI: 'linux-arm-musleabihf', + triple: 'armv7-unknown-linux-musleabihf', + }, { abi: 'eabi', arch: 'arm', diff --git a/cli/src/utils/__tests__/__snapshots__/target.spec.ts.snap b/cli/src/utils/__tests__/__snapshots__/target.spec.ts.snap index 3dd91803..3d019842 100644 Binary files a/cli/src/utils/__tests__/__snapshots__/target.spec.ts.snap and b/cli/src/utils/__tests__/__snapshots__/target.spec.ts.snap differ diff --git a/cli/src/utils/__tests__/__snapshots__/typegen.spec.ts.snap b/cli/src/utils/__tests__/__snapshots__/typegen.spec.ts.snap index cad503c8..541f4d14 100644 Binary files a/cli/src/utils/__tests__/__snapshots__/typegen.spec.ts.snap and b/cli/src/utils/__tests__/__snapshots__/typegen.spec.ts.snap differ diff --git a/cli/src/utils/__tests__/__snapshots__/version.spec.ts.snap b/cli/src/utils/__tests__/__snapshots__/version.spec.ts.snap index a9b699be..5a462fcb 100644 Binary files a/cli/src/utils/__tests__/__snapshots__/version.spec.ts.snap and b/cli/src/utils/__tests__/__snapshots__/version.spec.ts.snap differ diff --git a/cli/src/utils/ci.ts b/cli/src/utils/ci.ts index d77148db..9e3af6b0 100644 --- a/cli/src/utils/ci.ts +++ b/cli/src/utils/ci.ts @@ -79,6 +79,12 @@ export const CIConfig: Partial< yarn_cpu: 'arm', test_image: 'ghcr.io/napi-rs/napi-rs/nodejs:armhf-${{ matrix.node }}', }, + 'armv7-unknown-linux-musleabihf': { + host: 'ubuntu-latest', + test: false, + yarn_cpu: 'arm', + yarn_libc: 'musl', + }, 'aarch64-linux-android': { host: 'ubuntu-latest', build_setup: [ diff --git a/cli/src/utils/target.ts b/cli/src/utils/target.ts index a44e7b01..9b4e7c96 100644 --- a/cli/src/utils/target.ts +++ b/cli/src/utils/target.ts @@ -19,6 +19,7 @@ export const AVAILABLE_TARGETS = [ 'x86_64-unknown-freebsd', 'i686-pc-windows-msvc', 'armv7-unknown-linux-gnueabihf', + 'armv7-unknown-linux-musleabihf', 'armv7-linux-androideabi', 'universal-apple-darwin', 'riscv64gc-unknown-linux-gnu', diff --git a/examples/napi/index.cjs b/examples/napi/index.cjs index 2cf9a4bd..20dd6cf6 100644 --- a/examples/napi/index.cjs +++ b/examples/napi/index.cjs @@ -246,7 +246,20 @@ function requireNative() { } } else if (process.arch === 'arm') { + if (isMusl()) { + try { + return require('./example.linux-arm-musleabihf.node') + } catch (e) { + loadErrors.push(e) + } try { + return require('@examples/napi-linux-arm-musleabihf') + } catch (e) { + loadErrors.push(e) + } + + } else { + try { return require('./example.linux-arm-gnueabihf.node') } catch (e) { loadErrors.push(e) @@ -257,6 +270,7 @@ function requireNative() { loadErrors.push(e) } + } } else if (process.arch === 'riscv64') { if (isMusl()) { try { diff --git a/package.json b/package.json index e81e24f8..f5beb2fd 100644 --- a/package.json +++ b/package.json @@ -29,6 +29,7 @@ "format:toml": "taplo format", "lint": "eslint -c .eslintrc.yml .", "test": "lerna run test --concurrency=1 --ignore @napi-rs/cli", + "test:without-lerna": "yarn workspaces foreach -A --exclude \"{cli,napi-rs}\" run test", "test:bun": "bun test examples/napi/__tests__/values.spec.ts", "test:cli": "yarn workspace @napi-rs/cli test", "test:electron": "electron examples/napi/electron.cjs",