Skip to content

Commit

Permalink
Revert "Use fastcov to speed up coverage for CI (#2391)"
Browse files Browse the repository at this point in the history
This reverts commit 2c9b2c9.
  • Loading branch information
ruffsl committed Jun 19, 2021
1 parent 0e7fad3 commit 9131dc2
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 22 deletions.
2 changes: 1 addition & 1 deletion .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down
1 change: 0 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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 \
Expand Down
68 changes: 48 additions & 20 deletions tools/code_coverage_report.bash
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit 9131dc2

Please sign in to comment.