2022-01-04 20:26:22 +09:00
|
|
|
name: Zig-Cross-Compile
|
|
|
|
|
|
|
|
env:
|
|
|
|
DEBUG: 'napi:*'
|
2023-12-27 13:49:10 +09:00
|
|
|
TEST_ZIG_CROSS: '1'
|
2022-01-04 20:26:22 +09:00
|
|
|
|
2023-03-12 19:31:13 +09:00
|
|
|
concurrency:
|
|
|
|
group: ${{ github.workflow }}-${{ github.ref }}
|
|
|
|
cancel-in-progress: true
|
|
|
|
|
2022-01-04 20:26:22 +09:00
|
|
|
on:
|
|
|
|
push:
|
|
|
|
branches:
|
|
|
|
- main
|
|
|
|
pull_request:
|
|
|
|
|
|
|
|
jobs:
|
|
|
|
build:
|
|
|
|
name: Zig-Cross-Compile-On-Linux
|
|
|
|
runs-on: ubuntu-latest
|
|
|
|
strategy:
|
|
|
|
fail-fast: false
|
|
|
|
matrix:
|
|
|
|
target:
|
|
|
|
[
|
2024-04-23 13:14:06 +09:00
|
|
|
'aarch64-apple-darwin',
|
2022-01-04 20:26:22 +09:00
|
|
|
'x86_64-unknown-linux-musl',
|
|
|
|
'aarch64-unknown-linux-musl',
|
2024-04-08 22:04:57 +09:00
|
|
|
'armv7-unknown-linux-musleabihf',
|
2022-01-04 20:26:22 +09:00
|
|
|
]
|
|
|
|
|
|
|
|
steps:
|
|
|
|
- run: docker run --rm --privileged multiarch/qemu-user-static:register --reset
|
2023-09-04 23:34:40 +09:00
|
|
|
- uses: actions/checkout@v4
|
2022-01-04 20:26:22 +09:00
|
|
|
- name: Setup node
|
2023-10-24 12:03:35 +09:00
|
|
|
uses: actions/setup-node@v4
|
2022-01-04 20:26:22 +09:00
|
|
|
with:
|
2023-12-27 13:49:10 +09:00
|
|
|
node-version: 20
|
2022-01-04 20:26:22 +09:00
|
|
|
cache: 'yarn'
|
|
|
|
- name: Install
|
2023-03-12 19:24:48 +09:00
|
|
|
uses: dtolnay/rust-toolchain@stable
|
2022-01-04 20:26:22 +09:00
|
|
|
with:
|
|
|
|
toolchain: stable
|
2023-03-12 19:24:48 +09:00
|
|
|
targets: ${{ matrix.target }}
|
2022-04-15 22:22:04 +09:00
|
|
|
- name: Cache cargo
|
2024-01-18 11:35:59 +09:00
|
|
|
uses: actions/cache@v4
|
2022-04-15 22:22:04 +09:00
|
|
|
with:
|
|
|
|
path: |
|
|
|
|
~/.cargo/registry
|
|
|
|
~/.cargo/git
|
|
|
|
target
|
|
|
|
key: stable-zig-${{ matrix.target }}-cargo-cache
|
2022-01-04 20:26:22 +09:00
|
|
|
- name: Install ziglang
|
2022-12-09 18:29:03 +09:00
|
|
|
uses: goto-bus-stop/setup-zig@v2
|
2022-01-04 20:26:22 +09:00
|
|
|
with:
|
2024-04-23 13:14:06 +09:00
|
|
|
version: 0.12.0
|
2022-01-04 20:26:22 +09:00
|
|
|
- name: Install dependencies
|
2022-04-01 15:29:51 +09:00
|
|
|
run: yarn install --immutable --mode=skip-build
|
2023-04-06 12:04:53 +09:00
|
|
|
- name: install MacOS SDK
|
|
|
|
if: contains(matrix.target, 'apple')
|
|
|
|
run: |
|
|
|
|
curl -L "https://github.com/phracker/MacOSX-SDKs/releases/download/11.3/MacOSX11.3.sdk.tar.xz" | tar -J -x -C /opt
|
2022-01-04 20:26:22 +09:00
|
|
|
- name: Cross build native tests
|
2023-04-06 12:04:53 +09:00
|
|
|
env:
|
|
|
|
SDKROOT: /opt/MacOSX11.3.sdk
|
2022-01-04 20:26:22 +09:00
|
|
|
run: |
|
2023-04-06 12:04:53 +09:00
|
|
|
yarn build:test -- --target ${{ matrix.target }} --cross-compile
|
2022-01-04 20:26:22 +09:00
|
|
|
- name: Upload artifacts
|
2023-12-16 00:15:38 +09:00
|
|
|
uses: actions/upload-artifact@v4
|
2022-01-04 20:26:22 +09:00
|
|
|
with:
|
|
|
|
name: compat-${{ matrix.target }}
|
|
|
|
path: ./examples/napi-compat-mode/index.node
|
|
|
|
if-no-files-found: error
|
|
|
|
- name: Upload artifacts
|
2023-12-16 00:15:38 +09:00
|
|
|
uses: actions/upload-artifact@v4
|
2022-01-04 20:26:22 +09:00
|
|
|
with:
|
|
|
|
name: napi-${{ matrix.target }}
|
2024-02-26 16:46:07 +09:00
|
|
|
path: ./examples/napi/*.node
|
2022-01-04 20:26:22 +09:00
|
|
|
if-no-files-found: error
|
|
|
|
|
|
|
|
test:
|
|
|
|
name: Test Zig Cross Compiled ${{ matrix.settings.target }}
|
|
|
|
runs-on: ${{ matrix.settings.host }}
|
|
|
|
needs:
|
|
|
|
- build
|
|
|
|
strategy:
|
|
|
|
fail-fast: false
|
|
|
|
matrix:
|
|
|
|
settings:
|
|
|
|
- host: ubuntu-latest
|
|
|
|
target: x86_64-unknown-linux-musl
|
2024-04-23 13:14:06 +09:00
|
|
|
- host: macos-14
|
|
|
|
target: aarch64-apple-darwin
|
2022-01-04 20:26:22 +09:00
|
|
|
- host: ubuntu-latest
|
|
|
|
target: aarch64-unknown-linux-musl
|
2024-04-08 22:04:57 +09:00
|
|
|
docker-platform: arm64
|
|
|
|
- host: ubuntu-latest
|
|
|
|
target: armv7-unknown-linux-musleabihf
|
|
|
|
docker-platform: arm/v7
|
2022-01-04 20:26:22 +09:00
|
|
|
|
|
|
|
steps:
|
2023-09-04 23:34:40 +09:00
|
|
|
- uses: actions/checkout@v4
|
2022-01-04 20:26:22 +09:00
|
|
|
- name: Setup node
|
2023-10-24 12:03:35 +09:00
|
|
|
uses: actions/setup-node@v4
|
2022-01-04 20:26:22 +09:00
|
|
|
with:
|
2023-12-27 13:49:10 +09:00
|
|
|
node-version: 20
|
2022-01-04 20:26:22 +09:00
|
|
|
cache: 'yarn'
|
|
|
|
- name: Install dependencies
|
2023-04-11 11:47:52 +09:00
|
|
|
run: |
|
|
|
|
yarn config set --json supportedArchitectures.libc '["current", "musl"]'
|
2024-04-08 22:04:57 +09:00
|
|
|
yarn config set --json supportedArchitectures.cpu '["current", "arm64", "arm"]'
|
2023-04-11 11:47:52 +09:00
|
|
|
yarn install --immutable --mode=skip-build
|
2022-01-04 20:26:22 +09:00
|
|
|
- name: Download artifacts
|
2023-12-16 00:15:38 +09:00
|
|
|
uses: actions/download-artifact@v4
|
2022-01-04 20:26:22 +09:00
|
|
|
with:
|
|
|
|
name: napi-${{ matrix.settings.target }}
|
|
|
|
path: ./examples/napi/
|
|
|
|
- name: Download artifacts
|
2023-12-16 00:15:38 +09:00
|
|
|
uses: actions/download-artifact@v4
|
2022-01-04 20:26:22 +09:00
|
|
|
with:
|
|
|
|
name: compat-${{ matrix.settings.target }}
|
|
|
|
path: ./examples/napi-compat-mode/
|
|
|
|
- name: List files
|
|
|
|
run: |
|
|
|
|
ls ./examples/napi
|
|
|
|
ls ./examples/napi-compat-mode
|
|
|
|
- name: Test
|
|
|
|
run: yarn test --verbose
|
2022-08-20 00:36:36 +09:00
|
|
|
env:
|
|
|
|
SKIP_UNWIND_TEST: 1
|
2024-04-23 13:14:06 +09:00
|
|
|
if: matrix.settings.host == 'macos-14'
|
2023-04-11 11:47:52 +09:00
|
|
|
- run: docker run --rm --privileged multiarch/qemu-user-static --reset -p yes
|
|
|
|
if: matrix.settings.host == 'ubuntu-latest'
|
2022-01-04 20:26:22 +09:00
|
|
|
- name: Test
|
2023-04-11 11:47:52 +09:00
|
|
|
uses: addnab/docker-run-action@v3
|
2024-04-08 22:04:57 +09:00
|
|
|
if: matrix.settings.host == 'ubuntu-latest' && matrix.settings.target != 'x86_64-unknown-linux-musl' && matrix.settings.target != 'armv7-unknown-linux-musleabihf'
|
2022-01-04 20:26:22 +09:00
|
|
|
with:
|
2023-04-11 11:47:52 +09:00
|
|
|
image: node:lts-alpine
|
2024-04-08 22:04:57 +09:00
|
|
|
options: --platform linux/${{ matrix.settings.docker-platform }} -v ${{ github.workspace }}:/build -w /build
|
2023-04-11 11:47:52 +09:00
|
|
|
run: |
|
|
|
|
set -e
|
|
|
|
yarn test
|
2024-04-08 22:04:57 +09:00
|
|
|
- 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
|
2024-04-23 13:14:06 +09:00
|
|
|
yarn test
|
2022-01-04 20:26:22 +09:00
|
|
|
- name: Test
|
|
|
|
uses: addnab/docker-run-action@v3
|
|
|
|
if: matrix.settings.target == 'x86_64-unknown-linux-musl'
|
|
|
|
with:
|
2023-04-11 11:47:52 +09:00
|
|
|
image: node:lts-alpine
|
2022-01-04 20:26:22 +09:00
|
|
|
options: -v ${{ github.workspace }}:/napi-rs -w /napi-rs
|
|
|
|
run: yarn test
|