2022-01-04 20:26:22 +09:00
|
|
|
name: Zig-Cross-Compile
|
|
|
|
|
|
|
|
env:
|
|
|
|
DEBUG: 'napi:*'
|
|
|
|
|
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:
|
|
|
|
[
|
|
|
|
'x86_64-apple-darwin',
|
|
|
|
'x86_64-unknown-linux-musl',
|
|
|
|
'aarch64-unknown-linux-musl',
|
|
|
|
]
|
|
|
|
|
|
|
|
steps:
|
|
|
|
- run: docker run --rm --privileged multiarch/qemu-user-static:register --reset
|
2022-04-01 15:29:51 +09:00
|
|
|
- uses: actions/checkout@v3
|
2022-01-04 20:26:22 +09:00
|
|
|
- name: Setup node
|
2022-03-05 15:14:32 +09:00
|
|
|
uses: actions/setup-node@v3
|
2022-01-04 20:26:22 +09:00
|
|
|
with:
|
2022-12-09 18:29:03 +09:00
|
|
|
node-version: 18
|
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
|
|
|
|
uses: actions/cache@v3
|
|
|
|
with:
|
|
|
|
path: |
|
|
|
|
~/.cargo/registry
|
|
|
|
~/.cargo/git
|
|
|
|
target
|
|
|
|
key: stable-zig-${{ matrix.target }}-cargo-cache
|
2022-01-04 20:26:22 +09:00
|
|
|
- name: Install aarch64 toolchain
|
|
|
|
run: rustup target add aarch64-unknown-linux-gnu
|
|
|
|
- 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:
|
2023-01-20 22:31:16 +09:00
|
|
|
version: 0.10.1
|
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
|
2022-01-04 20:26:22 +09:00
|
|
|
- name: 'Build TypeScript'
|
|
|
|
run: yarn build
|
2022-10-24 00:03:18 +09:00
|
|
|
- name: Setup node
|
|
|
|
uses: actions/setup-node@v3
|
|
|
|
with:
|
|
|
|
# Testing for compatibility with node v12.x
|
|
|
|
node-version: 12
|
2022-01-04 20:26:22 +09:00
|
|
|
- name: Cross build native tests
|
|
|
|
run: |
|
2022-03-13 19:28:41 +09:00
|
|
|
yarn workspace compat-mode-examples build --target ${{ matrix.target }} --zig
|
|
|
|
yarn workspace examples build --target ${{ matrix.target }} --zig
|
2022-01-04 20:26:22 +09:00
|
|
|
- name: Upload artifacts
|
2022-12-09 18:29:03 +09:00
|
|
|
uses: actions/upload-artifact@v3
|
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
|
2022-12-09 18:29:03 +09:00
|
|
|
uses: actions/upload-artifact@v3
|
2022-01-04 20:26:22 +09:00
|
|
|
with:
|
|
|
|
name: napi-${{ matrix.target }}
|
|
|
|
path: ./examples/napi/index.node
|
|
|
|
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
|
|
|
|
- host: macos-latest
|
|
|
|
target: x86_64-apple-darwin
|
|
|
|
- host: ubuntu-latest
|
|
|
|
target: aarch64-unknown-linux-musl
|
|
|
|
|
|
|
|
steps:
|
|
|
|
- run: docker run --rm --privileged multiarch/qemu-user-static:register --reset
|
|
|
|
if: matrix.settings.host == 'ubuntu-latest'
|
2022-04-01 15:29:51 +09:00
|
|
|
- uses: actions/checkout@v3
|
2022-01-04 20:26:22 +09:00
|
|
|
- name: Setup node
|
2022-03-05 15:14:32 +09:00
|
|
|
uses: actions/setup-node@v3
|
2022-01-04 20:26:22 +09:00
|
|
|
with:
|
2022-12-09 18:29:03 +09:00
|
|
|
node-version: 18
|
2022-01-04 20:26:22 +09:00
|
|
|
check-latest: true
|
|
|
|
cache: 'yarn'
|
|
|
|
- name: Install dependencies
|
2022-04-01 15:29:51 +09:00
|
|
|
run: yarn install --immutable --mode=skip-build
|
2022-01-04 20:26:22 +09:00
|
|
|
- name: Download artifacts
|
2022-04-01 15:29:51 +09:00
|
|
|
uses: actions/download-artifact@v3
|
2022-01-04 20:26:22 +09:00
|
|
|
with:
|
|
|
|
name: napi-${{ matrix.settings.target }}
|
|
|
|
path: ./examples/napi/
|
|
|
|
- name: Download artifacts
|
2022-04-01 15:29:51 +09:00
|
|
|
uses: actions/download-artifact@v3
|
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
|
2022-01-04 20:26:22 +09:00
|
|
|
if: matrix.settings.host == 'macos-latest'
|
|
|
|
- name: Test
|
|
|
|
uses: docker://multiarch/alpine:aarch64-latest-stable
|
|
|
|
if: matrix.settings.target == 'aarch64-unknown-linux-musl'
|
|
|
|
with:
|
|
|
|
args: >
|
|
|
|
sh -c "
|
|
|
|
apk add nodejs yarn && \
|
|
|
|
yarn test
|
|
|
|
"
|
|
|
|
- name: Test
|
|
|
|
uses: addnab/docker-run-action@v3
|
|
|
|
if: matrix.settings.target == 'x86_64-unknown-linux-musl'
|
|
|
|
with:
|
2022-09-09 19:54:23 +09:00
|
|
|
image: ghcr.io/napi-rs/napi-rs/nodejs-rust:lts-alpine
|
2022-01-04 20:26:22 +09:00
|
|
|
options: -v ${{ github.workspace }}:/napi-rs -w /napi-rs
|
|
|
|
run: yarn test
|