refactor(simd): restructure distance function code using namespaces t… #33
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: Build & Test | |
| on: | |
| push: | |
| branches: [ main, master ] | |
| pull_request: | |
| branches: [ main, master ] | |
| jobs: | |
| build: | |
| name: ${{ matrix.os }} ${{ matrix.arch }} | |
| runs-on: ${{ matrix.runner }} | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| include: | |
| - os: macos | |
| arch: x86_64 | |
| runner: macos-latest | |
| - os: macos | |
| arch: arm64 | |
| runner: macos-latest | |
| - os: ubuntu | |
| arch: x86_64 | |
| runner: ubuntu-latest | |
| - os: ubuntu | |
| arch: arm64 | |
| runner: ubuntu-latest | |
| # disable now | |
| # - os: windows | |
| # arch: x86_64 | |
| # runner: windows-latest | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Set up dependencies (Linux) | |
| if: matrix.os == 'ubuntu' | |
| run: | | |
| sudo apt-get update | |
| sudo apt-get install -y cmake g++ gcc python3 python3-pip python3-venv | |
| - name: Set up dependencies (macOS) | |
| if: matrix.os == 'macos' | |
| run: | | |
| brew update | |
| brew install cmake python libomp | |
| - name: Set up dependencies (Windows) | |
| if: matrix.os == 'windows' | |
| run: choco install cmake python --installargs 'ADD_CMAKE_TO_PATH=System' -y | |
| - name: Build (x86_64) | |
| if: matrix.arch == 'x86_64' | |
| run: | | |
| mkdir build | |
| cd build | |
| cmake .. | |
| cmake --build . --config Release | |
| - name: Build (arm64, cross-compile) | |
| if: matrix.arch == 'arm64' && matrix.os == 'ubuntu' | |
| run: | | |
| sudo apt-get update | |
| sudo apt-get install -y gcc-aarch64-linux-gnu g++-aarch64-linux-gnu | |
| mkdir build | |
| cd build | |
| cmake .. -DCMAKE_SYSTEM_NAME=Linux -DCMAKE_SYSTEM_PROCESSOR=aarch64 -DCMAKE_C_COMPILER=aarch64-linux-gnu-gcc -DCMAKE_CXX_COMPILER=aarch64-linux-gnu-g++ | |
| cmake --build . --config Release | |
| - name: Build (arm64, macOS) | |
| if: matrix.arch == 'arm64' && matrix.os == 'macos' | |
| run: | | |
| mkdir build | |
| cd build | |
| cmake .. -DCMAKE_OSX_ARCHITECTURES=arm64 | |
| cmake --build . --config Release | |
| - name: Run main test | |
| if: matrix.arch != 'arm64' || matrix.os != 'ubuntu' | |
| run: | | |
| bash test.sh | |
| # Python 绑定测试 | |
| - name: Set up Python venv | |
| run: | | |
| python3 -m venv venv | |
| source venv/bin/activate || source venv/Scripts/activate | |
| python -m pip install --upgrade pip setuptools wheel numpy pybind11 | |
| - name: Build and install Python bindings | |
| run: | | |
| source venv/bin/activate || source venv/Scripts/activate | |
| cd python_bindings | |
| pip install . | |
| - name: Run Python binding tests | |
| run: | | |
| source venv/bin/activate || source venv/Scripts/activate | |
| cd python_bindings | |
| # 假设有 tests 目录,且用 pytest | |
| # pip install pytest | |
| # pytest tests | |
| # 你可以在这里添加 C++ 测试步骤 | |
| # - name: Run C++ tests | |
| # run: | | |
| # cd build | |
| # ctest --output-on-failure |