Implement coverage for Windows/Linux/MacOS (#126) (#128)

* Implement coverage for Windows/Linux/MacOS (#126)

* reverted

---------

Co-authored-by: Saikari <lin@sz.cn.eu.org>
This commit is contained in:
2025-12-25 02:28:17 +03:00
committed by GitHub
parent d16984a8b2
commit 29da13d244
11 changed files with 874 additions and 34 deletions

View File

@@ -24,13 +24,15 @@ jobs:
triplet: x64-linux
runner: ubuntu-latest
preset: linux-release-vcpkg
coverage: true
install_cmd: |
wget -qO- https://apt.llvm.org/llvm-snapshot.gpg.key | sudo tee /etc/apt/trusted.gpg.d/apt.llvm.org.asc
sudo add-apt-repository -y "deb http://apt.llvm.org/noble/ llvm-toolchain-noble-21 main"
sudo apt-get update
sudo apt-get install -y git build-essential cmake ninja-build \
zip unzip curl pkg-config ca-certificates \
clang-21 lld-21 libc++-21-dev libc++abi-21-dev
clang-21 lld-21 libc++-21-dev libc++abi-21-dev \
llvm-21
sudo update-alternatives --install /usr/bin/cc cc /usr/bin/clang-21 100
sudo update-alternatives --install /usr/bin/c++ c++ /usr/bin/clang++-21 100
sudo update-alternatives --install /usr/bin/lld lld /usr/bin/lld-21 100
@@ -38,6 +40,7 @@ jobs:
triplet: x86-linux
runner: ubuntu-latest
preset: linux-release-vcpkg-x86
coverage: false
install_cmd: |
# Add LLVM 21 repository
wget -qO- https://apt.llvm.org/llvm-snapshot.gpg.key | sudo tee /etc/apt/trusted.gpg.d/apt.llvm.org.asc
@@ -65,6 +68,7 @@ jobs:
triplet: arm64-linux
runner: ubuntu-24.04-arm
preset: linux-release-vcpkg-arm64
coverage: false
install_cmd: |
wget -qO- https://apt.llvm.org/llvm-snapshot.gpg.key | sudo tee /etc/apt/trusted.gpg.d/apt.llvm.org.asc
sudo add-apt-repository -y "deb http://apt.llvm.org/noble/ llvm-toolchain-noble-21 main"
@@ -91,7 +95,7 @@ jobs:
- name: Set up vcpkg
shell: bash
run: |
git clone --branch 2025.12.12 --single-branch https://github.com/microsoft/vcpkg "$VCPKG_ROOT"
git clone https://github.com/microsoft/vcpkg "$VCPKG_ROOT"
cd "$VCPKG_ROOT"
./bootstrap-vcpkg.sh
@@ -102,6 +106,7 @@ jobs:
-DVCPKG_INSTALL_OPTIONS="--allow-unsupported" \
-DOMATH_BUILD_TESTS=ON \
-DOMATH_BUILD_BENCHMARK=OFF \
-DOMATH_ENABLE_COVERAGE=${{ matrix.coverage == true && 'ON' || 'OFF' }} \
-DVCPKG_MANIFEST_FEATURES="imgui;avx2;tests"
- name: Build
@@ -112,6 +117,25 @@ jobs:
shell: bash
run: ./out/Release/unit_tests
- name: Run Coverage
if: ${{ matrix.coverage == true }}
shell: bash
run: |
sudo apt-get install lcov
chmod +x scripts/coverage-llvm.sh
./scripts/coverage-llvm.sh \
"${{ github.workspace }}" \
"cmake-build/build/${{ matrix.preset }}" \
"./out/Release/unit_tests" \
"cmake-build/build/${{ matrix.preset }}/coverage"
- name: Upload Coverage Report
if: ${{ matrix.coverage == true }}
uses: actions/upload-artifact@v4
with:
name: coverage-report-linux
path: cmake-build/build/${{ matrix.preset }}/coverage/
- name: Upload logs on failure
if: ${{ failure() }}
uses: actions/upload-artifact@v4
@@ -164,7 +188,7 @@ jobs:
- name: Configure (cmake --preset)
shell: bash
run: cmake --preset ${{ matrix.preset }} -DOMATH_BUILD_TESTS=ON -DOMATH_BUILD_BENCHMARK=OFF -DVCPKG_MANIFEST_FEATURES="imgui;avx2;tests"
run: cmake --preset ${{ matrix.preset }} -DOMATH_BUILD_TESTS=ON -DOMATH_BUILD_BENCHMARK=OFF -DOMATH_ENABLE_COVERAGE=OFF -DVCPKG_MANIFEST_FEATURES="imgui;avx2;tests"
- name: Build
shell: bash
@@ -174,6 +198,36 @@ jobs:
shell: bash
run: ./out/Release/unit_tests.exe
- name: Install OpenCppCoverage with Chocolatey
if: ${{ matrix.triplet == 'x64-windows' }}
run: choco install opencppcoverage -y
- name: Build Debug for Coverage
if: ${{ matrix.triplet == 'x64-windows' }}
shell: bash
run: |
cmake --preset ${{ matrix.preset }} \
-DOMATH_BUILD_TESTS=ON \
-DOMATH_BUILD_BENCHMARK=OFF \
-DOMATH_ENABLE_COVERAGE=ON \
-DCMAKE_BUILD_TYPE=Debug \
-DVCPKG_MANIFEST_FEATURES="imgui;avx2;tests"
cmake --build cmake-build/build/${{ matrix.preset }} --config Debug --target unit_tests omath
- name: Run Coverage
if: ${{ matrix.triplet == 'x64-windows' }}
shell: pwsh
run: |
$env:Path = "C:\Program Files\OpenCppCoverage;$env:Path"
cmake --build cmake-build/build/${{ matrix.preset }} --target coverage --config Debug
- name: Upload Coverage
if: ${{ matrix.triplet == 'x64-windows' }}
uses: actions/upload-artifact@v4
with:
name: coverage-report-windows
path: cmake-build/build/${{ matrix.preset }}/coverage/
- name: Upload logs on failure
if: ${{ failure() }}
uses: actions/upload-artifact@v4
@@ -193,13 +247,15 @@ jobs:
matrix:
include:
- name: macOS (AppleClang) (arm64-osx)
runner: macOS-latest
runner: macos-latest
preset: darwin-release-vcpkg
triplet: arm64-osx
coverage: true
- name: macOS (AppleClang) (x64-osx)
runner: macos-15-intel
preset: darwin-release-vcpkg-x64
triplet: x64-osx
coverage: false
fail-fast: false
env:
VCPKG_ROOT: ${{ github.workspace }}/vcpkg
@@ -217,20 +273,44 @@ jobs:
- name: Set up vcpkg
shell: bash
run: |
git clone --branch 2025.12.12 --single-branch https://github.com/microsoft/vcpkg "$VCPKG_ROOT"
git clone https://github.com/microsoft/vcpkg "$VCPKG_ROOT"
- name: Configure (cmake --preset)
shell: bash
run: cmake --preset ${{matrix.preset}} -DOMATH_BUILD_TESTS=ON -DOMATH_BUILD_BENCHMARK=OFF -DVCPKG_MANIFEST_FEATURES="imgui;avx2;tests"
run: |
cmake --preset ${{ matrix.preset }} \
-DOMATH_BUILD_TESTS=ON \
-DOMATH_BUILD_BENCHMARK=OFF \
-DOMATH_ENABLE_COVERAGE=${{ matrix.coverage == true && 'ON' || 'OFF' }} \
-DVCPKG_MANIFEST_FEATURES="imgui;avx2;tests"
- name: Build
shell: bash
run: cmake --build cmake-build/build/${{matrix.preset}} --target unit_tests omath
run: cmake --build cmake-build/build/${{ matrix.preset }} --target unit_tests omath
- name: Run unit_tests
shell: bash
run: ./out/Release/unit_tests
- name: Run Coverage
if: ${{ matrix.coverage == true }}
shell: bash
run: |
brew install lcov
chmod +x scripts/coverage-llvm.sh
./scripts/coverage-llvm.sh \
"${{ github.workspace }}" \
"cmake-build/build/${{ matrix.preset }}" \
"./out/Release/unit_tests" \
"cmake-build/build/${{ matrix.preset }}/coverage"
- name: Upload Coverage Report
if: ${{ matrix.coverage == true }}
uses: actions/upload-artifact@v4
with:
name: coverage-report-macos
path: cmake-build/build/${{ matrix.preset }}/coverage/
- name: Upload logs on failure
if: ${{ failure() }}
uses: actions/upload-artifact@v4
@@ -268,7 +348,7 @@ jobs:
- name: Set up vcpkg
shell: bash
run: |
git clone --branch 2025.12.12 --single-branch https://github.com/microsoft/vcpkg "$VCPKG_ROOT"
git clone https://github.com/microsoft/vcpkg "$VCPKG_ROOT"
cd "$VCPKG_ROOT"
./bootstrap-vcpkg.sh
@@ -330,7 +410,7 @@ jobs:
# Build vcpkg in /tmp to avoid sshfs timestamp sync issues
export VCPKG_ROOT=/tmp/vcpkg
rm -rf "$VCPKG_ROOT"
git clone --branch 2025.12.12 --single-branch https://github.com/microsoft/vcpkg "$VCPKG_ROOT"
git clone https://github.com/microsoft/vcpkg "$VCPKG_ROOT"
cd "$VCPKG_ROOT"
./bootstrap-vcpkg.sh
cd -
@@ -399,7 +479,7 @@ jobs:
- name: Set up vcpkg
shell: bash
run: |
git clone --branch 2025.12.12 --single-branch https://github.com/microsoft/vcpkg "$VCPKG_ROOT"
git clone https://github.com/microsoft/vcpkg "$VCPKG_ROOT"
cd "$VCPKG_ROOT"
./bootstrap-vcpkg.sh
@@ -468,7 +548,7 @@ jobs:
- name: Set up vcpkg
shell: bash
run: |
git clone --branch 2025.12.12 --single-branch https://github.com/microsoft/vcpkg "$VCPKG_ROOT"
git clone https://github.com/microsoft/vcpkg "$VCPKG_ROOT"
cd "$VCPKG_ROOT"
./bootstrap-vcpkg.sh
@@ -554,7 +634,7 @@ jobs:
- name: Set up vcpkg
run: |
git clone --branch 2025.12.12 --single-branch https://github.com/microsoft/vcpkg "$VCPKG_ROOT"
git clone https://github.com/microsoft/vcpkg "$VCPKG_ROOT"
cd "$VCPKG_ROOT"
./bootstrap-vcpkg.sh