Initial commit

This commit is contained in:
sanyi
2025-12-30 11:02:17 +08:00
commit 6524fabd80
841 changed files with 293919 additions and 0 deletions
+57
View File
@@ -0,0 +1,57 @@
name: Build Wheels
on:
workflow_dispatch:
jobs:
build_wheels:
name: Build wheels on self-hosted manylinux_2_28
runs-on: linux_x64
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
submodules: recursive
- name: Set up Python (for cibuildwheel controller)
uses: actions/setup-python@v5
with:
python-version: '3.11'
- name: Install cibuildwheel
run: |
pip install --upgrade pip
pip install cibuildwheel==2.17.0
- name: Build wheels using cibuildwheel
run: |
python -m cibuildwheel --output-dir wheelhouse
# Save list of built wheels for publishing
ls wheelhouse/*.whl | tee $GITHUB_STEP_SUMMARY
echo "wheels=$(ls wheelhouse/*.whl | tr '\n' ' ')" >> $GITHUB_ENV
- name: Publish to TestPyPI
if: success() && github.event_name == 'workflow_dispatch'
env:
TWINE_USERNAME: __token__
TWINE_PASSWORD: ${{ secrets.TEST_PYPI_API_TOKEN }}
TWINE_REPOSITORY_URL: https://test.pypi.org/legacy/
run: |
pip install twine
twine upload --skip-existing --verbose wheelhouse/*.whl
- name: (Optional) Install and test from TestPyPI
if: success() && github.event_name == 'workflow_dispatch'
run: |
# Create a clean venv
python -m venv test_env
source test_env/bin/activate
pip install --upgrade pip
# Install from TestPyPI (must allow pre-releases if version has dev/alpha)
pip install --index-url https://test.pypi.org/simple/ \
--extra-index-url https://pypi.org/simple/ \
zvec
# Run a simple smoke test
python -c "import zvec; print('Import OK:', zvec.__version__)"
shell: bash
@@ -0,0 +1,83 @@
# =============================================================================
# Dockerfile.linux_x64_glibc228
# Purpose: Ubuntu 18.10 gcc-9 + glibc 2.28 + CMake 3.30.0 + PyBind11 build environment
# Warning: ubuntu:18.10 is EOL; use only for glibc 2.28 compatibility testing.
# =============================================================================
# Use official Ubuntu 18.10 (Cosmic Cuttlefish)
# glibc version: 2.28 (confirmed via `ldd --version`)
FROM ubuntu:18.10
# Replace Ubuntu mirror with old-releases.ubuntu.com for older glibc compatibility
RUN sed -i 's|http://\(.*\)/ubuntu|http://old-releases.ubuntu.com/ubuntu|g' /etc/apt/sources.list && \
sed -i 's|http://security.ubuntu.com/ubuntu|http://old-releases.ubuntu.com/ubuntu|g' /etc/apt/sources.list
# Add Ubuntu 20.04 (focal) repo for GCC 9 ONLY
RUN echo "deb http://archive.ubuntu.com/ubuntu/ focal main universe" >> /etc/apt/sources.list && \
echo "deb http://security.ubuntu.com/ubuntu/ focal-security main universe" >> /etc/apt/sources.list
# Prevent interactive prompts & set non-root user
ENV DEBIAN_FRONTEND=noninteractive \
TZ=Etc/UTC
# Create non-root user for safety (optional but recommended)
RUN useradd -m -u 1000 builder && \
mkdir -p /workspace && chown builder:builder /workspace
# Install base system dependencies
RUN apt-get update && \
apt-get install -y --no-install-recommends \
build-essential \
gcc-9 g++-9 \
ninja-build git curl ca-certificates vim wget lcov gnupg clang-format-18\
rsync lsb-release \
uuid-dev zlib1g-dev libssl-dev libffi-dev \
pybind11-dev && \
update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-9 90 \
--slave /usr/bin/g++ g++ /usr/bin/g++-9 && \
rm -rf /var/lib/apt/lists/*
# Install Miniforge (Conda) as root, then assign to builder
ENV MINIFORGE_VERSION="latest"
ENV MINIFORGE_HOME="/opt/miniforge3"
RUN curl -sSL "https://github.com/conda-forge/miniforge/releases/${MINIFORGE_VERSION}/download/Miniforge3-Linux-x86_64.sh" -o miniforge.sh && \
bash miniforge.sh -b -p ${MINIFORGE_HOME} && \
rm miniforge.sh && \
chown -R builder:builder ${MINIFORGE_HOME}
# Switch to non-root user
USER builder
ENV PATH="${MINIFORGE_HOME}/bin:${PATH}"
WORKDIR /workspace
# Create conda envs for supported Python versions
RUN conda create -n py310 python=3.10 -y && \
conda create -n py311 python=3.11 -y && \
conda create -n py312 python=3.12 -y
RUN conda clean --all -f -y
# Install CMake 3.30.0 from Kitware official binary
# Ref: https://github.com/Kitware/CMake/releases/tag/v3.30.0
RUN mkdir -p /tmp/cmake && cd /tmp/cmake && \
curl -sSL -o cmake.tar.gz \
"https://github.com/Kitware/CMake/releases/download/v3.30.0/cmake-3.30.0-linux-x86_64.tar.gz" && \
tar -xzf cmake.tar.gz --strip-components=1 -C /tmp/cmake && \
mkdir -p /home/builder/.local && \
mv * /home/builder/.local/ && \
chown -R builder:builder /home/builder/.local && \
rm -rf /tmp/cmake
# Add CMake to PATH
ENV PATH="/home/builder/.local/bin:${PATH}"
# Verify installations
RUN cmake --version && \
conda info && \
conda env list && \
python --version && \
gcc --version && \
ldd --version | head -n1
# Final setup
WORKDIR /workspace
+124
View File
@@ -0,0 +1,124 @@
name: Zvec LinuxX64 CI
on:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]
workflow_dispatch:
jobs:
build:
runs-on: linux_x64
strategy:
matrix:
python-version: ['3.10']
fail-fast: false
container:
image: zvec-registry.cn-hongkong.cr.aliyuncs.com/zvec/zvec:0.0.2
options: --user root
steps:
- name: Activate Conda environment
run: |
# Map version to env name
if [[ "${{ matrix.python-version }}" == "3.10" ]]; then
ENV_NAME="py310"
elif [[ "${{ matrix.python-version }}" == "3.11" ]]; then
ENV_NAME="py311"
elif [[ "${{ matrix.python-version }}" == "3.12" ]]; then
ENV_NAME="py312"
else
echo "Unsupported Python version"
exit 1
fi
echo "CONDA_ENV_NAME=$ENV_NAME" >> $GITHUB_ENV
source /opt/miniforge3/bin/activate $ENV_NAME
pip install --upgrade pip pytest pytest-cov ruff
python --version
shell: bash
- name: Prepare clean build directory
run: |
export CLEAN_WORKSPACE="/tmp/zvec"
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.pull_request.head.sha }}" ]; then
git checkout "${{ github.event.pull_request.head.sha }}"
else
git checkout "${{ github.sha }}"
fi
echo "CLEAN_WORKSPACE=$CLEAN_WORKSPACE" >> $GITHUB_ENV
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
shell: bash
- name: Run Ruff Linter
run: |
source /opt/miniforge3/bin/activate ${{ env.CONDA_ENV_NAME }}
cd "$CLEAN_WORKSPACE"
ruff check .
shell: bash
- name: Run Ruff Formatter Check (ensure code is formatted)
run: |
source /opt/miniforge3/bin/activate ${{ env.CONDA_ENV_NAME }}
cd "$CLEAN_WORKSPACE"
ruff format --check .
shell: bash
- name: Run clang-format Check
run: |
source /opt/miniforge3/bin/activate ${{ env.CONDA_ENV_NAME }}
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/*" \
! -path "./scripts/*" \
! -path "./python/*" \
! -path "./thirdparty/*" \
! -path "./.git/*")
if [ -z "$CPP_FILES" ]; then
echo "No C++ files found to check."
exit 0
fi
clang-format-18 --dry-run --Werror $CPP_FILES
shell: bash
- name: Install Python dependencies and build package
run: |
source /opt/miniforge3/bin/activate ${{ env.CONDA_ENV_NAME }}
cd "$CLEAN_WORKSPACE"
NPROC=$(nproc 2>/dev/null || echo $(getconf _NPROCESSORS_ONLN 2>/dev/null || echo 2))
echo "ParallelGroup: Using $NPROC parallel jobs for build"
CMAKE_GENERATOR="Unix Makefiles" \
CMAKE_BUILD_PARALLEL_LEVEL="$NPROC" \
pip install -v .
shell: bash
- name: Run Python Tests with Coverage
run: |
source /opt/miniforge3/bin/activate ${{ env.CONDA_ENV_NAME }}
cd "$CLEAN_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$(nproc)
shell: bash
+85
View File
@@ -0,0 +1,85 @@
name: Zvec MacArm64 CI
on:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]
workflow_dispatch:
jobs:
build:
runs-on: mac_m1_arm
steps:
- name: Run Ruff Linter
run: |
cd "$CLEAN_WORKSPACE"
ruff check .
shell: bash
- name: Run Ruff Formatter Check (ensure code is formatted)
run: |
cd "$CLEAN_WORKSPACE"
ruff format --check .
shell: bash
- name: Run clang-format Check
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/*" \
! -path "./scripts/*" \
! -path "./python/*" \
! -path "./thirdparty/*" \
! -path "./.git/*")
if [ -z "$CPP_FILES" ]; then
echo "No C++ files found to check."
exit 0
fi
clang-format --dry-run --Werror $CPP_FILES
shell: bash
- name: Prepare clean build directory
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.pull_request.head.sha }}" ]; then
git checkout "${{ github.event.pull_request.head.sha }}"
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
pip install -v .
shell: bash
- name: Run Python Tests with Coverage
run: |
cd "$CLEAN_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
+95
View File
@@ -0,0 +1,95 @@
name: Nightly Coverage Report
on:
schedule:
# Runs daily at 00:00 CST (China Standard Time) = 16:00 UTC
- cron: '0 16 * * *'
workflow_dispatch:
jobs:
coverage:
runs-on: linux_x64
strategy:
matrix:
python-version: ['3.10']
fail-fast: false
container:
image: zvec-registry.cn-hongkong.cr.aliyuncs.com/zvec/zvec:0.0.2
options: --user root
steps:
- name: Activate Conda environment
run: |
if [[ "${{ matrix.python-version }}" == "3.10" ]]; then
ENV_NAME="py310"
elif [[ "${{ matrix.python-version }}" == "3.11" ]]; then
ENV_NAME="py311"
elif [[ "${{ matrix.python-version }}" == "3.12" ]]; then
ENV_NAME="py312"
else
echo "Unsupported Python version"
exit 1
fi
echo "CONDA_ENV_NAME=$ENV_NAME" >> $GITHUB_ENV
source /opt/miniforge3/bin/activate "$ENV_NAME"
python --version
shell: bash
- name: Prepare clean build directory
run: |
export CLEAN_WORKSPACE="/tmp/zvec"
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" .
git checkout main # Always use main for nightly
echo "CLEAN_WORKSPACE=$CLEAN_WORKSPACE" >> $GITHUB_ENV
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
shell: bash
- name: Build with COVERAGE config
run: |
source /opt/miniforge3/bin/activate "${{ env.CONDA_ENV_NAME }}"
cd "$CLEAN_WORKSPACE"
pip install --upgrade pip pytest pytest-cov
NPROC=$(nproc 2>/dev/null || echo 2)
echo "Using $NPROC parallel jobs"
CMAKE_GENERATOR="Unix Makefiles" \
CMAKE_BUILD_PARALLEL_LEVEL="$NPROC" \
pip install -v . \
--config-settings="cmake.build-type=COVERAGE"
shell: bash
- name: Run Python Tests with Coverage
run: |
source /opt/miniforge3/bin/activate "${{ env.CONDA_ENV_NAME }}"
cd "$CLEAN_WORKSPACE"
python -m pytest python/tests/ --cov=zvec --cov-report=xml
shell: bash
- name: Run C++ Tests and Generate Coverage
run: |
cd "$CLEAN_WORKSPACE/build"
make unittest -j$(nproc) # Run all (nightly can afford it)
cd "$CLEAN_WORKSPACE"
# Ensure gcov.sh is executable
chmod +x scripts/gcov.sh
bash scripts/gcov.sh -k
shell: bash
- name: Upload Coverage to Codecov
uses: codecov/codecov-action@v4
with:
files: ${{ env.CLEAN_WORKSPACE }}/proxima-zvec-filtered.lcov.info,${{ env.CLEAN_WORKSPACE }}/coverage.xml
flags: python,cpp,nightly
name: nightly-linux-py${{ matrix.python-version }}
token: ${{ secrets.CODECOV_TOKEN }}