Skip to content

Index serialization backward compatibility test #1

Index serialization backward compatibility test

Index serialization backward compatibility test #1

name: Cross-Build File I/O Test
on:
workflow_call:
pull_request:
paths:
- '.github/workflows/cross-build-file-io.yml'
- 'tests/cross_build_io/**'
env:
OMP_NUM_THREADS: '10'
MKL_THREADING_LAYER: GNU
jobs:
# Scenario 1: CMake writes files, then Conda reads them
cmake-write-conda-read:
name: CMake Write -> Conda Read
runs-on: ubuntu-latest
env:
# run_id does not change if we re-run the job, so this is safe for
# the partway-failure-rerun scenario.
SHARED_DATA_DIR: /tmp/faiss-cross-build-${{ github.run_id }}-cmake-write
steps:
- name: Checkout
uses: actions/checkout@v4
# Step 1: Build with CMake and write files
- name: Build with CMake
uses: ./.github/actions/build_cmake
- name: Create shared data directory
shell: bash
run: |
mkdir -p ${{ env.SHARED_DATA_DIR }}
chmod 777 ${{ env.SHARED_DATA_DIR }}
- name: Run CMake writer (write Faiss index and metadata)
shell: bash
run: |
eval "$(conda shell.bash hook)"
conda activate
$CONDA/bin/python tests/cross_build_io/cmake_writer.py ${{ env.SHARED_DATA_DIR }}
- name: Verify files were written
shell: bash
run: |
echo "Files created by CMake build:"
ls -lh ${{ env.SHARED_DATA_DIR }}
# Step 2: Build with Conda and read files
- name: Clean build artifacts
shell: bash
run: |
# Remove cmake build to ensure we're using conda build
rm -rf build
- name: Build with Conda
uses: ./.github/actions/build_conda
- name: Install Conda-built Faiss package
shell: bash
run: |
eval "$(conda shell.bash hook)"
conda activate
# Find and install the built package
CONDA_PKG=$(find $CONDA/conda-bld -name "faiss-*.tar.bz2" | head -1)
if [ -n "$CONDA_PKG" ]; then
conda install -y "$CONDA_PKG"
else
echo "Warning: Could not find conda package, using existing installation"
fi
- name: Run Conda reader (read Faiss index and verify)
shell: bash
run: |
eval "$(conda shell.bash hook)"
conda activate
$CONDA/bin/python tests/cross_build_io/conda_reader.py ${{ env.SHARED_DATA_DIR }}
- name: Upload artifacts from cmake->conda test
if: always()
uses: actions/upload-artifact@v4
with:
name: cmake-write-conda-read-data
path: ${{ env.SHARED_DATA_DIR }}
# Scenario 2: Conda writes files, then CMake reads them
conda-write-cmake-read:
name: Conda Write -> CMake Read
runs-on: ubuntu-latest
env:
SHARED_DATA_DIR: /tmp/faiss-cross-build-${{ github.run_id }}-conda-write
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
fetch-tags: true
# Step 1: Build with Conda and write files
- name: Build with Conda
uses: ./.github/actions/build_conda
- name: Create shared data directory
shell: bash
run: |
mkdir -p ${{ env.SHARED_DATA_DIR }}
chmod 777 ${{ env.SHARED_DATA_DIR }}
- name: Install Conda-built Faiss package
shell: bash
run: |
eval "$(conda shell.bash hook)"
conda activate
# Find and install the built package
CONDA_PKG=$(find $CONDA/conda-bld -name "faiss-*.tar.bz2" | head -1)
if [ -n "$CONDA_PKG" ]; then
conda install -y "$CONDA_PKG"
else
echo "Warning: Could not find conda package, using existing installation"
fi
- name: Run Conda writer (write Faiss index and metadata)
shell: bash
run: |
eval "$(conda shell.bash hook)"
conda activate
$CONDA/bin/python tests/cross_build_io/conda_writer.py ${{ env.SHARED_DATA_DIR }}
- name: Verify files were written
shell: bash
run: |
echo "Files created by Conda build:"
ls -lh ${{ env.SHARED_DATA_DIR }}
# Step 2: Build with CMake and read files
- name: Clean conda artifacts
shell: bash
run: |
# Uninstall conda-built faiss to avoid conflicts
eval "$(conda shell.bash hook)"
conda activate
conda uninstall -y faiss || true
- name: Build with CMake
uses: ./.github/actions/build_cmake
- name: Run CMake reader (read Faiss index and verify)
shell: bash
run: |
eval "$(conda shell.bash hook)"
conda activate
$CONDA/bin/python tests/cross_build_io/cmake_reader.py ${{ env.SHARED_DATA_DIR }}
- name: Upload artifacts from conda->cmake test
if: always()
uses: actions/upload-artifact@v4
with:
name: conda-write-cmake-read-data
path: ${{ env.SHARED_DATA_DIR }}