diff --git a/.github/workflows/node-v2.yaml b/.github/workflows/node-v2.yaml deleted file mode 100644 index ad8fdbac..00000000 --- a/.github/workflows/node-v2.yaml +++ /dev/null @@ -1,480 +0,0 @@ -name: NodeJS Bindings -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: - push: - branches: - - master - tags-ignore: - - '**' - paths: - - 'bindings/nodejs/**' - - 'core/**' - - 'test-data/**' - - '.github/workflows/node-v2.yaml' - pull_request: - -jobs: - build: - if: "!contains(github.event.head_commit.message, 'skip ci')" - - strategy: - fail-fast: false - matrix: - settings: -# - host: macos-latest -# target: 'x86_64-apple-darwin' -# build: | -# yarn build -# strip -x packages/*/*.node -# - host: windows-latest -# build: yarn build -# target: 'x86_64-pc-windows-msvc' -# - host: windows-latest -# build: | -# yarn lerna exec "yarn build --target i686-pc-windows-msvc" --concurrency 1 --stream --no-prefix -# yarn test -s -# target: 'i686-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 && - rustup target add x86_64-unknown-linux-gnu && - cd bindings/nodejs && - yarn lerna exec "yarn build --target x86_64-unknown-linux-gnu" --concurrency 1 --stream --no-prefix && - strip ./*.node -# - host: ubuntu-latest -# target: 'x86_64-unknown-linux-musl' -# docker: ghcr.io/napi-rs/napi-rs/nodejs-rust:lts-alpine -# build: yarn build -# - 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 lerna exec "yarn build --target aarch64-apple-darwin" --concurrency 1 --stream --no-prefix -# strip -x packages/*/*.node -# - host: ubuntu-latest -# target: aarch64-unknown-linux-gnu -# docker: ghcr.io/napi-rs/napi-rs/nodejs-rust:lts-debian-aarch64 -# build: >- -# rustup target add aarch64-unknown-linux-gnu && -# yarn lerna exec "yarn build --target aarch64-unknown-linux-gnu" --concurrency 1 --stream --no-prefix && -# llvm-strip packages/*/*.node -# - host: ubuntu-latest -# target: 'armv7-unknown-linux-gnueabihf' -# setup: | -# sudo apt-get update -# sudo apt-get install gcc-arm-linux-gnueabihf g++-arm-linux-gnueabihf -y -# build: yarn lerna exec "yarn build --target armv7-unknown-linux-gnueabihf" --concurrency 1 --stream --no-prefix -# - host: ubuntu-latest -# target: aarch64-linux-android -# build: | -# yarn lerna exec "yarn build --target aarch64-linux-android" --concurrency 1 --stream --no-prefix -# ${ANDROID_NDK_LATEST_HOME}/toolchains/llvm/prebuilt/linux-x86_64/bin/llvm-strip packages/*/*.node -# - host: ubuntu-latest -# architecture: x64 -# target: armv7-linux-androideabi -# build: | -# yarn lerna exec "yarn build --target armv7-linux-androideabi" --concurrency 1 --stream --no-prefix -# ${ANDROID_NDK_LATEST_HOME}/toolchains/llvm/prebuilt/linux-x86_64/bin/llvm-strip packages/*/*.node -# - host: ubuntu-latest -# target: 'aarch64-unknown-linux-musl' -# downloadTarget: 'aarch64-unknown-linux-musl' -# docker: ghcr.io/napi-rs/napi-rs/nodejs-rust:lts-alpine -# build: >- -# set -e && -# rustup target add aarch64-unknown-linux-musl && -# yarn lerna exec "yarn build --target aarch64-unknown-linux-musl" --concurrency 1 --stream --no-prefix -# - host: windows-latest -# target: 'aarch64-pc-windows-msvc' -# build: yarn lerna exec "yarn build --target aarch64-pc-windows-msvc" --ignore @node-rs/jsonwebtoken --concurrency 1 --stream --no-prefix - - name: stable - ${{ matrix.settings.target }} - node@18 - 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 - if: ${{ !matrix.settings.docker }} - with: - node-version: 18 - check-latest: true - cache: yarn - cache-dependency-path: 'bindings/nodejs/yarn.lock' - - - name: Install - uses: dtolnay/rust-toolchain@stable - if: ${{ !matrix.settings.docker }} - with: - toolchain: nightly-2023-03-01 - targets: ${{ matrix.settings.target }} - - - name: Cache cargo registry - uses: actions/cache@v3 - with: - path: | - ~/.cargo/registry - ~/.cargo/git - target - .cargo-cache - key: ${{ matrix.settings.target }}-cargo-registry - - - 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 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/.cargo/git:/usr/local/cargo/git -v ${{ github.workspace }}/.cargo-cache/.cargo/registry:/usr/local/cargo/registry -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: bindings/nodejs/*.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', '18'] -# 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 -# -# - name: Install dependencies -# run: yarn install --immutable --mode=skip-build -# -# - name: Download artifacts -# uses: actions/download-artifact@v3 -# with: -# name: bindings-${{ matrix.settings.target }} -# path: artifacts -# -# - name: Move artifacts -# run: yarn artifacts -# shell: bash -# -# - name: Test bindings -# run: | -# yarn test packages/argon2 - test-linux-x64-gnu-binding: - name: Test bindings on Linux-x64-gnu - node@${{ matrix.node }} - needs: - - build - defaults: - run: - working-directory: ${{ env.WORKING_DIRECTORY }} - strategy: - fail-fast: false - matrix: -# node: ['14', '16', '18'] - node: ['18'] - runs-on: ubuntu-latest - - steps: - - uses: actions/checkout@v3 - - - 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: Install dependencies - run: yarn install --immutable --mode=skip-build - - - name: Download artifacts - uses: actions/download-artifact@v3 - with: - name: bindings-x86_64-unknown-linux-gnu - path: artifacts - - - name: Move artifacts - run: yarn artifacts - shell: bash - - - name: List folder - run: ls ./ - shell: bash - - - name: Test bindings - uses: addnab/docker-run-action@v3 - with: - image: node:${{ matrix.node }}-slim - options: -v ${{ github.workspace }}:/workspace - run: | - cd workspace/bindings/nodejs - yarn install - yarn link - yarn test - -# test-linux-x64-centos-7: -# name: Test bindings on Linux-x64-glibc-2.17 -# needs: -# - build -# runs-on: ubuntu-latest -# container: -# image: centos:7 -# steps: -# - uses: actions/checkout@v3 -# -# - name: Install dependencies -# run: | -# curl -sL https://rpm.nodesource.com/setup_16.x | bash - -# yum install nodejs -y -# npm install -g yarn -# yarn install --immutable --mode=skip-build -# - name: Download artifacts -# uses: actions/download-artifact@v3 -# with: -# name: bindings-x86_64-unknown-linux-gnu -# path: artifacts -# -# - name: Move artifacts -# run: yarn artifacts -# shell: bash -# -# - name: List packages -# run: ls -R packages -# shell: bash -# -# - name: Test bindings -# run: | -# yarn lerna link -# yarn test -s -# test-linux-x64-musl-binding: -# name: Test bindings on x86_64-unknown-linux-musl - node@${{ matrix.node }} -# needs: -# - build -# strategy: -# fail-fast: false -# matrix: -# node: ['14', '16', '18'] -# runs-on: ubuntu-latest -# -# steps: -# - uses: actions/checkout@v3 -# -# - name: Setup node -# uses: actions/setup-node@v3 -# with: -# node-version: ${{ matrix.node }} -# check-latest: true -# cache: yarn -# -# - name: Install dependencies -# run: | -# yarn config set supportedArchitectures.libc "musl" -# yarn install --immutable --mode=skip-build -# -# - name: Download artifacts -# uses: actions/download-artifact@v3 -# with: -# name: bindings-x86_64-unknown-linux-musl -# path: artifacts -# -# - name: Move artifacts -# run: yarn artifacts -# shell: bash -# -# - name: List packages -# run: ls -R packages -# shell: bash -# -# - name: Test bindings -# uses: addnab/docker-run-action@v3 -# with: -# image: node:${{ matrix.node }}-alpine -# options: -v ${{ github.workspace }}:/build -w /build -# run: | -# yarn lerna link -# yarn test -# test-linux-aarch64-gnu-binding: -# name: Test bindings on aarch64-unknown-linux-gnu - node@${{ matrix.node }} -# needs: -# - build -# strategy: -# fail-fast: false -# matrix: -# node: ['14', '16', '18'] -# runs-on: ubuntu-latest -# -# steps: -# - run: docker run --rm --privileged multiarch/qemu-user-static:register --reset -# -# - uses: actions/checkout@v3 -# -# - name: Download artifacts -# uses: actions/download-artifact@v3 -# with: -# name: bindings-aarch64-unknown-linux-gnu -# path: artifacts -# -# - name: Install dependencies -# run: | -# yarn config set supportedArchitectures.cpu "arm64" -# yarn config set supportedArchitectures.libc "glibc" -# yarn install --immutable --mode=skip-build -# - name: Move artifacts -# run: yarn artifacts -# shell: bash -# -# - name: List packages -# run: ls -R packages -# shell: bash -# -# - name: Setup and run tests -# uses: addnab/docker-run-action@v3 -# with: -# image: ghcr.io/napi-rs/napi-rs/nodejs:aarch64-${{ matrix.node }} -# options: -v ${{ github.workspace }}:/build -w /build -# run: | -# set -e -# yarn build:ts -# yarn test -s -# ls -la -# test-linux-aarch64-musl-binding: -# name: Test bindings on aarch64-unknown-linux-musl - node@${{ matrix.node }} -# needs: -# - build -# -# runs-on: ubuntu-latest -# -# steps: -# - run: docker run --rm --privileged multiarch/qemu-user-static:register --reset -# -# - uses: actions/checkout@v3 -# -# - name: Install dependencies -# run: | -# yarn config set supportedArchitectures.cpu "arm64" -# yarn config set supportedArchitectures.libc "musl" -# yarn install --immutable --mode=skip-build -# - name: Download artifacts -# uses: actions/download-artifact@v3 -# with: -# name: bindings-aarch64-unknown-linux-musl -# path: packages -# -# - name: Move artifacts -# run: yarn artifacts -# shell: bash -# -# - name: List packages -# run: ls -R packages -# shell: bash -# -# - name: Setup and run tests -# uses: addnab/docker-run-action@v3 -# with: -# image: multiarch/alpine:aarch64-latest-stable -# options: -v ${{ github.workspace }}:/build -w /build -# run: | -# set -e -# apk add nodejs npm yarn -# yarn build:ts -# yarn test - - release: - name: Release - runs-on: ubuntu-latest - defaults: - run: - working-directory: ${{ env.WORKING_DIRECTORY }} - needs: - - test-linux-x64-gnu-binding -# - test-linux-x64-centos-7 -# - test-linux-x64-musl-binding -# - test-linux-aarch64-gnu-binding -# - test-linux-arm-gnueabihf-binding -# - test-macOS-windows-binding - steps: - - uses: actions/checkout@v3 - - - name: Setup node - uses: actions/setup-node@v3 - with: - node-version: 18 - check-latest: true - cache: yarn - cache-dependency-path: 'bindings/nodejs/yarn.lock' - registry-url: 'https://registry.npmjs.org' - # Defaults to the user or organization that owns the workflow file - scope: '@gorules' - - - name: 'Install dependencies' - run: yarn install --immutable --mode=skip-build - - - name: Download all artifacts - uses: actions/download-artifact@v3 - with: - path: artifacts - - - name: Copy LICENSE - run: cp ../../LICENSE . - - - name: Move artifacts - run: yarn artifacts - - - name: List folder - run: ls ./ - shell: bash - - - name: Lerna publish - if: "startsWith(github.event.head_commit.message, 'chore(release): publish nodejs')" - run: yarn lerna publish from-package --no-verify-access --yes - env: - NPM_TOKEN: ${{ secrets.NPM_TOKEN }} - NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/node.yaml b/.github/workflows/node.yaml new file mode 100644 index 00000000..4a6fa80e --- /dev/null +++ b/.github/workflows/node.yaml @@ -0,0 +1,387 @@ +name: NodeJS Bindings +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: + push: + branches: + - master + tags-ignore: + - '**' + paths: + - 'bindings/nodejs/**' + - 'core/**' + - 'test-data/**' + - '.github/workflows/node.yaml' + pull_request: + +jobs: + build: + if: "!contains(github.event.head_commit.message, 'skip ci')" + + strategy: + fail-fast: false + matrix: + settings: + - host: macos-latest + target: 'x86_64-apple-darwin' + build: | + yarn build && + strip -x ./*.node + - host: windows-latest + build: | + yarn build + 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 && + rustup target add x86_64-unknown-linux-gnu && + cd bindings/nodejs && + yarn lerna exec "yarn build --target x86_64-unknown-linux-gnu" --concurrency 1 --stream --no-prefix && + strip ./*.node +# - host: ubuntu-latest +# target: 'x86_64-unknown-linux-musl' +# docker: ghcr.io/napi-rs/napi-rs/nodejs-rust:lts-alpine +# build: | +# cd bindings/nodejs && +# yarn build + - 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 lerna exec "yarn build --target aarch64-apple-darwin" --concurrency 1 --stream --no-prefix + strip -x ./*.node + - host: ubuntu-latest + target: aarch64-unknown-linux-gnu + docker: ghcr.io/napi-rs/napi-rs/nodejs-rust:lts-debian-aarch64 + build: >- + rustup target add aarch64-unknown-linux-gnu && + cd bindings/nodejs && + yarn lerna exec "yarn build --target aarch64-unknown-linux-gnu" --concurrency 1 --stream --no-prefix && + llvm-strip ./*.node +# - host: ubuntu-latest +# target: 'aarch64-unknown-linux-musl' +# downloadTarget: 'aarch64-unknown-linux-musl' +# docker: ghcr.io/napi-rs/napi-rs/nodejs-rust:lts-alpine +# build: >- +# set -e && +# rustup target add aarch64-unknown-linux-musl && +# cd bindings/nodejs && +# yarn lerna exec "yarn build --target aarch64-unknown-linux-musl" --concurrency 1 --stream --no-prefix + + name: stable - ${{ matrix.settings.target }} - node@18 + 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 + if: ${{ !matrix.settings.docker }} + with: + node-version: 18 + check-latest: true + cache: yarn + cache-dependency-path: 'bindings/nodejs/yarn.lock' + + - name: Install + uses: dtolnay/rust-toolchain@stable + if: ${{ !matrix.settings.docker }} + with: + toolchain: nightly-2023-03-01 + targets: ${{ matrix.settings.target }} + + - name: Cache cargo registry + uses: actions/cache@v3 + with: + path: | + ~/.cargo/registry + ~/.cargo/git + target + .cargo-cache + key: ${{ matrix.settings.target }}-cargo-registry + + - 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 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/.cargo/git:/usr/local/cargo/git -v ${{ github.workspace }}/.cargo-cache/.cargo/registry:/usr/local/cargo/registry -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: bindings/nodejs/*.node + if-no-files-found: error + + test-macOS-windows-binding: + name: Test bindings on ${{ matrix.settings.target }} - node@${{ matrix.node }} + needs: + - build + defaults: + run: + working-directory: ${{ env.WORKING_DIRECTORY }} + 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', '18'] + 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: Install dependencies + run: yarn install --immutable --mode=skip-build + + - name: Download artifacts + uses: actions/download-artifact@v3 + with: + name: bindings-${{ matrix.settings.target }} + path: artifacts + + - name: Move artifacts + run: yarn artifacts + shell: bash + + - name: Test bindings + run: | + yarn install + yarn link + yarn test + test-linux-x64-gnu-binding: + name: Test bindings on Linux-x64-gnu - node@${{ matrix.node }} + needs: + - build + defaults: + run: + working-directory: ${{ env.WORKING_DIRECTORY }} + strategy: + fail-fast: false + matrix: + node: ['14', '16', '18'] + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v3 + + - 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: Install dependencies + run: yarn install --immutable --mode=skip-build + + - name: Download artifacts + uses: actions/download-artifact@v3 + with: + name: bindings-x86_64-unknown-linux-gnu + path: artifacts + + - name: Move artifacts + run: yarn artifacts + shell: bash + + - name: List folder + run: ls ./ + shell: bash + + - name: Test bindings + uses: addnab/docker-run-action@v3 + with: + image: node:${{ matrix.node }}-slim + options: -v ${{ github.workspace }}:/workspace + run: | + cd workspace/bindings/nodejs + yarn install + yarn link + yarn test + + test-linux-x64-centos-7: + name: Test bindings on Linux-x64-glibc-2.17 + needs: + - build + defaults: + run: + working-directory: ${{ env.WORKING_DIRECTORY }} + runs-on: ubuntu-latest + container: + image: centos:7 + steps: + - uses: actions/checkout@v3 + + - name: Install dependencies + run: | + curl -sL https://rpm.nodesource.com/setup_16.x | bash - + yum install nodejs -y + npm install -g yarn + yarn install --immutable --mode=skip-build + - name: Download artifacts + uses: actions/download-artifact@v3 + with: + name: bindings-x86_64-unknown-linux-gnu + path: artifacts + + - name: Move artifacts + run: yarn artifacts + shell: bash + + - name: List folder + run: ls ./ + shell: bash + + - name: Test bindings + run: | + yarn lerna link + yarn test + test-linux-aarch64-gnu-binding: + name: Test bindings on aarch64-unknown-linux-gnu - node@${{ matrix.node }} + needs: + - build + defaults: + run: + working-directory: ${{ env.WORKING_DIRECTORY }} + strategy: + fail-fast: false + matrix: + node: ['14', '16', '18'] + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v3 + - run: docker run --rm --privileged multiarch/qemu-user-static:register --reset + - name: List directory + run: | + ls -la && + pwd + + - name: Download artifacts + uses: actions/download-artifact@v3 + with: + name: bindings-aarch64-unknown-linux-gnu + path: artifacts + + - name: Install dependencies + run: | + yarn config set supportedArchitectures.cpu "arm64" + yarn config set supportedArchitectures.libc "glibc" + yarn install --immutable --mode=skip-build + - name: Move artifacts + run: yarn artifacts + shell: bash + + - name: List folder + run: ls ./ + shell: bash + + - name: Setup and run tests + uses: addnab/docker-run-action@v3 + with: + image: ghcr.io/napi-rs/napi-rs/nodejs:aarch64-${{ matrix.node }} + options: -v ${{ github.workspace }}:/workspace -w /workspace + run: | + ls -la + cd bindings/nodejs + yarn install + yarn link + yarn test + + release: + name: Release + runs-on: ubuntu-latest + defaults: + run: + working-directory: ${{ env.WORKING_DIRECTORY }} + needs: + - test-linux-x64-gnu-binding + - test-linux-x64-centos-7 +# - test-linux-x64-musl-binding + - test-linux-aarch64-gnu-binding +# - test-linux-arm-gnueabihf-binding + - test-macOS-windows-binding + steps: + - uses: actions/checkout@v3 + + - name: Setup node + uses: actions/setup-node@v3 + with: + node-version: 18 + 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@v3 + with: + path: artifacts + + - name: Copy LICENSE + run: cp ../../LICENSE . + + - name: Move artifacts + run: yarn artifacts + + - name: List folder + run: ls ./ + shell: bash + + - name: Lerna publish + if: "startsWith(github.event.head_commit.message, 'chore(release): publish nodejs')" + run: yarn lerna publish from-package --no-verify-access --yes + env: + NPM_TOKEN: ${{ secrets.NPM_TOKEN }} + NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/python.yaml b/.github/workflows/python.yaml index 324d4b5f..d9a937bf 100644 --- a/.github/workflows/python.yaml +++ b/.github/workflows/python.yaml @@ -27,17 +27,12 @@ jobs: strategy: matrix: # target: [x86_64, x86, aarch64, armv7, s390x, ppc64le] -# target: [x86_64, aarch64] - target: [x86_64] + target: [x86_64, aarch64] steps: - uses: actions/checkout@v3 - uses: actions/setup-python@v4 with: python-version: '3.10' - - - name: Copy LICENSE - run: cp ../../LICENSE . - - name: Build wheels uses: PyO3/maturin-action@v1 with: @@ -45,80 +40,81 @@ jobs: args: --release --out dist --find-interpreter -m bindings/python/Cargo.toml sccache: 'true' manylinux: auto -# - name: Test Bindings -# run: python index.py - name: Upload wheels uses: actions/upload-artifact@v3 with: name: wheels path: dist -# windows: -# runs-on: windows-latest -# strategy: -# matrix: -# target: [x64, x86] -# steps: -# - uses: actions/checkout@v3 -# - uses: actions/setup-python@v4 -# with: -# python-version: '3.10' -# architecture: ${{ matrix.target }} -# - name: Build wheels -# uses: PyO3/maturin-action@v1 -# with: -# target: ${{ matrix.target }} -# args: --release --out dist --find-interpreter -m bindings/python/Cargo.toml -# sccache: 'true' -# - name: Test Bindings -# run: python index.py -# - name: Upload wheels -# uses: actions/upload-artifact@v3 -# with: -# name: wheels -# path: dist -# -# macos: -# runs-on: macos-latest -# strategy: -# matrix: -# target: [x86_64, aarch64] -# steps: -# - uses: actions/checkout@v3 -# - uses: actions/setup-python@v4 -# with: -# python-version: '3.10' -# - name: Build wheels -# uses: PyO3/maturin-action@v1 -# with: -# target: ${{ matrix.target }} -# args: --release --out dist --find-interpreter -m bindings/python/Cargo.toml -# sccache: 'true' -# - name: Test Bindings -# run: python index.py -# - name: Upload wheels -# uses: actions/upload-artifact@v3 -# with: -# name: wheels -# path: dist + windows: + runs-on: windows-latest + defaults: + run: + working-directory: ${{ env.WORKING_DIRECTORY }} + strategy: + matrix: + target: [x64] + steps: + - uses: actions/checkout@v3 + - uses: actions/setup-python@v4 + with: + python-version: '3.10' + architecture: ${{ matrix.target }} + - name: Build wheels + uses: PyO3/maturin-action@v1 + with: + target: ${{ matrix.target }} + args: --release --out dist --find-interpreter -m bindings/python/Cargo.toml + sccache: 'true' + - name: Upload wheels + uses: actions/upload-artifact@v3 + with: + name: wheels + path: dist -# sdist: -# runs-on: ubuntu-latest -# defaults: -# run: -# working-directory: ${{ env.WORKING_DIRECTORY }} -# steps: -# - uses: actions/checkout@v3 -# - name: Build sdist -# uses: PyO3/maturin-action@v1 -# with: -# command: sdist -# args: --out dist -m bindings/python/Cargo.toml -# - name: Upload sdist -# uses: actions/upload-artifact@v3 -# with: -# name: wheels -# path: dist + macos: + runs-on: macos-latest + defaults: + run: + working-directory: ${{ env.WORKING_DIRECTORY }} + strategy: + matrix: + target: [x86_64, aarch64] + steps: + - uses: actions/checkout@v3 + - uses: actions/setup-python@v4 + with: + python-version: '3.10' + - name: Build wheels + uses: PyO3/maturin-action@v1 + with: + target: ${{ matrix.target }} + args: --release --out dist --find-interpreter -m bindings/python/Cargo.toml + sccache: 'true' + - name: Upload wheels + uses: actions/upload-artifact@v3 + with: + name: wheels + path: dist + + sdist: + runs-on: ubuntu-latest + defaults: + run: + working-directory: ${{ env.WORKING_DIRECTORY }} + steps: + - uses: actions/checkout@v3 + + - name: Build sdist + uses: PyO3/maturin-action@v1 + with: + command: sdist + args: --out dist -m bindings/python/Cargo.toml + - name: Upload sdist + uses: actions/upload-artifact@v3 + with: + name: wheels + path: dist release: name: Release @@ -127,9 +123,9 @@ jobs: run: working-directory: ${{ env.WORKING_DIRECTORY }} # if: "startsWith(github.ref, 'refs/tags/')" -# needs: [linux, windows, macos, sdist] + needs: [linux, windows, macos, sdist] # needs: [linux, sdist] - needs: [linux] +# needs: [linux] steps: - uses: actions/download-artifact@v3 with: diff --git a/bindings/nodejs/LICENSE b/bindings/nodejs/LICENSE new file mode 100644 index 00000000..ca6d24c6 --- /dev/null +++ b/bindings/nodejs/LICENSE @@ -0,0 +1,13 @@ +Copyright 2023 GoRules.io + +Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation +files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, +modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software +is furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE +WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR +COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, +ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. \ No newline at end of file diff --git a/bindings/nodejs/npm/linux-arm64-musl/README.md b/bindings/nodejs/npm/linux-arm64-musl/README.md deleted file mode 100644 index e79a96f2..00000000 --- a/bindings/nodejs/npm/linux-arm64-musl/README.md +++ /dev/null @@ -1,3 +0,0 @@ -# `@gorules/zen-engine-linux-arm64-musl` - -This is the **aarch64-unknown-linux-musl** binary for `@gorules/zen-engine` diff --git a/bindings/nodejs/npm/linux-arm64-musl/package.json b/bindings/nodejs/npm/linux-arm64-musl/package.json deleted file mode 100644 index c4415fe7..00000000 --- a/bindings/nodejs/npm/linux-arm64-musl/package.json +++ /dev/null @@ -1,51 +0,0 @@ -{ - "name": "@gorules/zen-engine-linux-arm64-musl", - "version": "0.1.4", - "os": [ - "linux" - ], - "cpu": [ - "arm64" - ], - "libc": [ - "musl" - ], - "main": "zen-engine.linux-arm64-musl.node", - "files": [ - "zen-engine.linux-arm64-musl.node" - ], - "description": "Rust zen-engine binding", - "keywords": [ - "gorules", - "zen-engine", - "business rules engine", - "rules engine", - "rule engine", - "bre", - "rule", - "rules", - "engine", - "decision", - "decision table", - "rust", - "N-API", - "napi-rs", - "node-rs" - ], - "author": "GoRules (https://gorules.io)", - "homepage": "https://github.com/gorules/zen", - "license": "MIT", - "engines": { - "node": ">= 14" - }, - "publishConfig": { - "registry": "https://registry.npmjs.org/" - }, - "repository": { - "type": "git", - "url": "git+https://github.com/gorules/zen.git" - }, - "bugs": { - "url": "https://github.com/gorules/zen/issues" - } -} \ No newline at end of file diff --git a/bindings/nodejs/npm/linux-x64-musl/README.md b/bindings/nodejs/npm/linux-x64-musl/README.md deleted file mode 100644 index a983ab4e..00000000 --- a/bindings/nodejs/npm/linux-x64-musl/README.md +++ /dev/null @@ -1,3 +0,0 @@ -# `@gorules/zen-engine-linux-x64-musl` - -This is the **x86_64-unknown-linux-musl** binary for `@gorules/zen-engine` diff --git a/bindings/nodejs/npm/linux-x64-musl/package.json b/bindings/nodejs/npm/linux-x64-musl/package.json deleted file mode 100644 index f085dc21..00000000 --- a/bindings/nodejs/npm/linux-x64-musl/package.json +++ /dev/null @@ -1,51 +0,0 @@ -{ - "name": "@gorules/zen-engine-linux-x64-musl", - "version": "0.1.4", - "os": [ - "linux" - ], - "cpu": [ - "x64" - ], - "libc": [ - "musl" - ], - "main": "zen-engine.linux-x64-musl.node", - "files": [ - "zen-engine.linux-x64-musl.node" - ], - "description": "Rust zen-engine binding", - "keywords": [ - "gorules", - "zen-engine", - "business rules engine", - "rules engine", - "rule engine", - "bre", - "rule", - "rules", - "engine", - "decision", - "decision table", - "rust", - "N-API", - "napi-rs", - "node-rs" - ], - "author": "GoRules (https://gorules.io)", - "homepage": "https://github.com/gorules/zen", - "license": "MIT", - "engines": { - "node": ">= 14" - }, - "publishConfig": { - "registry": "https://registry.npmjs.org/" - }, - "repository": { - "type": "git", - "url": "git+https://github.com/gorules/zen.git" - }, - "bugs": { - "url": "https://github.com/gorules/zen/issues" - } -} \ No newline at end of file diff --git a/bindings/nodejs/package.json b/bindings/nodejs/package.json index 7446c157..f7896195 100644 --- a/bindings/nodejs/package.json +++ b/bindings/nodejs/package.json @@ -18,10 +18,8 @@ "x86_64-apple-darwin", "x86_64-unknown-linux-gnu", "x86_64-pc-windows-msvc", - "x86_64-unknown-linux-musl", "aarch64-unknown-linux-gnu", - "aarch64-apple-darwin", - "aarch64-unknown-linux-musl" + "aarch64-apple-darwin" ] }, "npmClient": "yarn" diff --git a/bindings/nodejs/test/decision.spec.ts b/bindings/nodejs/test/decision.spec.ts index c774f382..431f07bb 100644 --- a/bindings/nodejs/test/decision.spec.ts +++ b/bindings/nodejs/test/decision.spec.ts @@ -1,13 +1,14 @@ import {ZenEngine} from "../index"; import fs from 'fs/promises'; import path from 'path'; -import {describe, expect, it} from "@jest/globals"; - +import {describe, expect, it, jest} from "@jest/globals"; const testDataRoot = path.join(__dirname, '../../../', 'test-data'); const loader = async (key: string) => fs.readFile(path.join(testDataRoot, key)) +jest.useRealTimers(); + describe('ZenEngine', () => { it('Evaluates decisions using loader', async () => { const engine = new ZenEngine({ @@ -21,7 +22,7 @@ describe('ZenEngine', () => { expect(r1.result.output).toEqual(10); expect(r2.result.output).toEqual(0); expect(r3.result.output).toEqual(10); - }); + }, 10000); it('Evaluates decisions using getDecision', async () => { const engine = new ZenEngine({ @@ -38,7 +39,7 @@ describe('ZenEngine', () => { expect(r1.result.output).toEqual(20); expect(r2.result.output).toEqual(0); expect(r3.result.output).toEqual(10); - }); + }, 10000); it('Creates a decision from contents', async () => { const engine = new ZenEngine(); @@ -47,5 +48,5 @@ describe('ZenEngine', () => { const r = await functionDecision.evaluate({input: 15}); expect(r.result.output).toEqual(30); - }) + }, 10000) }) diff --git a/bindings/python/LICENSE b/bindings/python/LICENSE new file mode 100644 index 00000000..ca6d24c6 --- /dev/null +++ b/bindings/python/LICENSE @@ -0,0 +1,13 @@ +Copyright 2023 GoRules.io + +Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation +files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, +modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software +is furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE +WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR +COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, +ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. \ No newline at end of file