From 12e56ac68e8860f589eba28c8001c4b38cf0736c Mon Sep 17 00:00:00 2001 From: Carl Delsey Date: Fri, 1 Feb 2019 14:43:17 -0800 Subject: [PATCH 01/25] Script to generate coverage report. Should be run after test. --- tools/codecoveragereport.bash | 37 +++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100755 tools/codecoveragereport.bash diff --git a/tools/codecoveragereport.bash b/tools/codecoveragereport.bash new file mode 100755 index 0000000000..5d9bfb8d22 --- /dev/null +++ b/tools/codecoveragereport.bash @@ -0,0 +1,37 @@ +#!/bin/bash + +if [ ! -d build ]; then + echo "Please run this script from the root of your workspace." + echo "Expected directory hierarchy is:" + echo "example_ws" + echo " - build" + echo " - - package_a" + echo " - - package_b" + exit 1 +fi + +set -e + +LCOVDIR=lcov +PWD=`pwd` + +REPORT_COMMAND="genhtml ${LCOVDIR}/projectcoverage.info --output-directory ${LCOVDIR}/html --branch-coverage -p ${PWD}" + +for opt in "$@" ; do + case "$opt" in + clean) + rm -rf install build log $LCOVDIR + exit 0 + ;; + codecovio) + REPORT_COMMAND="bash <(curl -s https://codecov.io/bash) -f ${LCOVDIR}/projectcoverage.info" + ;; + esac +done + +mkdir $LCOVDIR +lcov -c --initial --rc lcov_branch_coverage=1 --directory build --output-file ${LCOVDIR}/initialcoverage.info +lcov -c --rc lcov_branch_coverage=1 --directory build --output-file ${LCOVDIR}/testcoverage.info +lcov -a ${LCOVDIR}/initialcoverage.info -a ${LCOVDIR}/testcoverage.info --rc lcov_branch_coverage=1 --o ${LCOVDIR}/fullcoverage.info +lcov -e ${LCOVDIR}/fullcoverage.info "${PWD}/*" --rc lcov_branch_coverage=1 --output-file ${LCOVDIR}/projectcoverage.info +$REPORT_COMMAND From 857ba30022bd1e44f030781f4ce870c80526b436 Mon Sep 17 00:00:00 2001 From: Carl Delsey Date: Fri, 1 Feb 2019 14:53:22 -0800 Subject: [PATCH 02/25] Add helper script for test suite --- tools/runtestsuite.bash | 9 +++++++++ 1 file changed, 9 insertions(+) create mode 100755 tools/runtestsuite.bash diff --git a/tools/runtestsuite.bash b/tools/runtestsuite.bash new file mode 100755 index 0000000000..3cece7dba2 --- /dev/null +++ b/tools/runtestsuite.bash @@ -0,0 +1,9 @@ +#!/bin/bash + +set -ex + +colcon test --packages-skip nav2_system_tests +colcon test-result --verbose +cp src/navigation2/tools/ctest_retry.bash build/nav2_system_tests +cd build/nav2_system_tests +./ctest_retry.bash 3 From ac4fe7f610541faf16243b93f8e7dd89ef253ccf Mon Sep 17 00:00:00 2001 From: Carl Delsey Date: Fri, 1 Feb 2019 16:31:36 -0800 Subject: [PATCH 03/25] Modified travis to use runtestsuite.bash script --- .travis.yml | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/.travis.yml b/.travis.yml index cac16bd303..53a0567848 100644 --- a/.travis.yml +++ b/.travis.yml @@ -26,22 +26,16 @@ before_install: - if [ "${TRAVIS_REPO_SLUG}" != "ros-planning/navigation2" ]; then echo "Travis CI is supported only in ros-planning/navigation2" && exit 1; fi + +script: - docker build --tag navigation2:latest --build-arg PULLREQ=$TRAVIS_PULL_REQUEST --build-arg CMAKE_BUILD_TYPE ./ - -script: - docker run --rm --detach --name nav2_bash navigation2:latest sleep infinity - docker exec --interactive --tty nav2_bash /ros_entrypoint.sh - colcon test --packages-skip nav2_system_tests - - docker exec --interactive --tty nav2_bash /ros_entrypoint.sh - colcon test-result --verbose - - docker exec --interactive --tty nav2_bash /ros_entrypoint.sh - cp src/navigation2/tools/ctest_retry.bash build/nav2_system_tests - - docker exec --interactive --tty nav2_bash /ros_entrypoint.sh - bash -c "cd build/nav2_system_tests ; ./ctest_retry.bash 3" + src/navigation2/tools/runtestsuite.bash after_success: - if [ "$TRAVIS_BRANCH" == "master" ] && [ "$TRAVIS_PULL_REQUEST" == "false" ]; then From a8e772f5ed8fdefe3ea9db5bca64bbf375782142 Mon Sep 17 00:00:00 2001 From: Carl Delsey Date: Fri, 1 Feb 2019 16:39:37 -0800 Subject: [PATCH 04/25] Add coverage to .travis.yml file. --- .travis.yml | 28 +++++++++++-------- ...ereport.bash => code_coverage_report.bash} | 0 ...{runtestsuite.bash => run_test_suite.bash} | 0 3 files changed, 16 insertions(+), 12 deletions(-) rename tools/{codecoveragereport.bash => code_coverage_report.bash} (100%) rename tools/{runtestsuite.bash => run_test_suite.bash} (100%) diff --git a/.travis.yml b/.travis.yml index 53a0567848..f8fdbd4577 100644 --- a/.travis.yml +++ b/.travis.yml @@ -19,14 +19,26 @@ notifications: - carl.r.delsey@intel.com - matthew.k.hansen@intel.com -env: - - CMAKE_BUILD_TYPE=Release - before_install: - if [ "${TRAVIS_REPO_SLUG}" != "ros-planning/navigation2" ]; then echo "Travis CI is supported only in ros-planning/navigation2" && exit 1; fi +matrix: + include: + - env: CMAKE_BUILD_TYPE=Release + after_success: + - if [ "$TRAVIS_BRANCH" == "master" ] && [ "$TRAVIS_PULL_REQUEST" == "false" ]; then + echo "Successfully built! Deploying container..." + docker login -u $DOCKER_USERNAME -p $DOCKER_PASSWORD ; + docker tag navigation2:latest stevemacenski/navigation2:latest + docker push stevemacenski/navigation2:latest ; + fi + + - env: CMAKE_BUILD_TYPE=Debug COVERAGE_ARGS='--build-arg -DCMAKE_CXX_FLAGS=--coverage -DCMAKE_C_FLAGS=--coverage -DCMAKE_EXE_LINKER_FLAGS=--coverage -DCMAKE_SHARED_LINKER_FLAGS=--coverage' + after_success: + - src/navigation2/tools/code_coverage_report.bash codecovio + script: - docker build --tag navigation2:latest --build-arg PULLREQ=$TRAVIS_PULL_REQUEST @@ -35,12 +47,4 @@ script: - docker run --rm --detach --name nav2_bash navigation2:latest sleep infinity - docker exec --interactive --tty nav2_bash /ros_entrypoint.sh - src/navigation2/tools/runtestsuite.bash - -after_success: - - if [ "$TRAVIS_BRANCH" == "master" ] && [ "$TRAVIS_PULL_REQUEST" == "false" ]; then - echo "Successfully built! Deploying container..." - docker login -u $DOCKER_USERNAME -p $DOCKER_PASSWORD ; - docker tag navigation2:latest stevemacenski/navigation2:latest - docker push stevemacenski/navigation2:latest ; - fi + src/navigation2/tools/run_test_suite.bash diff --git a/tools/codecoveragereport.bash b/tools/code_coverage_report.bash similarity index 100% rename from tools/codecoveragereport.bash rename to tools/code_coverage_report.bash diff --git a/tools/runtestsuite.bash b/tools/run_test_suite.bash similarity index 100% rename from tools/runtestsuite.bash rename to tools/run_test_suite.bash From f7a28df77c18f54e8dfc637fba6ce89f50d6c469 Mon Sep 17 00:00:00 2001 From: Carl Delsey Date: Fri, 1 Feb 2019 16:50:29 -0800 Subject: [PATCH 05/25] Add coverage badge to main page --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index ec094f7346..4904fab1ae 100644 --- a/README.md +++ b/README.md @@ -10,6 +10,8 @@ ROS2 Navigation System [![Pulls](https://shields.beevelop.com/docker/pulls/stevemacenski/navigation2.svg?style=flat-square)](https://hub.docker.com/r/stevemacenski/navigation2) +[![codecov](https://codecov.io/gh/ros-planning/navigation2/branch/master/graph/badge.svg)](https://codecov.io/gh/ros-planning/navigation2) + # Overview The ROS 2 Navigation System is the control system that enables a robot to autonomously reach a goal state, such as a specific position and orientation relative to a specific map. Given a current pose, a map, and a goal, such as a destination pose, the navigation system generates a plan to reach the goal, and outputs commands to autonomously drive the robot, respecting any safety constraints and avoiding obstacles encountered along the way. From d0d826411a773fa4a452dd1735f7841d6d3925de Mon Sep 17 00:00:00 2001 From: Carl Delsey Date: Fri, 1 Feb 2019 18:52:43 -0800 Subject: [PATCH 06/25] Run the code coverage report in the docker container. --- .travis.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index f8fdbd4577..650a1fc30a 100644 --- a/.travis.yml +++ b/.travis.yml @@ -37,7 +37,8 @@ matrix: - env: CMAKE_BUILD_TYPE=Debug COVERAGE_ARGS='--build-arg -DCMAKE_CXX_FLAGS=--coverage -DCMAKE_C_FLAGS=--coverage -DCMAKE_EXE_LINKER_FLAGS=--coverage -DCMAKE_SHARED_LINKER_FLAGS=--coverage' after_success: - - src/navigation2/tools/code_coverage_report.bash codecovio + - docker exec --interactive --tty -e CODECOV_TOKEN nav2_bash /ros_entrypoint.sh + src/navigation2/tools/code_coverage_report.bash codecovio script: - docker build --tag navigation2:latest From aa7678300c20e0005eb721407a1d9453cf274ce8 Mon Sep 17 00:00:00 2001 From: Carl Delsey Date: Sat, 2 Feb 2019 15:17:16 -0800 Subject: [PATCH 07/25] Add lcov dependency. --- .travis.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.travis.yml b/.travis.yml index 650a1fc30a..a6f8ccb28c 100644 --- a/.travis.yml +++ b/.travis.yml @@ -37,6 +37,8 @@ matrix: - env: CMAKE_BUILD_TYPE=Debug COVERAGE_ARGS='--build-arg -DCMAKE_CXX_FLAGS=--coverage -DCMAKE_C_FLAGS=--coverage -DCMAKE_EXE_LINKER_FLAGS=--coverage -DCMAKE_SHARED_LINKER_FLAGS=--coverage' after_success: + - docker exec --interactive --tty -e CODECOV_TOKEN nav2_bash /ros_entrypoint.sh + apt-get -y install lcov - docker exec --interactive --tty -e CODECOV_TOKEN nav2_bash /ros_entrypoint.sh src/navigation2/tools/code_coverage_report.bash codecovio From 3d7165308f7240c5119f53e6a64c6cfa0c8c6d68 Mon Sep 17 00:00:00 2001 From: Carl Delsey Date: Sat, 2 Feb 2019 15:55:35 -0800 Subject: [PATCH 08/25] Trying to add lcov tool to build. --- .travis.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index a6f8ccb28c..82ad1d78e9 100644 --- a/.travis.yml +++ b/.travis.yml @@ -37,8 +37,8 @@ matrix: - env: CMAKE_BUILD_TYPE=Debug COVERAGE_ARGS='--build-arg -DCMAKE_CXX_FLAGS=--coverage -DCMAKE_C_FLAGS=--coverage -DCMAKE_EXE_LINKER_FLAGS=--coverage -DCMAKE_SHARED_LINKER_FLAGS=--coverage' after_success: - - docker exec --interactive --tty -e CODECOV_TOKEN nav2_bash /ros_entrypoint.sh - apt-get -y install lcov + - docker exec --interactive --tty -e CODECOV_TOKEN nav2_bash bash -c + "apt-get update ; apt-get -y install lcov" - docker exec --interactive --tty -e CODECOV_TOKEN nav2_bash /ros_entrypoint.sh src/navigation2/tools/code_coverage_report.bash codecovio From 0b38026319f2ca4c8069c473eaea39970a535a86 Mon Sep 17 00:00:00 2001 From: Carl Delsey Date: Sat, 2 Feb 2019 16:31:04 -0800 Subject: [PATCH 09/25] Add coverage args to build script. --- .travis.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.travis.yml b/.travis.yml index 82ad1d78e9..33993ac16c 100644 --- a/.travis.yml +++ b/.travis.yml @@ -46,6 +46,7 @@ script: - docker build --tag navigation2:latest --build-arg PULLREQ=$TRAVIS_PULL_REQUEST --build-arg CMAKE_BUILD_TYPE + $COVERAGE_ARGS ./ - docker run --rm --detach --name nav2_bash navigation2:latest sleep infinity From 4225761fae6512866b072e28ef09d8c127f32eb5 Mon Sep 17 00:00:00 2001 From: Carl Delsey Date: Sat, 2 Feb 2019 17:26:28 -0800 Subject: [PATCH 10/25] Fixing passing code coverage args. --- .travis.yml | 6 +++--- Dockerfile | 8 +++++++- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/.travis.yml b/.travis.yml index 33993ac16c..23f3a39357 100644 --- a/.travis.yml +++ b/.travis.yml @@ -26,7 +26,7 @@ before_install: matrix: include: - - env: CMAKE_BUILD_TYPE=Release + - env: CMAKE_BUILD_TYPE=Release COVERAGE_ENABLED=False after_success: - if [ "$TRAVIS_BRANCH" == "master" ] && [ "$TRAVIS_PULL_REQUEST" == "false" ]; then echo "Successfully built! Deploying container..." @@ -35,7 +35,7 @@ matrix: docker push stevemacenski/navigation2:latest ; fi - - env: CMAKE_BUILD_TYPE=Debug COVERAGE_ARGS='--build-arg -DCMAKE_CXX_FLAGS=--coverage -DCMAKE_C_FLAGS=--coverage -DCMAKE_EXE_LINKER_FLAGS=--coverage -DCMAKE_SHARED_LINKER_FLAGS=--coverage' + - env: CMAKE_BUILD_TYPE=Debug COVERAGE_ENABLED=True after_success: - docker exec --interactive --tty -e CODECOV_TOKEN nav2_bash bash -c "apt-get update ; apt-get -y install lcov" @@ -46,7 +46,7 @@ script: - docker build --tag navigation2:latest --build-arg PULLREQ=$TRAVIS_PULL_REQUEST --build-arg CMAKE_BUILD_TYPE - $COVERAGE_ARGS + --build-arg COVERAGE_ENABLED ./ - docker run --rm --detach --name nav2_bash navigation2:latest sleep infinity diff --git a/Dockerfile b/Dockerfile index 1e586704b1..fb5c6f037f 100644 --- a/Dockerfile +++ b/Dockerfile @@ -48,11 +48,17 @@ RUN . /opt/ros/$ROS_DISTRO/setup.sh && \ # build dependency package source ARG CMAKE_BUILD_TYPE=Release +ARG COVERAGE_ENABLED=False +if [ "$COVERAGE_ENABLED" = "True" ]; \ + then \ + ENV COVERAGE_ARGS='-DCMAKE_CXX_FLAGS=--coverage -DCMAKE_C_FLAGS=--coverage -DCMAKE_EXE_LINKER_FLAGS=--coverage -DCMAKE_SHARED_LINKER_FLAGS=--coverage' ; \ + fi + RUN . /opt/ros/$ROS_DISTRO/setup.sh && \ colcon build \ --symlink-install \ --cmake-args \ - -DCMAKE_BUILD_TYPE=$CMAKE_BUILD_TYPE + -DCMAKE_BUILD_TYPE=$CMAKE_BUILD_TYPE $COVERAGE_ARGS # install navigation2 package dependencies WORKDIR $NAV2_WS From 9d436231e86840357effba39a99621895515bbc4 Mon Sep 17 00:00:00 2001 From: Carl Delsey Date: Sat, 2 Feb 2019 18:26:43 -0800 Subject: [PATCH 11/25] Fixing setting env variable. --- Dockerfile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Dockerfile b/Dockerfile index fb5c6f037f..7b7b492176 100644 --- a/Dockerfile +++ b/Dockerfile @@ -49,9 +49,9 @@ RUN . /opt/ros/$ROS_DISTRO/setup.sh && \ # build dependency package source ARG CMAKE_BUILD_TYPE=Release ARG COVERAGE_ENABLED=False -if [ "$COVERAGE_ENABLED" = "True" ]; \ +RUN if [ "$COVERAGE_ENABLED" = "True" ]; \ then \ - ENV COVERAGE_ARGS='-DCMAKE_CXX_FLAGS=--coverage -DCMAKE_C_FLAGS=--coverage -DCMAKE_EXE_LINKER_FLAGS=--coverage -DCMAKE_SHARED_LINKER_FLAGS=--coverage' ; \ + export COVERAGE_ARGS='-DCMAKE_CXX_FLAGS=--coverage -DCMAKE_C_FLAGS=--coverage -DCMAKE_EXE_LINKER_FLAGS=--coverage -DCMAKE_SHARED_LINKER_FLAGS=--coverage' ; \ fi RUN . /opt/ros/$ROS_DISTRO/setup.sh && \ From ad95353f4442a631b3dab903d2be2254fe0ade62 Mon Sep 17 00:00:00 2001 From: Carl Delsey Date: Sat, 2 Feb 2019 23:47:54 -0800 Subject: [PATCH 12/25] Fixing docker file coverage_enabled flag. --- Dockerfile | 29 ++++++++++++++++++----------- 1 file changed, 18 insertions(+), 11 deletions(-) diff --git a/Dockerfile b/Dockerfile index 7b7b492176..2fd23c002c 100644 --- a/Dockerfile +++ b/Dockerfile @@ -48,17 +48,12 @@ RUN . /opt/ros/$ROS_DISTRO/setup.sh && \ # build dependency package source ARG CMAKE_BUILD_TYPE=Release -ARG COVERAGE_ENABLED=False -RUN if [ "$COVERAGE_ENABLED" = "True" ]; \ - then \ - export COVERAGE_ARGS='-DCMAKE_CXX_FLAGS=--coverage -DCMAKE_C_FLAGS=--coverage -DCMAKE_EXE_LINKER_FLAGS=--coverage -DCMAKE_SHARED_LINKER_FLAGS=--coverage' ; \ - fi RUN . /opt/ros/$ROS_DISTRO/setup.sh && \ colcon build \ --symlink-install \ --cmake-args \ - -DCMAKE_BUILD_TYPE=$CMAKE_BUILD_TYPE $COVERAGE_ARGS + -DCMAKE_BUILD_TYPE=$CMAKE_BUILD_TYPE # install navigation2 package dependencies WORKDIR $NAV2_WS @@ -73,11 +68,23 @@ RUN . $ROS_WS/install/setup.sh && \ # build navigation2 package source RUN rm $NAV2_WS/src/navigation2/nav2_system_tests/COLCON_IGNORE -RUN . $ROS_WS/install/setup.sh && \ - colcon build \ - --symlink-install \ - --cmake-args \ - -DCMAKE_BUILD_TYPE=$CMAKE_BUILD_TYPE +ARG COVERAGE_ENABLED=False +RUN if [ "$COVERAGE_ENABLED" = "True" ]; \ + then \ + . $ROS_WS/install/setup.sh && \ + colcon build \ + --symlink-install \ + --cmake-args \ + -DCMAKE_BUILD_TYPE=$CMAKE_BUILD_TYPE -DCMAKE_CXX_FLAGS=--coverage \ + -DCMAKE_C_FLAGS=--coverage -DCMAKE_EXE_LINKER_FLAGS=--coverage \ + -DCMAKE_SHARED_LINKER_FLAGS=--coverage ; \ + else \ + . $ROS_WS/install/setup.sh && \ + colcon build \ + --symlink-install \ + --cmake-args \ + -DCMAKE_BUILD_TYPE=$CMAKE_BUILD_TYPE ; \ + fi # source navigation2 workspace from entrypoint RUN sed --in-place \ From a48a7b5fb46d3d6da19984ca4b98ccec1772f98a Mon Sep 17 00:00:00 2001 From: Carl Delsey Date: Sun, 3 Feb 2019 01:07:53 -0800 Subject: [PATCH 13/25] Fixing coverage report script. --- tools/code_coverage_report.bash | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/tools/code_coverage_report.bash b/tools/code_coverage_report.bash index 5d9bfb8d22..b14b2786ee 100755 --- a/tools/code_coverage_report.bash +++ b/tools/code_coverage_report.bash @@ -15,7 +15,7 @@ set -e LCOVDIR=lcov PWD=`pwd` -REPORT_COMMAND="genhtml ${LCOVDIR}/projectcoverage.info --output-directory ${LCOVDIR}/html --branch-coverage -p ${PWD}" +COVERAGE_REPORT=genhtml for opt in "$@" ; do case "$opt" in @@ -24,14 +24,18 @@ for opt in "$@" ; do exit 0 ;; codecovio) - REPORT_COMMAND="bash <(curl -s https://codecov.io/bash) -f ${LCOVDIR}/projectcoverage.info" + COVERAGE_REPORT=codecovio ;; esac done -mkdir $LCOVDIR +mkdir -p $LCOVDIR lcov -c --initial --rc lcov_branch_coverage=1 --directory build --output-file ${LCOVDIR}/initialcoverage.info lcov -c --rc lcov_branch_coverage=1 --directory build --output-file ${LCOVDIR}/testcoverage.info lcov -a ${LCOVDIR}/initialcoverage.info -a ${LCOVDIR}/testcoverage.info --rc lcov_branch_coverage=1 --o ${LCOVDIR}/fullcoverage.info lcov -e ${LCOVDIR}/fullcoverage.info "${PWD}/*" --rc lcov_branch_coverage=1 --output-file ${LCOVDIR}/projectcoverage.info -$REPORT_COMMAND +if [ $COVERAGE_REPORT = codecovio ]; then + bash <(curl -s https://codecov.io/bash) -f ${LCOVDIR}/projectcoverage.info +else + genhtml ${LCOVDIR}/projectcoverage.info --output-directory ${LCOVDIR}/html --branch-coverage -p ${PWD} +fi From 9f13e554d738aa4f9c3c476d3d7137f21169066e Mon Sep 17 00:00:00 2001 From: Carl Delsey Date: Sun, 3 Feb 2019 01:52:16 -0800 Subject: [PATCH 14/25] Pass ci env through to docker --- .travis.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 23f3a39357..5bb5941d83 100644 --- a/.travis.yml +++ b/.travis.yml @@ -39,7 +39,8 @@ matrix: after_success: - docker exec --interactive --tty -e CODECOV_TOKEN nav2_bash bash -c "apt-get update ; apt-get -y install lcov" - - docker exec --interactive --tty -e CODECOV_TOKEN nav2_bash /ros_entrypoint.sh + - ci_env=`bash <(curl -s https://codecov.io/env)` + - docker exec --interactive --tty $ci_env nav2_bash /ros_entrypoint.sh src/navigation2/tools/code_coverage_report.bash codecovio script: From a5f5f44ed40d5ca696c1d553b0208a0aac879263 Mon Sep 17 00:00:00 2001 From: Carl Delsey Date: Sun, 3 Feb 2019 12:04:27 -0800 Subject: [PATCH 15/25] Fixing the filter rules for this workspace. --- tools/code_coverage_report.bash | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tools/code_coverage_report.bash b/tools/code_coverage_report.bash index b14b2786ee..5e97a52878 100755 --- a/tools/code_coverage_report.bash +++ b/tools/code_coverage_report.bash @@ -33,7 +33,8 @@ mkdir -p $LCOVDIR lcov -c --initial --rc lcov_branch_coverage=1 --directory build --output-file ${LCOVDIR}/initialcoverage.info lcov -c --rc lcov_branch_coverage=1 --directory build --output-file ${LCOVDIR}/testcoverage.info lcov -a ${LCOVDIR}/initialcoverage.info -a ${LCOVDIR}/testcoverage.info --rc lcov_branch_coverage=1 --o ${LCOVDIR}/fullcoverage.info -lcov -e ${LCOVDIR}/fullcoverage.info "${PWD}/*" --rc lcov_branch_coverage=1 --output-file ${LCOVDIR}/projectcoverage.info +lcov -e ${LCOVDIR}/fullcoverage.info "${PWD}/*" --rc lcov_branch_coverage=1 --output-file ${LCOVDIR}/workspacecoverage.info +lcov -r ${LCOVDIR}/workspacecoverage.info "${PWD}/build/*" --rc lcov_branch_coverage=1 --output-file ${LCOVDIR}/projectcoverage.info if [ $COVERAGE_REPORT = codecovio ]; then bash <(curl -s https://codecov.io/bash) -f ${LCOVDIR}/projectcoverage.info else From a3404b84b491683652b85425404eac7769e2a62a Mon Sep 17 00:00:00 2001 From: Carl Delsey Date: Mon, 4 Feb 2019 12:10:25 -0800 Subject: [PATCH 16/25] Removing unneeded dependency install line. --- .travis.yml | 2 -- nav2_system_tests/package.xml | 1 + 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index 5bb5941d83..507f21a891 100644 --- a/.travis.yml +++ b/.travis.yml @@ -37,8 +37,6 @@ matrix: - env: CMAKE_BUILD_TYPE=Debug COVERAGE_ENABLED=True after_success: - - docker exec --interactive --tty -e CODECOV_TOKEN nav2_bash bash -c - "apt-get update ; apt-get -y install lcov" - ci_env=`bash <(curl -s https://codecov.io/env)` - docker exec --interactive --tty $ci_env nav2_bash /ros_entrypoint.sh src/navigation2/tools/code_coverage_report.bash codecovio diff --git a/nav2_system_tests/package.xml b/nav2_system_tests/package.xml index 741e2bb516..27b80304eb 100644 --- a/nav2_system_tests/package.xml +++ b/nav2_system_tests/package.xml @@ -42,6 +42,7 @@ launch_ros launch_testing navigation2 + lcov launch_ros launch_testing From abea8020829d18b4351a0048bbe538827e98fa23 Mon Sep 17 00:00:00 2001 From: Carl Delsey Date: Mon, 4 Feb 2019 17:57:35 -0800 Subject: [PATCH 17/25] Add comments explaining what lcov lines do. --- tools/code_coverage_report.bash | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/tools/code_coverage_report.bash b/tools/code_coverage_report.bash index 5e97a52878..041c075c51 100755 --- a/tools/code_coverage_report.bash +++ b/tools/code_coverage_report.bash @@ -30,11 +30,22 @@ for opt in "$@" ; do done mkdir -p $LCOVDIR + +# Generate initial zero-coverage data. This adds files that were otherwise not run to the report lcov -c --initial --rc lcov_branch_coverage=1 --directory build --output-file ${LCOVDIR}/initialcoverage.info + +# Capture executed code data. lcov -c --rc lcov_branch_coverage=1 --directory build --output-file ${LCOVDIR}/testcoverage.info + +# Combine the initial zero-coverage report with the executed lines report lcov -a ${LCOVDIR}/initialcoverage.info -a ${LCOVDIR}/testcoverage.info --rc lcov_branch_coverage=1 --o ${LCOVDIR}/fullcoverage.info + +# Only include files that are within this workspace (eg filter out stdio.h etc) lcov -e ${LCOVDIR}/fullcoverage.info "${PWD}/*" --rc lcov_branch_coverage=1 --output-file ${LCOVDIR}/workspacecoverage.info + +# Remove files in the build subdirectory because they are generated files (like messages, services, etc) lcov -r ${LCOVDIR}/workspacecoverage.info "${PWD}/build/*" --rc lcov_branch_coverage=1 --output-file ${LCOVDIR}/projectcoverage.info + if [ $COVERAGE_REPORT = codecovio ]; then bash <(curl -s https://codecov.io/bash) -f ${LCOVDIR}/projectcoverage.info else From 68aea5607a072442838c6c6a8996f3d6b403f786 Mon Sep 17 00:00:00 2001 From: Carl Delsey Date: Tue, 5 Feb 2019 14:37:06 -0800 Subject: [PATCH 18/25] Rebasing on top of circle CI and common Cmake functions changes. --- .circleci/config.yml | 9 +-------- Dockerfile | 16 +++------------- nav2_common/cmake/nav2_package.cmake | 7 +++++++ 3 files changed, 11 insertions(+), 21 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index f455ce5d27..2a8ecdb218 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -129,14 +129,7 @@ references: name: Test Build command: | . install/setup.sh - colcon test \ - --packages-skip \ - nav2_system_tests - colcon test-result \ - --verbose - cp src/navigation2/tools/ctest_retry.bash build/nav2_system_tests - cd build/nav2_system_tests - ./ctest_retry.bash 3 + src/navigation2/tools/runtestsuite.bash copy_test_logs: ©_test_logs run: diff --git a/Dockerfile b/Dockerfile index 2fd23c002c..f5a8e03b55 100644 --- a/Dockerfile +++ b/Dockerfile @@ -69,22 +69,12 @@ RUN . $ROS_WS/install/setup.sh && \ # build navigation2 package source RUN rm $NAV2_WS/src/navigation2/nav2_system_tests/COLCON_IGNORE ARG COVERAGE_ENABLED=False -RUN if [ "$COVERAGE_ENABLED" = "True" ]; \ - then \ - . $ROS_WS/install/setup.sh && \ +RUN . $ROS_WS/install/setup.sh && \ colcon build \ --symlink-install \ --cmake-args \ - -DCMAKE_BUILD_TYPE=$CMAKE_BUILD_TYPE -DCMAKE_CXX_FLAGS=--coverage \ - -DCMAKE_C_FLAGS=--coverage -DCMAKE_EXE_LINKER_FLAGS=--coverage \ - -DCMAKE_SHARED_LINKER_FLAGS=--coverage ; \ - else \ - . $ROS_WS/install/setup.sh && \ - colcon build \ - --symlink-install \ - --cmake-args \ - -DCMAKE_BUILD_TYPE=$CMAKE_BUILD_TYPE ; \ - fi + -DCMAKE_BUILD_TYPE=$CMAKE_BUILD_TYPE \ + -DCOVERAGE_ENABLED=$COVERAGE_ENABLED # source navigation2 workspace from entrypoint RUN sed --in-place \ diff --git a/nav2_common/cmake/nav2_package.cmake b/nav2_common/cmake/nav2_package.cmake index db9dbea89f..80ab053bbf 100644 --- a/nav2_common/cmake/nav2_package.cmake +++ b/nav2_common/cmake/nav2_package.cmake @@ -26,4 +26,11 @@ macro(nav2_package) if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang") add_compile_options(-Wall -Wextra -Wpedantic -Werror -fPIC) endif() + + option(COVERAGE_ENABLED "Enable code coverage" FALSE) + if(COVERAGE_ENABLED) + add_compile_options(--coverage) + set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} --coverage") + set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} --coverage") + endif() endmacro() From 72f285625218ee2cad7805f2a2871ecd494a3e77 Mon Sep 17 00:00:00 2001 From: Carl Delsey Date: Tue, 5 Feb 2019 15:19:21 -0800 Subject: [PATCH 19/25] Fixing test suite script name. --- .circleci/config.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 2a8ecdb218..96ad58ea03 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -129,7 +129,7 @@ references: name: Test Build command: | . install/setup.sh - src/navigation2/tools/runtestsuite.bash + src/navigation2/tools/run_test_suite.bash copy_test_logs: ©_test_logs run: From 05215775f8c305a2c97bf072b12b3dad354f9955 Mon Sep 17 00:00:00 2001 From: Ruffin Date: Fri, 8 Feb 2019 11:35:50 -0800 Subject: [PATCH 20/25] Add codecov to CircleCI jobs --- .circleci/config.yml | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 96ad58ea03..513bb1ef6d 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -59,7 +59,9 @@ references: else . /opt/ros/$ROS_DISTRO/setup.sh colcon build \ - --symlink-install + --symlink-install \ + --cmake-args \ + -DCMAKE_BUILD_TYPE=$CMAKE_BUILD_TYPE fi save_upstream_cache: &save_upstream_cache save_cache: @@ -108,7 +110,10 @@ references: else . $ROS_WS/install/setup.sh colcon build \ - --symlink-install + --symlink-install \ + --cmake-args \ + -DCMAKE_BUILD_TYPE=$CMAKE_BUILD_TYPE \ + -DCOVERAGE_ENABLED=$COVERAGE_ENABLED fi save_build_cache: &save_build_cache save_cache: @@ -130,7 +135,6 @@ references: command: | . install/setup.sh src/navigation2/tools/run_test_suite.bash - copy_test_logs: ©_test_logs run: name: Copy Test Logs @@ -139,6 +143,13 @@ references: store_test_logs: &store_test_logs store_artifacts: path: log/test + report_code_coverage: &report_code_coverage + run: + name: Report Code Coverage + command: | + export ci_env=`bash <(curl -s https://codecov.io/env)` + . install/setup.sh + src/navigation2/tools/code_coverage_report.bash codecovio commands: checkout_source: @@ -171,6 +182,10 @@ commands: - *test_build - *copy_test_logs - *store_test_logs + report_coverage: + description: "Report Coverage" + steps: + - *report_code_coverage executors: docker_exec: @@ -179,6 +194,7 @@ executors: working_directory: /opt/nav2_ws environment: CMAKE_BUILD_TYPE: "Release" + COVERAGE_ENABLED: "True" MAKEFLAGS: "-j 1 -l 1" jobs: From 11acdb724875f50df483087d2206253cb57174b8 Mon Sep 17 00:00:00 2001 From: Ruffin Date: Fri, 8 Feb 2019 12:31:20 -0800 Subject: [PATCH 21/25] Add conditional to skip codecov if enable is false --- .circleci/config.yml | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 513bb1ef6d..8040e437c7 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -147,9 +147,14 @@ references: run: name: Report Code Coverage command: | - export ci_env=`bash <(curl -s https://codecov.io/env)` - . install/setup.sh - src/navigation2/tools/code_coverage_report.bash codecovio + if [ "$COVERAGE_ENABLED" = "True" ] + then + export ci_env=`bash <(curl -s https://codecov.io/env)` + . install/setup.sh + src/navigation2/tools/code_coverage_report.bash codecovio + else + echo "Skipping Code Coverage Report" + fi commands: checkout_source: From f124aa30a9477ced3712b4682be27bd6090e31e8 Mon Sep 17 00:00:00 2001 From: Ruffin Date: Fri, 8 Feb 2019 17:26:19 -0800 Subject: [PATCH 22/25] Remove unnecessary export for codecov --- .circleci/config.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 8040e437c7..7e13c592de 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -149,7 +149,6 @@ references: command: | if [ "$COVERAGE_ENABLED" = "True" ] then - export ci_env=`bash <(curl -s https://codecov.io/env)` . install/setup.sh src/navigation2/tools/code_coverage_report.bash codecovio else From 70d27834a322fbb82f7a22edf3e143598e1b934b Mon Sep 17 00:00:00 2001 From: Ruffin Date: Fri, 8 Feb 2019 18:24:26 -0800 Subject: [PATCH 23/25] Update workflow for paralel release and debug jobs --- .circleci/config.yml | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 7e13c592de..442c8f0a7e 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -197,13 +197,24 @@ executors: - image: rosplanning/navigation2:master working_directory: /opt/nav2_ws environment: - CMAKE_BUILD_TYPE: "Release" - COVERAGE_ENABLED: "True" MAKEFLAGS: "-j 1 -l 1" jobs: - build: + debug_build: + executor: docker_exec + environment: + CMAKE_BUILD_TYPE: "Debug" + COVERAGE_ENABLED: "True" + steps: + - checkout_source + - setup_upstream + - build_source + - test_source + release_build: executor: docker_exec + environment: + CMAKE_BUILD_TYPE: "Release" + COVERAGE_ENABLED: "False" steps: - checkout_source - setup_upstream @@ -214,7 +225,8 @@ workflows: version: 2 build-test: jobs: - - build + - debug_build + - release_build # nightly: # triggers: # - schedule: From bb856c64e7f1a91976bb05f4f7e2f906f3392c2b Mon Sep 17 00:00:00 2001 From: Ruffin Date: Fri, 8 Feb 2019 18:32:57 -0800 Subject: [PATCH 24/25] Forgot to append coverage step to job --- .circleci/config.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.circleci/config.yml b/.circleci/config.yml index 442c8f0a7e..06526e1ba0 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -210,6 +210,7 @@ jobs: - setup_upstream - build_source - test_source + - report_coverage release_build: executor: docker_exec environment: From 6cf7498f79818c0ca06d130c8aecaff1a6c05e7e Mon Sep 17 00:00:00 2001 From: Ruffin Date: Fri, 8 Feb 2019 18:36:00 -0800 Subject: [PATCH 25/25] Comment out travis codecove --- .travis.yml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/.travis.yml b/.travis.yml index 507f21a891..e85c4073c4 100644 --- a/.travis.yml +++ b/.travis.yml @@ -35,11 +35,11 @@ matrix: docker push stevemacenski/navigation2:latest ; fi - - env: CMAKE_BUILD_TYPE=Debug COVERAGE_ENABLED=True - after_success: - - ci_env=`bash <(curl -s https://codecov.io/env)` - - docker exec --interactive --tty $ci_env nav2_bash /ros_entrypoint.sh - src/navigation2/tools/code_coverage_report.bash codecovio + # - env: CMAKE_BUILD_TYPE=Debug COVERAGE_ENABLED=True + # after_success: + # - ci_env=`bash <(curl -s https://codecov.io/env)` + # - docker exec --interactive --tty $ci_env nav2_bash /ros_entrypoint.sh + # src/navigation2/tools/code_coverage_report.bash codecovio script: - docker build --tag navigation2:latest