From 512b451afd57f08ec469e7c28cdea0b9bd89f446 Mon Sep 17 00:00:00 2001 From: Matthew Carroll <28577806+MJC598@users.noreply.github.com> Date: Thu, 1 May 2025 08:16:02 -0400 Subject: [PATCH 1/3] Adding the code coverage and updating the cmake presets to function correctly --- CMakeLists.txt | 6 +- CMakePresets.json | 145 +++++++++++++++++++++++++------------- cmake/BuildBinaries.cmake | 9 +++ cmake/options.cmake | 2 + 4 files changed, 107 insertions(+), 55 deletions(-) create mode 100644 cmake/BuildBinaries.cmake diff --git a/CMakeLists.txt b/CMakeLists.txt index adde09e1..8a2f4f2e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -93,11 +93,7 @@ set_target_properties(datamanagement PROPERTIES VERSION ${DATAMANAGEMENT_VERSION # --------------------------------------------------------------------------------------- # Build Tests # --------------------------------------------------------------------------------------- -if(DATAMANAGEMENT_BUILD_TESTS) - message(STATUS "Generating tests") - enable_testing() - add_subdirectory(tests) -endif() +include(cmake/BuildBinaries.cmake) # --------------------------------------------------------------------------------------- # Install diff --git a/CMakePresets.json b/CMakePresets.json index 208904bf..7f4a7551 100644 --- a/CMakePresets.json +++ b/CMakePresets.json @@ -8,69 +8,65 @@ "include": [], "configurePresets": [ { - "name": "linux-ninja", + "name": "configuration-common", + "description": "General Configuration Settings for All Configs", "hidden": true, - "displayName": "Linux Config", - "description": "Linux Config build using Ninja generator", "generator": "Ninja", "binaryDir": "${sourceDir}/build", - "cacheVariables": { - "DATAMANAGEMENT_BUILD_PIC": { - "type": "BOOL", - "value": "ON" - } - }, - "environment": {} + "installDir": "${sourceDir}/install" }, { - "name": "linux-ninja-debug", - "inherits": "linux-ninja", + "name": "configuration-common-linux", + "description": "Linux Configuration Settings for GCC and Clang", "hidden": true, + "inherits": "configuration-common", + "condition": { + "type": "equals", + "lhs": "${hostSystemName}", + "rhs": "Linux" + }, + "architecture": { + "value": "x64", + "strategy": "external" + }, + "toolset": { + "value": "host=x64", + "strategy": "external" + }, "cacheVariables": { - "CMAKE_BUILD_TYPE": { - "type": "STRING", - "value": "Debug" - } + "DATAMANAGEMENT_BUILD_PIC": "ON" } }, { - "name": "linux-ninja-release", - "inherits": "linux-ninja", - "hidden": true, + "name": "gcc-debug", + "displayName": "gcc Debug", + "description": "Target Linux with the GCC compiler, debug build type", + "inherits": "configuration-common-linux", "cacheVariables": { - "CMAKE_BUILD_TYPE": { - "type": "STRING", - "value": "Release" - } + "CMAKE_BUILD_TYPE": "Debug", + "DATAMANAGEMENT_BUILD_TESTS": "ON", + "DATAMANAGEMENT_CALCULATE_COVERAGE": "ON", + "DATAMANAGEMENT_INSTALL": "OFF" } }, { - "name": "linux-ninja-debug-tests", - "inherits": "linux-ninja-debug", + "name": "gcc-release", + "displayName": "gcc Release", + "description": "Target Linux with the GCC compiler, release build type", + "inherits": "configuration-common-linux", "cacheVariables": { - "DATAMANAGEMENT_BUILD_TESTS": { - "type": "BOOL", - "value": "ON" - }, - "DATAMANAGEMENT_CALCULATE_COVERAGE": { - "type": "BOOL", - "value": "ON" - } + "CMAKE_BUILD_TYPE": "Release", + "DATAMANAGEMENT_BUILD_TESTS": "OFF", + "DATAMANAGEMENT_CALCULATE_COVERAGE": "OFF", + "DATAMANAGEMENT_INSTALL": "ON" } } ], - "buildPresets": [ - { - "name": "default-library", - "configurePreset": "linux-ninja-release", - "jobs": 4 - } - ], "testPresets": [ { - "name": "default-test", - "configurePreset": "linux-ninja-debug-tests", - "configuration": "Debug", + "name": "test-common", + "description": "Settings for all tests", + "hidden": true, "output": { "verbosity": "verbose", "outputOnFailure": true @@ -79,12 +75,46 @@ "noTestsAction": "error", "stopOnFailure": true } + }, + { + "name": "gcc-debug", + "displayName": "Strict", + "description": "Enable output and stop on failure", + "inherits": "test-common", + "configurePreset": "gcc-debug" + }, + { + "name": "gcc-release", + "displayName": "Strict", + "description": "Enable output and stop on failure", + "inherits": "test-common", + "configurePreset": "gcc-release" + } + ], + "buildPresets": [ + { + "name": "gcc-release", + "configurePreset": "gcc-release", + "jobs": 8 + }, + { + "name": "gcc-install", + "configurePreset": "gcc-release", + "jobs": 8, + "targets": [ + "install" + ] + }, + { + "name": "gcc-debug", + "configurePreset": "gcc-debug", + "jobs": 8 } ], "packagePresets": [ { - "name": "default-package", - "configurePreset": "linux-ninja-release", + "name": "gcc-release", + "configurePreset": "gcc-release", "generators": [ "TGZ" ] @@ -92,23 +122,38 @@ ], "workflowPresets": [ { - "name": "default", + "description": "Developer Debugging workflow without installation", + "name": "gcc-debug", "steps": [ { "type": "configure", - "name": "linux-ninja-release" + "name": "gcc-debug" }, { "type": "build", - "name": "default-library" + "name": "gcc-debug" }, { "type": "test", - "name": "default-test" + "name": "gcc-debug" + } + ] + }, + { + "description": "Release workflow without tests", + "name": "gcc-release", + "steps": [ + { + "type": "configure", + "name": "gcc-release" + }, + { + "type": "build", + "name": "gcc-release" }, { "type": "package", - "name": "default-package" + "name": "gcc-release" } ] } diff --git a/cmake/BuildBinaries.cmake b/cmake/BuildBinaries.cmake new file mode 100644 index 00000000..1fa91093 --- /dev/null +++ b/cmake/BuildBinaries.cmake @@ -0,0 +1,9 @@ +if(DATAMANAGEMENT_BUILD_TESTS OR DATAMANAGEMENT_BUILD_ALL) + message(STATUS "Generating tests") + if(DATAMANAGEMENT_CALCULATE_COVERAGE) + message(STATUS "Calculating Code Coverage") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} --coverage") + endif() + enable_testing() + add_subdirectory(tests) +endif() \ No newline at end of file diff --git a/cmake/options.cmake b/cmake/options.cmake index fc96605e..977fcb60 100644 --- a/cmake/options.cmake +++ b/cmake/options.cmake @@ -4,5 +4,7 @@ option(DATAMANAGEMENT_BUILD_PIC "Build position independent code (-fPIC)" OFF) # testing options option(DATAMANAGEMENT_BUILD_TESTS "Build tests" OFF) +option(DATAMANAGEMENT_CALCULATE_COVERAGE "Build Coverage Files" OFF) + # install options option(DATAMANAGEMENT_INSTALL "Generate the install target" ${DATAMANAGEMENT_MASTER_PROJECT}) \ No newline at end of file From 6863c0fefee606878cdbe41ed833c2746f49c684 Mon Sep 17 00:00:00 2001 From: Matthew Carroll <28577806+MJC598@users.noreply.github.com> Date: Thu, 1 May 2025 08:27:38 -0400 Subject: [PATCH 2/3] Bumping version and updating CI files --- .github/workflows/coverage.yml | 53 +++++++++++++++++++ .../{clang_formatting.yml => formatting.yml} | 2 +- .../{build_release.yml => ubuntu-release.yml} | 17 ++---- .../{unit_testing.yml => ubuntu-testing.yml} | 15 +----- include/datamanagement/version.hpp | 4 +- 5 files changed, 63 insertions(+), 28 deletions(-) create mode 100644 .github/workflows/coverage.yml rename .github/workflows/{clang_formatting.yml => formatting.yml} (96%) rename .github/workflows/{build_release.yml => ubuntu-release.yml} (68%) rename .github/workflows/{unit_testing.yml => ubuntu-testing.yml} (69%) diff --git a/.github/workflows/coverage.yml b/.github/workflows/coverage.yml new file mode 100644 index 00000000..f46bd26a --- /dev/null +++ b/.github/workflows/coverage.yml @@ -0,0 +1,53 @@ +name: Code Coverage Results + +on: + push: + branches: [ "main" ] + pull_request: + branches: [ "main" ] + +jobs: + build: + name: ubuntu-latest, Debug + runs-on: ubuntu-latest + steps: + - name: Checkout Respond Repository + uses: actions/checkout@v4 + + - name: Install Boost + uses: MarkusJx/install-boost@v2.4.5 + id: install-boost + with: + boost_version: 1.86.0 + platform_version: 22.04 + + - name: Install Eigen3 + uses: kupns-aka-kupa/setup-eigen3@master + id: install-eigen3 + with: + version: 3.4.0 + env: + CMAKE_GENERATOR: Ninja + + - name: Configure Project + env: + BOOST_ROOT: ${{ steps.install-boost.outputs.BOOST_ROOT }} + EIGEN3_INCLUDE_DIR: ${{ steps.install-eigen3.outputs.EIGEN3_INCLUDE_DIR }} + EIGEN3_DIR: ${{ steps.install-eigen3.outputs.EIGEN3_DIR}} + run: cmake --workflow --preset gcc-debug + + - name: Check Test Coverage + uses: threeal/gcovr-action@v1.1.0 + with: + working-directory: ${{github.workspace}} + excludes: | + Eigen3/* + boost/* + gtest/* + googletest/* + build/* + fail-under-line: 80 + html-out: coverage.html + html-details: true + html-title: TESPOND Test Coverage Report + html-theme: github.green \ No newline at end of file diff --git a/.github/workflows/clang_formatting.yml b/.github/workflows/formatting.yml similarity index 96% rename from .github/workflows/clang_formatting.yml rename to .github/workflows/formatting.yml index ff0010ed..2fba4624 100644 --- a/.github/workflows/clang_formatting.yml +++ b/.github/workflows/formatting.yml @@ -1,4 +1,4 @@ -name: clang-format Check +name: Code Formatting on: push: branches: '*' diff --git a/.github/workflows/build_release.yml b/.github/workflows/ubuntu-release.yml similarity index 68% rename from .github/workflows/build_release.yml rename to .github/workflows/ubuntu-release.yml index c30610d2..bc76aa6a 100644 --- a/.github/workflows/build_release.yml +++ b/.github/workflows/ubuntu-release.yml @@ -1,4 +1,4 @@ -name: Build and Upload Static Release +name: Ubuntu Static Library Release on: release: @@ -13,17 +13,13 @@ env: jobs: build: - strategy: - matrix: - os: [ubuntu-latest] name: Build Release - runs-on: ${{ matrix.os }} + runs-on: 'ubuntu-latest' steps: - name: Checkout uses: actions/checkout@v4 - name: Ubuntu Install Boost - if: ${{ matrix.os == 'ubuntu-latest' }} uses: MarkusJx/install-boost@v2.4.5 id: install-boost with: @@ -34,20 +30,17 @@ jobs: # Configure CMake in a 'build' subdirectory. `CMAKE_BUILD_TYPE` is only required if you are using a single-configuration generator such as make. # See https://cmake.org/cmake/help/latest/variable/CMAKE_BUILD_TYPE.html?highlight=cmake_build_type run: | - cmake -B ${{github.workspace}}/build -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} -DBUILD_SHARED_LIBS=OFF + cmake --workflow --preset gcc-release env: BOOST_ROOT: ${{ steps.install-boost.outputs.BOOST_ROOT }} - - name: Build - # Build your program with the given configuration - run: cmake --build ${{github.workspace}}/build --config ${{env.BUILD_TYPE}} - - name: Get Latest Release Tag id: get-latest-release uses: ddbaptiste/get-latest-release@v1.0.0 - name: Release and Upload - run: gh release upload ${{ steps.get-latest-release.outputs.latest-release }} libDataManagement.a include/DataManagerBase.hpp include/DataManager.hpp + working-directory: ${{github.workspace}}/build + run: gh release upload ${{ steps.get-latest-release.outputs.latest-release }} datamanagement-1.1.0-Linux.tar.gz env: GITHUB_TOKEN: ${{ github.TOKEN }} shell: bash diff --git a/.github/workflows/unit_testing.yml b/.github/workflows/ubuntu-testing.yml similarity index 69% rename from .github/workflows/unit_testing.yml rename to .github/workflows/ubuntu-testing.yml index 54d0e17b..9556ecae 100644 --- a/.github/workflows/unit_testing.yml +++ b/.github/workflows/ubuntu-testing.yml @@ -1,4 +1,4 @@ -name: Cross Platform Testing +name: Ubuntu Unit Testing on: push: @@ -29,19 +29,8 @@ jobs: - name: Install GTest Ubuntu run: sudo apt-get install libgtest-dev - - name: Create Build Directory - run: mkdir build - - name: Configure CMake working-directory: ${{github.workspace}}/build - run: cmake .. -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} -DBUILD_TESTS=ON -DBUILD_SHARED_LIBS=OFF -DDATAMANAGEMENT_INSTALL=OFF + run: cmake --workflow --preset gcc-debug env: BOOST_ROOT: ${{ steps.install-boost.outputs.BOOST_ROOT }} - - - name: Build Project - working-directory: ${{github.workspace}}/build - run: cmake --build . - - - name: Run Tests - working-directory: ${{github.workspace}}/build - run: tests/dataTests diff --git a/include/datamanagement/version.hpp b/include/datamanagement/version.hpp index 8df79302..5a5b266d 100644 --- a/include/datamanagement/version.hpp +++ b/include/datamanagement/version.hpp @@ -4,7 +4,7 @@ // Created Date: Th Feb 2025 // // Author: Matthew Carroll // // ----- // -// Last Modified: Thu Feb 20 2025 // +// Last Modified: 2025-05-01 // // Modified By: Matthew Carroll // // ----- // // Copyright (c) 2025 Syndemics Lab at Boston Medical Center // @@ -18,7 +18,7 @@ #define DATAMANAGEMENT_VERSION_HPP_ #define DATAMANAGEMENT_VER_MAJOR 1 -#define DATAMANAGEMENT_VER_MINOR 15 +#define DATAMANAGEMENT_VER_MINOR 1 #define DATAMANAGEMENT_VER_PATCH 0 #define DATAMANAGEMENT_TO_VERSION(major, minor, patch) \ From 47b5dc1358411527fb90cf902111e392a55f3bd9 Mon Sep 17 00:00:00 2001 From: Matthew Carroll <28577806+MJC598@users.noreply.github.com> Date: Thu, 1 May 2025 08:37:38 -0400 Subject: [PATCH 3/3] Adding upload and addressing CI build issue with tests --- .github/workflows/coverage.yml | 9 +++++++-- .github/workflows/ubuntu-testing.yml | 12 +++++++++++- 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/.github/workflows/coverage.yml b/.github/workflows/coverage.yml index f46bd26a..495ae59a 100644 --- a/.github/workflows/coverage.yml +++ b/.github/workflows/coverage.yml @@ -1,4 +1,4 @@ -name: Code Coverage Results +name: Code Coverage on: push: @@ -50,4 +50,9 @@ jobs: html-out: coverage.html html-details: true html-title: TESPOND Test Coverage Report - html-theme: github.green \ No newline at end of file + html-theme: github.green + - name: Upload Code Coverage Results + uses: actions/upload-artifact@v4 + with: + name: coverage + path: ${{github.workspace}}/coverage.html \ No newline at end of file diff --git a/.github/workflows/ubuntu-testing.yml b/.github/workflows/ubuntu-testing.yml index 9556ecae..a1708cb4 100644 --- a/.github/workflows/ubuntu-testing.yml +++ b/.github/workflows/ubuntu-testing.yml @@ -25,12 +25,22 @@ jobs: boost_version: 1.84.0 platform_version: 22.04 toolset: 'gcc' + + - name: Install Eigen3 + uses: kupns-aka-kupa/setup-eigen3@master + id: install-eigen3 + with: + version: 3.4.0 + env: + CMAKE_GENERATOR: Ninja - name: Install GTest Ubuntu run: sudo apt-get install libgtest-dev - name: Configure CMake - working-directory: ${{github.workspace}}/build + working-directory: ${{github.workspace}} run: cmake --workflow --preset gcc-debug env: BOOST_ROOT: ${{ steps.install-boost.outputs.BOOST_ROOT }} + EIGEN3_INCLUDE_DIR: ${{ steps.install-eigen3.outputs.EIGEN3_INCLUDE_DIR }} + EIGEN3_DIR: ${{ steps.install-eigen3.outputs.EIGEN3_DIR}}