diff --git a/.github/workflows/BuildAndRun.yaml b/.github/workflows/BuildAndRun.yaml index 54a3945e0c6..1b344986866 100644 --- a/.github/workflows/BuildAndRun.yaml +++ b/.github/workflows/BuildAndRun.yaml @@ -68,7 +68,7 @@ jobs: - name: Resolve rosdep and install colcon mixin run: | apt-get update - apt-get install -y python3-pip python3-colcon-lcov-result lcov unzip + apt-get install -y python3-pip python3-colcon-lcov-result lcov unzip gcovr rosdep update --include-eol-distros rosdep install -iy --from-paths src --rosdistro ${{ matrix.rosdistro }} colcon mixin add default https://raw.githubusercontent.com/colcon/colcon-mixin-repository/master/index.yaml @@ -84,7 +84,14 @@ jobs: run: | source /opt/ros/${{ matrix.rosdistro }}/setup.bash build-wrapper-linux-x86-64 --out-dir src/scenario_simulator_v2/bw-output \ - colcon build --symlink-install --cmake-args -DCMAKE_BUILD_TYPE=${{ matrix.cmake_build_type }} -DBUILD_CPP_MOCK_SCENARIOS=ON -DBUILD_TESTING=true -DCMAKE_CXX_FLAGS='-fprofile-arcs -ftest-coverage' -DCMAKE_C_FLAGS='-fprofile-arcs -ftest-coverage' --packages-up-to ${{ steps.list_packages.outputs.package_list }} + colcon build --symlink-install \ + --cmake-args \ + -DCMAKE_BUILD_TYPE=${{ matrix.cmake_build_type }} \ + -DBUILD_CPP_MOCK_SCENARIOS=ON \ + -DBUILD_TESTING=true \ + -DCMAKE_CXX_FLAGS='-fprofile-arcs -ftest-coverage' \ + -DCMAKE_C_FLAGS='-fprofile-arcs -ftest-coverage' \ + --packages-up-to ${{ steps.list_packages.outputs.package_list }} shell: bash - name: Colcon test @@ -95,14 +102,8 @@ jobs: colcon lcov-result --packages-select ${{ steps.list_packages.outputs.package_list }} shell: bash - - name: Collect and run gcov on coverage data - run: | - mkdir -p ./gcov && \ - find ./build -name "*.gcda" -o -name "*.gcno" | \ - while read -r line; do \ - gcov -o $(dirname "$line") $(echo "$line" | sed 's/\.gcda$/.cpp/;s/\.gcno$/.cpp/;s/\.gcda$/.hpp/;s/\.gcno$/.hpp/'); \ - done && mv *.gcov ./gcov/ - + - name: generate gcov report for sonarcloud + run: gcovr -r src/scenario_simulator_v2 build --sonarqube coverage.xml - name: Show test result if: always() @@ -126,6 +127,13 @@ jobs: path: lcov retention-days: 1 + - name: Upload Gcov result + uses: actions/upload-artifact@v4 + with: + name: coverage${{ matrix.cmake_build_type }}.xml + path: coverage.xml + retention-days: 1 + - name: Run SonarCloud scan env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/custom_spell.json b/.github/workflows/custom_spell.json index c9c0c5841a9..676f628922b 100644 --- a/.github/workflows/custom_spell.json +++ b/.github/workflows/custom_spell.json @@ -18,6 +18,7 @@ "euclidian", "gcda", "gcno", + "gcovr", "libunwind", "linelint", "Mersenne", @@ -37,6 +38,8 @@ "pyproject", "randomizer", "randomizers", + "sonarcloud", + "sonarqube", "subspline", "TESTRANDOMIZER", "travelling", diff --git a/sonar-project.properties b/sonar-project.properties index f7a0a900525..edeb3632e2a 100644 --- a/sonar-project.properties +++ b/sonar-project.properties @@ -12,5 +12,5 @@ sonar.exclusions=**/test/**,**/mock/** # Encoding of the source code. Default is default system encoding sonar.sourceEncoding=UTF-8 -#~/scenario_simulator_ws/gcov -sonar.cfamily.gcov.reportsPath=../../gcov/ +#~/scenario_simulator_ws/coverage.xml +sonar.coverageReportPaths=../../coverage.xml