Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
218 changes: 175 additions & 43 deletions .github/workflows/CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ env:
APP_NAME: node-tantivy-binding
MACOSX_DEPLOYMENT_TARGET: '10.13'
CARGO_INCREMENTAL: '1'
permissions:
contents: write
id-token: write
'on':
push:
branches:
Expand All @@ -26,49 +29,83 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- name: setup pnpm
uses: pnpm/action-setup@v6
- name: Setup node
uses: actions/setup-node@v6
with:
node-version: 24
cache: yarn
node-version: 22
cache: 'pnpm'

- name: Install
uses: dtolnay/rust-toolchain@stable
with:
components: clippy, rustfmt

- name: Install dependencies
run: yarn install
run: pnpm install

- name: Oxlint
run: yarn lint
run: pnpm lint

- name: Cargo fmt
run: cargo fmt -- --check

- name: Clippy
run: cargo clippy

build:
strategy:
fail-fast: false
matrix:
settings:
- host: macos-latest
target: x86_64-apple-darwin
build: yarn build --target x86_64-apple-darwin
build: pnpm build --target x86_64-apple-darwin
- host: windows-latest
build: yarn build --target x86_64-pc-windows-msvc
build: pnpm build --target x86_64-pc-windows-msvc
target: x86_64-pc-windows-msvc
- host: windows-latest
build: pnpm build --target i686-pc-windows-msvc
target: i686-pc-windows-msvc
- host: ubuntu-latest
target: x86_64-unknown-linux-gnu
build: yarn build --target x86_64-unknown-linux-gnu --use-napi-cross
build: pnpm build --target x86_64-unknown-linux-gnu --use-napi-cross
- host: ubuntu-latest
target: x86_64-unknown-linux-musl
build: pnpm build --target x86_64-unknown-linux-musl -x
- host: macos-latest
target: aarch64-apple-darwin
build: yarn build --target aarch64-apple-darwin
build: pnpm build --target aarch64-apple-darwin
- host: ubuntu-latest
target: aarch64-unknown-linux-gnu
build: pnpm build --target aarch64-unknown-linux-gnu --use-napi-cross
- host: ubuntu-latest
target: armv7-unknown-linux-gnueabihf
build: pnpm build --target armv7-unknown-linux-gnueabihf --use-napi-cross
- host: ubuntu-latest
target: aarch64-linux-android
build: pnpm build --target aarch64-linux-android
- host: ubuntu-latest
target: armv7-linux-androideabi
build: pnpm build --target armv7-linux-androideabi
- host: ubuntu-latest
target: aarch64-unknown-linux-musl
build: pnpm build --target aarch64-unknown-linux-musl -x
- host: windows-latest
target: aarch64-pc-windows-msvc
build: pnpm build --target aarch64-pc-windows-msvc
name: stable - ${{ matrix.settings.target }} - node@22
runs-on: ${{ matrix.settings.host }}
steps:
- uses: actions/checkout@v6
- name: setup pnpm
uses: pnpm/action-setup@v6
- name: Setup node
uses: actions/setup-node@v6
with:
node-version: 24
cache: yarn
node-version: 22
cache: pnpm
- name: Install
uses: dtolnay/rust-toolchain@stable
with:
Expand All @@ -88,7 +125,7 @@ jobs:
- uses: mlugg/setup-zig@v2
if: ${{ contains(matrix.settings.target, 'musl') }}
with:
version: 0.14.1
version: 0.15.2
- name: Install cargo-zigbuild
uses: taiki-e/install-action@v2
if: ${{ contains(matrix.settings.target, 'musl') }}
Expand All @@ -101,17 +138,77 @@ jobs:
if: ${{ matrix.settings.setup }}
shell: bash
- name: Install dependencies
run: yarn install
run: pnpm install
- name: Setup node x86
uses: actions/setup-node@v6
if: matrix.settings.target == 'i686-pc-windows-msvc'
with:
node-version: 22
cache: pnpm
architecture: x86
- name: Build
run: ${{ matrix.settings.build }}
shell: bash
- name: Upload artifact
uses: actions/upload-artifact@v7
if: matrix.settings.target != 'wasm32-wasip1-threads'
with:
name: bindings-${{ matrix.settings.target }}
path: |
${{ env.APP_NAME }}.*.node
${{ env.APP_NAME }}.*.wasm
path: '*.node'
if-no-files-found: error

