Skip to content

Commit

Permalink
impl engine for js sdk 1.0 (#38)
Browse files Browse the repository at this point in the history
switch to surrealdb 2.0 and switch to support surrealdb.js 1.0
  • Loading branch information
RaphaelDarley authored Jun 26, 2024
1 parent f0e400a commit 0080766
Show file tree
Hide file tree
Showing 26 changed files with 2,932 additions and 1,256 deletions.
3 changes: 3 additions & 0 deletions .cargo/config.toml
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
[build]
rustflags = ["--cfg", "surrealdb_unstable", ]

[target.aarch64-unknown-linux-musl]
linker = "aarch64-linux-musl-gcc"
rustflags = ["-C", "target-feature=-crt-static"]
269 changes: 159 additions & 110 deletions .github/workflows/CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,26 +21,29 @@ on:
- '**/*.gitignore'
- .editorconfig
- docs/**
pull_request: null
pull_request:
branches: ["main"]
jobs:
build:
strategy:
fail-fast: false
matrix:
settings:
- host: macos-latest
- host: macos-13
target: x86_64-apple-darwin
build: |
yarn build
yarn build --target x86_64-apple-darwin
strip -x *.node
- host: windows-latest
build: yarn build
target: x86_64-pc-windows-msvc
- host: windows-latest
build: |
yarn build --target i686-pc-windows-msvc
yarn build
yarn test
target: i686-pc-windows-msvc
target: x86_64-pc-windows-msvc
# - host: windows-latest
# build: |
# yarn build --target i686-pc-windows-msvc
# yarn test
# 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
Expand Down Expand Up @@ -77,19 +80,24 @@ jobs:
build: |
yarn build --target aarch64-linux-android
${ANDROID_NDK_LATEST_HOME}/toolchains/llvm/prebuilt/linux-x86_64/bin/llvm-strip *.node
- host: ubuntu-latest
target: armv7-linux-androideabi
build: |
yarn build --target armv7-linux-androideabi
${ANDROID_NDK_LATEST_HOME}/toolchains/llvm/prebuilt/linux-x86_64/bin/llvm-strip *.node
- host: ubuntu-latest
target: 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 build --target aarch64-unknown-linux-musl &&
/aarch64-linux-musl-cross/bin/aarch64-linux-musl-strip *.node
# - host: ubuntu-latest
# target: armv7-linux-androideabi
# build: |
# yarn build --target armv7-linux-androideabi
# ${ANDROID_NDK_LATEST_HOME}/toolchains/llvm/prebuilt/linux-x86_64/bin/llvm-strip *.node
# - host: ubuntu-latest
# target: 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 build --target aarch64-unknown-linux-musl &&
# /aarch64-linux-musl-cross/bin/aarch64-linux-musl-strip *.node
# - host: [self-hosted, linux, ARM64]
# target: aarch64-unknown-linux-musl
# build: rustup target add aarch64-unknown-linux-musl &&
# yarn build --target aarch64-unknown-linux-musl &&
# /aarch64-linux-musl-cross/bin/aarch64-linux-musl-strip *.node
# - host: windows-latest
# target: aarch64-pc-windows-msvc
# build: yarn build --target aarch64-pc-windows-msvc
Expand Down Expand Up @@ -161,54 +169,54 @@ jobs:
name: bindings-${{ matrix.settings.target }}
path: ${{ env.APP_NAME }}.*.node
if-no-files-found: error
build-freebsd:
runs-on: macos-12
name: Build FreeBSD
steps:
- uses: actions/checkout@v3
- name: Build
id: build
uses: vmactions/freebsd-vm@v0
env:
DEBUG: napi:*
RUSTUP_HOME: /usr/local/rustup
CARGO_HOME: /usr/local/cargo
RUSTUP_IO_THREADS: 1
with:
envs: DEBUG RUSTUP_HOME CARGO_HOME RUSTUP_IO_THREADS
usesh: true
mem: 3000
prepare: |
pkg install -y -f curl node libnghttp2 npm yarn
curl https://sh.rustup.rs -sSf --output rustup.sh
sh rustup.sh -y --profile minimal --default-toolchain beta
export PATH="/usr/local/cargo/bin:$PATH"
echo "~~~~ rustc --version ~~~~"
rustc --version
echo "~~~~ node -v ~~~~"
node -v
echo "~~~~ yarn --version ~~~~"
yarn --version
run: |
export PATH="/usr/local/cargo/bin:$PATH"
pwd
ls -lah
whoami
env
freebsd-version
yarn install
yarn build
strip -x *.node
yarn test
rm -rf node_modules
rm -rf target
rm -rf .yarn/cache
- name: Upload artifact
uses: actions/upload-artifact@v3
with:
name: bindings-freebsd
path: ${{ env.APP_NAME }}.*.node
if-no-files-found: error
# build-freebsd:
# runs-on: macos-12
# name: Build FreeBSD
# steps:
# - uses: actions/checkout@v3
# - name: Build
# id: build
# uses: vmactions/freebsd-vm@v0
# env:
# DEBUG: napi:*
# RUSTUP_HOME: /usr/local/rustup
# CARGO_HOME: /usr/local/cargo
# RUSTUP_IO_THREADS: 1
# with:
# envs: DEBUG RUSTUP_HOME CARGO_HOME RUSTUP_IO_THREADS
# usesh: true
# mem: 3000
# prepare: |
# pkg install -y -f curl node libnghttp2 npm yarn
# curl https://sh.rustup.rs -sSf --output rustup.sh
# sh rustup.sh -y --profile minimal --default-toolchain beta
# export PATH="/usr/local/cargo/bin:$PATH"
# echo "~~~~ rustc --version ~~~~"
# rustc --version
# echo "~~~~ node -v ~~~~"
# node -v
# echo "~~~~ yarn --version ~~~~"
# yarn --version
# run: |
# export PATH="/usr/local/cargo/bin:$PATH"
# pwd
# ls -lah
# whoami
# env
# freebsd-version
# yarn install
# yarn build
# strip -x *.node
# yarn test
# rm -rf node_modules
# rm -rf target
# rm -rf .yarn/cache
# - name: Upload artifact
# uses: actions/upload-artifact@v3
# 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 }}
needs:
Expand All @@ -218,11 +226,11 @@ jobs:
matrix:
settings:
- host: macos-latest
target: x86_64-apple-darwin
target: aarch64-apple-darwin
- host: windows-latest
target: x86_64-pc-windows-msvc
node:
- '14'
# - '14'
- '16'
- '18'
runs-on: ${{ matrix.settings.host }}
Expand Down Expand Up @@ -286,7 +294,7 @@ jobs:
fail-fast: false
matrix:
node:
- '14'
# - '14'
- '16'
- '18'
runs-on: ubuntu-latest
Expand Down Expand Up @@ -320,8 +328,8 @@ jobs:
fail-fast: false
matrix:
node:
- '14'
- '16'
# - '14'
# - '16'
- '18'
runs-on: ubuntu-latest
steps:
Expand Down Expand Up @@ -353,39 +361,39 @@ jobs:
set -e
yarn test
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:
- uses: actions/checkout@v3
- name: Download artifacts
uses: actions/download-artifact@v3
with:
name: bindings-aarch64-unknown-linux-musl
path: .
- name: List packages
run: ls -R .
shell: bash
- name: Install dependencies
run: |
yarn config set supportedArchitectures.cpu "arm64"
yarn config set supportedArchitectures.libc "musl"
yarn install
- name: Set up QEMU
uses: docker/setup-qemu-action@v2
with:
platforms: arm64
- run: docker run --rm --privileged multiarch/qemu-user-static --reset -p yes
- name: Setup and run tests
uses: addnab/docker-run-action@v3
with:
image: node:lts-alpine
options: '--platform linux/arm64 -v ${{ github.workspace }}:/build -w /build'
run: |
set -e
yarn test
# test-linux-aarch64-musl-binding:
# name: Test bindings on aarch64-unknown-linux-musl - node@${{ matrix.node }}
# needs:
# - build
# runs-on: ubuntu-latest
# steps:
# - uses: actions/checkout@v3
# - name: Download artifacts
# uses: actions/download-artifact@v3
# with:
# name: bindings-aarch64-unknown-linux-musl
# path: .
# - name: List packages
# run: ls -R .
# shell: bash
# - name: Install dependencies
# run: |
# yarn config set supportedArchitectures.cpu "arm64"
# yarn config set supportedArchitectures.libc "musl"
# yarn install
# - name: Set up QEMU
# uses: docker/setup-qemu-action@v2
# with:
# platforms: arm64
# - run: docker run --rm --privileged multiarch/qemu-user-static --reset -p yes
# - name: Setup and run tests
# uses: addnab/docker-run-action@v3
# with:
# image: node:lts-alpine
# options: '--platform linux/arm64 -v ${{ github.workspace }}:/build -w /build'
# run: |
# set -e
# yarn test
# test-linux-arm-gnueabihf-binding:
# name: Test bindings on armv7-unknown-linux-gnueabihf - node@${{ matrix.node }}
# needs:
Expand Down Expand Up @@ -446,11 +454,15 @@ jobs:
with:
name: bindings-x86_64-apple-darwin
path: artifacts
- name: List artifacts
run: ls /Users/runner/work/surrealdb.node/surrealdb.node/artifacts
- name: Download macOS arm64 artifact
uses: actions/download-artifact@v3
with:
name: bindings-aarch64-apple-darwin
path: artifacts
- name: List artifacts
run: ls /Users/runner/work/surrealdb.node/surrealdb.node/artifacts
- name: Combine binaries
run: yarn universal
- name: Upload artifact
Expand All @@ -459,17 +471,52 @@ jobs:
name: bindings-universal-apple-darwin
path: ${{ env.APP_NAME }}.*.node
if-no-files-found: error
publish-dry-run:
name: Publish dry run
runs-on: ubuntu-latest
needs:
# - build-freebsd
- test-macOS-windows-binding
- test-linux-x64-gnu-binding
- test-linux-x64-musl-binding
# - test-linux-aarch64-gnu-binding
# - test-linux-aarch64-musl-binding
# - test-linux-arm-gnueabihf-binding
- universal-macOS
steps:
- uses: actions/checkout@v3
- name: Setup node
uses: actions/setup-node@v3
with:
node-version: 18
check-latest: true
cache: yarn
- name: Install dependencies
run: yarn install
- name: Download all artifacts
uses: actions/download-artifact@v3
with:
path: artifacts
- name: Move artifacts
run: yarn artifacts
- name: Fix npm dirs
run: yarn napi create-npm-dir -t .
- name: List packages
run: ls -R ./npm
shell: bash
- name: Compile TypeScript
run: yarn ts-compile
publish:
if: ${{github.event_name == 'release'}}
name: Publish
runs-on: ubuntu-latest
needs:
- build-freebsd
# - build-freebsd
- test-macOS-windows-binding
- test-linux-x64-gnu-binding
- test-linux-x64-musl-binding
- test-linux-aarch64-gnu-binding
- test-linux-aarch64-musl-binding
# - test-linux-aarch64-gnu-binding
# - test-linux-aarch64-musl-binding
# - test-linux-arm-gnueabihf-binding
- universal-macOS
steps:
Expand All @@ -493,6 +540,8 @@ jobs:
- name: List packages
run: ls -R ./npm
shell: bash
- name: Compile TypeScript
run: yarn ts-compile
- name: Publish
run: |
npm config set provenance true
Expand Down
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -232,4 +232,7 @@ $RECYCLE.BIN/

*.node

examples
examples
.idea
lib/*
test.skv
Loading

0 comments on commit 0080766

Please sign in to comment.