Skip to content

Commit

Permalink
ci: Update CI pipeline to include coverage report
Browse files Browse the repository at this point in the history
  • Loading branch information
2b-t committed Feb 17, 2024
1 parent 0b2a990 commit c48a80c
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 2 deletions.
14 changes: 12 additions & 2 deletions .github/workflows/run-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,14 @@ jobs:
sudo apt-get install -y can-utils iproute2 linux-modules-extra-$(uname -r)
sudo apt-get install -y python3 python3-pybind11
sudo apt-get install -y libboost-all-dev libgmock-dev libgtest-dev
- name: Install gcovr
run: |
sudo apt-get update
sudo apt-get install -y gcovr
- name: Create build folder
run: mkdir ${GITHUB_WORKSPACE}/build
- name: Run CMake
run: cmake -B ${GITHUB_WORKSPACE}/build -S ${GITHUB_WORKSPACE} -D PYTHON_BINDINGS=on -D BUILD_TESTING=on
run: cmake -B ${GITHUB_WORKSPACE}/build -S ${GITHUB_WORKSPACE} -D PYTHON_BINDINGS=on -D BUILD_TESTING=on -D ENABLE_COVERAGE=on
- name: Compile with Make
run: make -j $(nproc) -C ${GITHUB_WORKSPACE}/build
- name: Set-up virtual CAN interface for loopback tests
Expand All @@ -42,8 +46,14 @@ jobs:
sudo ip link set up ${VCAN_IFNAME}
- name: Run tests
run: (cd ${GITHUB_WORKSPACE}/build && ctest)
- name: Generate code coverage report
run: gcovr -j $(nproc) --filter ${GITHUB_WORKSPACE}/include --filter ${GITHUB_WORKSPACE}/src --print-summary --xml-pretty --xml ${GITHUB_WORKSPACE}/build/coverage.xml
- name: Update Codecov code coverage report
uses: codecov/codecov-action@v4
with:
files: ${GITHUB_WORKSPACE}/build/coverage.xml
token: ${{ secrets.CODECOV_TOKEN }}
- name: Remove virtual CAN interface
run: |
sudo ip link set down ${VCAN_IFNAME}
sudo ip link delete ${VCAN_IFNAME}
10 changes: 10 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,16 @@ option(PYTHON_BINDINGS "Building Python bindings" OFF)
option(BUILD_TESTING "Build unit and integration tests" OFF)
option(SETUP_TEST_IFNAME "Set-up the test VCAN interface automatically" OFF)

if (CMAKE_COMPILER_IS_GNUCC)
option(ENABLE_COVERAGE "Enable coverage reporting for GCC/Clang" OFF)

if (ENABLE_COVERAGE)
message(STATUS "Building with coverage reporting for GCC/Clang.")
add_compile_options(--coverage -O0)
link_libraries(--coverage)
endif()
endif()

if(NOT UNIX)
message(FATAL_ERROR "Currently this driver only supports Linux!")
endif()
Expand Down

0 comments on commit c48a80c

Please sign in to comment.