diff --git a/.github/workflows/coverage.yml b/.github/workflows/coverage.yml index 3f11c8af..429fcfc3 100644 --- a/.github/workflows/coverage.yml +++ b/.github/workflows/coverage.yml @@ -4,6 +4,9 @@ on: push: branches: - develop + pull_request: + branches: + - develop jobs: posix: @@ -18,34 +21,24 @@ jobs: LDFLAGS: --coverage CMAKE_BUILD_PARALLEL_LEVEL: 4 steps: + - name: Install lcov + run: sudo apt-get --no-install-recommends -y install lcov libgd-perl + - name: Checkout uses: actions/checkout@v3 - - name: Install dependencies - run: sudo apt-get --no-install-recommends -y install cmake lcov g++-11 redis-server python3 libgd-perl - - - name: Setup Boost - run: ./tools/ci.py setup-boost --source-dir=$(pwd) - - - name: Build Boost - run: ./tools/ci.py build-b2-distro --toolset=gcc-11 - - # Having our library there confuses the coverage reports - - name: Remove Boost.Redis from the b2 distro - run: rm -rf ~/boost-b2-distro/include/boost/redis - - - name: Run CMake - run: cmake -DCMAKE_PREFIX_PATH=$HOME/boost-b2-distro --preset coverage . + - name: Configure CMake + run: cmake -DCMAKE_PREFIX_PATH=${{github.workspace}}/build --preset coverage . - name: Build run: cmake --build --preset coverage - name: Test - run: ctest --preset coverage + run: cmake --build --preset coverage --target check - name: Make the coverage file run: cmake --build --preset coverage --target coverage - name: Upload to codecov run: | - bash <(curl -s https://codecov.io/bash) -f ./build/coverage/coverage.info + bash <(curl -s https://codecov.io/bash) -f ${{github.workspace}}/build/coverage/coverage.info diff --git a/CMakePresets.json b/CMakePresets.json index 34b32648..728f6d99 100644 --- a/CMakePresets.json +++ b/CMakePresets.json @@ -15,10 +15,6 @@ "uninitialized": false, "unusedCli": true, "systemVars": false - }, - "errors": { - "dev": true, - "deprecated": true } }, { @@ -30,134 +26,16 @@ "cacheVariables": { "CMAKE_BUILD_TYPE": "Coverage", "CMAKE_CXX_EXTENSIONS": "OFF", - "CMAKE_CXX_FLAGS": "-Wall -Wextra", - "CMAKE_CXX_FLAGS_COVERAGE": "-Og -g --coverage -fkeep-inline-functions -fkeep-static-functions", + "CMAKE_CXX_FLAGS": "-Wall -std=c++17 -Og -g --coverage -fkeep-inline-functions -fkeep-static-functions", "CMAKE_CXX_STANDARD_REQUIRED": "ON", - "CMAKE_EXE_LINKER_FLAGS_COVERAGE": "--coverage", - "CMAKE_SHARED_LINKER_FLAGS_COVERAGE": "--coverage", - "PROJECT_BINARY_DIR": "${sourceDir}/build/coverage", - "COVERAGE_HTML_COMMAND": "" - } - }, - { - "name": "g++-11", - "generator": "Unix Makefiles", - "hidden": false, - "inherits": ["cmake-pedantic"], - "binaryDir": "${sourceDir}/build/g++-11", - "cacheVariables": { - "CMAKE_BUILD_TYPE": "Debug", - "CMAKE_CXX_EXTENSIONS": "OFF", - "CMAKE_CXX_FLAGS": "-Wall -Wextra -fsanitize=address", - "CMAKE_CXX_COMPILER": "g++-11", - "CMAKE_SHARED_LINKER_FLAGS": "-fsanitize=address", - "CMAKE_CXX_STANDARD_REQUIRED": "ON", - "PROJECT_BINARY_DIR": "${sourceDir}/build/g++-11" - } - }, - { - "name": "g++-11-release", - "generator": "Unix Makefiles", - "hidden": false, - "inherits": ["cmake-pedantic"], - "binaryDir": "${sourceDir}/build/g++-11-release", - "cacheVariables": { - "CMAKE_BUILD_TYPE": "Release", - "CMAKE_CXX_EXTENSIONS": "OFF", - "CMAKE_CXX_FLAGS": "-Wall -Wextra", - "CMAKE_CXX_COMPILER": "g++-11", - "CMAKE_SHARED_LINKER_FLAGS": "", - "CMAKE_CXX_STANDARD_REQUIRED": "ON", - "PROJECT_BINARY_DIR": "${sourceDir}/build/g++-11-release" - } - }, - { - "name": "clang++-13", - "generator": "Unix Makefiles", - "hidden": false, - "inherits": ["cmake-pedantic"], - "binaryDir": "${sourceDir}/build/clang++-13", - "cacheVariables": { - "CMAKE_BUILD_TYPE": "Debug", - "CMAKE_CXX_EXTENSIONS": "OFF", - "CMAKE_CXX_FLAGS": "-Wall -Wextra -fsanitize=address", - "CMAKE_CXX_COMPILER": "clang++-13", - "CMAKE_SHARED_LINKER_FLAGS": "-fsanitize=address", - "CMAKE_CXX_STANDARD_REQUIRED": "ON", - "PROJECT_BINARY_DIR": "${sourceDir}/build/clang++-13" - } - }, - { - "name": "clang++-14", - "generator": "Unix Makefiles", - "hidden": false, - "inherits": ["cmake-pedantic"], - "binaryDir": "${sourceDir}/build/clang++-14", - "cacheVariables": { - "CMAKE_BUILD_TYPE": "Debug", - "CMAKE_CXX_EXTENSIONS": "OFF", - "CMAKE_CXX_FLAGS": "-Wall -Wextra -fsanitize=address", - "CMAKE_CXX_COMPILER": "clang++-14", - "CMAKE_SHARED_LINKER_FLAGS": "-fsanitize=address", - "CMAKE_CXX_STANDARD_REQUIRED": "ON", - "PROJECT_BINARY_DIR": "${sourceDir}/build/clang++-14" - } - }, - { - "name": "libc++-14-cpp17", - "generator": "Unix Makefiles", - "hidden": false, - "inherits": ["cmake-pedantic"], - "binaryDir": "${sourceDir}/build/libc++-14-cpp17", - "cacheVariables": { - "CMAKE_BUILD_TYPE": "Debug", - "CMAKE_CXX_EXTENSIONS": "OFF", - "CMAKE_CXX_FLAGS": "-Wall -Wextra -stdlib=libc++ -std=c++17", - "CMAKE_EXE_LINKER_FLAGS": "-lc++", - "CMAKE_CXX_COMPILER": "clang++-14", - "CMAKE_SHARED_LINKER_FLAGS": "", - "CMAKE_CXX_STANDARD_REQUIRED": "ON", - "PROJECT_BINARY_DIR": "${sourceDir}/build/libc++-14-cpp17" - } - }, - { - "name": "libc++-14-cpp20", - "generator": "Unix Makefiles", - "hidden": false, - "inherits": ["cmake-pedantic"], - "binaryDir": "${sourceDir}/build/libc++-14-cpp20", - "cacheVariables": { - "CMAKE_BUILD_TYPE": "Debug", - "CMAKE_CXX_EXTENSIONS": "OFF", - "CMAKE_CXX_FLAGS": "-Wall -Wextra -stdlib=libc++ -std=c++17", - "CMAKE_EXE_LINKER_FLAGS": "-lc++", - "CMAKE_CXX_COMPILER": "clang++-14", - "CMAKE_SHARED_LINKER_FLAGS": "", - "CMAKE_CXX_STANDARD_REQUIRED": "ON", - "PROJECT_BINARY_DIR": "${sourceDir}/build/libc++-14-cpp20" - } - }, - { - "name": "clang-tidy", - "generator": "Unix Makefiles", - "hidden": false, - "inherits": ["g++-11"], - "binaryDir": "${sourceDir}/build/clang-tidy", - "cacheVariables": { - "CMAKE_CXX_CLANG_TIDY": "clang-tidy;--header-filter=${sourceDir}/include/*", - "CMAKE_CXX_STANDARD": "20" + "CMAKE_EXE_LINKER_FLAGS": "--coverage", + "CMAKE_SHARED_LINKER_FLAGS": "--coverage", + "PROJECT_BINARY_DIR": "${sourceDir}/build/coverage" } } ], "buildPresets": [ - { "name": "coverage", "configurePreset": "coverage" }, - { "name": "g++-11", "configurePreset": "g++-11" }, - { "name": "g++-11-release", "configurePreset": "g++-11-release" }, - { "name": "clang++-13", "configurePreset": "clang++-13" }, - { "name": "clang++-14", "configurePreset": "clang++-14" }, - { "name": "libc++-14-cpp17", "configurePreset": "libc++-14-cpp17" }, - { "name": "libc++-14-cpp20", "configurePreset": "libc++-14-cpp20" }, - { "name": "clang-tidy", "configurePreset": "clang-tidy" } + { "name": "coverage", "configurePreset": "coverage" } ], "testPresets": [ { @@ -166,13 +44,6 @@ "output": {"outputOnFailure": true}, "execution": {"noTestsAction": "error", "stopOnFailure": true} }, - { "name": "coverage", "configurePreset": "coverage", "inherits": ["test"] }, - { "name": "g++-11", "configurePreset": "g++-11", "inherits": ["test"] }, - { "name": "g++-11-release", "configurePreset": "g++-11-release", "inherits": ["test"] }, - { "name": "clang++-13", "configurePreset": "clang++-13", "inherits": ["test"] }, - { "name": "clang++-14", "configurePreset": "clang++-14", "inherits": ["test"] }, - { "name": "libc++-14-cpp17", "configurePreset": "libc++-14-cpp17", "inherits": ["test"] }, - { "name": "libc++-14-cpp20", "configurePreset": "libc++-14-cpp20", "inherits": ["test"] }, - { "name": "clang-tidy", "configurePreset": "clang-tidy", "inherits": ["test"] } + { "name": "coverage", "configurePreset": "coverage", "inherits": ["test"] } ] } diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 23ab84ff..0b93e460 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -75,3 +75,25 @@ add_test_executable(parser_seq_permutations_1) add_test_executable(parser_seq_permutations_2) add_test_executable(parser_or_permutations_1) add_test_executable(parser_or_permutations_2) + +set(COVERAGE_TRACE_COMMAND + lcov --capture + -output-file ${PROJECT_BINARY_DIR}/coverage.info + --directory ${PROJECT_BINARY_DIR} + --include ${PROJECT_SOURCE_DIR}/include/* +) + +set(COVERAGE_HTML_COMMAND + genhtml --legend -f -q + ${PROJECT_BINARY_DIR}/coverage.info + --prefix ${PROJECT_SOURCE_DIR} + --output-directory ${PROJECT_BINARY_DIR}/coverage_html +) + +add_custom_target( + coverage + COMMAND ${COVERAGE_TRACE_COMMAND} + COMMAND ${COVERAGE_HTML_COMMAND} + COMMENT "Generating coverage report" + VERBATIM +)