Skip to content

Commit 2079ced

Browse files
committed
ci: split RISC-V build and test into separate jobs
Signed-off-by: ihb2032 <hebome@foxmail.com>
1 parent 7145e48 commit 2079ced

3 files changed

Lines changed: 216 additions & 35 deletions

File tree

.github/workflows/01-ci-pipeline.yml

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -87,10 +87,7 @@ jobs:
8787
build-and-test-linux-riscv64:
8888
name: Build & Test (linux-riscv64)
8989
needs: lint
90-
uses: ./.github/workflows/03-macos-linux-build.yml
91-
with:
92-
platform: linux-riscv64
93-
os: ubuntu-24.04-riscv
90+
uses: ./.github/workflows/07-linux-riscv-build.yml
9491

9592
build-android:
9693
name: Build & Test (android)

.github/workflows/03-macos-linux-build.yml

Lines changed: 12 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -40,27 +40,12 @@ jobs:
4040
submodules: recursive
4141

4242
- name: Set up Python
43-
if: ${{ !contains(inputs.os, 'riscv') }}
4443
uses: actions/setup-python@v6
4544
with:
4645
python-version: '3.10'
4746
cache: 'pip'
4847
cache-dependency-path: 'pyproject.toml'
4948

50-
- name: Select Python on RISC-V
51-
if: ${{ contains(inputs.os, 'riscv') }}
52-
run: |
53-
python3.10 --version
54-
echo "PYTHON=python3.10" >> $GITHUB_ENV
55-
shell: bash
56-
57-
- name: Select Python on non-RISC-V
58-
if: ${{ !contains(inputs.os, 'riscv') }}
59-
run: |
60-
python --version
61-
echo "PYTHON=python" >> $GITHUB_ENV
62-
shell: bash
63-
6449
- name: Install Clang
6550
if: inputs.compiler == 'clang' && runner.os == 'Linux'
6651
run: |
@@ -88,23 +73,19 @@ jobs:
8873
echo "CXX=clang++" >> $GITHUB_ENV
8974
fi
9075
91-
echo "$($PYTHON -c 'import site; print(site.USER_BASE)')/bin" >> $GITHUB_PATH
76+
echo "$(python -c 'import site; print(site.USER_BASE)')/bin" >> $GITHUB_PATH
9277
shell: bash
9378

9479
- name: Install dependencies
9580
run: |
96-
$PYTHON -m pip install --upgrade pip
97-
98-
if [[ "${{ inputs.os }}" == *"riscv"* ]]; then
99-
echo "RISC-V architecture detected. Installing pre-built NumPy, CMake and ninja from RISE..."
100-
RISE_PYPI="https://gitlab.com/api/v4/projects/56254198/packages/pypi/simple"
101-
$PYTHON -m pip install numpy==2.2.2 cmake==3.30.0 ninja==1.11.1.1 --index-url "$RISE_PYPI"
102-
DEPS="pybind11==3.0 pytest scikit-build-core setuptools_scm"
103-
else
104-
DEPS="pybind11==3.0 cmake==3.30.0 ninja==1.11.1 pytest scikit-build-core setuptools_scm"
105-
fi
106-
107-
$PYTHON -m pip install $DEPS
81+
python -m pip install --upgrade pip
82+
python -m pip install \
83+
pybind11==3.0 \
84+
cmake==3.30.0 \
85+
ninja==1.11.1 \
86+
pytest \
87+
scikit-build-core \
88+
setuptools_scm
10889
shell: bash
10990

11091
- name: Build from source
@@ -113,7 +94,7 @@ jobs:
11394
11495
CMAKE_GENERATOR="Unix Makefiles" \
11596
CMAKE_BUILD_PARALLEL_LEVEL="$NPROC" \
116-
$PYTHON -m pip install -v . \
97+
python -m pip install -v . \
11798
--no-build-isolation \
11899
--config-settings='cmake.define.BUILD_TOOLS="ON"' \
119100
${{ matrix.arch_flag }}
@@ -128,7 +109,7 @@ jobs:
128109
- name: Run Python Tests
129110
run: |
130111
cd "$GITHUB_WORKSPACE"
131-
$PYTHON -m pytest python/tests/
112+
python -m pytest python/tests/
132113
shell: bash
133114

