tarzi 0.2.2

Rust-native lite search for AI applications
Documentation
name: Rust CI

on:
  push:
    branches: [ main ]
  pull_request:
    branches: [ main ]

env:
  CARGO_TERM_COLOR: always

jobs:
  test:
    name: Test on ${{ matrix.os }}
    runs-on: ${{ matrix.os }}
    strategy:
      matrix:
        os: [ubuntu-latest, macos-latest]
        python-version: ['3.10']
    steps:
    - uses: actions/checkout@v4

    - name: Set up Python ${{ matrix.python-version }}
      uses: actions/setup-python@v5
      with:
        python-version: ${{ matrix.python-version }}

    - name: Set up Python environment for PyO3
      run: |
        python${{ matrix.python-version }} --version
        PYTHON_BIN=$(which python${{ matrix.python-version }})
        echo "Found Python at: $PYTHON_BIN"
        PYTHON_LIBDIR=$($PYTHON_BIN -c "import sysconfig; print(sysconfig.get_config_var('LIBDIR') or sysconfig.get_path('stdlib'))")
        echo "Python lib dir: $PYTHON_LIBDIR"
        echo "PYO3_PYTHON=$PYTHON_BIN" >> $GITHUB_ENV
        echo "PYTHON_LIBDIR=$PYTHON_LIBDIR" >> $GITHUB_ENV

    - name: Install system dependencies (Linux)
      if: runner.os == 'Linux'
      run: |
        sudo apt-get update
        sudo apt-get install -y libssl-dev pkg-config
        
    - name: Install system dependencies (macOS)
      if: runner.os == 'macOS'
      run: |
        brew install openssl pkg-config

    - name: Install Rust toolchain
      uses: dtolnay/rust-toolchain@stable
      with:
        toolchain: stable

    - name: Cache dependencies
      uses: actions/cache@v4
      with:
        path: |
          ~/.cargo/registry
          ~/.cargo/git
          target
        key: ${{ runner.os }}-cargo-${{ hashFiles('Cargo.lock') }}
        restore-keys: |
          ${{ runner.os }}-cargo-

    - name: Run unit tests
      run: RUSTFLAGS="-L$PYTHON_LIBDIR -lpython${{ matrix.python-version }}" cargo test --lib --all-features

    - name: Run doctests
      run: RUSTFLAGS="-L$PYTHON_LIBDIR -lpython${{ matrix.python-version }}" cargo test --doc --all-features

  build:
    name: Build Release on ${{ matrix.os }}
    runs-on: ${{ matrix.os }}
    needs: [test]
    strategy:
      matrix:
        os: [ubuntu-latest, macos-latest]
        python-version: ['3.10']
    steps:
    - uses: actions/checkout@v4

    - name: Set up Python ${{ matrix.python-version }}
      uses: actions/setup-python@v5
      with:
        python-version: ${{ matrix.python-version }}

    - name: Required environment variables for PyO3
      run: |
        python${{ matrix.python-version }} --version
        PYTHON_BIN=$(which python${{ matrix.python-version }})
        echo "Found Python at: $PYTHON_BIN"
        PYTHON_LIBDIR=$($PYTHON_BIN -c "import sysconfig; print(sysconfig.get_config_var('LIBDIR') or sysconfig.get_path('stdlib'))")
        echo "Python lib dir: $PYTHON_LIBDIR"
        echo "PYO3_PYTHON=$PYTHON_BIN" >> $GITHUB_ENV
        echo "PYTHON_LIBDIR=$PYTHON_LIBDIR" >> $GITHUB_ENV

    - name: Install system dependencies (Linux)
      if: runner.os == 'Linux'
      run: |
        sudo apt-get update
        sudo apt-get install -y libssl-dev pkg-config
        
    - name: Install system dependencies (macOS)
      if: runner.os == 'macOS'
      run: |
        brew install openssl pkg-config

    - name: Install Rust toolchain
      uses: dtolnay/rust-toolchain@stable
      with:
        toolchain: stable

    - name: Cache dependencies
      uses: actions/cache@v4
      with:
        path: |
          ~/.cargo/registry
          ~/.cargo/git
          target
        key: ${{ runner.os }}-cargo-${{ hashFiles('Cargo.lock') }}
        restore-keys: |
          ${{ runner.os }}-cargo-

    - name: Build release binary
      run: RUSTFLAGS="-L$PYTHON_LIBDIR -lpython${{ matrix.python-version }}" cargo build --release --all-features

    - name: Build with Python bindings
      run: RUSTFLAGS="-L$PYTHON_LIBDIR -lpython${{ matrix.python-version }}" cargo build --release --features pyo3

    - name: Test binary works
      run: ./target/release/tarzi --version

    - name: Upload binary artifact
      uses: actions/upload-artifact@v4
      with:
        name: tarzi-binary-${{ runner.os }}
        path: target/release/tarzi