140 lines
4.1 KiB
YAML
140 lines
4.1 KiB
YAML
name: Zvec LinuxX64 CI
|
|
|
|
on:
|
|
push:
|
|
branches: [ "main" ]
|
|
paths-ignore:
|
|
- '**.md'
|
|
merge_group:
|
|
pull_request:
|
|
branches: [ "main" ]
|
|
paths-ignore:
|
|
- '**.md'
|
|
workflow_dispatch:
|
|
|
|
concurrency:
|
|
group: pr-${{ github.workflow }}-${{ github.event.pull_request.number }}
|
|
cancel-in-progress: true
|
|
|
|
permissions:
|
|
contents: read
|
|
|
|
jobs:
|
|
build:
|
|
name: Zvec LinuxX64 CI
|
|
runs-on: linux_x64
|
|
|
|
strategy:
|
|
matrix:
|
|
python-version: ['3.10']
|
|
fail-fast: false
|
|
|
|
container:
|
|
image: quay.io/pypa/manylinux_2_28_x86_64:2024-03-10-4935fcc
|
|
options: --user root
|
|
|
|
steps:
|
|
- name: Set up Python path for manylinux
|
|
run: |
|
|
case "${{ matrix.python-version }}" in
|
|
"3.10") PY_PATH="/opt/python/cp310-cp310" ;;
|
|
"3.11") PY_PATH="/opt/python/cp311-cp311" ;;
|
|
"3.12") PY_PATH="/opt/python/cp312-cp312" ;;
|
|
*) echo "Unsupported Python version: ${{ matrix.python-version }}"; exit 1 ;;
|
|
esac
|
|
echo "PYTHON_BIN=$PY_PATH/bin/python" >> $GITHUB_ENV
|
|
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
|
|
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.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 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"
|
|
${{ env.PYTHON_BIN }} -m ruff check .
|
|
shell: bash
|
|
|
|
- name: Run Ruff Formatter Check
|
|
run: |
|
|
cd "$CLEAN_WORKSPACE"
|
|
${{ env.PYTHON_BIN }} -m 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
|
|
|
|
${{ env.CLANG_FORMATTER_BIN }} --dry-run --Werror $CPP_FILES
|
|
shell: bash
|
|
|
|
- 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"'
|
|
shell: bash
|
|
|
|
- name: Run Python Tests with Coverage
|
|
run: |
|
|
cd "$CLEAN_WORKSPACE"
|
|
${{ env.PYTHON_BIN }} -m pytest python/tests/ --cov=zvec --cov-report=xml --no-cov-on-fail
|
|
shell: bash
|
|
|
|
- name: Run Cpp Tests
|
|
run: |
|
|
cd "$CLEAN_WORKSPACE/build"
|
|
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
|