Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(sonar): sonar cloud coverage #1452

Merged
merged 5 commits into from
Nov 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 18 additions & 10 deletions .github/workflows/BuildAndRun.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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()
Expand All @@ -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 }}
Expand Down
3 changes: 3 additions & 0 deletions .github/workflows/custom_spell.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
"euclidian",
"gcda",
"gcno",
"gcovr",
"libunwind",
"linelint",
"Mersenne",
Expand All @@ -37,6 +38,8 @@
"pyproject",
"randomizer",
"randomizers",
"sonarcloud",
"sonarqube",
"subspline",
"TESTRANDOMIZER",
"travelling",
Expand Down
4 changes: 2 additions & 2 deletions sonar-project.properties
Original file line number Diff line number Diff line change
Expand Up @@ -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
Loading