Skip to content

Merge branch 'main-dev' of https://github.com/unum-cloud/usearch into… #867

Merge branch 'main-dev' of https://github.com/unum-cloud/usearch into…

Merge branch 'main-dev' of https://github.com/unum-cloud/usearch into… #867

Workflow file for this run

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
# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages
permissions:
contents: read
jobs:
test_ubuntu_gcc:
name: Ubuntu (GCC 12)
runs-on: ubuntu-22.04
env:
CC: gcc-12
CXX: g++-12
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 -DCMAKE_BUILD_TYPE=RelWithDebInfo -DUSEARCH_BUILD_TEST_CPP=1 -DUSEARCH_BUILD_TEST_C=1 -DUSEARCH_BUILD_LIB_C=1 -DUSEARCH_BUILD_SQLITE=1 -DUSEARCH_USE_OPENMP=1 -DUSEARCH_USE_SIMSIMD=1 -DUSEARCH_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: Test Rust
uses: actions-rs/toolchain@v1
with:
toolchain: stable
override: true
# 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 16)
runs-on: ubuntu-22.04
env:
CC: clang-16
CXX: clang++-16
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
wget https://apt.llvm.org/llvm.sh
chmod +x llvm.sh
sudo ./llvm.sh 16
cmake -B build_artifacts -DCMAKE_BUILD_TYPE=RelWithDebInfo -DUSEARCH_BUILD_TEST_CPP=1 -DUSEARCH_BUILD_TEST_C=1 -DUSEARCH_BUILD_LIB_C=1 -DUSEARCH_BUILD_SQLITE=1 -DUSEARCH_USE_OPENMP=0 -DUSEARCH_USE_SIMSIMD=1 -DUSEARCH_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 .
- name: Test Python
run: pytest
# 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-12
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 -DCMAKE_BUILD_TYPE=RelWithDebInfo -DUSEARCH_BUILD_TEST_CPP=1 -DUSEARCH_BUILD_TEST_C=1 -DUSEARCH_BUILD_LIB_C=1 -DUSEARCH_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 .
- name: Test Python
run: pytest
# ObjC/Swift
- name: Build ObjC/Swift
run: swift build
- name: Test ObjC/Swift
run: swift 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-x64/native"
cp "${{ github.workspace }}/build_artifacts/libusearch_c.dylib" "${{ github.workspace }}/csharp/lib/runtimes/osx-x64/native"
dotnet test -c Debug --logger "console;verbosity=detailed" --filter "FullyQualifiedName!=Cloud.Unum.USearch.Tests.UsearchIndexTests.PersistAndRestore"
shell: bash
working-directory: ${{ github.workspace }}/csharp
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 -DCMAKE_BUILD_TYPE=RelWithDebInfo -DUSEARCH_BUILD_TEST_CPP=1 -DUSEARCH_BUILD_TEST_C=1 -DUSEARCH_BUILD_LIB_C=1 -DUSEARCH_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
# 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 \
-DCMAKE_BUILD_TYPE=RelWithDebInfo \
-DCMAKE_EXPORT_COMPILE_COMMANDS=1 \
-DCMAKE_C_COMPILER_TARGET=${{ matrix.target }} \
-DCMAKE_CXX_COMPILER_TARGET=${{ matrix.target }} \
-DCMAKE_SYSTEM_NAME=Linux \
-DCMAKE_SYSTEM_PROCESSOR=${{ matrix.arch }} \
-DUSEARCH_BUILD_LIB_C=1 \
-DUSEARCH_BUILD_SQLITE=1 \
-DUSEARCH_BUILD_TEST_CPP=0 \
-DUSEARCH_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