-
Notifications
You must be signed in to change notification settings - Fork 4.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
681 additions
and
113 deletions.
There are no files selected for viewing
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,198 @@ | ||
name: Build Rust Binaries | ||
|
||
on: | ||
workflow_call: | ||
inputs: | ||
name: | ||
description: 'The name of the binary to build' | ||
required: false | ||
default: 'taro' | ||
type: string | ||
|
||
jobs: | ||
build: | ||
strategy: | ||
fail-fast: false | ||
matrix: | ||
settings: | ||
- host: macos-latest | ||
target: x86_64-apple-darwin | ||
build: | | ||
pnpm build:binding:release | ||
strip -x *.node | ||
- host: windows-latest | ||
build: pnpm build:binding:release | ||
target: x86_64-pc-windows-msvc | ||
- host: ubuntu-latest | ||
target: x86_64-unknown-linux-gnu | ||
docker: ghcr.io/napi-rs/napi-rs/nodejs-rust:lts-debian | ||
build: |- | ||
set -e && | ||
pnpm build:binding:release --target x86_64-unknown-linux-gnu && | ||
strip *.node | ||
- host: macos-latest | ||
target: aarch64-apple-darwin | ||
build: | | ||
pnpm build:binding:release --target aarch64-apple-darwin | ||
strip -x *.node | ||
name: stable - ${{ matrix.settings.target }} | ||
runs-on: ${{ matrix.settings.host }} | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
with: | ||
ref: ${{ github.ref || github.head_ref || github.ref_name }} | ||
- name: Setup Node.js | ||
uses: actions/setup-node@v3 | ||
if: ${{ !matrix.settings.docker }} | ||
with: | ||
node-version: 16 | ||
check-latest: true | ||
- name: Rust Install | ||
uses: dtolnay/rust-toolchain@stable | ||
if: ${{ !matrix.settings.docker }} | ||
with: | ||
toolchain: stable | ||
targets: ${{ matrix.settings.target }} | ||
# Bootstrap project | ||
- name: Cache pnpm modules | ||
uses: actions/cache@v3 | ||
with: | ||
path: ~/.pnpm-store | ||
key: ${{ runner.os }}-${{ hashFiles('**/pnpm-lock.yaml') }} | ||
restore-keys: | | ||
${{ runner.os }}- | ||
- name: Pnpm Install | ||
uses: pnpm/action-setup@v2.4.0 | ||
with: | ||
version: 7 | ||
run_install: | | ||
- recursive: true | ||
args: [--frozen-lockfile] | ||
- name: Build in docker | ||
uses: addnab/docker-run-action@v3 | ||
if: ${{ matrix.settings.docker }} | ||
with: | ||
image: ${{ matrix.settings.docker }} | ||
options: '--user 0:0 -v ${{ github.workspace }}/.cargo-cache/git/db:/usr/local/cargo/git/db -v ${{ github.workspace }}/.cargo/registry/cache:/usr/local/cargo/registry/cache -v ${{ github.workspace }}/.cargo/registry/index:/usr/local/cargo/registry/index -v ${{ github.workspace }}:/build -w /build' | ||
run: ${{ matrix.settings.build }} | ||
- name: Build | ||
run: ${{ matrix.settings.build }} | ||
if: ${{ !matrix.settings.docker }} | ||
shell: bash | ||
- name: Upload artifact | ||
uses: actions/upload-artifact@v3 | ||
with: | ||
name: bindings-${{ matrix.settings.target }} | ||
path: ${{ inputs.name }}.*.node | ||
if-no-files-found: error | ||
test-macOS-windows-binding: | ||
name: Test bindings on ${{ matrix.settings.target }} - node@${{ matrix.node }} | ||
needs: | ||
- build | ||
strategy: | ||
fail-fast: false | ||
matrix: | ||
settings: | ||
- host: macos-latest | ||
target: x86_64-apple-darwin | ||
- host: windows-latest | ||
target: x86_64-pc-windows-msvc | ||
node: | ||
- '14' | ||
- '16' | ||
runs-on: ${{ matrix.settings.host }} | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
with: | ||
ref: ${{ github.ref || github.head_ref || github.ref_name }} | ||
- name: Setup node | ||
uses: actions/setup-node@v3 | ||
with: | ||
node-version: ${{ matrix.node }} | ||
check-latest: true | ||
cache: pnpm | ||
- name: Install dependencies | ||
run: pnpm install | ||
- name: Download artifacts | ||
uses: actions/download-artifact@v3 | ||
with: | ||
name: bindings-${{ matrix.settings.target }} | ||
path: . | ||
- name: List packages | ||
run: ls -R . | ||
shell: bash | ||
- name: Test bindings | ||
run: pnpm test:binding | ||
test-linux-x64-gnu-binding: | ||
name: Test bindings on Linux-x64-gnu - node@${{ matrix.node }} | ||
needs: | ||
- build | ||
strategy: | ||
fail-fast: false | ||
matrix: | ||
node: | ||
- '14' | ||
- '16' | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
with: | ||
ref: ${{ github.ref || github.head_ref || github.ref_name }} | ||
- name: Setup node | ||
uses: actions/setup-node@v3 | ||
with: | ||
node-version: ${{ matrix.node }} | ||
check-latest: true | ||
cache: pnpm | ||
- name: Install dependencies | ||
run: pnpm install | ||
- name: Download artifacts | ||
uses: actions/download-artifact@v3 | ||
with: | ||
name: bindings-x86_64-unknown-linux-gnu | ||
path: . | ||
- name: List packages | ||
run: ls -R . | ||
shell: bash | ||
- name: Test bindings | ||
run: docker run --rm -v $(pwd):/build -w /build node:${{ matrix.node }}-slim pnpm test:binding | ||
universal-macOS: | ||
name: Build universal macOS binary | ||
needs: | ||
- build | ||
runs-on: macos-latest | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
with: | ||
ref: ${{ github.ref || github.head_ref || github.ref_name }} | ||
- name: Setup node | ||
uses: actions/setup-node@v3 | ||
with: | ||
node-version: 16 | ||
check-latest: true | ||
cache: pnpm | ||
- name: Install dependencies | ||
run: pnpm install | ||
- name: Download macOS x64 artifact | ||
uses: actions/download-artifact@v3 | ||
with: | ||
name: bindings-x86_64-apple-darwin | ||
path: artifacts | ||
- name: Download macOS arm64 artifact | ||
uses: actions/download-artifact@v3 | ||
with: | ||
name: bindings-aarch64-apple-darwin | ||
path: artifacts | ||
- name: Combine binaries | ||
run: pnpm universal | ||
- name: Upload artifact | ||
uses: actions/upload-artifact@v3 | ||
with: | ||
name: bindings-universal-apple-darwin | ||
path: ${{ inputs.name }}.*.node | ||
if-no-files-found: error | ||
|
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
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,5 @@ | ||
import test from 'ava' | ||
|
||
test('native_binding', async t => { | ||
t.pass() | ||
}) |
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
Oops, something went wrong.