From 8897a70ff8d68ab73ac54188347669fce21e7802 Mon Sep 17 00:00:00 2001 From: 4c3y Date: Thu, 6 Mar 2025 13:09:09 +0100 Subject: [PATCH 1/9] Use custom docker container to decrease build time --- .github/workflows/cpp_ubuntu20_04.yml | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/.github/workflows/cpp_ubuntu20_04.yml b/.github/workflows/cpp_ubuntu20_04.yml index 07c46be..8273da0 100644 --- a/.github/workflows/cpp_ubuntu20_04.yml +++ b/.github/workflows/cpp_ubuntu20_04.yml @@ -16,7 +16,11 @@ jobs: rosdistro: ['noetic'] gcc: ['8', '9', '10', '11', '13'] cxx: ['11', '14', '17', '20'] - container: ros:${{ matrix.rosdistro }}-ros-base-focal + container: + image: ${{ secrets.DOCKER_USERNAME }}/ubuntu-omav-ros:ros-noetic-ros-base + credentials: + username: ${{ secrets.DOCKER_USERNAME }} + password: ${{ secrets.DOCKER_PASSWORD }} name: ROS ${{ matrix.rosdistro }} - GCC ${{ matrix.gcc }} - C++${{ matrix.cxx }} steps: - uses: actions/checkout@v4 @@ -26,17 +30,12 @@ jobs: 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/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 }} && gcc --version && g++ --version - - - 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: Switch GCC version + run: | + update-alternatives --set gcc /usr/bin/gcc-${{ matrix.gcc_version }} + update-alternatives --set g++ /usr/bin/g++-${{ matrix.gcc_version }} + gcc --version + g++ --version - name: Build lpp run: source /opt/ros/${{ matrix.rosdistro }}/setup.bash && catkin build -DCMAKE_C_COMPILER=/usr/bin/gcc -DCMAKE_CXX_COMPILER=/usr/bin/g++ -DCMAKE_CXX_STANDARD=${{ matrix.cxx }} -DLPP_BUILD_TESTS=1 lpp && source ${GITHUB_WORKSPACE}/catkin_ws/devel/setup.bash From 48b1a3338d2369031151ee8dca6acfd92f725b48 Mon Sep 17 00:00:00 2001 From: 4c3y Date: Thu, 6 Mar 2025 13:11:08 +0100 Subject: [PATCH 2/9] fix indentation --- .github/workflows/cpp_ubuntu20_04.yml | 40 +++++++++++++-------------- 1 file changed, 20 insertions(+), 20 deletions(-) diff --git a/.github/workflows/cpp_ubuntu20_04.yml b/.github/workflows/cpp_ubuntu20_04.yml index 8273da0..d2c94f6 100644 --- a/.github/workflows/cpp_ubuntu20_04.yml +++ b/.github/workflows/cpp_ubuntu20_04.yml @@ -9,13 +9,13 @@ on: jobs: build: - runs-on: [self-hosted, linux] + runs-on: [ self-hosted, linux ] strategy: fail-fast: false matrix: - rosdistro: ['noetic'] - gcc: ['8', '9', '10', '11', '13'] - cxx: ['11', '14', '17', '20'] + rosdistro: [ 'noetic' ] + gcc: [ '8', '9', '10', '11', '13' ] + cxx: [ '11', '14', '17', '20' ] container: image: ${{ secrets.DOCKER_USERNAME }}/ubuntu-omav-ros:ros-noetic-ros-base credentials: @@ -23,26 +23,26 @@ jobs: password: ${{ secrets.DOCKER_PASSWORD }} name: ROS ${{ matrix.rosdistro }} - GCC ${{ matrix.gcc }} - C++${{ matrix.cxx }} steps: - - uses: actions/checkout@v4 - name: Checkout lpp - with: - repository: ethz-asl/lpp - token: ${{ secrets.PAT }} - path: catkin_ws/src/lpp + - uses: actions/checkout@v4 + name: Checkout lpp + with: + repository: ethz-asl/lpp + token: ${{ secrets.PAT }} + path: catkin_ws/src/lpp - - name: Switch GCC version - run: | + - name: Switch GCC version + run: | update-alternatives --set gcc /usr/bin/gcc-${{ matrix.gcc_version }} update-alternatives --set g++ /usr/bin/g++-${{ matrix.gcc_version }} gcc --version g++ --version - - name: Build lpp - run: source /opt/ros/${{ matrix.rosdistro }}/setup.bash && catkin build -DCMAKE_C_COMPILER=/usr/bin/gcc -DCMAKE_CXX_COMPILER=/usr/bin/g++ -DCMAKE_CXX_STANDARD=${{ matrix.cxx }} -DLPP_BUILD_TESTS=1 lpp && source ${GITHUB_WORKSPACE}/catkin_ws/devel/setup.bash - working-directory: catkin_ws - shell: bash + - name: Build lpp + run: source /opt/ros/${{ matrix.rosdistro }}/setup.bash && catkin build -DCMAKE_C_COMPILER=/usr/bin/gcc -DCMAKE_CXX_COMPILER=/usr/bin/g++ -DCMAKE_CXX_STANDARD=${{ matrix.cxx }} -DLPP_BUILD_TESTS=1 lpp && source ${GITHUB_WORKSPACE}/catkin_ws/devel/setup.bash + working-directory: catkin_ws + shell: bash - - name: Run unittests - run: source /opt/ros/${{ matrix.rosdistro }}/setup.bash && source ${GITHUB_WORKSPACE}/catkin_ws/devel/setup.bash && rosrun lpp test_lpp && rosrun lpp test_glog && rosrun lpp test_lpp_custom && rosrun lpp test_nolog && rosrun lpp test_default && rosrun lpp test_roslog - working-directory: catkin_ws - shell: bash + - name: Run unittests + run: source /opt/ros/${{ matrix.rosdistro }}/setup.bash && source ${GITHUB_WORKSPACE}/catkin_ws/devel/setup.bash && rosrun lpp test_lpp && rosrun lpp test_glog && rosrun lpp test_lpp_custom && rosrun lpp test_nolog && rosrun lpp test_default && rosrun lpp test_roslog + working-directory: catkin_ws + shell: bash From 086174627632522add9cc03cf8a84340ac7b9d6e Mon Sep 17 00:00:00 2001 From: 4c3y Date: Thu, 6 Mar 2025 13:12:42 +0100 Subject: [PATCH 3/9] fix image value --- .github/workflows/cpp_ubuntu20_04.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/cpp_ubuntu20_04.yml b/.github/workflows/cpp_ubuntu20_04.yml index d2c94f6..84aa9cc 100644 --- a/.github/workflows/cpp_ubuntu20_04.yml +++ b/.github/workflows/cpp_ubuntu20_04.yml @@ -17,7 +17,7 @@ jobs: gcc: [ '8', '9', '10', '11', '13' ] cxx: [ '11', '14', '17', '20' ] container: - image: ${{ secrets.DOCKER_USERNAME }}/ubuntu-omav-ros:ros-noetic-ros-base + image: omavteam/ubuntu-omav-ros:ros-noetic-ros-base credentials: username: ${{ secrets.DOCKER_USERNAME }} password: ${{ secrets.DOCKER_PASSWORD }} From 55889347a63081841a751ed2b0150e126e72ee35 Mon Sep 17 00:00:00 2001 From: 4c3y Date: Thu, 6 Mar 2025 13:14:13 +0100 Subject: [PATCH 4/9] Fix matrix.gcc --- .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 84aa9cc..323e3de 100644 --- a/.github/workflows/cpp_ubuntu20_04.yml +++ b/.github/workflows/cpp_ubuntu20_04.yml @@ -32,8 +32,8 @@ jobs: - name: Switch GCC version run: | - update-alternatives --set gcc /usr/bin/gcc-${{ matrix.gcc_version }} - update-alternatives --set g++ /usr/bin/g++-${{ matrix.gcc_version }} + update-alternatives --set gcc /usr/bin/gcc-${{ matrix.gcc }} + update-alternatives --set g++ /usr/bin/g++-${{ matrix.gcc}} gcc --version g++ --version From 668a37765141dab87d536660cf5a6e906c432bed Mon Sep 17 00:00:00 2001 From: 4c3y Date: Thu, 6 Mar 2025 13:27:07 +0100 Subject: [PATCH 5/9] Merge coverage_report.yml and deploy_coverage_report.yml --- .github/workflows/coverage_report.yml | 58 -------------------- .github/workflows/deploy_coverage_report.yml | 29 +++++----- 2 files changed, 15 insertions(+), 72 deletions(-) delete mode 100644 .github/workflows/coverage_report.yml diff --git a/.github/workflows/coverage_report.yml b/.github/workflows/coverage_report.yml deleted file mode 100644 index 5df9c21..0000000 --- a/.github/workflows/coverage_report.yml +++ /dev/null @@ -1,58 +0,0 @@ -name: Generate coverage report -on: - pull_request: - branches: - - "master" - push: - branches: - - "master" - -jobs: - build: - 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: source /opt/ros/${{ matrix.rosdistro }}/setup.bash && mkdir build && cd build && cmake .. -DCMAKE_BUILD_TYPE="Debug" -DENABLE_COVERAGE=1 -DLPP_BUILD_TESTS=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: Print coverage - run: gcovr - working-directory: catkin_ws/src/lpp - - - diff --git a/.github/workflows/deploy_coverage_report.yml b/.github/workflows/deploy_coverage_report.yml index e8b83d0..b7368f1 100644 --- a/.github/workflows/deploy_coverage_report.yml +++ b/.github/workflows/deploy_coverage_report.yml @@ -1,5 +1,8 @@ name: Coverage report on: + pull_request: + branches: + - "master" push: branches: - "master" @@ -17,7 +20,11 @@ jobs: rosdistro: ['noetic'] gcc: ['10'] cxx: ['17'] - container: ros:${{ matrix.rosdistro }}-ros-base-focal + container: + image: omavteam/ubuntu-omav-ros:ros-noetic-ros-base + credentials: + username: ${{ secrets.DOCKER_USERNAME }} + password: ${{ secrets.DOCKER_PASSWORD }} permissions: pages: write # to deploy to Pages id-token: write # to verify the deployment originates from an appropriate source @@ -29,23 +36,11 @@ jobs: 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 -DLPP_BUILD_TESTS=1 && make + run: source /opt/ros/${{ matrix.rosdistro }}/setup.bash && mkdir build && cd build && cmake .. -DCMAKE_BUILD_TYPE="Debug" -DENABLE_COVERAGE=1 -DLPP_BUILD_TESTS=1 working-directory: catkin_ws/src/lpp shell: bash @@ -58,14 +53,20 @@ jobs: run: make coverage working-directory: catkin_ws/src/lpp/build + - name: Print coverage + run: gcovr + working-directory: catkin_ws/src/lpp + - name: Upload artifact uses: actions/upload-pages-artifact@v3 with: path: ./catkin_ws/src/lpp/build/coverage + if: ${{ github.ref == 'refs/heads/master' }} - name: Deploy to Github pages uses: actions/deploy-pages@v4 id: deployment + if: ${{ github.ref == 'refs/heads/master' }} From 4c0510843cb0e6b05ca5338564250c7a34c96b71 Mon Sep 17 00:00:00 2001 From: 4c3y Date: Thu, 6 Mar 2025 13:31:35 +0100 Subject: [PATCH 6/9] Revert because of protection rules and change to custom container in coverage_report.yml and deploy_coverage_report.yml --- .github/workflows/coverage_report.yml | 50 ++++++++++++++++++++ .github/workflows/deploy_coverage_report.yml | 11 +---- 2 files changed, 51 insertions(+), 10 deletions(-) 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..2762154 --- /dev/null +++ b/.github/workflows/coverage_report.yml @@ -0,0 +1,50 @@ +name: Generate coverage report +on: + pull_request: + branches: + - "master" + push: + branches: + - "master" + +jobs: + build: + runs-on: [self-hosted, linux] + strategy: + fail-fast: false + matrix: + rosdistro: ['noetic'] + gcc: ['10'] + cxx: ['17'] + container: + image: omavteam/ubuntu-omav-ros:ros-noetic-ros-base + credentials: + username: ${{ secrets.DOCKER_USERNAME }} + password: ${{ secrets.DOCKER_PASSWORD }} + steps: + - uses: actions/checkout@v3 + name: Checkout lpp + with: + repository: ethz-asl/lpp + token: ${{ secrets.PAT }} + path: catkin_ws/src/lpp + + - 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 -DLPP_BUILD_TESTS=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: Print coverage + run: gcovr + working-directory: catkin_ws/src/lpp + + + diff --git a/.github/workflows/deploy_coverage_report.yml b/.github/workflows/deploy_coverage_report.yml index b7368f1..2732fcc 100644 --- a/.github/workflows/deploy_coverage_report.yml +++ b/.github/workflows/deploy_coverage_report.yml @@ -1,8 +1,5 @@ name: Coverage report on: - pull_request: - branches: - - "master" push: branches: - "master" @@ -40,7 +37,7 @@ jobs: 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 -DLPP_BUILD_TESTS=1 + run: source /opt/ros/${{ matrix.rosdistro }}/setup.bash && mkdir build && cd build && cmake .. -DCMAKE_BUILD_TYPE="Debug" -DENABLE_COVERAGE=1 -DLPP_BUILD_TESTS=1 && make working-directory: catkin_ws/src/lpp shell: bash @@ -53,20 +50,14 @@ jobs: run: make coverage working-directory: catkin_ws/src/lpp/build - - name: Print coverage - run: gcovr - working-directory: catkin_ws/src/lpp - - name: Upload artifact uses: actions/upload-pages-artifact@v3 with: path: ./catkin_ws/src/lpp/build/coverage - if: ${{ github.ref == 'refs/heads/master' }} - name: Deploy to Github pages uses: actions/deploy-pages@v4 id: deployment - if: ${{ github.ref == 'refs/heads/master' }} From bbb36413a7eee49ca0bf5f151d3dead1337ae838 Mon Sep 17 00:00:00 2001 From: 4c3y Date: Thu, 6 Mar 2025 13:46:10 +0100 Subject: [PATCH 7/9] apt update before installing gcovr --- .github/workflows/coverage_report.yml | 2 +- .github/workflows/deploy_coverage_report.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/coverage_report.yml b/.github/workflows/coverage_report.yml index 2762154..03f6a42 100644 --- a/.github/workflows/coverage_report.yml +++ b/.github/workflows/coverage_report.yml @@ -30,7 +30,7 @@ jobs: path: catkin_ws/src/lpp - name: Install gcovr - run: sudo apt install -y gcovr + run: sudo apt update && 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 -DLPP_BUILD_TESTS=1 && make diff --git a/.github/workflows/deploy_coverage_report.yml b/.github/workflows/deploy_coverage_report.yml index 2732fcc..ec6d3e0 100644 --- a/.github/workflows/deploy_coverage_report.yml +++ b/.github/workflows/deploy_coverage_report.yml @@ -34,7 +34,7 @@ jobs: path: catkin_ws/src/lpp - name: Install gcovr - run: sudo apt install -y gcovr + run: sudo apt update && 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 -DLPP_BUILD_TESTS=1 && make From f2b44c6aea816e6c8040ded167f4ac1cdc117d5e Mon Sep 17 00:00:00 2001 From: 4c3y Date: Thu, 6 Mar 2025 14:24:59 +0100 Subject: [PATCH 8/9] Disable -Werror for coverage builds --- CMakeLists.txt | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 484f7a0..026b267 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -11,7 +11,11 @@ endif () # Set standard of top level project or C++17 if (NOT DEFINED CMAKE_CXX_STANDARD) set(CMAKE_CXX_STANDARD 17) - add_definitions(-Wall -Wextra -Wpedantic -Werror -Wno-unknown-pragmas) + if (ENABLE_COVERAGE) # Do not enable -Werror for coverage builds + add_definitions(-Wall -Wextra -Wpedantic -Wno-unknown-pragmas) + else () + add_definitions(-Wall -Wextra -Wpedantic -Werror -Wno-unknown-pragmas) + endif () else () set(CMAKE_CXX_STANDARD ${CMAKE_CXX_STANDARD}) endif () From 5f4d4a0dc8a4fd609453178665b4c4d1222f08e6 Mon Sep 17 00:00:00 2001 From: 4c3y Date: Thu, 10 Apr 2025 11:05:40 +0200 Subject: [PATCH 9/9] Remove PAT in CI --- .github/workflows/coverage_report.yml | 1 - .github/workflows/cpp_ubuntu20_04.yml | 1 - .github/workflows/deploy_coverage_report.yml | 1 - 3 files changed, 3 deletions(-) diff --git a/.github/workflows/coverage_report.yml b/.github/workflows/coverage_report.yml index 03f6a42..0c2acc9 100644 --- a/.github/workflows/coverage_report.yml +++ b/.github/workflows/coverage_report.yml @@ -26,7 +26,6 @@ jobs: name: Checkout lpp with: repository: ethz-asl/lpp - token: ${{ secrets.PAT }} path: catkin_ws/src/lpp - name: Install gcovr diff --git a/.github/workflows/cpp_ubuntu20_04.yml b/.github/workflows/cpp_ubuntu20_04.yml index 323e3de..d21434b 100644 --- a/.github/workflows/cpp_ubuntu20_04.yml +++ b/.github/workflows/cpp_ubuntu20_04.yml @@ -27,7 +27,6 @@ jobs: name: Checkout lpp with: repository: ethz-asl/lpp - token: ${{ secrets.PAT }} path: catkin_ws/src/lpp - name: Switch GCC version diff --git a/.github/workflows/deploy_coverage_report.yml b/.github/workflows/deploy_coverage_report.yml index ec6d3e0..51fb213 100644 --- a/.github/workflows/deploy_coverage_report.yml +++ b/.github/workflows/deploy_coverage_report.yml @@ -30,7 +30,6 @@ jobs: name: Checkout lpp with: repository: ethz-asl/lpp - token: ${{ secrets.PAT }} path: catkin_ws/src/lpp - name: Install gcovr