- name: Upload artifact
uses: actions/upload-artifact@v7
if: matrix.settings.target == 'wasm32-wasip1-threads'
with:
name: bindings-${{ matrix.settings.target }}
path: '*.wasm'
if-no-files-found: error
build-freebsd:
runs-on: ubuntu-latest
name: Build FreeBSD
steps:
- uses: actions/checkout@v6
- name: Build
id: build
uses: cross-platform-actions/action@v1.1.0
env:
DEBUG: napi:*
RUSTUP_IO_THREADS: 1
with:
operating_system: freebsd
version: '15.0'
memory: 8G
cpu_count: 3
environment_variables: 'DEBUG RUSTUP_IO_THREADS'
shell: bash
run: |
sudo pkg install -y -f curl node libnghttp2 npm
sudo npm install -g corepack
curl https://sh.rustup.rs -sSf --output rustup.sh
sh rustup.sh -y --profile minimal --default-toolchain beta
sudo corepack enable
source "$HOME/.cargo/env"
echo "~~~~ rustc --version ~~~~"
rustc --version
echo "~~~~ node -v ~~~~"
node -v
echo "~~~~ pnpm --version ~~~~"
pnpm --version
pwd
ls -lah
whoami
env
freebsd-version
pnpm install
pnpm build
rm -rf node_modules
rm -rf target
- name: Upload artifact
uses: actions/upload-artifact@v7
with:
name: bindings-freebsd
path: ${{ env.APP_NAME }}.*.node
if-no-files-found: error
test-macOS-windows-binding:
name: Test bindings on ${{ matrix.settings.target }} - node@${{ matrix.node }}
Expand All @@ -124,26 +221,27 @@ jobs:
- host: windows-latest
target: x86_64-pc-windows-msvc
architecture: x64
- host: macos-latest
target: aarch64-apple-darwin
architecture: arm64
- host: macos-latest
target: x86_64-apple-darwin
architecture: x64
- host: macos-latest
target: aarch64-apple-darwin
architecture: arm64
node:
- '20'
- '22'
runs-on: ${{ matrix.settings.host }}
steps:
- uses: actions/checkout@v6
- name: setup pnpm
uses: pnpm/action-setup@v6
- name: Setup node
uses: actions/setup-node@v6
with:
node-version: ${{ matrix.node }}
cache: yarn
cache: pnpm
architecture: ${{ matrix.settings.architecture }}
- name: Install dependencies
run: yarn install
run: pnpm install
- name: Download artifacts
uses: actions/download-artifact@v8
with:
Expand All @@ -153,7 +251,7 @@ jobs:
run: ls -R .
shell: bash
- name: Test bindings
run: yarn test
run: pnpm test
test-linux-binding:
name: Test ${{ matrix.target }} - node@${{ matrix.node }}
needs:
Expand All @@ -163,17 +261,22 @@ jobs:
matrix:
target:
- x86_64-unknown-linux-gnu
- x86_64-unknown-linux-musl
- aarch64-unknown-linux-gnu
- aarch64-unknown-linux-musl
- armv7-unknown-linux-gnueabihf
node:
- '20'
- '22'
runs-on: ${{ contains(matrix.target, 'aarch64') && 'ubuntu-24.04-arm' || 'ubuntu-latest' }}
steps:
- uses: actions/checkout@v6
- name: setup pnpm
uses: pnpm/action-setup@v6
- name: Setup node
uses: actions/setup-node@v6
with:
node-version: ${{ matrix.node }}
cache: yarn
cache: pnpm
- name: Output docker params
id: docker
run: |
Expand All @@ -193,11 +296,10 @@ jobs:
console.log('IMAGE=node:${{ matrix.node }}-slim')
}
" >> $GITHUB_OUTPUT
echo "PNPM_STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_OUTPUT
# use --force to download the all platform/arch dependencies
- name: Install dependencies
run: |
yarn config set --json supportedArchitectures.cpu '["current", "arm64", "x64", "arm"]'
yarn config set --json supportedArchitectures.libc '["current", "musl", "gnu"]'
yarn install
run: pnpm install --force
- name: Download artifacts
uses: actions/download-artifact@v8
with:
Expand All @@ -214,50 +316,80 @@ jobs:
- run: docker run --rm --privileged multiarch/qemu-user-static --reset -p yes
if: ${{ contains(matrix.target, 'armv7') }}
- name: Test bindings
uses: addnab/docker-run-action@v3
uses: tj-actions/docker-run@v2
with:
image: ${{ steps.docker.outputs.IMAGE }}
options: '-v ${{ github.workspace }}:${{ github.workspace }} -w ${{ github.workspace }} --platform ${{ steps.docker.outputs.PLATFORM }}'
run: yarn test
name: test-binding
options: -v ${{ steps.docker.outputs.PNPM_STORE_PATH }}:${{ steps.docker.outputs.PNPM_STORE_PATH }} -v ${{ github.workspace }}:${{ github.workspace }} -w ${{ github.workspace }} --platform ${{ steps.docker.outputs.PLATFORM }}
args: npm run test
test-wasi:
name: Test WASI target
needs:
- build
runs-on: ubuntu-latest
if: false # WASI target removed from build matrix
steps:
- uses: actions/checkout@v6
- name: setup pnpm
uses: pnpm/action-setup@v6
- name: Setup node
uses: actions/setup-node@v6
with:
node-version: 22
cache: pnpm
- name: Install dependencies
run: pnpm install
- name: Download artifacts
uses: actions/download-artifact@v8
with:
name: bindings-wasm32-wasip1-threads
path: .
- name: List packages
run: ls -R .
shell: bash
- name: Test bindings
run: pnpm test
env:
NAPI_RS_FORCE_WASI: 1
publish:
name: Publish
runs-on: ubuntu-latest
environment: Release
permissions:
contents: write
id-token: write
needs:
- lint
- build-freebsd
- test-macOS-windows-binding
- test-linux-binding
- test-wasi
steps:
- uses: actions/checkout@v6
- name: setup pnpm
uses: pnpm/action-setup@v6
- name: Setup node
uses: actions/setup-node@v6
with:
node-version: 24
cache: yarn
node-version: 22
cache: pnpm
- name: Install dependencies
run: yarn install
- name: create npm dirs
run: yarn napi create-npm-dirs
run: pnpm install
- name: Download all artifacts
uses: actions/download-artifact@v8
with:
path: artifacts
- name: create npm dirs
run: pnpm napi create-npm-dirs
- name: Move artifacts
run: yarn artifacts
run: pnpm artifacts
- name: List packages
run: ls -R ./npm
shell: bash
- name: Publish
run: |
npm config set provenance true
if git log -1 --pretty=%B | grep "^[0-9]\+\.[0-9]\+\.[0-9]\+$";
if git log -1 --pretty=%B | grep "^v\?[0-9]\+\.[0-9]\+\.[0-9]\+$";
then
echo "//registry.npmjs.org/:_authToken=$NPM_TOKEN" >> ~/.npmrc
npm publish --access public
elif git log -1 --pretty=%B | grep "^[0-9]\+\.[0-9]\+\.[0-9]\+";
elif git log -1 --pretty=%B | grep "^v\?[0-9]\+\.[0-9]\+\.[0-9]\+";
then
echo "//registry.npmjs.org/:_authToken=$NPM_TOKEN" >> ~/.npmrc
npm publish --tag next --access public
Expand Down
2 changes: 2 additions & 0 deletions .npmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
shamefully-hoist=true
strict-peer-dependencies=false
Loading
Loading