134115
- name: Run C++ Examples
@@ -154,4 +135,4 @@ jobs:
154135
./c_api_field_schema_example
155136
./c_api_index_example
156137
./c_api_optimized_example
157-
shell: bash
138+
shell: bash
Lines changed: 203 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,203 @@
1+
name: Linux RISC-V Build
2+
3+
on:
4+
workflow_call:
5+
6+
permissions:
7+
contents: read
8+
9+
env:
10+
RISE_PYPI: https://gitlab.com/api/v4/projects/56254198/packages/pypi/simple
11+
12+
jobs:
13+
build:
14+
name: Build (linux-riscv64)
15+
runs-on: ubuntu-24.04-riscv
16+
17+
steps:
18+
- name: Checkout code
19+
uses: actions/checkout@v6
20+
with:
21+
submodules: recursive
22+
23+
- name: Install build dependencies
24+
run: |
25+
sudo apt-get update
26+
sudo apt-get install -y python3-pybind11 pybind11-dev
27+
shell: bash
28+
29+
- name: Build from source
30+
run: |
31+
cd "$GITHUB_WORKSPACE"
32+
NPROC=$(nproc 2>/dev/null || echo 2)
33+
echo "Using $NPROC parallel jobs for builds"
34+
cmake -S . -B build \
35+
-G "Unix Makefiles" \
36+
-DCMAKE_BUILD_TYPE=Release \
37+
-DBUILD_TOOLS=ON \
38+
-DBUILD_PYTHON_BINDINGS=ON
39+
make -C build -j"$NPROC"
40+
shell: bash
41+
42+
- name: Upload build artifacts
43+
uses: actions/upload-artifact@v4
44+
with:
45+
name: linux-riscv64-build
46+
path: build
47+
if-no-files-found: error
48+
compression-level: 0
49+
50+
cpp-tests:
51+
name: C++ Tests (linux-riscv64)
52+
runs-on: ubuntu-24.04-riscv
53+
needs: build
54+
55+
steps:
56+
- name: Checkout code
57+
uses: actions/checkout@v6
58+
with:
59+
submodules: recursive
60+
61+
- name: Set up environment variables
62+
run: |
63+
NPROC=$(nproc 2>/dev/null || echo 2)
64+
echo "NPROC=$NPROC" >> "$GITHUB_ENV"
65+
shell: bash
66+
67+
- name: Download build artifacts
68+
uses: actions/download-artifact@v4
69+
with:
70+
name: linux-riscv64-build
71+
path: build
72+
73+
- name: Run C++ Tests
74+
run: |
75+
cd "$GITHUB_WORKSPACE/build"
76+
make unittest -j"$NPROC"
77+
shell: bash
78+
79+
python-tests:
80+
name: Python Tests (linux-riscv64)
81+
runs-on: ubuntu-24.04-riscv
82+
needs: build
83+
84+
steps:
85+
- name: Checkout code
86+
uses: actions/checkout@v6
87+
with:
88+
submodules: recursive
89+
90+
- name: Select Python
91+
run: |
92+
python3.10 --version
93+
echo "PYTHON=python3.10" >> "$GITHUB_ENV"
94+
shell: bash
95+
96+
- name: Set up environment variables
97+
run: |
98+
NPROC=$(nproc 2>/dev/null || echo 2)
99+
echo "NPROC=$NPROC" >> "$GITHUB_ENV"
100+
echo "$($PYTHON -c 'import site; print(site.USER_BASE)')/bin" >> "$GITHUB_PATH"
101+
shell: bash
102+
103+
- name: Download build artifacts
104+
uses: actions/download-artifact@v4
105+
with:
106+
name: linux-riscv64-build
107+
path: build
108+
109+
- name: Install dependencies
110+
run: |
111+
$PYTHON -m pip install --upgrade pip
112+
$PYTHON -m pip install numpy==2.2.2 cmake==3.30.0 ninja==1.11.1.1 --index-url "$RISE_PYPI"
113+
$PYTHON -m pip install pybind11==3.0 pytest scikit-build-core setuptools_scm
114+
shell: bash
115+
116+
- name: Install from existing build directory
117+
run: |
118+
cd "$GITHUB_WORKSPACE"
119+
120+
export SKBUILD_BUILD_DIR="$GITHUB_WORKSPACE/build"
121+
CMAKE_GENERATOR="Unix Makefiles" \
122+
CMAKE_BUILD_PARALLEL_LEVEL="$NPROC" \
123+
$PYTHON -m pip install -v . \
124+
--no-build-isolation \
125+
--config-settings='cmake.define.BUILD_TOOLS="ON"'
126+
shell: bash
127+
128+
- name: Run Python Tests
129+
run: |
130+
cd "$GITHUB_WORKSPACE"
131+
$PYTHON -m pytest python/tests/
132+
shell: bash
133+
134+
cpp-examples:
135+
name: C++ Examples (linux-riscv64)
136+
runs-on: ubuntu-24.04-riscv
137+
needs: build
138+
139+
steps:
140+
- name: Checkout code
141+
uses: actions/checkout@v6
142+
with:
143+
submodules: recursive
144+
145+
- name: Set up environment variables
146+
run: |
147+
NPROC=$(nproc 2>/dev/null || echo 2)
148+
echo "NPROC=$NPROC" >> "$GITHUB_ENV"
149+
shell: bash
150+
151+
- name: Download build artifacts
152+
uses: actions/download-artifact@v4
153+
with:
154+
name: linux-riscv64-build
155+
path: build
156+
157+
- name: Run C++ Examples
158+
run: |
159+
cd "$GITHUB_WORKSPACE/examples/c++"
160+
mkdir build && cd build
161+
cmake .. -DCMAKE_BUILD_TYPE=Release
162+
make -j "$NPROC"
163+
./db-example
164+
./core-example
165+
./ailego-example
166+
shell: bash
167+
168+
c-examples:
169+
name: C Examples (linux-riscv64)
170+
runs-on: ubuntu-24.04-riscv
171+
needs: build
172+
173+
steps:
174+
- name: Checkout code
175+
uses: actions/checkout@v6
176+
with:
177+
submodules: recursive
178+
179+
- name: Set up environment variables
180+
run: |
181+
NPROC=$(nproc 2>/dev/null || echo 2)
182+
echo "NPROC=$NPROC" >> "$GITHUB_ENV"
183+
shell: bash
184+
185+
- name: Download build artifacts
186+
uses: actions/download-artifact@v4
187+
with:
188+
name: linux-riscv64-build
189+
path: build
190+
191+
- name: Run C Examples
192+
run: |
193+
cd "$GITHUB_WORKSPACE/examples/c"
194+
mkdir build && cd build
195+
cmake .. -DCMAKE_BUILD_TYPE=Release
196+
make -j "$NPROC"
197+
./c_api_basic_example
198+
./c_api_collection_schema_example
199+
./c_api_doc_example
200+
./c_api_field_schema_example
201+
./c_api_index_example
202+
./c_api_optimized_example
203+
shell: bash

0 commit comments

Comments
 (0)