|
| 1 | +################################################################################ |
| 2 | +# Licensed to the Apache Software Foundation (ASF) under one |
| 3 | +# or more contributor license agreements. See the NOTICE file |
| 4 | +# distributed with this work for additional information |
| 5 | +# regarding copyright ownership. The ASF licenses this file |
| 6 | +# to you under the Apache License, Version 2.0 (the |
| 7 | +# "License"); you may not use this file except in compliance |
| 8 | +# with the License. You may obtain a copy of the License at |
| 9 | +# |
| 10 | +# http://www.apache.org/licenses/LICENSE-2.0 |
| 11 | +# |
| 12 | +# Unless required by applicable law or agreed to in writing, software |
| 13 | +# distributed under the License is distributed on an "AS IS" BASIS, |
| 14 | +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 15 | +# See the License for the specific language governing permissions and |
| 16 | +# limitations under the License. |
| 17 | +################################################################################ |
| 18 | + |
| 19 | +name: Paimon Faiss Tests |
| 20 | + |
| 21 | +on: |
| 22 | + push: |
| 23 | + paths: |
| 24 | + - 'paimon-faiss/**' |
| 25 | + - 'paimon-faiss-jni/**' |
| 26 | + - '.github/workflows/utitcase-faiss.yml' |
| 27 | + pull_request: |
| 28 | + paths: |
| 29 | + - 'paimon-faiss/**' |
| 30 | + - 'paimon-faiss-jni/**' |
| 31 | + - '.github/workflows/utitcase-faiss.yml' |
| 32 | + |
| 33 | +env: |
| 34 | + JDK_VERSION: 8 |
| 35 | + MAVEN_OPTS: -Dmaven.wagon.httpconnectionManager.ttlSeconds=30 -Dmaven.wagon.http.retryHandler.requestSentEnabled=true |
| 36 | + |
| 37 | +concurrency: |
| 38 | + group: ${{ github.workflow }}-${{ github.event_name }}-${{ github.event.number || github.run_id }} |
| 39 | + cancel-in-progress: true |
| 40 | + |
| 41 | +jobs: |
| 42 | + build-native-and-test: |
| 43 | + runs-on: ubuntu-latest |
| 44 | + |
| 45 | + steps: |
| 46 | + - name: Checkout code |
| 47 | + uses: actions/checkout@v4 |
| 48 | + |
| 49 | + - name: Set up JDK ${{ env.JDK_VERSION }} |
| 50 | + uses: actions/setup-java@v4 |
| 51 | + with: |
| 52 | + java-version: ${{ env.JDK_VERSION }} |
| 53 | + distribution: 'temurin' |
| 54 | + |
| 55 | + - name: Install native dependencies |
| 56 | + run: | |
| 57 | + sudo apt-get update |
| 58 | + sudo apt-get install -y \ |
| 59 | + build-essential \ |
| 60 | + libopenblas-dev \ |
| 61 | + liblapack-dev \ |
| 62 | + patchelf \ |
| 63 | + libgomp1 \ |
| 64 | + wget |
| 65 | +
|
| 66 | + - name: Install GCC 9 |
| 67 | + run: | |
| 68 | + sudo apt-get install -y gcc-9 g++-9 |
| 69 | + sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-9 90 |
| 70 | + sudo update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-9 90 |
| 71 | + gcc --version |
| 72 | + g++ --version |
| 73 | + # Verify GCC version is >= 9.3.0 |
| 74 | + # Use -dumpfullversion for full version, fall back to -dumpversion |
| 75 | + GCC_VERSION=$(gcc -dumpfullversion 2>/dev/null || gcc -dumpversion) |
| 76 | + echo "GCC version: $GCC_VERSION" |
| 77 | + # Extract major version |
| 78 | + GCC_MAJOR=$(echo "$GCC_VERSION" | cut -d. -f1) |
| 79 | + if [[ "$GCC_MAJOR" -lt 9 ]]; then |
| 80 | + echo "ERROR: GCC major version must be >= 9, got $GCC_MAJOR" |
| 81 | + exit 1 |
| 82 | + fi |
| 83 | + echo "GCC version check passed: $GCC_VERSION (major: $GCC_MAJOR)" |
| 84 | +
|
| 85 | + - name: Install CMake 3.30.1 |
| 86 | + run: | |
| 87 | + CMAKE_VERSION="3.30.1" |
| 88 | + wget -q https://github.com/Kitware/CMake/releases/download/v${CMAKE_VERSION}/cmake-${CMAKE_VERSION}-linux-x86_64.tar.gz |
| 89 | + tar -xzf cmake-${CMAKE_VERSION}-linux-x86_64.tar.gz |
| 90 | + sudo mv cmake-${CMAKE_VERSION}-linux-x86_64 /opt/cmake |
| 91 | + sudo ln -sf /opt/cmake/bin/cmake /usr/local/bin/cmake |
| 92 | + sudo ln -sf /opt/cmake/bin/ctest /usr/local/bin/ctest |
| 93 | + sudo ln -sf /opt/cmake/bin/cpack /usr/local/bin/cpack |
| 94 | + cmake --version |
| 95 | + # Verify CMake version |
| 96 | + CMAKE_INSTALLED=$(cmake --version | head -n1 | awk '{print $3}') |
| 97 | + echo "CMake version: $CMAKE_INSTALLED" |
| 98 | + if [[ "$(printf '%s\n' "3.30.1" "$CMAKE_INSTALLED" | sort -V | head -n1)" != "3.30.1" ]]; then |
| 99 | + echo "ERROR: CMake version must be >= 3.30.1, got $CMAKE_INSTALLED" |
| 100 | + exit 1 |
| 101 | + fi |
| 102 | +
|
| 103 | + - name: Install FAISS |
| 104 | + run: | |
| 105 | + # Clone and build FAISS |
| 106 | + git clone --depth 1 --branch v1.7.4 https://github.com/facebookresearch/faiss.git /tmp/faiss |
| 107 | + cd /tmp/faiss |
| 108 | + cmake -B build \ |
| 109 | + -DFAISS_ENABLE_GPU=OFF \ |
| 110 | + -DFAISS_ENABLE_PYTHON=OFF \ |
| 111 | + -DBUILD_TESTING=OFF \ |
| 112 | + -DCMAKE_BUILD_TYPE=Release |
| 113 | + cmake --build build -j $(nproc) |
| 114 | + sudo cmake --install build |
| 115 | +
|
| 116 | + - name: Build native library |
| 117 | + run: | |
| 118 | + cd paimon-faiss-jni |
| 119 | + ./scripts/build-native.sh --clean --fat-lib |
| 120 | +
|
| 121 | + - name: List bundled libraries |
| 122 | + run: | |
| 123 | + echo "=== Bundled libraries ===" |
| 124 | + ls -la paimon-faiss-jni/src/main/resources/linux/amd64/ |
| 125 | + echo "" |
| 126 | + echo "=== Library dependencies ===" |
| 127 | + ldd paimon-faiss-jni/src/main/resources/linux/amd64/libpaimon_faiss_jni.so || true |
| 128 | +
|
| 129 | + - name: Build paimon-faiss-jni |
| 130 | + run: | |
| 131 | + mvn -B clean install -pl paimon-faiss-jni -am -DskipTests -Ppaimon-faiss |
| 132 | +
|
| 133 | + - name: Test paimon-faiss-jni |
| 134 | + timeout-minutes: 10 |
| 135 | + run: | |
| 136 | + mvn -B test -pl paimon-faiss-jni -DskipFaissTests=false -Ppaimon-faiss |
| 137 | + env: |
| 138 | + MAVEN_OPTS: -Xmx2048m |
| 139 | + |
| 140 | + - name: Build paimon-faiss |
| 141 | + run: | |
| 142 | + mvn -B clean install -pl paimon-faiss -am -DskipTests -Ppaimon-faiss |
| 143 | +
|
| 144 | + - name: Test paimon-faiss |
| 145 | + timeout-minutes: 30 |
| 146 | + run: | |
| 147 | + mvn -B test -pl paimon-faiss -Ppaimon-faiss |
| 148 | + env: |
| 149 | + MAVEN_OPTS: -Xmx4096m |
| 150 | + |
| 151 | + - name: Upload native library artifact |
| 152 | + uses: actions/upload-artifact@v4 |
| 153 | + if: always() |
| 154 | + with: |
| 155 | + name: native-libraries-linux-amd64 |
| 156 | + path: paimon-faiss-jni/src/main/resources/linux/amd64/ |
| 157 | + retention-days: 7 |
| 158 | + |
0 commit comments