mirror of
https://github.com/gorules/zen.git
synced 2026-11-28 16:06:26 +00:00
* fix(engine): keep decision table analysis memory and time in proportion to the table Schema queries no longer run table verification; graph table checks are deferred to diagnostics. Gap search and unreachable-rule cover run on per-dimension bitsets when the table is small enough to index densely, and on the set-based path otherwise. Missing cases are merged on interned ids and rendered lazily. Compression works on borrowed rows and interned cell ids, assigned once per round. Small string sets are held inline or as a sorted list instead of a tree. Findings are unchanged: the previous implementations stay as test-only references and are compared on generated tables, and tests/table_scaling.rs bounds peak memory with a counting allocator. * fix(nodejs): accept bytes and JSON text in Workspace setDocument, setPolicy and enhanceGraphTrace Documents with more than one million JSON values were rejected by the object conversion limit, which a two-column decision table reaches at 250,000 rows. Buffers and strings are parsed directly, and objects are converted without that limit. * ci: pin Rust to 1.99.0 Rust 1.100 passes one -L dependency directory per dependency, which pushes the rustc command for zen-engine past the Windows command-line limit when sccache spawns it (os error 206). Every workflow that installed stable now installs 1.99.0; miri stays on nightly. * ci: pin the UniFFI native build to Rust 1.99.0 actions-rust-cross installs its own toolchain and defaults to stable, so the Windows and macOS UniFFI builds were still on 1.100.
414 lines
13 KiB
YAML
414 lines
13 KiB
YAML
name: NodeJS
|
|
|
|
env:
|
|
WORKING_DIRECTORY: bindings/nodejs
|
|
DEBUG: 'napi:*'
|
|
MACOSX_DEPLOYMENT_TARGET: '10.13'
|
|
NODE_OPTIONS: '--max-old-space-size=3072'
|
|
CARGO_UNSTABLE_TARGET_APPLIES_TO_HOST: true
|
|
CARGO_TARGET_APPLIES_TO_HOST: false
|
|
|
|
on:
|
|
pull_request:
|
|
paths:
|
|
- 'bindings/nodejs/**'
|
|
- 'core/**'
|
|
- 'test-data/**'
|
|
- '.github/workflows/node.yaml'
|
|
push:
|
|
tags:
|
|
- 'nodejs-v*'
|
|
|
|
permissions:
|
|
contents: write
|
|
id-token: write
|
|
|
|
jobs:
|
|
build:
|
|
strategy:
|
|
fail-fast: false
|
|
matrix:
|
|
settings:
|
|
- host: windows-latest
|
|
target: 'x86_64-pc-windows-msvc'
|
|
build: |
|
|
yarn build -- --target x86_64-pc-windows-msvc -- --locked
|
|
|
|
- host: macos-15-intel
|
|
target: 'x86_64-apple-darwin'
|
|
build: |
|
|
rustup target add x86_64-apple-darwin
|
|
yarn build -- --target x86_64-apple-darwin -- --locked
|
|
strip -x ./*.node
|
|
|
|
- host: macos-latest
|
|
target: 'aarch64-apple-darwin'
|
|
build: |
|
|
sudo rm -Rf /Library/Developer/CommandLineTools/SDKs/*;
|
|
export CC=$(xcrun -f clang);
|
|
export CXX=$(xcrun -f clang++);
|
|
SYSROOT=$(xcrun --sdk macosx --show-sdk-path);
|
|
export CFLAGS="-isysroot $SYSROOT -isystem $SYSROOT";
|
|
yarn build -- --target aarch64-apple-darwin -- --locked
|
|
strip -x ./*.node
|
|
|
|
- host: ubuntu-latest
|
|
target: 'x86_64-unknown-linux-gnu'
|
|
zig: true
|
|
build: |
|
|
set -e
|
|
rustup target add x86_64-unknown-linux-gnu
|
|
cargo zigbuild --release --locked -p zen-nodejs --target x86_64-unknown-linux-gnu.$GLIBC_VERSION
|
|
cp ../../target/x86_64-unknown-linux-gnu/release/libzen_nodejs.so zen-engine.linux-x64-gnu.node
|
|
strip zen-engine.linux-x64-gnu.node
|
|
|
|
- host: ubuntu-latest
|
|
target: 'aarch64-unknown-linux-gnu'
|
|
zig: true
|
|
build: |
|
|
set -e
|
|
rustup target add aarch64-unknown-linux-gnu
|
|
cargo zigbuild --release --locked -p zen-nodejs --target aarch64-unknown-linux-gnu.$GLIBC_VERSION
|
|
cp ../../target/aarch64-unknown-linux-gnu/release/libzen_nodejs.so zen-engine.linux-arm64-gnu.node
|
|
|
|
- host: ubuntu-latest
|
|
target: 'x86_64-unknown-linux-musl'
|
|
zig: true
|
|
build: |
|
|
set -e
|
|
rustup target add x86_64-unknown-linux-musl
|
|
yarn build -- --target x86_64-unknown-linux-musl --cross-compile -- --locked
|
|
strip ./*.node
|
|
|
|
- host: ubuntu-latest
|
|
target: 'aarch64-unknown-linux-musl'
|
|
zig: true
|
|
build: |
|
|
set -e
|
|
rustup target add aarch64-unknown-linux-musl
|
|
yarn build -- --target aarch64-unknown-linux-musl --cross-compile -- --locked
|
|
|
|
- host: ubuntu-latest
|
|
target: 'wasm32-wasip1'
|
|
setup: |
|
|
wget https://github.com/WebAssembly/wasi-sdk/releases/download/wasi-sdk-27/wasi-sdk-27.0-x86_64-linux.tar.gz
|
|
tar -xvf wasi-sdk-27.0-x86_64-linux.tar.gz
|
|
build: |
|
|
set -e
|
|
WASI_SDK="$(pwd)/wasi-sdk-27.0-x86_64-linux"
|
|
export CMAKE_BUILD_PARALLEL_LEVEL=2
|
|
export CC_wasm32_wasip1="$WASI_SDK/bin/clang"
|
|
export AR_wasm32_wasip1="$WASI_SDK/bin/llvm-ar"
|
|
export CFLAGS_wasm32_wasip1="--target=wasm32-wasip1 --sysroot=$WASI_SDK/share/wasi-sysroot -mllvm -wasm-enable-sjlj"
|
|
export CARGO_TARGET_WASM32_WASIP1_RUSTFLAGS="-C link-arg=$WASI_SDK/share/wasi-sysroot/lib/wasm32-wasip1/libsetjmp.a"
|
|
cargo clean -p napi-async-runtime --target wasm32-wasip1 --release
|
|
yarn build -- --target wasm32-wasip1 -- --locked
|
|
|
|
name: stable - ${{ matrix.settings.target }} - node@22
|
|
runs-on: ${{ matrix.settings.host }}
|
|
defaults:
|
|
run:
|
|
working-directory: ${{ env.WORKING_DIRECTORY }}
|
|
|
|
steps:
|
|
- uses: actions/checkout@v3
|
|
|
|
- name: Setup node
|
|
uses: actions/setup-node@v3
|
|
with:
|
|
node-version: 22
|
|
check-latest: true
|
|
cache: yarn
|
|
cache-dependency-path: 'bindings/nodejs/yarn.lock'
|
|
|
|
- name: Install
|
|
uses: dtolnay/rust-toolchain@1.99.0
|
|
with:
|
|
toolchain: 1.99.0
|
|
targets: ${{ matrix.settings.target }}
|
|
|
|
- name: Rust cache + sccache (+ zig for linux legs)
|
|
uses: ./.github/actions/setup-rust
|
|
with:
|
|
shared-key: nodejs-${{ matrix.settings.target }}
|
|
key: ${{ matrix.settings.target }}
|
|
zig: ${{ matrix.settings.zig }}
|
|
sccache-bucket: ${{ secrets.SCCACHE_S3_BUCKET }}
|
|
sccache-region: ${{ secrets.SCCACHE_AWS_REGION }}
|
|
sccache-role-arn: ${{ secrets.SCCACHE_AWS_ROLE_ARN }}
|
|
|
|
- name: Setup toolchain
|
|
run: ${{ matrix.settings.setup }}
|
|
if: ${{ matrix.settings.setup }}
|
|
shell: bash
|
|
|
|
- name: 'Install dependencies'
|
|
run: yarn install --immutable --mode=skip-build
|
|
|
|
- name: 'Build'
|
|
run: ${{ matrix.settings.build }}
|
|
shell: bash
|
|
|
|
- name: 'Check'
|
|
run: ls -la
|
|
shell: bash
|
|
|
|
- name: Upload typings
|
|
if: ${{ matrix.settings.target == 'aarch64-apple-darwin' }}
|
|
uses: actions/upload-artifact@v4
|
|
with:
|
|
name: typings
|
|
path: bindings/nodejs/index.d.ts
|
|
if-no-files-found: error
|
|
|
|
- name: Upload JS binding
|
|
if: ${{ matrix.settings.target == 'wasm32-wasip1' }}
|
|
uses: actions/upload-artifact@v4
|
|
with:
|
|
name: js-binding
|
|
path: bindings/nodejs/index.js
|
|
if-no-files-found: error
|
|
|
|
- name: Upload artifact ${{ matrix.settings.target }}
|
|
if: ${{ matrix.settings.target != 'wasm32-wasip1' }}
|
|
uses: actions/upload-artifact@v4
|
|
with:
|
|
name: bindings-${{ matrix.settings.target }}
|
|
path: bindings/nodejs/*.node
|
|
if-no-files-found: error
|
|
|
|
- name: Upload artifact ${{ matrix.settings.target }}
|
|
if: ${{ matrix.settings.target == 'wasm32-wasip1' }}
|
|
uses: actions/upload-artifact@v4
|
|
with:
|
|
name: bindings-wasm32-wasip1
|
|
if-no-files-found: error
|
|
path: |
|
|
bindings/nodejs/zen-engine.wasm32-wasip1*
|
|
bindings/nodejs/zen-engine.wasip1*
|
|
|
|
test:
|
|
name: Test ${{ matrix.settings.target }} - node@${{ matrix.node }}
|
|
needs:
|
|
- build
|
|
defaults:
|
|
run:
|
|
working-directory: ${{ env.WORKING_DIRECTORY }}
|
|
strategy:
|
|
fail-fast: false
|
|
matrix:
|
|
node: [ '20', '22' ]
|
|
settings:
|
|
# Native runners
|
|
- host: macos-15-intel
|
|
target: 'x86_64-apple-darwin'
|
|
- host: macos-latest
|
|
target: 'aarch64-apple-darwin'
|
|
- host: windows-latest
|
|
target: 'x86_64-pc-windows-msvc'
|
|
# Linux: run inside the matching libc container; arm adds QEMU
|
|
- host: ubuntu-latest
|
|
target: 'x86_64-unknown-linux-gnu'
|
|
image: 'node:{0}-slim'
|
|
- host: ubuntu-latest
|
|
target: 'x86_64-unknown-linux-musl'
|
|
image: 'node:{0}-alpine'
|
|
- host: ubuntu-latest
|
|
target: 'aarch64-unknown-linux-musl'
|
|
image: 'node:{0}-alpine'
|
|
arm: true
|
|
runs-on: ${{ matrix.settings.host }}
|
|
|
|
steps:
|
|
- uses: actions/checkout@v3
|
|
with:
|
|
submodules: true
|
|
|
|
- name: Setup node
|
|
uses: actions/setup-node@v3
|
|
with:
|
|
node-version: ${{ matrix.node }}
|
|
check-latest: true
|
|
cache: yarn
|
|
cache-dependency-path: 'bindings/nodejs/yarn.lock'
|
|
|
|
- name: Set up QEMU
|
|
if: ${{ matrix.settings.arm }}
|
|
uses: docker/setup-qemu-action@v3
|
|
with:
|
|
platforms: arm64
|
|
- if: ${{ matrix.settings.arm }}
|
|
run: docker run --rm --privileged multiarch/qemu-user-static --reset -p yes
|
|
|
|
- name: Install dependencies (arm64/musl)
|
|
if: ${{ matrix.settings.arm }}
|
|
run: |
|
|
yarn config set supportedArchitectures.cpu "arm64"
|
|
yarn config set supportedArchitectures.libc "musl"
|
|
yarn install --immutable --mode=skip-build
|
|
- name: Install dependencies
|
|
if: ${{ !matrix.settings.arm }}
|
|
run: yarn install --immutable --mode=skip-build
|
|
|
|
- name: Download artifacts
|
|
uses: actions/download-artifact@v4
|
|
with:
|
|
name: bindings-${{ matrix.settings.target }}
|
|
path: bindings/nodejs
|
|
|
|
- name: Download typings
|
|
uses: actions/download-artifact@v4
|
|
with:
|
|
name: typings
|
|
path: bindings/nodejs
|
|
|
|
- name: Download JS binding
|
|
uses: actions/download-artifact@v4
|
|
with:
|
|
name: js-binding
|
|
path: bindings/nodejs
|
|
|
|
- name: Test bindings (native)
|
|
if: ${{ !matrix.settings.image }}
|
|
run: |
|
|
yarn install
|
|
yarn link
|
|
yarn test
|
|
|
|
- name: Test bindings (docker)
|
|
if: ${{ matrix.settings.image }}
|
|
uses: stefan-gorules/docker-run-action@v1
|
|
with:
|
|
image: ${{ format(matrix.settings.image, matrix.node) }}
|
|
options: ${{ matrix.settings.arm && format('--platform linux/arm64 -v {0}:/workspace', github.workspace) || format('-v {0}:/workspace', github.workspace) }}
|
|
run: |
|
|
cd workspace/bindings/nodejs
|
|
yarn install
|
|
yarn link
|
|
yarn test
|
|
|
|
test-wasm:
|
|
name: Test wasm32-wasip1 - node@22
|
|
needs:
|
|
- build
|
|
runs-on: ubuntu-latest
|
|
defaults:
|
|
run:
|
|
working-directory: ${{ env.WORKING_DIRECTORY }}
|
|
steps:
|
|
- uses: actions/checkout@v3
|
|
|
|
- name: Setup node
|
|
uses: actions/setup-node@v3
|
|
with:
|
|
node-version: 22
|
|
check-latest: true
|
|
cache: yarn
|
|
cache-dependency-path: 'bindings/nodejs/yarn.lock'
|
|
|
|
- name: Install dependencies
|
|
run: yarn install --immutable --mode=skip-build
|
|
|
|
- name: Download artifacts
|
|
uses: actions/download-artifact@v4
|
|
with:
|
|
name: bindings-wasm32-wasip1
|
|
path: bindings/nodejs
|
|
|
|
- name: Download typings
|
|
uses: actions/download-artifact@v4
|
|
with:
|
|
name: typings
|
|
path: bindings/nodejs
|
|
|
|
- name: Download JS binding
|
|
uses: actions/download-artifact@v4
|
|
with:
|
|
name: js-binding
|
|
path: bindings/nodejs
|
|
|
|
- name: Test bindings (wasm)
|
|
run: yarn test:wasm
|
|
|
|
release:
|
|
name: Release
|
|
runs-on: ubuntu-latest
|
|
environment: release
|
|
# Publishes only on the release-please GitHub Release for the nodejs component.
|
|
if: "github.ref_type == 'tag'"
|
|
defaults:
|
|
run:
|
|
working-directory: ${{ env.WORKING_DIRECTORY }}
|
|
needs:
|
|
- test
|
|
- test-wasm
|
|
steps:
|
|
- uses: actions/checkout@v3
|
|
|
|
- name: Setup node
|
|
uses: actions/setup-node@v3
|
|
with:
|
|
node-version: 22
|
|
check-latest: true
|
|
cache: yarn
|
|
cache-dependency-path: 'bindings/nodejs/yarn.lock'
|
|
registry-url: 'https://registry.npmjs.org'
|
|
# Organisation
|
|
scope: '@gorules'
|
|
|
|
- name: 'Install dependencies'
|
|
run: yarn install --immutable --mode=skip-build
|
|
|
|
- name: Download all artifacts
|
|
uses: actions/download-artifact@v4
|
|
with:
|
|
pattern: bindings-*
|
|
path: artifacts
|
|
|
|
- name: Download typings
|
|
uses: actions/download-artifact@v4
|
|
with:
|
|
name: typings
|
|
path: bindings/nodejs
|
|
|
|
- name: Download JS binding
|
|
uses: actions/download-artifact@v4
|
|
with:
|
|
name: js-binding
|
|
path: bindings/nodejs
|
|
|
|
- name: List all artifacts
|
|
run: ls -la ../../artifacts
|
|
|
|
- name: Copy LICENSE
|
|
run: cp ../../LICENSE .
|
|
|
|
- name: Create dirs
|
|
run: yarn createNpmDirs
|
|
shell: bash
|
|
|
|
- name: Move artifacts
|
|
run: yarn artifacts
|
|
|
|
- name: List folder
|
|
run: ls ./
|
|
shell: bash
|
|
|
|
- name: Verify JS binding version
|
|
run: |
|
|
version=$(node -p "require('./package.json').version")
|
|
stale=$(grep -o "bindingPackageVersion !== '[^']*'" index.js | grep -v "'$version'" || true)
|
|
if [ -n "$stale" ] || ! grep -q "bindingPackageVersion !== '$version'" index.js; then
|
|
echo "index.js does not check for version $version:"
|
|
echo "$stale" | sort | uniq -c
|
|
exit 1
|
|
fi
|
|
shell: bash
|
|
|
|
- name: Lerna publish
|
|
run: yarn lerna publish from-package --dist-tag ${{ contains(github.ref, '-beta') && 'beta' || 'latest' }} --no-verify-access --yes
|
|
env:
|
|
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
|
|
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
|
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|