Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Redo the javascript version and use pre-built binaries #342

Merged
merged 15 commits into from
Mar 31, 2024
Merged
Prev Previous commit
Next Next commit
test some stuff
sroussey committed Jan 11, 2024
commit 924aa44bff878933f3bf01a546d2a2c495afbbba
8 changes: 6 additions & 2 deletions .github/workflows/prerelease.yml
Original file line number Diff line number Diff line change
@@ -2,9 +2,9 @@ name: Pre-Release

on:
push:
branches: ["main-dev"]
branches: ["main-dev", "test-ga-*"]
pull_request:
branches: ["main-dev"]
branches: ["main-dev", "test-ga-*"]

env:
GH_TOKEN: ${{ secrets.SEMANTIC_RELEASE_TOKEN }}
@@ -19,6 +19,7 @@ permissions:
jobs:
test_ubuntu_gcc:
name: Ubuntu (GCC 12)
if: github.ref == 'refs/heads/main'
runs-on: ubuntu-22.04
env:
CC: gcc-12
@@ -107,6 +108,7 @@ jobs:

test_ubuntu_clang:
name: Ubuntu (Clang 16)
if: github.ref == 'refs/heads/main'
runs-on: ubuntu-22.04
env:
CC: clang-16
@@ -236,6 +238,7 @@ jobs:

test_windows:
name: Windows
if: github.ref == 'refs/heads/main'
runs-on: windows-2022
steps:
- uses: actions/checkout@v3
@@ -292,6 +295,7 @@ jobs:

build_docker:
name: Docker
if: github.ref == 'refs/heads/main'
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v3
105 changes: 90 additions & 15 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -2,7 +2,7 @@ name: Release

on:
push:
branches: ["main"]
branches: ["main", "test-ga-*"]

env:
BUILD_TYPE: Release
@@ -29,6 +29,7 @@ jobs:

rebase:
name: Rebase Dev. Branch
if: github.ref == 'refs/heads/main'
needs: versioning
runs-on: ubuntu-22.04
steps:
@@ -53,6 +54,7 @@ jobs:

create_linux_deb_package:
name: Create Debian Package for ${{ matrix.arch }}
if: github.ref == 'refs/heads/main'
runs-on: ubuntu-22.04
needs: versioning
strategy:
@@ -108,6 +110,7 @@ jobs:

create_windows_dll_library:
name: Create Dll Library for Windows ${{ matrix.arch }}
if: github.ref == 'refs/heads/main'
runs-on: windows-2022
needs: versioning
strategy:
@@ -184,7 +187,7 @@ jobs:
run: |
cmake -DCMAKE_BUILD_TYPE=Release -DUSEARCH_BUILD_LIB_C=1 -DUSEARCH_BUILD_TEST_CPP=0 -DUSEARCH_BUILD_BENCH_CPP=0 -B ./build_release
cmake --build ./build_release --config Release
zip -r usearch_macOS_${{ matrix.arch }}_${{ steps.version.outputs.version }}.zip build_release/libusearch_c.so c/usearch.h
zip -r usearch_macOS_${{ matrix.arch }}_${{ steps.version.outputs.version }}.zip build_release/libusearch_c.* c/usearch.h

- name: Upload archive
uses: xresloader/upload-to-github-release@v1
@@ -196,6 +199,7 @@ jobs:

wasm_c_library:
name: WASM builds for C libraries on ${{ matrix.os }}
if: github.ref == 'refs/heads/main'
runs-on: ${{ matrix.os }}
needs: versioning
strategy:
@@ -281,6 +285,7 @@ jobs:

