diff --git a/.github/workflows/cmake_ubuntu.yml b/.github/workflows/cmake_ubuntu.yml index ca4c87344..de95c6af3 100644 --- a/.github/workflows/cmake_ubuntu.yml +++ b/.github/workflows/cmake_ubuntu.yml @@ -6,17 +6,13 @@ on: - master pull_request: types: [opened, synchronize, reopened] + workflow_dispatch: env: - # Customize the CMake build type here (Release, Debug, RelWithDebInfo, etc.) BUILD_TYPE: Release jobs: build: - # The CMake configure and build commands are platform agnostic and should work equally - # well on Windows or Mac. You can convert this to a matrix build if you need - # cross-platform coverage. - # See: https://docs.github.com/en/free-pro-team@latest/actions/learn-github-actions/managing-complex-workflows#using-a-build-matrix runs-on: ${{ matrix.os }} strategy: matrix: @@ -37,8 +33,6 @@ jobs: - name: Normalize build type shell: bash - # The build type is Capitalized, e.g. Release, but the preset is all lowercase, e.g. release. - # There is no built in way to do string manipulations on GHA as far as I know.` run: echo "BUILD_TYPE_LOWERCASE=$(echo "${BUILD_TYPE}" | tr '[:upper:]' '[:lower:]')" >> $GITHUB_ENV - name: Configure CMake @@ -52,5 +46,58 @@ jobs: - name: run test (Linux) run: ctest --test-dir build/${{env.BUILD_TYPE}} + coverage: + runs-on: ubuntu-24.04 + + steps: + - uses: actions/checkout@v6 + + - name: Install lcov + run: sudo apt-get update && sudo apt-get install -y lcov + + - name: Install Conan + id: conan + uses: turtlebrowser/get-conan@main + + - name: Create default profile + run: conan profile detect + + - name: Install conan dependencies + run: conan install conanfile.py -s build_type=Debug --build=missing + + - name: Configure CMake with coverage + shell: bash + run: | + cmake --preset conan-debug \ + -DCMAKE_C_FLAGS="--coverage -fprofile-update=atomic" \ + -DCMAKE_CXX_FLAGS="--coverage -fprofile-update=atomic" + + - name: Build + shell: bash + run: cmake --build --preset conan-debug + + - name: Run tests + run: ctest --test-dir build/Debug --output-on-failure + + - name: Collect coverage + run: | + lcov --capture --directory build/Debug \ + --output-file coverage.info \ + --ignore-errors mismatch \ + --ignore-errors negative + lcov --remove coverage.info \ + '/usr/*' \ + '*/3rdparty/*' \ + '*/tests/*' \ + '*/examples/*' \ + '*/sample_nodes/*' \ + '*/tools/*' \ + --output-file coverage.info \ + --ignore-errors unused + lcov --list coverage.info + - name: Upload coverage reports to Codecov uses: codecov/codecov-action@v5 + with: + files: coverage.info + token: ${{ secrets.CODECOV_TOKEN }} diff --git a/README.md b/README.md index 286c838bd..0a52d208b 100644 --- a/README.md +++ b/README.md @@ -3,6 +3,7 @@ [![conan Windows](https://github.com/BehaviorTree/BehaviorTree.CPP/actions/workflows/cmake_windows.yml/badge.svg)](https://github.com/BehaviorTree/BehaviorTree.CPP/actions/workflows/cmake_windows.yml) [![ros2](https://github.com/BehaviorTree/BehaviorTree.CPP/actions/workflows/ros2.yaml/badge.svg)](https://github.com/BehaviorTree/BehaviorTree.CPP/actions/workflows/ros2.yaml) [![pixi (Conda)](https://github.com/BehaviorTree/BehaviorTree.CPP/actions/workflows/pixi.yaml/badge.svg)](https://github.com/BehaviorTree/BehaviorTree.CPP/actions/workflows/pixi.yaml) +[![codecov](https://codecov.io/github/BehaviorTree/BehaviorTree.CPP/graph/badge.svg)](https://app.codecov.io/github/BehaviorTree/BehaviorTree.CPP) # BehaviorTree.CPP 4.8