File tree 7 files changed +86
-4
lines changed
7 files changed +86
-4
lines changed Original file line number Diff line number Diff line change @@ -2,7 +2,9 @@ FROM gcc:13.2.0
2
2
RUN \
3
3
apt update && \
4
4
apt upgrade -y && \
5
- apt install -y cmake gdb valgrind vim
5
+ apt install -y cmake gdb valgrind vim lcov python3-pip python3-venv && \
6
+ python3 -m venv /tmp/gcovr && \
7
+ /tmp/gcovr/bin/pip install gcovr lxml
6
8
7
9
ARG USERNAME=devcontainer
8
10
ARG USER_UID=1000
@@ -13,4 +15,5 @@ ARG USER_GID=$USER_UID
13
15
RUN groupadd --gid ${USER_GID} ${USERNAME} \
14
16
&& useradd --uid ${USER_UID} --gid ${USER_GID} -m ${USERNAME}
15
17
18
+ ENV PATH="/tmp/gcovr/bin:${PATH}"
16
19
ENTRYPOINT /bin/bash
Original file line number Diff line number Diff line change 31
31
" source=${localEnv:HOME}/.gitconfig,target=/home/${localEnv:USER}/.gitconfig,type=bind"
32
32
],
33
33
34
+ "containerEnv" : {
35
+ "SHELL" : " /bin/bash"
36
+ },
34
37
// Uncomment to connect as an existing user other than the container default. More info: https://aka.ms/dev-containers-non-root.
35
38
"remoteUser" : " ${localEnv:USER}"
36
39
Original file line number Diff line number Diff line change @@ -22,10 +22,13 @@ jobs:
22
22
steps :
23
23
- uses : actions/checkout@v3
24
24
25
+ - name : install
26
+ run : sudo apt-get update && sudo apt-get install lcov # libxrandr-dev libxcursor-dev libudev-dev libopenal-dev libflac-dev libvorbis-dev libgl1-mesa-dev libegl1-mesa-dev freeglut3-dev # OpenGL dependencies only needed for SFML
27
+
25
28
- name : Configure CMake
26
29
# Configure CMake in a 'build' subdirectory. `CMAKE_BUILD_TYPE` is only required if you are using a single-configuration generator such as make.
27
30
# See https://cmake.org/cmake/help/latest/variable/CMAKE_BUILD_TYPE.html?highlight=cmake_build_type
28
- run : cmake -B ${{github.workspace}}/build -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} -DCMAKE_CXX_COMPILER=g++-13
31
+ run : cmake -B ${{github.workspace}}/build -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} -DCMAKE_CXX_COMPILER=g++-13 -DENABLE_TEST -DENABLE_COVERAGE
29
32
30
33
- name : Build
31
34
# Build your program with the given configuration
37
40
# See https://cmake.org/cmake/help/latest/manual/ctest.1.html for more detail
38
41
run : ctest -C ${{env.BUILD_TYPE}}
39
42
43
+ - name : generate coverage
44
+ working-directory : ./build
45
+ run : |
46
+ make cov
47
+
48
+ - name : Install gcovr
49
+ run : |
50
+ pip install -r requirements.txt
51
+
52
+ - name : Generate JSON coverage report
53
+ working-directory : ./build
54
+ run : |
55
+ gcovr -r .. . --branches --cobertura --filter ../include > coverage.xml
56
+
57
+ - name : Upload coverage reports to Codecov
58
+ uses : codecov/codecov-action@v3
59
+ env :
60
+ CODECOV_TOKEN : ${{ secrets.CODECOV_TOKEN }}
Original file line number Diff line number Diff line change 30
30
* .exe
31
31
* .out
32
32
* .app
33
+
34
+ # Visual Studio Code personal configuration
35
+ .vscode
36
+
37
+ # Build directory
38
+ build
39
+ Testing
Original file line number Diff line number Diff line change @@ -35,5 +35,13 @@ install(TARGETS lzc-coro
35
35
# INSTALL_DESTINATION
36
36
# ${CMAKE_INSTALL_DATAROOTDIR}/${PROJECT_NAME}/cmake)
37
37
38
- enable_testing ()
39
- add_subdirectory (tests)
38
+ option (ENABLE_TESTS "Build tests" OFF )
39
+ option (ENABLE_COVERAGE "If ENABLE_TESTS is ON then coverage could be produced" OFF )
40
+ if (ENABLE_TESTS)
41
+ enable_testing ()
42
+ if (ENABLE_COVERAGE)
43
+ include (cmake/coverage.cmake)
44
+ add_coverage_target("*/tests/*" )
45
+ endif ()
46
+ add_subdirectory (tests)
47
+ endif ()
Original file line number Diff line number Diff line change
1
+ function (add_coverage_target exclude )
2
+
3
+ find_program (GCOV gcov)
4
+ if (NOT GCOV)
5
+ message (WARNING "program gcov not found" )
6
+ endif ()
7
+
8
+ find_program (LCOV lcov)
9
+ if (NOT LCOV)
10
+ message (WARNING "program lcov not found" )
11
+ endif ()
12
+
13
+ find_program (GENHTML genhtml)
14
+ if (NOT GENHTML)
15
+ message (WARNING "program genhtml not found" )
16
+ endif ()
17
+
18
+ if (LCOV AND GCOV AND GENHTML)
19
+ set (covname cov.info)
20
+ add_compile_options (-fprofile-arcs -ftest-coverage)
21
+ add_link_options (--coverage)
22
+ add_custom_target (cov DEPENDS ${covname} )
23
+ add_custom_command (
24
+ OUTPUT ${covname}
25
+ COMMAND ${LCOV} -c -o ${covname} -d . -b . --gcov-tool ${GCOV}
26
+ COMMAND ${LCOV} -r ${covname} -o ${covname} ${exclude}
27
+ COMMAND ${LCOV} -l ${covname}
28
+ COMMAND ${GENHTML} ${covname} -output coverage
29
+ COMMAND ${LCOV} -l ${covname} 2>/dev/null | grep Total | sed 's/|//g' | sed 's/Total://g' | awk '{print $1}' | sed s/%//g > coverage/total
30
+ )
31
+ set_directory_properties (PROPERTIES
32
+ ADDITIONAL_CLEAN_FILES ${covname}
33
+ )
34
+ else ()
35
+ message (WARNING "unable to add target `cov`: missing coverage tools" )
36
+ endif ()
37
+
38
+ endfunction ()
Original file line number Diff line number Diff line change
1
+ gcovr == 6.0
2
+ lxml == 5.1.0
You can’t perform that action at this time.
0 commit comments