kiddo 6.0.2

A high-performance, flexible, ergonomic k-d tree library. Ideal for geo- and astro- nearest-neighbour and k-nearest-neighbor queries
Documentation
name: CI / Stable

on:
  push:
    branches:
      - master
      - v5.x.x
  # Pull requests reach these jobs through `PR Mergeable`, which aggregates every
  # required check into a single status. Triggering here as well would double every
  # run and leave two competing statuses on the PR.
  workflow_call:
  workflow_dispatch:

concurrency:
  # Literal prefix, not `github.workflow`: under `workflow_call` that expands to the
  # calling workflow's name, so every called workflow would share one group and
  # deadlock against its caller.
  group: ci-stable-${{ github.ref }}
  cancel-in-progress: true

permissions:
  contents: read

env:
  LATEST_STABLE_RUST_VERSION: "TBD"

jobs:
  lint-stable:
    name: Lint (Stable)
    runs-on: ubuntu-latest

    steps:
      - uses: actions/checkout@v7
        with:
          show-progress: false

      - name: Get latest stable Rust version
        run: |
          echo "LATEST_STABLE_RUST_VERSION=$(gh api /repos/rust-lang/rust/releases --jq ".[0].tag_name")" >> "$GITHUB_ENV"
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

      - name: Cache Toolchain
        uses: actions/cache@v6
        with:
          path: ~/.rustup
          key: toolchain-x86-64-${{ env.LATEST_STABLE_RUST_VERSION }}

      - name: Install `stable` Toolchain
        uses: actions-rust-lang/setup-rust-toolchain@v1
        with:
          components: rustfmt, clippy

      - name: Prepare example artifacts
        run: bash .github/scripts/prepare-example-artifacts.sh

      - name: Run Clippy
        run: cargo clippy --features=serde,rkyv_08,test_utils --no-deps

      - name: Install cpp_competitors system dependencies
        # benches/profile_cpp_competitors.rs is gated behind the cpp_competitors
        # feature, which cargo-hack's --each-feature sweep below checks in
        # isolation. Its build script (build_cpp_competitors.rs) vendors and
        # compiles nanoflann/ALGLIB/Pkd-tree itself, but skd-tree's shim links
        # against three system packages it deliberately does not vendor.
        run: sudo apt-get update && sudo apt-get install -y --no-install-recommends libboost-dev libarmadillo-dev libensmallen-dev

      - name: Install cargo-hack
        uses: baptiste0928/cargo-install@v3
        with:
          crate: cargo-hack
          version: "^0.6"

      - name: Cargo Hack (check all stable targets and features)
        run: cargo hack check --workspace --each-feature --all-targets --exclude-features simd

      # `--all-targets` unifies features via the dev-dependency on kiddo itself,
      # which re-enables `fixed` and `multi-threaded`. Check the lib alone so
      # optional dependencies and serial fallback paths stay covered.
      - name: Check minimal feature combinations
        run: |
          cargo check --lib --no-default-features
          cargo check --lib --no-default-features --features=fixed
          cargo check --lib --no-default-features --features=serde

          normal_dependencies=$(cargo tree --edges=normal --no-default-features --features=serde --prefix=none)
          if grep -Eq '^(fixed|test-log) v' <<< "$normal_dependencies"; then
            echo "fixed and test-log must not be normal dependencies without the fixed feature" >&2
            exit 1
          fi

  test-stable:
    name: Test (Stable)
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v7
        with:
          show-progress: false

      - name: Get latest stable Rust version
        run: |
          echo "LATEST_STABLE_RUST_VERSION=$(gh api /repos/rust-lang/rust/releases --jq ".[0].tag_name")" >> "$GITHUB_ENV"
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

      - name: Cache Toolchain
        uses: actions/cache@v6
        with:
          path: ~/.rustup
          key: toolchain-x86-64-${{ env.LATEST_STABLE_RUST_VERSION }}

      - name: Install `stable` Toolchain
        uses: actions-rust-lang/setup-rust-toolchain@v1
        with:
          components: rustfmt, clippy

      - name: Prepare example artifacts
        run: bash .github/scripts/prepare-example-artifacts.sh

      - name: Install cargo-nextest
        uses: taiki-e/install-action@nextest

      - name: Cargo nextest
        run: |
          cargo nextest run --workspace --features=serde,rkyv_08,test_utils

      - name: Cargo test (Doctests)
        run: |
          cargo test --workspace --doc --features=serde,rkyv_08,test_utils