diff --git a/.github/workflows/coverage.yml b/.github/workflows/coverage.yml new file mode 100644 index 000000000..4b6b6f845 --- /dev/null +++ b/.github/workflows/coverage.yml @@ -0,0 +1,117 @@ +# SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. +# SPDX-License-Identifier: Apache-2.0 + +name: Coverage + +on: + push: + branches: [ main, 'release/*.*.x' ] + pull_request: + workflow_dispatch: + +# For PRs, cancel superseded coverage runs. For main/release pushes, let each +# published signal complete. +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: ${{ github.event_name == 'pull_request' }} + +jobs: + ctest-coverage-ubuntu: + name: CTest coverage (Ubuntu) + runs-on: ubuntu-22.04 + permissions: + contents: read + timeout-minutes: 45 + + steps: + - name: Checkout code + # actions/checkout@v6 + uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 + with: + fetch-depth: 0 + persist-credentials: false + + - name: Install uv + uses: ./.github/actions/setup-uv + + - name: Install Apt dependencies + run: | + sudo apt-get update + sudo apt-get install -y build-essential cmake ninja-build ccache gcovr clang-format-14 \ + libx11-dev libvulkan-dev glslang-tools libxrandr-dev libxinerama-dev libxcursor-dev \ + libxi-dev libxext-dev libxkbcommon-dev libwayland-dev wayland-protocols \ + autoconf automake libtool pkg-config libudev-dev + + - name: Configure coverage build + run: | + set -euo pipefail + cmake -S . -B build-coverage -G Ninja \ + -DCMAKE_BUILD_TYPE=Debug \ + -DISAAC_TELEOP_PYTHON_VERSION=3.11 \ + -DBUILD_VIZ=OFF \ + -DBUILD_PLUGINS=OFF \ + -DBUILD_EXAMPLES=OFF \ + -DBUNDLE_ROBOTIC_GROUNDING=OFF \ + -DENABLE_CLOUDXR_BUNDLE_CHECK=OFF \ + -DENABLE_CLANG_FORMAT_CHECK=OFF \ + -DCMAKE_C_COMPILER_LAUNCHER=ccache \ + -DCMAKE_CXX_COMPILER_LAUNCHER=ccache \ + -DCMAKE_C_FLAGS="--coverage -O0 -g" \ + -DCMAKE_CXX_FLAGS="--coverage -O0 -g" \ + -DCMAKE_EXE_LINKER_FLAGS="--coverage" \ + -DCMAKE_SHARED_LINKER_FLAGS="--coverage" \ + -DCMAKE_MODULE_LINKER_FLAGS="--coverage" + + - name: Build + run: cmake --build build-coverage --parallel 4 + + - name: Run CTest + run: ctest --test-dir build-coverage --output-on-failure --parallel 4 + + - name: Generate coverage report + run: | + set -euo pipefail + mkdir -p coverage/html + + gcovr_args=( + --root "${GITHUB_WORKSPACE}" + --object-directory build-coverage/src + --filter "src/" + --exclude "src/.*/.*_tests/.*" + --exclude "src/.*/tests/.*" + --exclude "src/.*/python_tests/.*" + ) + + gcovr "${gcovr_args[@]}" --txt --output coverage/summary.txt --print-summary | tee coverage/totals.txt + gcovr "${gcovr_args[@]}" --xml-pretty --output coverage/cobertura.xml + gcovr "${gcovr_args[@]}" --html-details --output coverage/html/index.html + + - name: Publish coverage summary + run: | + set -euo pipefail + { + echo "## CTest coverage" + echo + echo "Native coverage was generated from the Debug CTest build with plugins, examples, and Televiz disabled." + echo + echo "### Totals" + echo '```' + cat coverage/totals.txt + echo '```' + echo + echo "Download the \`isaacteleop-coverage\` artifact for the HTML report and \`coverage/cobertura.xml\`." + } >> "${GITHUB_STEP_SUMMARY}" + + - name: Upload coverage artifact + if: ${{ always() }} + # actions/upload-artifact@v6 + uses: actions/upload-artifact@b7c566a772e6b6bfb58ed0dc250532a479d7789f + with: + name: isaacteleop-coverage + path: | + coverage/summary.txt + coverage/totals.txt + coverage/cobertura.xml + coverage/html + if-no-files-found: error + retention-days: 14