File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 99jobs :
1010 test :
1111 runs-on : ubuntu-latest
12+ permissions :
13+ pull-requests : write
1214 steps :
1315 - uses : actions/checkout@v6
1416 with :
@@ -17,11 +19,11 @@ jobs:
1719 - name : Install build dependencies from debian/control
1820 run : |
1921 sudo apt-get update
20- sudo apt-get install --yes devscripts equivs ninja-build
22+ sudo apt-get install --yes devscripts equivs ninja-build lcov
2123 sudo mk-build-deps -i -r -t "apt-get --yes" debian/control
2224
2325 - name : Configure
24- run : cmake -B build -G Ninja -DCMAKE_BUILD_TYPE=Debug -DUSE_STATIC_MPVQT=ON
26+ run : cmake -B build -G Ninja -DCMAKE_BUILD_TYPE=Debug -DUSE_STATIC_MPVQT=ON -DCOVERAGE=ON
2527
2628 - name : Build
2729 run : cmake --build build
3032 run : |
3133 cd build
3234 ctest --output-on-failure
35+
36+ - name : Collect coverage
37+ run : |
38+ lcov --capture --directory build --output-file coverage.info \
39+ --ignore-errors mismatch
40+ lcov --remove coverage.info \
41+ '/usr/*' '*/external/*' '*/tests/*' '*/build/*' \
42+ --output-file coverage.info \
43+ --ignore-errors unused
44+ lcov --summary coverage.info > coverage_summary.txt 2>&1
45+
46+ - name : Comment coverage on PR
47+ if : github.event_name == 'pull_request'
48+ env :
49+ GH_TOKEN : ${{ github.token }}
50+ run : |
51+ {
52+ echo "## Test Coverage"
53+ echo ""
54+ echo '```'
55+ cat coverage_summary.txt
56+ echo '```'
57+ } > comment_body.md
58+ gh pr comment "${{ github.event.pull_request.number }}" --body-file comment_body.md
Original file line number Diff line number Diff line change @@ -15,6 +15,7 @@ option(OPENELEC "Make an OpenELEC build" OFF)
1515option (LINUX_X11POWER "Enable non D-Bus screensaver management" OFF )
1616option (USE_STATIC_MPVQT "Build MpvQt from bundled submodule instead of using system library" OFF )
1717option (MACOS_LAUNCH_WRAPPER "Wrap macOS binary in a shell script to block DYLD_FRAMEWORK_PATH injection" OFF )
18+ option (COVERAGE "Gemerate test code coverage with gcov" OFF )
1819
1920if (NOT CHECK_FOR_UPDATES)
2021 add_definitions (-DDISABLE_UPDATE_CHECK )
@@ -35,6 +36,11 @@ if(BUILD_TARGET STREQUAL "RPI")
3536 Message (STATUS "Build for Raspberry PI target" )
3637endif (BUILD_TARGET STREQUAL "RPI" )
3738
39+ if (COVERAGE)
40+ add_compile_options (--coverage -fno-inline )
41+ add_link_options (--coverage )
42+ endif ()
43+
3844set (CMAKE_INCLUDE_CURRENT_DIR ON )
3945set (CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR} /CMakeModules/" )
4046set (CMAKE_INSTALL_DEFAULT_COMPONENT_NAME Core)
You can’t perform that action at this time.
0 commit comments