diff --git a/.circleci/config.yml b/.circleci/config.yml index 9749d524e8d..b1a3aae3675 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -374,7 +374,7 @@ _steps: codecov_version=$(grep -o 'VERSION=\"[0-9\.]*\"' codecov | cut -d'"' -f2) shasum -a 512 -c <(curl -s "https://raw.githubusercontent.com/codecov/codecov-bash/${codecov_version}/SHA512SUM" | grep -w "codecov") bash codecov \ - -f "lcov/total_coverage.info" \ + -f "lcov/project_coverage.info" \ -R "src/navigation2" \ -F "project" \ -Z || echo 'Codecov upload failed' diff --git a/Dockerfile b/Dockerfile index 0523cbacc4d..37e72180997 100644 --- a/Dockerfile +++ b/Dockerfile @@ -63,7 +63,6 @@ RUN apt-get update && \ ros-$ROS_DISTRO-rmw-connextdds \ ros-$ROS_DISTRO-rmw-cyclonedds-cpp \ && pip3 install \ - fastcov \ git+https://github.com/ruffsl/colcon-cache.git@c1cedadc1ac6131fe825d075526ed4ae8e1b473c \ git+https://github.com/ruffsl/colcon-clean.git@87dee2dd1e47c2b97ac6d8300f76e3f607d19ef6 \ && rosdep update \ diff --git a/tools/code_coverage_report.bash b/tools/code_coverage_report.bash index ccc8220b91c..e836a3ed944 100755 --- a/tools/code_coverage_report.bash +++ b/tools/code_coverage_report.bash @@ -36,36 +36,64 @@ for opt in "$@" ; do done set -o xtrace -mkdir -p ${LCOVDIR} +mkdir -p $LCOVDIR -# Ignore certain packages: -# - messages, which are auto generated files -# - system tests, which are themselves all test artifacts -# - rviz plugins, which are not used for real navigation -INCLUDE_PACKAGES=$( - colcon list \ - --paths-only \ - --packages-ignore-regex \ - ".*_msgs" \ - ".*_tests" \ - ".*_rviz.*" \ - | xargs) +# Generate initial zero-coverage data. +# This adds files that were otherwise not run to the report +lcov --capture --initial \ + --directory build \ + --output-file ${LCOVDIR}/initial_coverage.info \ + --rc lcov_branch_coverage=0 # Capture executed code data. -fastcov \ - -d build \ - --exclude test/ \ - --include $INCLUDE_PACKAGES \ - --output ${LCOVDIR}/total_coverage.info --lcov +lcov --capture \ + --directory build \ + --output-file ${LCOVDIR}/test_coverage.info \ + --rc lcov_branch_coverage=0 + +# Combine the initial zero-coverage report with the executed lines report. +lcov \ + --add-tracefile ${LCOVDIR}/initial_coverage.info \ + --add-tracefile ${LCOVDIR}/test_coverage.info \ + --output-file ${LCOVDIR}/full_coverage.info \ + --rc lcov_branch_coverage=0 + +# Only include files that are within this workspace. +# (eg filter out stdio.h etc) +lcov \ + --extract ${LCOVDIR}/full_coverage.info \ + "${PWD}/*" \ + --output-file ${LCOVDIR}/workspace_coverage.info \ + --rc lcov_branch_coverage=0 + +# Remove files in the build subdirectory. +# Those are generated files (like messages, services, etc) +# And system tests, which are themselves all test artifacts +# And rviz plugins, which are not used for real navigation +lcov \ + --remove ${LCOVDIR}/workspace_coverage.info \ + "${PWD}/build/*" \ + --remove ${LCOVDIR}/workspace_coverage.info \ + "${PWD}/*/dwb_msgs/*" \ + --remove ${LCOVDIR}/workspace_coverage.info \ + "${PWD}/*/nav2_msgs/*" \ + --remove ${LCOVDIR}/workspace_coverage.info \ + "${PWD}/*/nav_2d_msgs/*" \ + --remove ${LCOVDIR}/workspace_coverage.info \ + "${PWD}/*/nav2_system_tests/*" \ + --remove ${LCOVDIR}/workspace_coverage.info \ + "${PWD}/*/nav2_rviz_plugins/*" \ + --output-file ${LCOVDIR}/project_coverage.info \ + --rc lcov_branch_coverage=0 if [ $COVERAGE_REPORT_VIEW = codecovio ]; then curl -s https://codecov.io/bash > codecov codecov_version=$(grep -o 'VERSION=\"[0-9\.]*\"' codecov | cut -d'"' -f2) shasum -a 512 -c <(curl -s "https://raw.githubusercontent.com/codecov/codecov-bash/${codecov_version}/SHA512SUM" | grep -w "codecov") bash codecov \ - -f ${LCOVDIR}/total_coverage.info \ + -f ${LCOVDIR}/project_coverage.info \ -R src/navigation2 elif [ $COVERAGE_REPORT_VIEW = genhtml ]; then - genhtml ${LCOVDIR}/total_coverage.info \ + genhtml ${LCOVDIR}/project_coverage.info \ --output-directory ${LCOVDIR}/html fi