-
-
Notifications
You must be signed in to change notification settings - Fork 245
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(cli): support macOS with --zig flag
- Loading branch information
1 parent
de140c6
commit 0db94cc
Showing
4 changed files
with
211 additions
and
93 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,139 @@ | ||
name: Zig-Cross-Compile | ||
|
||
env: | ||
DEBUG: 'napi:*' | ||
|
||
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 | ||
- uses: actions/checkout@v2 | ||
- name: Setup node | ||
uses: actions/setup-node@v2 | ||
with: | ||
node-version: 16 | ||
check-latest: true | ||
cache: 'yarn' | ||
- name: Install | ||
uses: actions-rs/toolchain@v1 | ||
with: | ||
toolchain: stable | ||
profile: minimal | ||
override: true | ||
target: ${{ matrix.target }} | ||
- name: Install aarch64 toolchain | ||
run: rustup target add aarch64-unknown-linux-gnu | ||
- name: Install ziglang | ||
uses: goto-bus-stop/setup-zig@v1 | ||
with: | ||
version: 0.9.0 | ||
- name: Cache NPM dependencies | ||
uses: actions/cache@v2 | ||
with: | ||
path: node_modules | ||
key: npm-cache-linux-aarch64-gnu-node@16-${{ hashFiles('yarn.lock') }} | ||
- name: Install dependencies | ||
run: yarn install --frozen-lockfile --ignore-platform --registry https://registry.npmjs.org --network-timeout 300000 | ||
- name: 'Build TypeScript' | ||
run: yarn build | ||
- name: Cross build native tests | ||
run: | | ||
yarn --cwd ./examples/napi-compat-mode build --target ${{ matrix.target }} --zig | ||
yarn --cwd ./examples/napi build --target ${{ matrix.target }} --zig | ||
- name: Upload artifacts | ||
uses: actions/upload-artifact@v2 | ||
with: | ||
name: compat-${{ matrix.target }} | ||
path: ./examples/napi-compat-mode/index.node | ||
if-no-files-found: error | ||
- name: Upload artifacts | ||
uses: actions/upload-artifact@v2 | ||
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' | ||
- uses: actions/checkout@v2 | ||
- name: Setup node | ||
uses: actions/setup-node@v2 | ||
with: | ||
node-version: 16 | ||
check-latest: true | ||
cache: 'yarn' | ||
- name: Cache NPM dependencies | ||
uses: actions/cache@v2 | ||
with: | ||
path: node_modules | ||
key: npm-cache-${{ matrix.settings.host }}-node@16-${{ hashFiles('yarn.lock') }} | ||
- name: Install dependencies | ||
run: yarn install --frozen-lockfile --ignore-platform --registry https://registry.npmjs.org --network-timeout 300000 | ||
- name: Download artifacts | ||
uses: actions/download-artifact@v2 | ||
with: | ||
name: napi-${{ matrix.settings.target }} | ||
path: ./examples/napi/ | ||
- name: Download artifacts | ||
uses: actions/download-artifact@v2 | ||
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 | ||
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: | ||
image: ghcr.io/${{ github.repository }}/nodejs-rust:lts-alpine | ||
options: -v ${{ github.workspace }}:/napi-rs -w /napi-rs | ||
run: yarn test |
This file contains 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
This file contains 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