diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index b93815c9e6..06751dc784 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -105,6 +105,78 @@ jobs: with: name: ReferenceDocumentation path: build/doc/html + + Coverage: + name: "Coverage (Ubuntu GCC)" + runs-on: ubuntu-24.04 + steps: + - name: Check out repository code + uses: actions/checkout@v4 + with: + submodules: recursive + + - name: Install latest CMake 3 and Ninja + uses: lukka/get-cmake@latest + with: + cmakeVersion: "3.31.6" + + - name: Install coverage tools + run: | + sudo apt-get update + sudo apt-get install -y jq python3-pip + + - name: Install pinned gcovr + run: | + python3 -m pip install --user --upgrade gcovr==8.4 + echo "$HOME/.local/bin" >> "$GITHUB_PATH" + gcovr --version + + - name: Add VCPKG_ROOT + run: | + echo "VCPKG_ROOT=${VCPKG_INSTALLATION_ROOT}" >> "$GITHUB_ENV" + + - name: Make more swap space available + run: | + sudo swapoff -a + sudo fallocate -l 10G /mnt/swapfile + sudo chmod 600 /mnt/swapfile + sudo mkswap /mnt/swapfile + sudo swapon /mnt/swapfile + sudo swapon --show + + - name: Configure coverage build + run: | + cp doc/cmake-presets/CMakeUserPresets.json . + cmake --preset=vcpkg-linux -DCMAKE_BUILD_TYPE=Debug -DCESIUM_COVERAGE_ENABLED=ON + + - name: Run coverage target + run: | + cmake --build build --target cesium-native-tests-coverage --parallel 2 + + - name: Generate machine-readable coverage summary + run: | + gcovr --json-summary --json-summary-pretty \ + -r . \ + -e ".*/extern/.*" \ + -e ".*/generated/.*" \ + -e ".*/test/.*" \ + -e ".*/build.*" \ + --object-directory build \ + -o build/coverage-summary.json + + - name: Upload HTML coverage report + if: ${{ !cancelled() }} + uses: actions/upload-artifact@v4 + with: + name: CoverageReportHtml + path: build/cesium-native-tests-coverage + + - name: Upload current coverage summary + if: ${{ !cancelled() }} + uses: actions/upload-artifact@v4 + with: + name: coverage-current-summary + path: build/coverage-summary.json WindowsBuild: strategy: fail-fast: false diff --git a/CMakeLists.txt b/CMakeLists.txt index 96522ec5e8..59d3a1b502 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -337,7 +337,11 @@ if (CESIUM_COVERAGE_ENABLED AND NOT MSVC) setup_target_for_coverage_gcovr_html( NAME cesium-native-tests-coverage EXECUTABLE ctest -j ${PROCESSOR_COUNT} - EXCLUDE "${PROJECT_SOURCE_DIR}/extern/*" "${PROJECT_BINARY_DIR}" + EXCLUDE + ".*/extern/.*" + ".*/generated/.*" + ".*/test/.*" + "${PROJECT_BINARY_DIR}" DEPENDENCIES cesium-native-tests ) endif()