From 009783e47aac6d46ae4be7b8acfc64536b880c9b Mon Sep 17 00:00:00 2001 From: 4c3y <69460051+4c3y@users.noreply.github.com> Date: Wed, 10 Jan 2024 18:26:50 +0100 Subject: [PATCH 01/20] Added code coverage flags in CMakeLists.txt --- CMakeLists.txt | 30 ++++++++++++++++++------------ 1 file changed, 18 insertions(+), 12 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 3ceecc3..3a589d4 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -85,9 +85,9 @@ if (GLOG_FOUND AND catkin_FOUND AND LPP_BUILD_TESTS) test/glog/test_glog_vlog.cc) target_include_directories(${GLOG_TESTS} PRIVATE ${LPP_INCLUDE_DIRECTORIES} test/glog) - target_link_libraries(${GLOG_TESTS} glog gtest ${catkin_LIBRARIES}) + target_link_libraries(${GLOG_TESTS} glog gtest ${catkin_LIBRARIES} gcov) target_compile_definitions(${GLOG_TESTS} PRIVATE MODE_GLOG) - target_compile_options(${GLOG_TESTS} PRIVATE "-fcompare-debug-second") + target_compile_options(${GLOG_TESTS} PRIVATE ${CMAKE_CXX_FLAGS} "-fprofile-arcs" "-ftest-coverage") ##### Log++ Tests ##### set(LPP_TESTS "test_lpp") @@ -101,9 +101,9 @@ if (GLOG_FOUND AND catkin_FOUND AND LPP_BUILD_TESTS) test/lpp/test_lpp_vlog.cc) target_include_directories(${LPP_TESTS} PRIVATE ${LPP_INCLUDE_DIRECTORIES} test/lpp) - target_link_libraries(${LPP_TESTS} glog gtest ${catkin_LIBRARIES}) + target_link_libraries(${LPP_TESTS} glog gtest ${catkin_LIBRARIES} gcov) target_compile_definitions(${LPP_TESTS} PRIVATE MODE_LPP) - target_compile_options(${LPP_TESTS} PRIVATE "-fcompare-debug-second") + target_compile_options(${LPP_TESTS} PRIVATE "-fprofile-arcs" "-ftest-coverage") ##### Log++ Custom Output Tests ##### set(LPP_TESTS_CUSTOM "test_lpp_custom") @@ -118,9 +118,9 @@ if (GLOG_FOUND AND catkin_FOUND AND LPP_BUILD_TESTS) test/lpp/custom/test_lpp_custom_vlog.cc) target_include_directories(${LPP_TESTS_CUSTOM} PRIVATE ${LPP_INCLUDE_DIRECTORIES} test/lpp) - target_link_libraries(${LPP_TESTS_CUSTOM} glog gtest ${catkin_LIBRARIES}) + target_link_libraries(${LPP_TESTS_CUSTOM} glog gtest ${catkin_LIBRARIES} gcov) target_compile_definitions(${LPP_TESTS_CUSTOM} PRIVATE MODE_LPP) - target_compile_options(${LPP_TESTS_CUSTOM} PRIVATE "-fcompare-debug-second") + target_compile_options(${LPP_TESTS_CUSTOM} PRIVATE "-fprofile-arcs" "-ftest-coverage") ##### Roslog Tests ##### set(ROSLOG_TESTS "test_roslog") @@ -134,9 +134,9 @@ if (GLOG_FOUND AND catkin_FOUND AND LPP_BUILD_TESTS) test/roslog/test_roslog_vlog.cc) target_include_directories(${ROSLOG_TESTS} PRIVATE ${LPP_INCLUDE_DIRECTORIES} test/roslog) - target_link_libraries(${ROSLOG_TESTS} glog gtest ${catkin_LIBRARIES}) + target_link_libraries(${ROSLOG_TESTS} glog gtest ${catkin_LIBRARIES} gcov) target_compile_definitions(${ROSLOG_TESTS} PRIVATE MODE_ROSLOG) - target_compile_options(${ROSLOG_TESTS} PRIVATE "-fcompare-debug-second") + target_compile_options(${ROSLOG_TESTS} PRIVATE "-fprofile-arcs" "-ftest-coverage") ##### Default Tests ##### set(DEFAULT_TESTS "test_default") @@ -153,9 +153,9 @@ if (GLOG_FOUND AND catkin_FOUND AND LPP_BUILD_TESTS) test/default/test_severity_conversions.cc) target_include_directories(${DEFAULT_TESTS} PRIVATE ${LPP_INCLUDE_DIRECTORIES} test/default) - target_link_libraries(${DEFAULT_TESTS} glog gtest ${catkin_LIBRARIES}) + target_link_libraries(${DEFAULT_TESTS} glog gtest ${catkin_LIBRARIES} gcov) target_compile_definitions(${DEFAULT_TESTS} PRIVATE MODE_DEFAULT) - target_compile_options(${DEFAULT_TESTS} PRIVATE "-fcompare-debug-second") + target_compile_options(${DEFAULT_TESTS} PRIVATE "-fprofile-arcs" "-ftest-coverage") ##### Nolog Tests ##### set(NOLOG_TESTS "test_nolog") @@ -171,7 +171,13 @@ if (GLOG_FOUND AND catkin_FOUND AND LPP_BUILD_TESTS) ) target_include_directories(${NOLOG_TESTS} PRIVATE ${LPP_INCLUDE_DIRECTORIES} test/nolog) - target_link_libraries(${NOLOG_TESTS} glog gtest ${catkin_LIBRARIES}) + target_link_libraries(${NOLOG_TESTS} glog gtest ${catkin_LIBRARIES} gcov) target_compile_definitions(${NOLOG_TESTS} PRIVATE MODE_NOLOG) - target_compile_options(${NOLOG_TESTS} PRIVATE "-fcompare-debug-second") + target_compile_options(${NOLOG_TESTS} PRIVATE "-fprofile-arcs" "-ftest-coverage") + + add_custom_target(coverage + COMMAND mkdir coverage && cd coverage && gcovr -r ${CMAKE_SOURCE_DIR} --html --html-details -o coverage.html + COMMENT "Generating coverage report" + WORKING_DIRECTORY ${CMAKE_BINARY_DIR} + ) endif () From 2699296413b80f9974074a74562d0e27f313694e Mon Sep 17 00:00:00 2001 From: 4c3y <69460051+4c3y@users.noreply.github.com> Date: Wed, 10 Jan 2024 18:31:40 +0100 Subject: [PATCH 02/20] Added coverage report workflow --- .github/workflows/coverage_report.yml | 64 +++++++++++++++++++++++++++ 1 file changed, 64 insertions(+) create mode 100644 .github/workflows/coverage_report.yml diff --git a/.github/workflows/coverage_report.yml b/.github/workflows/coverage_report.yml new file mode 100644 index 0000000..c43430c --- /dev/null +++ b/.github/workflows/coverage_report.yml @@ -0,0 +1,64 @@ +name: Coverage report +on: + push: + branches: + - "master" + - "feature/coverage" + +jobs: + deploy: + environment: + name: github-pages + url: ${{ steps.deployment.outputs.url }} + runs-on: [self-hosted, linux] + strategy: + fail-fast: false + matrix: + rosdistro: ['noetic'] + gcc: ['10'] + cxx: ['17'] + container: ros:${{ matrix.rosdistro }}-ros-base-focal + steps: + - uses: actions/checkout@v3 + name: Checkout lpp + with: + repository: ethz-asl/lpp + token: ${{ secrets.PAT }} + path: catkin_ws/src/lpp + + - name: Install newest git version + run: sudo apt update && sudo apt-get install -y software-properties-common && sudo add-apt-repository -y ppa:git-core/ppa && sudo apt-get update && sudo apt-get install -y git + + - name: Install GCC version ${{ matrix.gcc }} + run: sudo add-apt-repository ppa:ubuntu-toolchain-r/ppa -y && sudo apt update && sudo apt install -y gcc-${{ matrix.gcc }} g++-${{ matrix.gcc }} && sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-${{ matrix.gcc }} 100 --slave /usr/bin/g++ g++ /usr/bin/g++-${{ matrix.gcc }} + + - name: Install catkin tools + run: sudo apt install -y python3-rosdep python3-rosinstall python3-rosinstall-generator python3-wstool build-essential python3-catkin-tools + + - name: Install system dependencies + run: sudo apt install -y libgoogle-glog-dev + + - name: Install gcovr + run: sudo apt install -y gcovr + + - name: Build lpp + run: mkdir build && cd build && cmake .. -DCMAKE_BUILD_TYPE="Debug" -DENABLE_COVERAGE=1 && make + working-directory: catkin_ws/src/lpp + shell: bash + + - name: Run unittests + run: ./test_default && ./test_glog && ./test_lpp && ./test_lpp_custom && ./test_nolog && ./test_roslog + working-directory: catkin_ws/src/lpp/build/devel/lib/lpp + shell: bash + + - name: Generate coverage report + run: make coverage + working-directory: catkin_ws/src/lpp/build + + - name: Upload artifact + uses: actions/upload-pages-artifact@v3 + with: + path: ${{runner.temp}}/catkin_ws/src/lpp/build/coverage" + + + From 80d260a9c3f35176c20fcc34e20c5e1abccbcc6d Mon Sep 17 00:00:00 2001 From: 4c3y <69460051+4c3y@users.noreply.github.com> Date: Wed, 10 Jan 2024 18:44:31 +0100 Subject: [PATCH 03/20] Source ros in coverage_report.yml --- .github/workflows/coverage_report.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/coverage_report.yml b/.github/workflows/coverage_report.yml index c43430c..9084001 100644 --- a/.github/workflows/coverage_report.yml +++ b/.github/workflows/coverage_report.yml @@ -41,6 +41,9 @@ jobs: - name: Install gcovr run: sudo apt install -y gcovr + - name: Source ROS + run: source /opt/ros/${{ matrix.rosdistro }}/setup.bash + - name: Build lpp run: mkdir build && cd build && cmake .. -DCMAKE_BUILD_TYPE="Debug" -DENABLE_COVERAGE=1 && make working-directory: catkin_ws/src/lpp From edddd23fb0f56e0b22e90b44da6a5615103b6943 Mon Sep 17 00:00:00 2001 From: 4c3y <69460051+4c3y@users.noreply.github.com> Date: Wed, 10 Jan 2024 18:53:10 +0100 Subject: [PATCH 04/20] Use bash shell --- .github/workflows/coverage_report.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/coverage_report.yml b/.github/workflows/coverage_report.yml index 9084001..cc490f7 100644 --- a/.github/workflows/coverage_report.yml +++ b/.github/workflows/coverage_report.yml @@ -7,6 +7,7 @@ on: jobs: deploy: + name: Deploy coverage report environment: name: github-pages url: ${{ steps.deployment.outputs.url }} @@ -43,6 +44,8 @@ jobs: - name: Source ROS run: source /opt/ros/${{ matrix.rosdistro }}/setup.bash + working-directory: catkin_ws + shell: bash - name: Build lpp run: mkdir build && cd build && cmake .. -DCMAKE_BUILD_TYPE="Debug" -DENABLE_COVERAGE=1 && make From 12f740edc0c893e748e395fb3726666c6c8b8817 Mon Sep 17 00:00:00 2001 From: 4c3y <69460051+4c3y@users.noreply.github.com> Date: Wed, 10 Jan 2024 19:04:02 +0100 Subject: [PATCH 05/20] Merge source ROS with build step --- .github/workflows/coverage_report.yml | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/.github/workflows/coverage_report.yml b/.github/workflows/coverage_report.yml index cc490f7..5909a01 100644 --- a/.github/workflows/coverage_report.yml +++ b/.github/workflows/coverage_report.yml @@ -42,13 +42,8 @@ jobs: - name: Install gcovr run: sudo apt install -y gcovr - - name: Source ROS - run: source /opt/ros/${{ matrix.rosdistro }}/setup.bash - working-directory: catkin_ws - shell: bash - - name: Build lpp - run: mkdir build && cd build && cmake .. -DCMAKE_BUILD_TYPE="Debug" -DENABLE_COVERAGE=1 && make + run: source /opt/ros/${{ matrix.rosdistro }}/setup.bash && mkdir build && cd build && cmake .. -DCMAKE_BUILD_TYPE="Debug" -DENABLE_COVERAGE=1 && make working-directory: catkin_ws/src/lpp shell: bash From 6fca6ebabf42b874f02a1e97340f45cb2ad4cb6c Mon Sep 17 00:00:00 2001 From: 4c3y <69460051+4c3y@users.noreply.github.com> Date: Wed, 10 Jan 2024 19:04:55 +0100 Subject: [PATCH 06/20] Temporarily disabled CI matrix build --- .github/workflows/cpp_ubuntu20_04.yml | 3 --- 1 file changed, 3 deletions(-) diff --git a/.github/workflows/cpp_ubuntu20_04.yml b/.github/workflows/cpp_ubuntu20_04.yml index d588868..d64b6cb 100644 --- a/.github/workflows/cpp_ubuntu20_04.yml +++ b/.github/workflows/cpp_ubuntu20_04.yml @@ -1,8 +1,5 @@ name: lpp on: - pull_request: - branches: - - "master" push: branches: - "master" From 53a7ef564509543df8f633d12398562e783b81c9 Mon Sep 17 00:00:00 2001 From: 4c3y <69460051+4c3y@users.noreply.github.com> Date: Wed, 10 Jan 2024 19:09:38 +0100 Subject: [PATCH 07/20] Also source before building unittests without catkin --- .github/workflows/coverage_report.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/coverage_report.yml b/.github/workflows/coverage_report.yml index 5909a01..9c111fc 100644 --- a/.github/workflows/coverage_report.yml +++ b/.github/workflows/coverage_report.yml @@ -48,7 +48,7 @@ jobs: shell: bash - name: Run unittests - run: ./test_default && ./test_glog && ./test_lpp && ./test_lpp_custom && ./test_nolog && ./test_roslog + run: source /opt/ros/${{ matrix.rosdistro }}/setup.bash && ./test_default && ./test_glog && ./test_lpp && ./test_lpp_custom && ./test_nolog && ./test_roslog working-directory: catkin_ws/src/lpp/build/devel/lib/lpp shell: bash From 8f016da19b0b5c6d6209eb78af779ff2a1b1a38e Mon Sep 17 00:00:00 2001 From: 4c3y <69460051+4c3y@users.noreply.github.com> Date: Wed, 10 Jan 2024 19:17:29 +0100 Subject: [PATCH 08/20] Fixed relative path --- .github/workflows/coverage_report.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/coverage_report.yml b/.github/workflows/coverage_report.yml index 9c111fc..ec02da0 100644 --- a/.github/workflows/coverage_report.yml +++ b/.github/workflows/coverage_report.yml @@ -59,7 +59,7 @@ jobs: - name: Upload artifact uses: actions/upload-pages-artifact@v3 with: - path: ${{runner.temp}}/catkin_ws/src/lpp/build/coverage" + path: ${{runner.temp}}/../lpp/lpp/catkin_ws/src/lpp/build/coverage" From e911f588af217a5c595fef3f1f08cc92b0d23d21 Mon Sep 17 00:00:00 2001 From: 4c3y <69460051+4c3y@users.noreply.github.com> Date: Wed, 10 Jan 2024 19:27:45 +0100 Subject: [PATCH 09/20] test with default path --- .github/workflows/coverage_report.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/coverage_report.yml b/.github/workflows/coverage_report.yml index ec02da0..a9cb858 100644 --- a/.github/workflows/coverage_report.yml +++ b/.github/workflows/coverage_report.yml @@ -59,7 +59,7 @@ jobs: - name: Upload artifact uses: actions/upload-pages-artifact@v3 with: - path: ${{runner.temp}}/../lpp/lpp/catkin_ws/src/lpp/build/coverage" + path: . From 406a81d535be00a27a386ad69f83a832a1b592f8 Mon Sep 17 00:00:00 2001 From: 4c3y <69460051+4c3y@users.noreply.github.com> Date: Wed, 10 Jan 2024 19:32:21 +0100 Subject: [PATCH 10/20] Fixed artifact path --- .github/workflows/coverage_report.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/coverage_report.yml b/.github/workflows/coverage_report.yml index a9cb858..27e47a8 100644 --- a/.github/workflows/coverage_report.yml +++ b/.github/workflows/coverage_report.yml @@ -59,7 +59,7 @@ jobs: - name: Upload artifact uses: actions/upload-pages-artifact@v3 with: - path: . + path: ./catkin_ws/src/lpp/build/coverage From 41e1bcbbeb284390b3f7f4178c29817dc8ab1f58 Mon Sep 17 00:00:00 2001 From: 4c3y <69460051+4c3y@users.noreply.github.com> Date: Wed, 10 Jan 2024 20:01:27 +0100 Subject: [PATCH 11/20] Added Deploy to Github pages steps --- .github/workflows/coverage_report.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.github/workflows/coverage_report.yml b/.github/workflows/coverage_report.yml index 27e47a8..a9ed4bf 100644 --- a/.github/workflows/coverage_report.yml +++ b/.github/workflows/coverage_report.yml @@ -61,5 +61,9 @@ jobs: with: path: ./catkin_ws/src/lpp/build/coverage + - name: Deploy to Github pages + uses: actions/deploy-pages@v4 + id: deployment + From 510a02d4804e0020b47ecd2c4954d302f21e1b0b Mon Sep 17 00:00:00 2001 From: 4c3y <69460051+4c3y@users.noreply.github.com> Date: Wed, 10 Jan 2024 20:07:48 +0100 Subject: [PATCH 12/20] Fix permissions --- .github/workflows/coverage_report.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/coverage_report.yml b/.github/workflows/coverage_report.yml index a9ed4bf..e3129e2 100644 --- a/.github/workflows/coverage_report.yml +++ b/.github/workflows/coverage_report.yml @@ -19,6 +19,9 @@ jobs: gcc: ['10'] cxx: ['17'] container: ros:${{ matrix.rosdistro }}-ros-base-focal + permissions: + pages: write # to deploy to Pages + id-token: write # to verify the deployment originates from an appropriate source steps: - uses: actions/checkout@v3 name: Checkout lpp From bdb98f5b59801b13f8c263824b42f6a68b295102 Mon Sep 17 00:00:00 2001 From: 4c3y <69460051+4c3y@users.noreply.github.com> Date: Thu, 11 Jan 2024 00:11:02 +0100 Subject: [PATCH 13/20] Only deploy coverage report on push to master, added Print Coverage step --- .github/workflows/coverage_report.yml | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/.github/workflows/coverage_report.yml b/.github/workflows/coverage_report.yml index e3129e2..c960e39 100644 --- a/.github/workflows/coverage_report.yml +++ b/.github/workflows/coverage_report.yml @@ -55,16 +55,23 @@ jobs: working-directory: catkin_ws/src/lpp/build/devel/lib/lpp shell: bash + - name: Print coverage + run: gcovr + working-directory: catkin_ws/src/lpp + - name: Generate coverage report + if: github.ref == 'refs/heads/master' run: make coverage working-directory: catkin_ws/src/lpp/build - name: Upload artifact + if: github.ref == 'refs/heads/master' uses: actions/upload-pages-artifact@v3 with: path: ./catkin_ws/src/lpp/build/coverage - name: Deploy to Github pages + if: github.ref == 'refs/heads/master' uses: actions/deploy-pages@v4 id: deployment From 5fe0ba1c2b7b351c37a01a4a33f48a32871d0594 Mon Sep 17 00:00:00 2001 From: 4c3y <69460051+4c3y@users.noreply.github.com> Date: Thu, 11 Jan 2024 00:21:18 +0100 Subject: [PATCH 14/20] Moved coverage deployment to different workflow --- .github/workflows/coverage_report.yml | 25 ++----- .github/workflows/deploy_coverage_report.yml | 71 ++++++++++++++++++++ 2 files changed, 76 insertions(+), 20 deletions(-) create mode 100644 .github/workflows/deploy_coverage_report.yml diff --git a/.github/workflows/coverage_report.yml b/.github/workflows/coverage_report.yml index c960e39..76f17d4 100644 --- a/.github/workflows/coverage_report.yml +++ b/.github/workflows/coverage_report.yml @@ -1,13 +1,14 @@ -name: Coverage report on: + pull_request: + branches: + - "master" push: branches: - "master" - - "feature/coverage" jobs: - deploy: - name: Deploy coverage report + build: + name: Generate coverage report environment: name: github-pages url: ${{ steps.deployment.outputs.url }} @@ -59,21 +60,5 @@ jobs: run: gcovr working-directory: catkin_ws/src/lpp - - name: Generate coverage report - if: github.ref == 'refs/heads/master' - run: make coverage - working-directory: catkin_ws/src/lpp/build - - - name: Upload artifact - if: github.ref == 'refs/heads/master' - uses: actions/upload-pages-artifact@v3 - with: - path: ./catkin_ws/src/lpp/build/coverage - - - name: Deploy to Github pages - if: github.ref == 'refs/heads/master' - uses: actions/deploy-pages@v4 - id: deployment - diff --git a/.github/workflows/deploy_coverage_report.yml b/.github/workflows/deploy_coverage_report.yml new file mode 100644 index 0000000..2734c57 --- /dev/null +++ b/.github/workflows/deploy_coverage_report.yml @@ -0,0 +1,71 @@ +name: Coverage report +on: + push: + branches: + - "master" + +jobs: + deploy: + name: Deploy coverage report + environment: + name: github-pages + url: ${{ steps.deployment.outputs.url }} + runs-on: [self-hosted, linux] + strategy: + fail-fast: false + matrix: + rosdistro: ['noetic'] + gcc: ['10'] + cxx: ['17'] + container: ros:${{ matrix.rosdistro }}-ros-base-focal + permissions: + pages: write # to deploy to Pages + id-token: write # to verify the deployment originates from an appropriate source + steps: + - uses: actions/checkout@v3 + name: Checkout lpp + with: + repository: ethz-asl/lpp + token: ${{ secrets.PAT }} + path: catkin_ws/src/lpp + + - name: Install newest git version + run: sudo apt update && sudo apt-get install -y software-properties-common && sudo add-apt-repository -y ppa:git-core/ppa && sudo apt-get update && sudo apt-get install -y git + + - name: Install GCC version ${{ matrix.gcc }} + run: sudo add-apt-repository ppa:ubuntu-toolchain-r/ppa -y && sudo apt update && sudo apt install -y gcc-${{ matrix.gcc }} g++-${{ matrix.gcc }} && sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-${{ matrix.gcc }} 100 --slave /usr/bin/g++ g++ /usr/bin/g++-${{ matrix.gcc }} + + - name: Install catkin tools + run: sudo apt install -y python3-rosdep python3-rosinstall python3-rosinstall-generator python3-wstool build-essential python3-catkin-tools + + - name: Install system dependencies + run: sudo apt install -y libgoogle-glog-dev + + - name: Install gcovr + run: sudo apt install -y gcovr + + - name: Build lpp + run: source /opt/ros/${{ matrix.rosdistro }}/setup.bash && mkdir build && cd build && cmake .. -DCMAKE_BUILD_TYPE="Debug" -DENABLE_COVERAGE=1 && make + working-directory: catkin_ws/src/lpp + shell: bash + + - name: Run unittests + run: source /opt/ros/${{ matrix.rosdistro }}/setup.bash && ./test_default && ./test_glog && ./test_lpp && ./test_lpp_custom && ./test_nolog && ./test_roslog + working-directory: catkin_ws/src/lpp/build/devel/lib/lpp + shell: bash + + - name: Generate coverage report + run: make coverage + working-directory: catkin_ws/src/lpp/build + + - name: Upload artifact + uses: actions/upload-pages-artifact@v3 + with: + path: ./catkin_ws/src/lpp/build/coverage + + - name: Deploy to Github pages + uses: actions/deploy-pages@v4 + id: deployment + + + From 04c5ff3f892d0a4eb16b0f7478903405c8a54129 Mon Sep 17 00:00:00 2001 From: 4c3y <69460051+4c3y@users.noreply.github.com> Date: Thu, 11 Jan 2024 00:22:02 +0100 Subject: [PATCH 15/20] Removed environment and permissions --- .github/workflows/coverage_report.yml | 6 ------ 1 file changed, 6 deletions(-) diff --git a/.github/workflows/coverage_report.yml b/.github/workflows/coverage_report.yml index 76f17d4..7e6b230 100644 --- a/.github/workflows/coverage_report.yml +++ b/.github/workflows/coverage_report.yml @@ -9,9 +9,6 @@ on: jobs: build: name: Generate coverage report - environment: - name: github-pages - url: ${{ steps.deployment.outputs.url }} runs-on: [self-hosted, linux] strategy: fail-fast: false @@ -20,9 +17,6 @@ jobs: gcc: ['10'] cxx: ['17'] container: ros:${{ matrix.rosdistro }}-ros-base-focal - permissions: - pages: write # to deploy to Pages - id-token: write # to verify the deployment originates from an appropriate source steps: - uses: actions/checkout@v3 name: Checkout lpp From 24114db480707eec09a0b2006e4945a3777a1e22 Mon Sep 17 00:00:00 2001 From: 4c3y <69460051+4c3y@users.noreply.github.com> Date: Thu, 11 Jan 2024 00:23:02 +0100 Subject: [PATCH 16/20] Fixed name in coverage_report.yml --- .github/workflows/coverage_report.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/coverage_report.yml b/.github/workflows/coverage_report.yml index 7e6b230..2c623a4 100644 --- a/.github/workflows/coverage_report.yml +++ b/.github/workflows/coverage_report.yml @@ -1,3 +1,4 @@ +name: Generate coverage report on: pull_request: branches: @@ -8,7 +9,6 @@ on: jobs: build: - name: Generate coverage report runs-on: [self-hosted, linux] strategy: fail-fast: false From 4cdcc28cd68fd394e62d5f0f3e727a1fbbf2a9c3 Mon Sep 17 00:00:00 2001 From: 4c3y <69460051+4c3y@users.noreply.github.com> Date: Thu, 11 Jan 2024 00:23:58 +0100 Subject: [PATCH 17/20] Re-enabled CI matrix build --- .github/workflows/cpp_ubuntu20_04.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/cpp_ubuntu20_04.yml b/.github/workflows/cpp_ubuntu20_04.yml index d64b6cb..d588868 100644 --- a/.github/workflows/cpp_ubuntu20_04.yml +++ b/.github/workflows/cpp_ubuntu20_04.yml @@ -1,5 +1,8 @@ name: lpp on: + pull_request: + branches: + - "master" push: branches: - "master" From 9274ea29f244e645c82b4ffb3c69b69aee1e8c57 Mon Sep 17 00:00:00 2001 From: 4c3y <69460051+4c3y@users.noreply.github.com> Date: Thu, 11 Jan 2024 00:32:55 +0100 Subject: [PATCH 18/20] Added badge and link to code coverage report --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index f71b551..ef4bee5 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,7 @@ # Log++ Logging framework +[![lpp](https://github.com/ethz-asl/lpp/actions/workflows/cpp_ubuntu20_04.yml/badge.svg)](https://github.com/ethz-asl/lpp/actions/workflows/cpp_ubuntu20_04.yml) +[Latest Code Coverage Report](https://ethz-asl.github.io/lpp/coverage.html) (master branch) ![](docs/Log++.svg) *** From d09bcc2ed122349dfee6c2c284fa48ce6804cbe0 Mon Sep 17 00:00:00 2001 From: 4c3y <69460051+4c3y@users.noreply.github.com> Date: Thu, 11 Jan 2024 00:47:35 +0100 Subject: [PATCH 19/20] Added enable coverage switch in CMakeLists.txt --- CMakeLists.txt | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 3a589d4..25b6377 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -6,6 +6,13 @@ if (${CMAKE_PROJECT_NAME} STREQUAL ${PROJECT_NAME}) set(LPP_BUILD_TESTS 1) endif () +if (ENABLE_COVERAGE) + set(LPP_TEST_CXX_FLAGS ${CMAKE_CXX_FLAGS} -g -O0 -fprofile-arcs -ftest-coverage) + message(STATUS "Coverage enabled") +else () + set(LPP_TEST_CXX_FLAGS ${CMAKE_CXX_FLAGS} -fcompare-debug-second) +endif () + # Set standard of top level project or C++17 if (NOT DEFINED CMAKE_CXX_STANDARD) set(CMAKE_CXX_STANDARD 17) @@ -87,7 +94,7 @@ if (GLOG_FOUND AND catkin_FOUND AND LPP_BUILD_TESTS) target_include_directories(${GLOG_TESTS} PRIVATE ${LPP_INCLUDE_DIRECTORIES} test/glog) target_link_libraries(${GLOG_TESTS} glog gtest ${catkin_LIBRARIES} gcov) target_compile_definitions(${GLOG_TESTS} PRIVATE MODE_GLOG) - target_compile_options(${GLOG_TESTS} PRIVATE ${CMAKE_CXX_FLAGS} "-fprofile-arcs" "-ftest-coverage") + target_compile_options(${GLOG_TESTS} PRIVATE ${LPP_TEST_CXX_FLAGS}) ##### Log++ Tests ##### set(LPP_TESTS "test_lpp") @@ -103,7 +110,7 @@ if (GLOG_FOUND AND catkin_FOUND AND LPP_BUILD_TESTS) target_include_directories(${LPP_TESTS} PRIVATE ${LPP_INCLUDE_DIRECTORIES} test/lpp) target_link_libraries(${LPP_TESTS} glog gtest ${catkin_LIBRARIES} gcov) target_compile_definitions(${LPP_TESTS} PRIVATE MODE_LPP) - target_compile_options(${LPP_TESTS} PRIVATE "-fprofile-arcs" "-ftest-coverage") + target_compile_options(${LPP_TESTS} PRIVATE ${LPP_TEST_CXX_FLAGS}) ##### Log++ Custom Output Tests ##### set(LPP_TESTS_CUSTOM "test_lpp_custom") @@ -120,7 +127,7 @@ if (GLOG_FOUND AND catkin_FOUND AND LPP_BUILD_TESTS) target_include_directories(${LPP_TESTS_CUSTOM} PRIVATE ${LPP_INCLUDE_DIRECTORIES} test/lpp) target_link_libraries(${LPP_TESTS_CUSTOM} glog gtest ${catkin_LIBRARIES} gcov) target_compile_definitions(${LPP_TESTS_CUSTOM} PRIVATE MODE_LPP) - target_compile_options(${LPP_TESTS_CUSTOM} PRIVATE "-fprofile-arcs" "-ftest-coverage") + target_compile_options(${LPP_TESTS_CUSTOM} PRIVATE ${LPP_TEST_CXX_FLAGS}) ##### Roslog Tests ##### set(ROSLOG_TESTS "test_roslog") @@ -136,7 +143,7 @@ if (GLOG_FOUND AND catkin_FOUND AND LPP_BUILD_TESTS) target_include_directories(${ROSLOG_TESTS} PRIVATE ${LPP_INCLUDE_DIRECTORIES} test/roslog) target_link_libraries(${ROSLOG_TESTS} glog gtest ${catkin_LIBRARIES} gcov) target_compile_definitions(${ROSLOG_TESTS} PRIVATE MODE_ROSLOG) - target_compile_options(${ROSLOG_TESTS} PRIVATE "-fprofile-arcs" "-ftest-coverage") + target_compile_options(${ROSLOG_TESTS} PRIVATE ${LPP_TEST_CXX_FLAGS}) ##### Default Tests ##### set(DEFAULT_TESTS "test_default") @@ -155,7 +162,7 @@ if (GLOG_FOUND AND catkin_FOUND AND LPP_BUILD_TESTS) target_include_directories(${DEFAULT_TESTS} PRIVATE ${LPP_INCLUDE_DIRECTORIES} test/default) target_link_libraries(${DEFAULT_TESTS} glog gtest ${catkin_LIBRARIES} gcov) target_compile_definitions(${DEFAULT_TESTS} PRIVATE MODE_DEFAULT) - target_compile_options(${DEFAULT_TESTS} PRIVATE "-fprofile-arcs" "-ftest-coverage") + target_compile_options(${DEFAULT_TESTS} PRIVATE ${LPP_TEST_CXX_FLAGS}) ##### Nolog Tests ##### set(NOLOG_TESTS "test_nolog") @@ -173,7 +180,7 @@ if (GLOG_FOUND AND catkin_FOUND AND LPP_BUILD_TESTS) target_include_directories(${NOLOG_TESTS} PRIVATE ${LPP_INCLUDE_DIRECTORIES} test/nolog) target_link_libraries(${NOLOG_TESTS} glog gtest ${catkin_LIBRARIES} gcov) target_compile_definitions(${NOLOG_TESTS} PRIVATE MODE_NOLOG) - target_compile_options(${NOLOG_TESTS} PRIVATE "-fprofile-arcs" "-ftest-coverage") + target_compile_options(${NOLOG_TESTS} PRIVATE ${LPP_TEST_CXX_FLAGS}) add_custom_target(coverage COMMAND mkdir coverage && cd coverage && gcovr -r ${CMAKE_SOURCE_DIR} --html --html-details -o coverage.html From a63e5512c7386525b263a7ec1d1ce4fdceefd718 Mon Sep 17 00:00:00 2001 From: 4c3y <69460051+4c3y@users.noreply.github.com> Date: Thu, 11 Jan 2024 00:56:44 +0100 Subject: [PATCH 20/20] Added GCC version 11 --- .github/workflows/cpp_ubuntu20_04.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/cpp_ubuntu20_04.yml b/.github/workflows/cpp_ubuntu20_04.yml index d588868..96857c3 100644 --- a/.github/workflows/cpp_ubuntu20_04.yml +++ b/.github/workflows/cpp_ubuntu20_04.yml @@ -14,7 +14,7 @@ jobs: fail-fast: false matrix: rosdistro: ['noetic'] - gcc: ['8', '9', '10'] + gcc: ['8', '9', '10', '11'] cxx: ['11', '14', '17'] container: ros:${{ matrix.rosdistro }}-ros-base-focal name: ROS ${{ matrix.rosdistro }} - GCC ${{ matrix.gcc }} - C++${{ matrix.cxx }} @@ -30,7 +30,7 @@ jobs: run: sudo apt update && sudo apt-get install -y software-properties-common && sudo add-apt-repository -y ppa:git-core/ppa && sudo apt-get update && sudo apt-get install -y git - name: Install GCC version ${{ matrix.gcc }} - run: sudo add-apt-repository ppa:ubuntu-toolchain-r/ppa -y && sudo apt update && sudo apt install -y gcc-${{ matrix.gcc }} g++-${{ matrix.gcc }} && sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-${{ matrix.gcc }} 100 --slave /usr/bin/g++ g++ /usr/bin/g++-${{ matrix.gcc }} + run: sudo add-apt-repository ppa:ubuntu-toolchain-r/test -y && sudo apt update && sudo apt install -y gcc-${{ matrix.gcc }} g++-${{ matrix.gcc }} && sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-${{ matrix.gcc }} 100 --slave /usr/bin/g++ g++ /usr/bin/g++-${{ matrix.gcc }} - name: Install catkin tools run: sudo apt install -y python3-rosdep python3-rosinstall python3-rosinstall-generator python3-wstool build-essential python3-catkin-tools