114 lines
3.2 KiB
YAML
114 lines
3.2 KiB
YAML
name: Zvec MacArm64 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 MacArm64 CI
|
|
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.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"
|
|
|
|
CMAKE_GENERATOR="Unix Makefiles" \
|
|
CMAKE_BUILD_PARALLEL_LEVEL="$NPROC" \
|
|
pip install -v . \
|
|
--config-settings='cmake.define.BUILD_TOOLS="ON"'
|
|
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
|
|
|
|
- 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
|
|
shell: bash
|