Merge pull request #499 from CCnut/main-dev #954
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Pre-Release | |
on: | |
push: | |
branches: ["main-dev"] | |
pull_request: | |
branches: ["main-dev"] | |
env: | |
GH_TOKEN: ${{ secrets.SEMANTIC_RELEASE_TOKEN }} | |
PYTHONUTF8: 1 | |
PYTHON_VERSION: 3.11 | |
DOTNET_VERSION: 7.0.x | |
ANDROID_NDK_VERSION: 26.3.11579264 | |
ANDROID_SDK_VERSION: 21 | |
# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages | |
permissions: | |
contents: read | |
jobs: | |
versioning: | |
name: Update Version | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
persist-credentials: false | |
- name: Run TinySemVer | |
uses: ashvardanian/[email protected] | |
with: | |
verbose: "true" | |
version-file: "VERSION" | |
update-version-in: | | |
package.json:"version": "(\d+\.\d+\.\d+)" | |
package-lock.json:"usearch",\n\s+"version": "(\d+\.\d+\.\d+)" | |
CITATION.cff:^version: (\d+\.\d+\.\d+) | |
Cargo.toml:^version = "(\d+\.\d+\.\d+)" | |
Cargo.lock:name = "usearch"\nversion = "(\d+\.\d+\.\d+)" | |
wasmer.toml:^version = "(\d+\.\d+\.\d+)" | |
conanfile.py:version = "(\d+\.\d+\.\d+)" | |
java/README.md:<version>(\d+\.\d+\.\d+)</version> | |
README.md:version = {(\d+\.\d+\.\d+)} | |
csharp/nuget/nuget-package.props:>(\d+\.\d+\.\d+)</Version> | |
CMakeLists.txt:VERSION (\d+\.\d+\.\d+) | |
update-major-version-in: | | |
include/usearch/index.hpp:^#define USEARCH_VERSION_MAJOR (\d+) | |
update-minor-version-in: | | |
include/usearch/index.hpp:^#define USEARCH_VERSION_MINOR (\d+) | |
update-patch-version-in: | | |
include/usearch/index.hpp:^#define USEARCH_VERSION_PATCH (\d+) | |
dry-run: "true" | |
test_ubuntu_gcc: | |
name: Ubuntu (GCC 14) | |
runs-on: ubuntu-24.04 | |
env: | |
CC: gcc | |
CXX: g++ | |
steps: | |
- uses: actions/checkout@v4 | |
- run: git submodule update --init --recursive | |
# C/C++ | |
- name: Build C/C++ | |
run: | | |
sudo apt update | |
sudo apt install -y cmake build-essential libjemalloc-dev libomp-dev gcc-12 g++-12 | |
cmake -B build_artifacts -D CMAKE_BUILD_TYPE=RelWithDebInfo -D USEARCH_BUILD_TEST_CPP=1 -D USEARCH_BUILD_TEST_C=1 -D USEARCH_BUILD_LIB_C=1 -D USEARCH_BUILD_SQLITE=1 -D USEARCH_USE_OPENMP=1 -D USEARCH_USE_SIMSIMD=1 -D USEARCH_USE_JEMALLOC=1 | |
cmake --build build_artifacts --config RelWithDebInfo | |
- name: Test C++ | |
run: build_artifacts/test_cpp | |
- name: Test C | |
run: build_artifacts/test_c | |
# Python | |
- name: Set up Python ${{ env.PYTHON_VERSION }} | |
uses: actions/setup-python@v5 | |
with: | |
python-version: ${{ env.PYTHON_VERSION }} | |
- name: Build Python | |
run: | | |
python -m pip install --upgrade pip | |
pip install pytest pytest-repeat numpy numba cppyy | |
pip install --upgrade git+https://github.com/Maratyszcza/PeachPy | |
python -m pip install . | |
- name: Test Python | |
run: pytest | |
# JavaScript | |
- name: Set up Node.js | |
uses: actions/setup-node@v4 | |
with: | |
node-version: 20 | |
- name: Install dependencies | |
run: npm ci --skip-scripts | |
- name: Build JavaScript | |
run: npm run build-js | |
- name: Test JavaScript | |
run: npm test | |
# Rust | |
- name: Set up Rust | |
run: | | |
rustup update stable | |
rustup default stable | |
rustc -vV | |
- name: Build Rust | |
run: cargo build | |
- name: Test Rust | |
run: cargo test | |
# Java | |
- name: Setup Java | |
uses: actions/setup-java@v4 | |
with: | |
java-version: "21" | |
distribution: "adopt" | |
- name: Setup Gradle | |
uses: gradle/[email protected] | |
- name: Test Java | |
run: gradle clean build | |
# C# | |
- name: Setup .NET ${{ env.DOTNET_VERSION }} | |
uses: actions/setup-dotnet@v3 | |
with: | |
dotnet-version: ${{ env.DOTNET_VERSION }} | |
- name: Test .NET | |
run: | | |
mkdir -p "${{ github.workspace }}/csharp/lib/runtimes/linux-x64/native" | |
cp "${{ github.workspace }}/build_artifacts/libusearch_c.so" "${{ github.workspace }}/csharp/lib/runtimes/linux-x64/native" | |
dotnet test -c Debug --logger "console;verbosity=detailed" | |
shell: bash | |
working-directory: ${{ github.workspace }}/csharp | |
# GoLang | |
# With `LD_DEBUG=all` we detect the addresses of the libraries that are loaded | |
- name: Test GoLang | |
run: | | |
sudo cp ${{ github.workspace }}/build_artifacts/libusearch_c.so /usr/lib/libusearch_c.so | |
sudo cp ${{ github.workspace }}/c/usearch.h /usr/include/usearch.h | |
LD_DEBUG=all go test -v | |
working-directory: ${{ github.workspace }}/golang/ | |
test_ubuntu_clang: | |
name: Ubuntu (Clang 18) | |
runs-on: ubuntu-24.04 | |
env: | |
CC: clang | |
CXX: clang++ | |
steps: | |
- uses: actions/checkout@v4 | |
- run: git submodule update --init --recursive | |
# C/C++ | |
# Clang 16 isn't available from default repos on Ubuntu 22.04, so we have to install it manually | |
- name: Build C/C++ | |
run: | | |
sudo apt update | |
sudo apt install -y cmake build-essential libjemalloc-dev clang | |
cmake -B build_artifacts -D CMAKE_BUILD_TYPE=RelWithDebInfo -D USEARCH_BUILD_TEST_CPP=1 -D USEARCH_BUILD_TEST_C=1 -D USEARCH_BUILD_LIB_C=1 -D USEARCH_BUILD_SQLITE=1 -D USEARCH_USE_OPENMP=0 -D USEARCH_USE_SIMSIMD=1 -D USEARCH_USE_JEMALLOC=1 | |
cmake --build build_artifacts --config RelWithDebInfo | |
- name: Test C++ | |
run: build_artifacts/test_cpp | |
- name: Test C | |
run: build_artifacts/test_c | |
# JavaScript | |
- name: Set up Node.js | |
uses: actions/setup-node@v4 | |
with: | |
node-version: 20 | |
- name: Install dependencies | |
run: npm ci --skip-scripts | |
- name: Build JavaScript | |
run: npm run build-js | |
- name: Test JavaScript | |
run: npm test | |
# Python | |
- name: Set up Python ${{ env.PYTHON_VERSION }} | |
uses: actions/setup-python@v4 | |
with: | |
python-version: ${{ env.PYTHON_VERSION }} | |
- name: Build Python | |
run: | | |
python -m pip install --upgrade pip | |
pip install pytest pytest-repeat numpy numba cppyy | |
pip install --upgrade git+https://github.com/Maratyszcza/PeachPy | |
python -m pip install . | |
env: | |
CXX: clang++ | |
CC: clang++ # Override the default compiler | |
- name: Test Python | |
run: pytest | |
# Rust | |
- name: Set up Rust | |
run: | | |
rustup update stable | |
rustup default stable | |
rustc -vV | |
- name: Build Rust | |
run: cargo build | |
- name: Test Rust | |
run: cargo test | |
# C# | |
- name: Setup .NET ${{ env.DOTNET_VERSION }} | |
uses: actions/setup-dotnet@v3 | |
with: | |
dotnet-version: ${{ env.DOTNET_VERSION }} | |
- name: Test .NET | |
run: | | |
mkdir -p "${{ github.workspace }}/csharp/lib/runtimes/linux-x64/native" | |
cp "${{ github.workspace }}/build_artifacts/libusearch_c.so" "${{ github.workspace }}/csharp/lib/runtimes/linux-x64/native" | |
dotnet test -c Debug --logger "console;verbosity=detailed" | |
shell: bash | |
working-directory: ${{ github.workspace }}/csharp | |
test_macos: | |
name: MacOS | |
runs-on: macos-14 | |
steps: | |
- uses: actions/checkout@v4 | |
- run: git submodule update --init --recursive | |
# C/C++ | |
- name: Build C/C++ | |
run: | | |
brew update | |
brew install cmake | |
cmake -B build_artifacts -D CMAKE_BUILD_TYPE=RelWithDebInfo -D USEARCH_BUILD_TEST_CPP=1 -D USEARCH_BUILD_TEST_C=1 -D USEARCH_BUILD_LIB_C=1 -D USEARCH_BUILD_SQLITE=1 | |
cmake --build build_artifacts --config RelWithDebInfo | |
- name: Test C++ | |
run: build_artifacts/test_cpp | |
- name: Test C | |
run: build_artifacts/test_c | |
# JavaScript | |
- name: Set up Node.js | |
uses: actions/setup-node@v4 | |
with: | |
node-version: 20 | |
- name: Install dependencies | |
run: npm ci --skip-scripts | |
- name: Build JavaScript | |
run: npm run build-js | |
- name: Test JavaScript | |
run: npm test | |
# Python | |
- name: Set up Python ${{ env.PYTHON_VERSION }} | |
uses: actions/setup-python@v4 | |
with: | |
python-version: ${{ env.PYTHON_VERSION }} | |
- name: Build Python | |
run: | | |
python -m pip install --upgrade pip | |
pip install pytest pytest-repeat numpy | |
python -m pip install . | |
env: | |
CXX: clang++ | |
CC: clang++ # Override the default compiler | |
- name: Test Python | |
run: pytest | |
# ObjC/Swift | |
- name: Build ObjC/Swift | |
run: swift build | |
- name: Test ObjC/Swift | |
run: swift test | |
# Rust | |
- name: Set up Rust | |
run: | | |
rustup update stable | |
rustup default stable | |
rustc -vV | |
- name: Build Rust | |
run: cargo build | |
- name: Test Rust | |
run: cargo test | |
# C# | |
- name: Setup .NET ${{ env.DOTNET_VERSION }} | |
uses: actions/setup-dotnet@v3 | |
with: | |
dotnet-version: ${{ env.DOTNET_VERSION }} | |
- name: Test .NET | |
run: | | |
mkdir -p "${{ github.workspace }}/csharp/lib/runtimes/osx-arm64/native" | |
cp "${{ github.workspace }}/build_artifacts/libusearch_c.dylib" "${{ github.workspace }}/csharp/lib/runtimes/osx-arm64/native" | |
dotnet test -c Debug --logger "console;verbosity=detailed" --filter "FullyQualifiedName!=Cloud.Unum.USearch.Tests.UsearchIndexTests.PersistAndRestore" | |
shell: bash | |
working-directory: ${{ github.workspace }}/csharp | |
env: | |
DYLD_PRINT_LIBRARIES: 1 | |
test_windows: | |
name: Windows | |
runs-on: windows-2022 | |
steps: | |
- uses: actions/checkout@v4 | |
- run: git submodule update --init --recursive | |
# C/C++ | |
- name: Build C/C++ | |
run: | | |
choco install cmake | |
cmake -B build_artifacts -D CMAKE_BUILD_TYPE=RelWithDebInfo -D USEARCH_BUILD_TEST_CPP=1 -D USEARCH_BUILD_TEST_C=1 -D USEARCH_BUILD_LIB_C=1 -D USEARCH_BUILD_SQLITE=0 | |
cmake --build build_artifacts --config RelWithDebInfo | |
- name: Test C++ | |
run: .\build_artifacts\test_cpp.exe | |
- name: Test C | |
run: .\build_artifacts\test_c.exe | |
# Python | |
- name: Set up Python ${{ env.PYTHON_VERSION }} | |
uses: actions/setup-python@v4 | |
with: | |
python-version: ${{ env.PYTHON_VERSION }} | |
- name: Build Python | |
run: | | |
python -m pip install --upgrade pip | |
pip install pytest pytest-repeat numpy | |
python -m pip install . | |
- name: Test Python | |
run: pytest | |
# JavaScript | |
- name: Set up Node.js | |
uses: actions/setup-node@v4 | |
with: | |
node-version: 20 | |
- name: Install dependencies | |
run: npm ci --skip-scripts | |
- name: Build JavaScript | |
run: npm run build-js | |
- name: Test JavaScript | |
run: npm test | |
# Rust | |
- name: Set up Rust | |
run: | | |
rustup update stable | |
rustup default stable | |
rustc -vV | |
- name: Build Rust | |
run: cargo build | |
- name: Test Rust | |
run: cargo test | |
# C# | |
- name: Setup .NET ${{ env.DOTNET_VERSION }} | |
uses: actions/setup-dotnet@v3 | |
with: | |
dotnet-version: ${{ env.DOTNET_VERSION }} | |
- name: Test .NET | |
run: | | |
mkdir -p "${{ github.workspace }}\csharp\lib\runtimes\win-x64\native" | |
cp "${{ github.workspace }}\build_artifacts\libusearch_c.dll" "${{ github.workspace }}\csharp\lib\runtimes\win-x64\native" | |
dotnet test -c Debug --logger "console;verbosity=detailed" | |
shell: bash | |
working-directory: ${{ github.workspace }}/csharp | |
build_docker: | |
name: Docker | |
runs-on: ubuntu-22.04 | |
steps: | |
- uses: actions/checkout@v4 | |
- run: git submodule update --init --recursive | |
- name: Build | |
uses: docker/build-push-action@v6 | |
with: | |
context: . | |
load: true | |
push: false | |
build_wheels: | |
name: Build Python Wheels | |
runs-on: ${{ matrix.os }} | |
needs: [test_ubuntu_gcc, test_ubuntu_clang, test_macos, test_windows] | |
strategy: | |
matrix: | |
os: [ubuntu-latest, macos-latest, windows-latest] | |
python-version: ["37", "38", "39", "310", "311", "312"] | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Set up Python | |
uses: actions/setup-python@v5 | |
with: | |
python-version: 3.x | |
# We only need QEMU for Linux builds | |
- name: Setup QEMU | |
if: matrix.os == 'ubuntu-latest' | |
uses: docker/setup-qemu-action@v3 | |
- name: Install cibuildwheel | |
run: python -m pip install cibuildwheel | |
- name: Build wheels | |
run: cibuildwheel --output-dir wheelhouse | |
env: | |
CIBW_BUILD: cp${{ matrix.python-version }}-* | |
test_ubuntu_cross_compilation: | |
name: Cross Compilation | |
runs-on: ubuntu-22.04 | |
env: | |
CC: clang | |
CXX: clang++ | |
AR: llvm-ar | |
NM: llvm-nm | |
RANLIB: llvm-ranlib | |
strategy: | |
fail-fast: false | |
matrix: | |
include: | |
- arch: amd64 | |
target: x86_64-linux-gnu | |
- arch: arm64 | |
target: aarch64-linux-gnu | |
steps: | |
- uses: actions/checkout@v4 | |
- run: git submodule update --init --recursive | |
# C/C++ | |
# We need to install the cross-compilation toolchain for ARM64 and ARMHF | |
- name: Install dependencies | |
run: | | |
sudo apt-get update | |
sudo apt-get install -y clang lld make crossbuild-essential-arm64 crossbuild-essential-armhf libjemalloc-dev | |
- name: Build C/C++ | |
run: | | |
cmake -B build_artifacts \ | |
-D CMAKE_BUILD_TYPE=RelWithDebInfo \ | |
-D CMAKE_EXPORT_COMPILE_COMMANDS=1 \ | |
-D CMAKE_C_COMPILER_TARGET=${{ matrix.target }} \ | |
-D CMAKE_CXX_COMPILER_TARGET=${{ matrix.target }} \ | |
-D CMAKE_SYSTEM_NAME=Linux \ | |
-D CMAKE_SYSTEM_PROCESSOR=${{ matrix.arch }} \ | |
-D USEARCH_BUILD_LIB_C=1 \ | |
-D USEARCH_BUILD_SQLITE=1 \ | |
-D USEARCH_BUILD_TEST_CPP=0 \ | |
-D USEARCH_BUILD_BENCH_CPP=0 | |
cmake --build build_artifacts --config RelWithDebInfo | |
# We can't run the produced builds, but we can make sure they exist | |
- name: Test artifacts presense | |
run: | | |
test -e build_artifacts/libusearch_c.so | |
test -e build_artifacts/libusearch_sqlite.so | |
test_ubuntu_android_ndk: | |
name: Android NDK Build | |
runs-on: ubuntu-22.04 | |
strategy: | |
matrix: | |
include: | |
- processor: armv7a | |
abi: armeabi-v7a | |
target: armv7-linux-androideabi | |
- processor: aarch64 | |
abi: arm64-v8a | |
target: aarch64-linux-android | |
steps: | |
- uses: actions/checkout@v4 | |
- run: git submodule update --init --recursive | |
- name: Install NDK ndk | |
run: | | |
${ANDROID_HOME}/cmdline-tools/latest/bin/sdkmanager --install "ndk;${{ env.ANDROID_NDK_VERSION }}" | |
- name: Build C/C++ | |
run: | | |
cmake -B build_artifacts \ | |
-D CMAKE_BUILD_TYPE=RelWithDebInfo \ | |
-D CMAKE_EXPORT_COMPILE_COMMANDS=1 \ | |
-D CMAKE_TOOLCHAIN_FILE=${ANDROID_HOME}/ndk/${{ env.ANDROID_NDK_VERSION }}/build/cmake/android.toolchain.cmake \ | |
-D CMAKE_ANDROID_STL_TYPE=c++_static \ | |
-D ANDROID_PLATFORM=${{ env.ANDROID_SDK_VERSION }} \ | |
-D ANDROID_ABI=${{ matrix.abi }} \ | |
-D USEARCH_BUILD_LIB_C=1 \ | |
-D USEARCH_BUILD_TEST_CPP=0 \ | |
-D USEARCH_BUILD_BENCH_CPP=0 | |
cmake --build build_artifacts --config RelWithDebInfo | |
# We can't run the produced builds, but we can make sure they exist | |
- name: Test artifacts presense | |
run: | | |
test -e build_artifacts/libusearch_c.so | |
# Rust | |
- name: Set up Rust | |
run: | | |
rustup update stable | |
rustup default stable | |
rustup target add ${{ matrix.target }} | |
rustc -vV | |
- name: Set up Rust Env | |
run: | | |
TOOLCHAIN=${ANDROID_HOME}/ndk/${{ env.ANDROID_NDK_VERSION }}/toolchains/llvm/prebuilt/linux-x86_64/bin/ | |
NDK_CLANG=$(find ${TOOLCHAIN} -name "${{ matrix.processor }}*${{ env.ANDROID_SDK_VERSION }}-clang") | |
echo "CC_${{ matrix.target }}=${NDK_CLANG}" >> ${GITHUB_ENV} | |
echo "CXX_${{ matrix.target }}=${NDK_CLANG}++" >> ${GITHUB_ENV} | |
echo "AR_${{ matrix.target }}=${TOOLCHAIN}/llvm-ar" >> ${GITHUB_ENV} | |
echo "CARGO_${{ matrix.target }}=${NDK_CLANG}" >> ${GITHUB_ENV} | |
echo "CARGO_${{ matrix.target }}=${TOOLCHAIN}/llvm-ar" >> ${GITHUB_ENV} | |
- name: Build Rust | |
run: | | |
cargo build --target ${{ matrix.target }} |