feat(ci): macos ci with github-runner (#94)

This commit is contained in:
Cuiys
2026-02-13 14:41:57 +08:00
committed by GitHub
parent 729d8d5904
commit e60ae09e5a
6 changed files with 118 additions and 69 deletions
+1 -1
View File
@@ -101,4 +101,4 @@ jobs:
pip install --index-url https://test.pypi.org/simple/ zvec
# Run a simple smoke test
python -c "import zvec; print('Import OK:', zvec.__version__)"
shell: bash
shell: bash
+14 -5
View File
@@ -71,7 +71,16 @@ jobs:
- name: Install dependencies
run: |
${{ env.PIP_BIN }} install --upgrade pip ruff==v0.14.4 clang-format==18.1.8 pybind11==3.0 pytest pytest-cov
${{ env.PIP_BIN }} install --upgrade pip \
ruff==v0.14.4 \
clang-format==18.1.8 \
pybind11==3.0 \
cmake==3.30.0 \
ninja==1.11.1 \
pytest \
pytest-cov \
scikit-build-core \
setuptools_scm
shell: bash
- name: Run Ruff Linter
@@ -112,11 +121,11 @@ jobs:
cd "$CLEAN_WORKSPACE"
NPROC=$(nproc 2>/dev/null || getconf _NPROCESSORS_ONLN 2>/dev/null || echo 2)
${{ env.PIP_BIN }} install cmake ninja
CMAKE_GENERATOR="Unix Makefiles" \
CMAKE_BUILD_PARALLEL_LEVEL="$NPROC" \
${{ env.PIP_BIN }} install -v . --config-settings='cmake.define.BUILD_TOOLS="ON"'
${{ env.PIP_BIN }} install -v . \
--no-build-isolation \
--config-settings='cmake.define.BUILD_TOOLS="ON"'
shell: bash
- name: Run Python Tests with Coverage
@@ -136,4 +145,4 @@ jobs:
cd "$CLEAN_WORKSPACE/examples/c++"
mkdir build && cd build && cmake .. -DCMAKE_BUILD_TYPE=Release
make -j $(nproc) && ./db-example && ./core-example && ./ailego-example
shell: bash
shell: bash
+28 -14
View File
@@ -46,6 +46,28 @@ jobs:
echo "PIP_BIN=$PY_PATH/bin/pip" >> $GITHUB_ENV
echo "CLANG_FORMATTER_BIN=$PY_PATH/bin/clang-format" >> $GITHUB_ENV
$PY_PATH/bin/python --version
# Set number of processors for parallel builds
NPROC=$(nproc 2>/dev/null || getconf _NPROCESSORS_ONLN 2>/dev/null || echo 2)
echo "NPROC=$NPROC" >> $GITHUB_ENV
echo "Using $NPROC parallel jobs for builds"
# Add Python user base bin to PATH for pip-installed CLI tools
echo "$(python -c 'import site; print(site.USER_BASE)')/bin" >> $GITHUB_PATH
shell: bash
- name: Install dependencies
run: |
${{ env.PYTHON_BIN }} -m pip install --upgrade pip \
ruff==v0.14.4 \
clang-format==18.1.8 \
pybind11==3.0 \
cmake==3.30.0 \
ninja==1.11.1 \
pytest \
pytest-cov \
scikit-build-core \
setuptools_scm
shell: bash
- name: Prepare clean build directory
@@ -69,11 +91,6 @@ jobs:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
shell: bash
- name: Install dependencies
run: |
${{ env.PIP_BIN }} install --upgrade pip ruff==v0.14.4 clang-format==18.1.8 pybind11==3.0 pytest pytest-cov
shell: bash
- name: Run Ruff Linter
run: |
cd "$CLEAN_WORKSPACE"
@@ -90,7 +107,6 @@ jobs:
run: |
cd "$CLEAN_WORKSPACE"
CPP_FILES=$(find . -type f \( -name "*.cpp" -o -name "*.h" -o -name "*.hpp" -o -name "*.cc" -o -name "*.cxx" \) \
! -path "./build/*" \
! -path "./tests/*" \
@@ -110,13 +126,11 @@ jobs:
- name: Install Python dependencies and build package
run: |
cd "$CLEAN_WORKSPACE"
NPROC=$(nproc 2>/dev/null || getconf _NPROCESSORS_ONLN 2>/dev/null || echo 2)
${{ env.PIP_BIN }} install cmake ninja
CMAKE_GENERATOR="Unix Makefiles" \
CMAKE_BUILD_PARALLEL_LEVEL="$NPROC" \
${{ env.PIP_BIN }} install -v . --config-settings='cmake.define.BUILD_TOOLS="ON"'
${{ env.PYTHON_BIN }} -m pip install -v . \
--no-build-isolation \
--config-settings='cmake.define.BUILD_TOOLS="ON"'
shell: bash
- name: Run Python Tests with Coverage
@@ -128,12 +142,12 @@ jobs:
- name: Run Cpp Tests
run: |
cd "$CLEAN_WORKSPACE/build"
make unittest -j$(nproc)
make unittest -j$NPROC
shell: bash
- name: Run Cpp Examples
run: |
cd "$CLEAN_WORKSPACE/examples/c++"
mkdir build && cd build && cmake .. -DCMAKE_BUILD_TYPE=Release
make -j $(nproc) && ./db-example && ./core-example && ./ailego-example
shell: bash
make -j $NPROC && ./db-example && ./core-example && ./ailego-example
shell: bash
+65 -46
View File
@@ -22,24 +22,66 @@ permissions:
jobs:
build:
name: Zvec MacArm64 CI
runs-on: mac_m1_arm
runs-on: macos-15
strategy:
matrix:
python-version: ['3.10']
fail-fast: false
steps:
- name: Run Ruff Linter
- name: Checkout code
uses: actions/checkout@v4
with:
submodules: recursive
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
cache: 'pip'
cache-dependency-path: 'pyproject.toml'
- name: Set up environment variables
run: |
cd "$CLEAN_WORKSPACE"
ruff check .
# Set number of processors for parallel builds
NPROC=$(sysctl -n hw.ncpu 2>/dev/null || echo 2)
echo "NPROC=$NPROC" >> $GITHUB_ENV
echo "Using $NPROC parallel jobs for builds"
# Add Python user base bin to PATH for pip-installed CLI tools
echo "$(python -c 'import site; print(site.USER_BASE)')/bin" >> $GITHUB_PATH
shell: bash
- name: Run Ruff Formatter Check (ensure code is formatted)
- name: Install dependencies
run: |
cd "$CLEAN_WORKSPACE"
ruff format --check .
python -m pip install --upgrade pip \
ruff==v0.14.4 \
clang-format==18.1.8 \
pybind11==3.0 \
cmake==3.30.0 \
ninja==1.11.1 \
pytest \
pytest-cov \
scikit-build-core \
setuptools_scm
shell: bash
- name: Run Ruff Linter
run: |
cd "$GITHUB_WORKSPACE"
python -m ruff check .
shell: bash
- name: Run Ruff Formatter Check
run: |
cd "$GITHUB_WORKSPACE"
python -m ruff format --check .
shell: bash
- name: Run clang-format Check
run: |
cd "$CLEAN_WORKSPACE"
cd "$GITHUB_WORKSPACE"
CPP_FILES=$(find . -type f \( -name "*.cpp" -o -name "*.h" -o -name "*.hpp" -o -name "*.cc" -o -name "*.cxx" \) \
! -path "./build/*" \
@@ -57,57 +99,34 @@ jobs:
clang-format --dry-run --Werror $CPP_FILES
shell: bash
- name: Prepare clean build directory
- name: Build from source
run: |
export CLEAN_WORKSPACE="/tmp/zvec"
rm -rf "$CLEAN_WORKSPACE"
mkdir -p "$CLEAN_WORKSPACE"
cd "$CLEAN_WORKSPACE"
git config --global --add safe.directory "$CLEAN_WORKSPACE"
git clone --recursive "https://x-access-token:${GITHUB_TOKEN}@github.com/${GITHUB_REPOSITORY}.git" .
if [ -n "${{ github.event.number }}" ]; then
git fetch origin "pull/${{ github.event.number }}/head"
git checkout FETCH_HEAD
else
git checkout "${{ github.sha }}"
fi
echo "CLEAN_WORKSPACE=$CLEAN_WORKSPACE" >> $GITHUB_ENV
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
shell: bash
- name: Install Python dependencies and build package
run: |
cd "$CLEAN_WORKSPACE"
pip install --upgrade pip pytest pytest-cov ruff
NPROC=$(nproc 2>/dev/null || echo $(getconf _NPROCESSORS_ONLN 2>/dev/null || echo 2))
echo "ParallelGroup: Using $NPROC parallel jobs for build"
cd "$GITHUB_WORKSPACE"
CMAKE_GENERATOR="Unix Makefiles" \
CMAKE_BUILD_PARALLEL_LEVEL="$NPROC" \
pip install -v . \
python -m pip install -v . \
--no-build-isolation \
--config-settings='cmake.define.BUILD_TOOLS="ON"'
shell: bash
- name: Run Cpp Tests
run: |
cd "$GITHUB_WORKSPACE/build"
make unittest -j$NPROC
shell: bash
- name: Run Python Tests with Coverage
run: |
cd "$CLEAN_WORKSPACE"
cd "$GITHUB_WORKSPACE"
python -m pytest python/tests/ --cov=zvec --cov-report=xml --no-cov-on-fail
shell: bash
- name: Run Cpp Tests with Coverage
run: |
cd "$CLEAN_WORKSPACE/build"
make unittest -j 16
shell: bash
- name: Run Cpp Examples
run: |
cd "$CLEAN_WORKSPACE/examples/c++"
mkdir build && cd build && cmake .. -DCMAKE_BUILD_TYPE=Release
make -j 16 && ./db-example && ./core-example && ./ailego-example
cd "$GITHUB_WORKSPACE/examples/c++"
mkdir build && cd build
cmake .. -DCMAKE_BUILD_TYPE=Release
make -j $NPROC && ./db-example && ./core-example && ./ailego-example
shell: bash