diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 147c965..f734c8c 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -16,6 +16,9 @@ on: - 'README.md' - 'docs/**' +env: + JUNIT_REPORT: junit.xml + jobs: build-and-test: runs-on: ${{ matrix.config.os }} @@ -381,6 +384,7 @@ jobs: - name: Build Framework shell: bash + id: build run: | cmake --build build \ -j5 \ @@ -390,12 +394,27 @@ jobs: shell: bash run: | ctest --test-dir build \ + --output-junit ${{env.JUNIT_REPORT}} \ --output-on-failure \ --schedule-random \ --no-tests=error \ --parallel \ -C ${{ matrix.build_mode }} \ + mv build/${{env.JUNIT_REPORT}} . # # End Build # ############# + + - name: Upload test results to Codecov + if: ${{ steps.build.outcome == 'success' && !cancelled() }} + uses: codecov/codecov-action@v5 + with: + token: ${{secrets.CODECOV_TOKEN}} + flags: ${{matrix.config.compiler.name}},${{matrix.config.compiler.version}} + report_type: test_results + files: /__w/gimo/gimo/${{env.JUNIT_REPORT}} + disable_search: true + fail_ci_if_error: true + handle_no_reports_found: true + verbose: true diff --git a/.github/workflows/coverage.yml b/.github/workflows/coverage.yml new file mode 100644 index 0000000..f347f1a --- /dev/null +++ b/.github/workflows/coverage.yml @@ -0,0 +1,200 @@ +# Copyright Dominic (DNKpp) Koepke 2025. +# Distributed under the Boost Software License, Version 1.0. +# (See accompanying file LICENSE_1_0.txt or copy at +# https://www.boost.org/LICENSE_1_0.txt) + +name: coverage + +env: + COBERTURA_REPORT: cobertura.xml + COVERALLS_REPORT: coveralls.json + JSON_REPORT: report.json + JSON_SUMMARY: summary.json + HTML_REPORT_DIR: html/ + COVERAGE_ARTIFACT_NAME: coverage-report + JUNIT_REPORT: junit.xml + +on: + push: + branches: [ main, development ] + paths-ignore: + - 'README.md' + - 'docs/**' + pull_request: + branches: [ main, development ] + paths-ignore: + - 'README.md' + - 'docs/**' + +jobs: + create-coverage-report: + runs-on: ubuntu-latest + container: + image: "ghcr.io/dnkpp/gcc:15" + + steps: + - uses: actions/checkout@v6 + + - name: Install gcovr + run: | + python -m pip install gcovr + + - name: Print versions + run: | + cmake --version + gcc --version + g++ --version + gcov --version + gcovr --version + + - name: Configure + shell: bash + env: + COMPILER_FLAGS: "--coverage;-fno-inline;-fprofile-abs-path;-fkeep-inline-functions;-fkeep-static-functions" + LINKER_FLAGS: "--coverage" + LDFLAGS: "-Wl,--whole-archive -lstdc++exp -Wl,--no-whole-archive" + run: | + cmake -S . \ + -B build \ + --log-level=DEBUG \ + -D CMAKE_VERBOSE_MAKEFILE=YES \ + -D CMAKE_BUILD_TYPE="Debug" \ + -D MIMICPP_CONFIG_EXPERIMENTAL_STACKTRACE=c++23 \ + -D MIMICPP_CONFIG_EXPERIMENTAL_PRETTY_TYPES=OFF \ + -D MIMICPP_CONFIG_USE_FMT=OFF \ + -D GIMO_TEST_ADDITIONAL_COMPILER_FLAGS=${COMPILER_FLAGS} \ + -D GIMO_TEST_ADDITIONAL_LINKER_FLAGS=${LINKER_FLAGS} \ + -D GIMO_CONFIG_CXX_STANDARD=23 \ + -D GIMO_BUILD_BENCHMARKS=NO \ + -D GIMO_BUILD_EXAMPLES=YES \ + -D GIMO_BUILD_TESTS=YES + + - name: Build + run: | + cmake --build build --parallel + + - name: Run tests + shell: bash + run: | + ctest --test-dir build \ + --output-junit ${{env.JUNIT_REPORT}} \ + --output-on-failure \ + --no-tests=error \ + --parallel \ + -C Debug + mv build/${{env.JUNIT_REPORT}} . + + - name: Run gcovr + run: | + # circumvent "fatal: detected dubious ownership in repository" error + git config --global --add safe.directory ${GITHUB_WORKSPACE} + cd build + gcovr --root .. \ + --verbose \ + --include "${GITHUB_WORKSPACE}/include/gimo(_ext)?" \ + --filter "${GITHUB_WORKSPACE}/include/gimo(_ext)?" \ + --exclude-lines-by-pattern "\s*GIMO_ASSERT\(" \ + --exclude-unreachable-branches \ + --exclude-function-lines \ + --exclude-noncode-lines \ + --exclude-throw-branches \ + --decisions \ + --calls \ + --keep \ + --merge-lines \ + --txt \ + --cobertura ${{env.COBERTURA_REPORT}} --cobertura-pretty \ + --html-nested ${{env.HTML_REPORT_DIR}} --html-title "gimo Coverage Report" \ + --coveralls ${{env.COVERALLS_REPORT}} --coveralls-pretty \ + --json-summary ${{env.JSON_SUMMARY}} --json-summary-pretty \ + --json ${{env.JSON_REPORT}} --json-pretty + + mv ${{env.COBERTURA_REPORT}} .. + mv ${{env.HTML_REPORT_DIR}} .. + mv ${{env.COVERALLS_REPORT}} .. + mv ${{env.JSON_SUMMARY}} .. + mv ${{env.JSON_REPORT}} .. + + - name: Find gcov-files + shell: bash + run: find . -type f -name "*.gcov" + + - name: Upload gcov coverage report artifacts + uses: actions/upload-artifact@v6 + with: + name: gcov-files + path: "**/*.json.gz" + if-no-files-found: error + + - name: Upload generated report artifacts + uses: actions/upload-artifact@v6 + with: + name: ${{env.COVERAGE_ARTIFACT_NAME}} + path: | + ${{env.COBERTURA_REPORT}} + ${{env.COVERALLS_REPORT}} + ${{env.JSON_REPORT}} + ${{env.JSON_SUMMARY}} + ${{env.JUNIT_REPORT}} + ${{env.HTML_REPORT_DIR}} + if-no-files-found: error + + codacy-report: + needs: create-coverage-report + runs-on: ubuntu-latest + steps: + - uses: actions/download-artifact@v7 + with: + name: ${{env.COVERAGE_ARTIFACT_NAME}} + + - name: Upload coverage to Codacy + uses: codacy/codacy-coverage-reporter-action@v1 + with: + project-token: ${{secrets.CODACY_PROJECT_TOKEN}} + coverage-reports: ${{env.COBERTURA_REPORT}} + + codecov-report: + needs: create-coverage-report + runs-on: ubuntu-latest + steps: + - uses: actions/download-artifact@v7 + with: + name: ${{env.COVERAGE_ARTIFACT_NAME}} + + - name: Upload coverage to Codecov + uses: codecov/codecov-action@v5 + with: + name: $GITHUB_REPOSITORY + token: ${{secrets.CODECOV_TOKEN}} + files: ${{env.COBERTURA_REPORT}} + disable_search: true + fail_ci_if_error: true + verbose: true + + - name: Upload test results to Codecov + uses: codecov/codecov-action@v5 + with: + token: ${{secrets.CODECOV_TOKEN}} + flags: coverage + report_type: test_results + files: ./${{env.JUNIT_REPORT}} + disable_search: true + fail_ci_if_error: true + verbose: true + + coveralls-report: + needs: create-coverage-report + runs-on: ubuntu-latest + steps: + - uses: actions/download-artifact@v7 + with: + name: ${{env.COVERAGE_ARTIFACT_NAME}} + + - name: Upload coverage to Coveralls + uses: coverallsapp/github-action@v2 + with: + github-token: ${{secrets.GITHUB_TOKEN}} + file: ${{env.COVERALLS_REPORT}} + format: coveralls + debug: true + fail-on-error: true diff --git a/CMakeLists.txt b/CMakeLists.txt index b1a9136..4bcd344 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -3,7 +3,7 @@ # (See accompanying file LICENSE_1_0.txt or copy at # https://www.boost.org/LICENSE_1_0.txt) -cmake_minimum_required(VERSION 3.15) +cmake_minimum_required(VERSION 3.15...3.31) set(MESSAGE_PREFIX "gimo:") list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake") @@ -12,10 +12,10 @@ include(GimoReadVersion) gimo_read_version("include/gimo/Version.hpp" GIMO_VERSION) project(gimo - LANGUAGES CXX - VERSION ${GIMO_VERSION} - DESCRIPTION "TBD" - HOMEPAGE_URL "https://github.com/DNKpp/nullables" + LANGUAGES CXX + VERSION ${GIMO_VERSION} + DESCRIPTION "TBD" + HOMEPAGE_URL "https://github.com/DNKpp/gimo" ) message(STATUS "${MESSAGE_PREFIX} version: v${PROJECT_VERSION} from: ${gimo_SOURCE_DIR}") diff --git a/cmake/Findgimo-mimic++.cmake b/cmake/Findgimo-mimic++.cmake index 7f08fc0..baa94e3 100644 --- a/cmake/Findgimo-mimic++.cmake +++ b/cmake/Findgimo-mimic++.cmake @@ -5,7 +5,7 @@ include(Gimo-get_cpm) -set(MIMICPP_CONFIG_EXPERIMENTAL_STACKTRACE "cpptrace" CACHE BOOL "" FORCE) -set(MIMICPP_CONFIG_EXPERIMENTAL_PRETTY_TYPES ON CACHE BOOL "" FORCE) -set(MIMICPP_CONFIG_USE_FMT ON CACHE BOOL "" FORCE) +set(MIMICPP_CONFIG_EXPERIMENTAL_STACKTRACE "cpptrace" CACHE BOOL "") +set(MIMICPP_CONFIG_EXPERIMENTAL_PRETTY_TYPES ON CACHE BOOL "") +set(MIMICPP_CONFIG_USE_FMT ON CACHE BOOL "") CPMAddPackage("gh:DNKpp/mimicpp@9.2.1") diff --git a/cmake/Gimo-EnableTestFlags.cmake b/cmake/Gimo-EnableTestFlags.cmake new file mode 100644 index 0000000..efa3e00 --- /dev/null +++ b/cmake/Gimo-EnableTestFlags.cmake @@ -0,0 +1,23 @@ +# Copyright Dominic (DNKpp) Koepke 2025. +# Distributed under the Boost Software License, Version 1.0. +# (See accompanying file LICENSE_1_0.txt or copy at +# https://www.boost.org/LICENSE_1_0.txt) + +if (NOT TARGET gimo-internal-test-flags) + add_library(gimo-internal-test-flags INTERFACE) + add_library(gimo::internal::enable-test-flags ALIAS gimo-internal-test-flags) + + if (GIMO_TEST_ADDITIONAL_COMPILER_FLAGS) + message(DEBUG "${MESSAGE_PREFIX} enabled additional compiler-flags: ${GIMO_TEST_ADDITIONAL_COMPILER_FLAGS}") + target_compile_options(gimo-internal-test-flags INTERFACE + ${GIMO_TEST_ADDITIONAL_COMPILER_FLAGS} + ) + endif () + + if (GIMO_TEST_ADDITIONAL_LINKER_FLAGS) + message(DEBUG "${MESSAGE_PREFIX} enabled additional linker-flags: ${GIMO_TEST_ADDITIONAL_LINKER_FLAGS}") + target_link_options(gimo-internal-test-flags INTERFACE + ${GIMO_TEST_ADDITIONAL_LINKER_FLAGS} + ) + endif () +endif () diff --git a/test/unit-tests/CMakeLists.txt b/test/unit-tests/CMakeLists.txt index 5b2c6c9..f81b4a9 100644 --- a/test/unit-tests/CMakeLists.txt +++ b/test/unit-tests/CMakeLists.txt @@ -21,11 +21,13 @@ include(EnableSanitizers) enable_sanitizers(${TARGET_NAME}) include(EnableWarnings) +include(Gimo-EnableTestFlags) find_package(Catch2 REQUIRED) find_package(gimo-mimic++ REQUIRED) target_link_libraries(${TARGET_NAME} PRIVATE gimo::gimo gimo::internal::enable-warnings + gimo::internal::enable-test-flags Catch2::Catch2WithMain mimicpp::mimicpp