Support error handling without exceptions #428
Workflow file for this run
This file contains hidden or 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: HNSW CI | |
on: [push, pull_request] | |
jobs: | |
python: | |
runs-on: ${{ matrix.os }} | |
strategy: | |
matrix: | |
os: [ubuntu-latest, windows-latest, macos-latest] | |
python-version: ["3.9", "3.10", "3.11", "3.12", "3.13"] | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: actions/setup-python@v5 | |
with: | |
python-version: ${{ matrix.python-version }} | |
- name: Build and install | |
run: python -m pip install . | |
- name: Test examples | |
timeout-minutes: 15 | |
run: | | |
# Run example files directly | |
for example in examples/python/example*.py; do | |
echo "Running example: $example" | |
python "$example" | |
echo "---------------------------------------" | |
done | |
shell: bash | |
- name: Test bindings | |
timeout-minutes: 15 | |
run: | | |
# Run the unittest tests | |
python -m unittest discover -v --start-directory tests/python --pattern "bindings_test*.py" | |
shell: bash | |
cpp: | |
runs-on: ${{ matrix.os }} | |
strategy: | |
matrix: | |
os: [ubuntu-latest, windows-latest, macos-latest] | |
sanitizer: [no_sanitizers, asan_ubsan] | |
exceptions: [no_exceptions, with_exceptions] | |
compiler: [clang, gcc, msvc] | |
exclude: | |
# No sanitizers on Windows | |
- os: windows-latest | |
sanitizer: asan_ubsan | |
# No sanitizers on macOS -- might not be well supported on arm64 | |
- os: macos-latest | |
sanitizer: asan_ubsan | |
# No clang or gcc on Windows | |
- os: windows-latest | |
compiler: clang | |
- os: windows-latest | |
compiler: gcc | |
# No MSVC on Unix | |
- os: ubuntu-latest | |
compiler: msvc | |
- os: macos-latest | |
compiler: msvc | |
# No GCC on macOS | |
- os: macos-latest | |
compiler: gcc | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: actions/setup-python@v5 | |
with: | |
python-version: "3.11" | |
- name: Build | |
run: | | |
mkdir build | |
cd build | |
cmake_cmd=( cmake -S .. -B . ) | |
if [[ "${RUNNER_OS}" != "Windows" ]]; then | |
c_compiler="${{matrix.compiler}}" | |
if [[ "${c_compiler}" == "gcc" ]]; then | |
cxx_compiler=g++ | |
elif [[ "${c_compiler}" == "clang" ]]; then | |
cxx_compiler=clang++ | |
else | |
echo "Invalid compiler ${c_compiler} for OS ${RUNNER_OS}" >&2 | |
exit 1 | |
fi | |
cmake_cmd+=( | |
-DCMAKE_BUILD_TYPE=Debug | |
-DCMAKE_C_COMPILER=${c_compiler} | |
-DCMAKE_CXX_COMPILER=${cxx_compiler} | |
) | |
fi | |
if [[ "${{ matrix.sanitizer }}" == "asan_ubsan" ]]; then | |
cmake_cmd+=( -DENABLE_ASAN=ON -DENABLE_UBSAN=ON ) | |
fi | |
if [[ "${{ matrix.exceptions }}" == "with_exceptions" ]]; then | |
cmake_cmd+=( -DHNSWLIB_ENABLE_EXCEPTIONS=ON ) | |
else | |
cmake_cmd+=( -DHNSWLIB_ENABLE_EXCEPTIONS=OFF ) | |
fi | |
if [[ "${RUNNER_OS}" != "Windows" ]]; then | |
cmake_cmd+=( -G Ninja ) | |
fi | |
"${cmake_cmd[@]}" | |
if [[ "${RUNNER_OS}" == "Windows" ]]; then | |
cmake --build ./ --config Debug --verbose | |
else | |
ninja -v | |
fi | |
shell: bash | |
- name: Prepare test data | |
run: | | |
pip install numpy | |
cd tests/cpp/ | |
python update_gen_data.py | |
shell: bash | |
- name: Test | |
# Without sanitizers, 15 minutes might be sufficient. | |
timeout-minutes: 30 | |
run: | | |
cd build | |
if [ "$RUNNER_OS" == "Windows" ]; then | |
cp "./Debug/"* ./ | |
fi | |
ctest --build-config Debug | |
# These tests could be ctest-enabled in CMakeLists.txt, but that | |
# requires auto-generating test data and installing numpy for that. | |
./test_updates | |
./test_updates update | |
shell: bash |