publish_checksums:
name: Compute Assets Checksums
if: github.ref == 'refs/heads/main'
runs-on: ubuntu-22.04
needs:
[
@@ -347,6 +352,7 @@ jobs:

build_wheels:
name: Build Python
if: github.ref == 'refs/heads/main'
needs: versioning
runs-on: ${{ matrix.os }}
strategy:
@@ -382,6 +388,7 @@ jobs:

publish_python:
name: Publish Python
if: github.ref == 'refs/heads/main'
needs: build_wheels
runs-on: ubuntu-22.04
environment:
@@ -403,43 +410,108 @@ jobs:
verbose: true
print-hash: true

publish_javascript:
name: Publish JavaScript
build_javascript:
name: Build JavaScript Native Modules
needs: versioning
runs-on: ubuntu-22.04
strategy:
fail-fast: false
matrix:
arch:
- x64
- x86
os:
- macos-latest
- ubuntu-22.04
- windows-latest
exclude:
- arch: x86
os: macos-latest
- arch: x86
os: ubuntu-22.04
runs-on: ${{ matrix.os }}
env:
CC: gcc-12
CXX: g++-12

steps:
- uses: actions/checkout@v3
with:
ref: "main"
- name: Checkout the latest code
uses: actions/checkout@v4
- run: git submodule update --init --recursive

- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: 20
architecture: ${{ matrix.arch }}

- name: Update compilers
if: matrix.os == 'ubuntu-22.04'
run: |
sudo apt update
sudo apt install -y cmake build-essential libjemalloc-dev libomp-dev gcc-12 g++-12
sudo apt install gcc-aarch64-linux-gnu binutils-aarch64-linux-gnu

- run: npm ci --ignore-scripts
- run: npm run prebuild-single
if: matrix.os != 'macos-latest'
- run: npm run prebuild-darwin-x64+arm64
env:
CC: clang
CXX: clang++
if: matrix.os == 'macos-latest'
- run: file prebuilds/*/*
if: matrix.os == 'macos-latest'
- name: Extra for cross build
if: matrix.os == 'ubuntu-22.04'
run: npm run prebuild-arm64
- uses: actions/upload-artifact@v3
with:
name: prebuilds
path: prebuilds
retention-days: 1

publish_javascript:
name: Publish JavaScript
needs: build_javascript
runs-on: ubuntu-22.04

steps:
- uses: actions/checkout@v3
- run: git submodule update --init --recursive

- name: Set up Node.js
uses: actions/setup-node@v3
with:
node-version: 18
node-version: 20

- name: Build and Test
run: |
npm ci
npm test
npm run typegen
- uses: actions/download-artifact@v3

- name: Look for links
run: find . -type f -links +1

- name: Build the JS from TS
run: npm ci --ignore-scripts

- name: Build the JS from TS
run: npm run build-js

- name: Last minute test with prebuild artifact
run: npm run test

- name: Publish Dry Run
run: npm publish --dry-run
if: github.ref != 'refs/heads/main'

- name: Publish
uses: JS-DevTools/npm-publish@v2
if: github.ref == 'refs/heads/main'
uses: JS-DevTools/npm-publish@v3
with:
token: ${{ secrets.NPM_TOKEN }}
access: public

publish_rust:
name: Publish Rust
if: github.ref == 'refs/heads/main'
needs: versioning
runs-on: ubuntu-22.04
steps:
@@ -457,6 +529,7 @@ jobs:

publish_java:
name: Publish Java
if: github.ref == 'refs/heads/main'
needs: versioning
runs-on: ubuntu-22.04
permissions:
@@ -487,6 +560,7 @@ jobs:

publish_swift:
name: Publish ObjC & Swift
if: github.ref == 'refs/heads/main'
needs: versioning
runs-on: macos-12
steps:
@@ -543,6 +617,7 @@ jobs:

build_csharp:
name: Build C Dependencies for C#
if: github.ref == 'refs/heads/main'
needs: versioning
strategy:
fail-fast: false
15 changes: 13 additions & 2 deletions binding.gyp
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
{
"variables": {
"openssl_fips": ""
},
"targets": [
{
"target_name": "usearch",
@@ -24,8 +27,16 @@
"xcode_settings": {
"GCC_ENABLE_CPP_EXCEPTIONS": "YES",
"CLANG_CXX_LIBRARY": "libc++",
"MACOSX_DEPLOYMENT_TARGET": "10.15",
},
"MACOSX_DEPLOYMENT_TARGET": "11.0",
"OTHER_CFLAGS": [
"-arch arm64",
"-arch x86_64"
],
"OTHER_LDFLAGS": [
"-arch arm64",
"-arch x86_64"
]
},
"msvs_settings": {
"VCCLCompilerTool": {
"ExceptionHandling": 1,
1,358 changes: 1,351 additions & 7 deletions package-lock.json

Large diffs are not rendered by default.

36 changes: 17 additions & 19 deletions package.json
Original file line number Diff line number Diff line change
@@ -3,6 +3,7 @@
"version": "2.8.14",
"description": "Smaller & Faster Single-File Vector Search Engine from Unum",
"author": "Ash Vardanian (https://ashvardanian.com/)",
"contributors": ["Steven Roussey <sroussey@gmail.com>"],
"license": "Apache 2.0",
"homepage": "https://unum-cloud.github.io/usearch/",
"repository": {
@@ -13,37 +14,34 @@
"url": "https://github.com/unum-cloud/usearch/issues",
"email": "info@unum.cloud"
},
"main": "javascript/usearch.js",
"gypfile": true,
"engines": {
"node": "~10 >=10.20 || >=12.17"
},
"dependencies": {
"@types/node": "^20.4.5",
"bindings": "~1.2.1",
"node-gyp-build": "^4.8.0",
"node-addon-api": "^3.0.0"
},
"scripts": {
"test": "node --test ./javascript/usearch.test.js",
"install": "node-gyp rebuild",
"build-js": "rm -fr javascript/dist/* && tsc -p javascript/tsconfig-esm.json && tsc -p javascript/tsconfig-cjs.json && cp javascript/dist-package-esm.json javascript/dist/esm/package.json && cp javascript/dist-package-cjs.json javascript/dist/cjs/package.json",
"typegen": "npx tsc"
"install": "node-gyp-build",
"prebuild-single": "prebuildify --napi --strip --target=10.4.0",
"prebuild-arm64": "prebuildify --arch arm64 --napi --strip --target=10.4.0",
"prebuild-darwin-x64+arm64": "prebuildify --arch arm64+x64 --napi --strip --target=10.4.0",
"build-js": "rm -fr javascript/dist/* && tsc -p javascript/tsconfig-esm.json && tsc -p javascript/tsconfig-cjs.json && cp javascript/dist-package-esm.json javascript/dist/esm/package.json && cp javascript/dist-package-cjs.json javascript/dist/cjs/package.json"
},
"devDependencies": {
"@types/node": "^20.4.5",
"prebuildify": "^6.0.0",
"node-gyp": "^10.0.1",
"typescript": "^5.1.6"
},
"main": "javascript/dist/cjs/usearch.js",
"module": "javascript/dist/esm/usearch.js",
"exports": {
".": {
"types": "./javascript/types/usearch.d.ts",
"require": "./javascript/usearch.js"
},
"./package.json": "./package.json"
},
"typesVersions": {
"*": {
"*": [
"./javascript/types/usearch.d.ts"
]
}
}
"import": "./javascript/dist/esm/usearch.js",
"require": "./javascript/dist/cjs/usearch.js"
}
}

}