From 1c8ab533a57e50aaa1850fc83c3b8a152a77bf5d Mon Sep 17 00:00:00 2001 From: Tyler Weaver Date: Wed, 30 Oct 2019 22:10:27 -0600 Subject: [PATCH 01/33] add codecov.io support --- README.md | 41 +++++++++++++++++++++++++++++++++++++++++ after_success.sh | 16 ++++++++++++++++ travis.sh | 9 +++++++++ 3 files changed, 66 insertions(+) create mode 100644 after_success.sh diff --git a/README.md b/README.md index 458fee2e..a802079b 100644 --- a/README.md +++ b/README.md @@ -40,6 +40,7 @@ env: - TEST=clang-format # check code formatting for compliance to .clang-format rules - TEST=clang-tidy-fix # perform static code analysis and compliance check against .clang-tidy rules - TEST=catkin_lint # perform catkin_lint checks + - TEST=code-coverage # perform code coverage report # pull in packages from a local .rosinstall file - UPSTREAM_WORKSPACE=moveit.rosinstall # pull in packages from a remote .rosinstall file and run for a non-default ROS_DISTRO @@ -60,6 +61,10 @@ before_script: script: # Run the test script - .moveit_ci/travis.sh + +after_success: + # Report code coverage + - .travis/after_success.sh ``` ## Configurations @@ -143,3 +148,39 @@ It's also possible to run the script without using docker. To this end, issue th export ROS_WS=/tmp/ros_ws # define a new ROS workspace location mkdir $ROS_WS # and create it .moveit_ci/travis.sh + +## Enabling codecov.io reporting + +To enable codecov enabling you'll need to add this to your CMakeLists.txt file: + + option(CMAKE_CODE_COVERAGE_CONFIG + "Generate code coverage reporting for codecov.io" + OFF + ) + + # Code coverage build settings + add_library(coverage_config INTERFACE) + if(CMAKE_CODE_COVERAGE_CONFIG) + # Add required flags (GCC & LLVM/Clang) + target_compile_options(coverage_config INTERFACE + -O0 # no optimization + -g # generate debug info + --coverage # sets all required flags + ) + target_link_libraries(coverage_config INTERFACE --coverage) + endif() + +Then you'll need to change the `target_link_libraries` command to turn on code coverage specifically for your project without propigating these settings to external dependencies: + + target_link_libraries( + ${PROJECT_NAME} + PUBLIC + ${catkin_LIBRARIES} + ${Boost_LIBRARIES} + ) + + target_link_libraries( + ${PROJECT_NAME} + PRIVATE + coverage_config + ) diff --git a/after_success.sh b/after_success.sh new file mode 100644 index 00000000..6b2a577e --- /dev/null +++ b/after_success.sh @@ -0,0 +1,16 @@ +#!/bin/bash -u +# -*- indent-tabs-mode: nil -*- + +# Software License Agreement - BSD License +# +# This script runs after successful travis run +# +# Author: Tyler Weaver + +# Helper functions +source .travis/util.sh + +if [[ "${TEST:=}" == *code-coverage* ]]; then + echo -e $(colorize BOLD "Generating codecov.io report") + travis_run --title "codecov.io report upload" bash <(curl -s https://codecov.io/bash) +fi diff --git a/travis.sh b/travis.sh index dbb517b6..543b4cc8 100755 --- a/travis.sh +++ b/travis.sh @@ -61,6 +61,9 @@ function run_docker() { esac fi + # make build directory to copy build products into for code coverage reporting + [[ "${TEST:=}" == *code-coverage* ]] && mkdir -p $(pwd)/build + echo -e $(colorize BOLD "Starting Docker image: $DOCKER_IMAGE") travis_run docker pull $DOCKER_IMAGE @@ -167,6 +170,9 @@ function run_early_tests() { abi) # abi-checker requires debug symbols CMAKE_ARGS="$CMAKE_ARGS -DCMAKE_BUILD_TYPE=Debug -DCMAKE_CXX_FLAGS_DEBUG=\"-g -Og\"" ;; + code-coverage) # code coverage test requres special build instructions + CMAKE_ARGS="$CMAKE_ARGS -DCMAKE_CODE_COVERAGE_CONFIG=ON" + ;; *) echo -e $(colorize RED "Unknown TEST: $t") EARLY_RESULT=$(( ${EARLY_RESULT:-0} + 1 )) @@ -311,6 +317,9 @@ function test_workspace() { # Show test results summary and throw error if necessary catkin_test_results || exit 2 + + # Copy build products for code coverage reporting + [[ "${TEST:=}" == *code-coverage* ]] && travis_run_simple cp -r $ROS_WS/build /root/$REPOSITORY_NAME } ########################################################################################################### From 3ff0dce9b97a0a94e1125d9ba2e039a112dd0be7 Mon Sep 17 00:00:00 2001 From: Tyler Weaver Date: Thu, 31 Oct 2019 09:03:38 -0600 Subject: [PATCH 02/33] fixup! add codecov.io support --- README.md | 4 ++-- after_success.sh | 1 + 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index a802079b..5fe09b04 100644 --- a/README.md +++ b/README.md @@ -151,7 +151,7 @@ It's also possible to run the script without using docker. To this end, issue th ## Enabling codecov.io reporting -To enable codecov enabling you'll need to add this to your CMakeLists.txt file: +For codecov to work you need to build and link your libraries with the coverage flag. Here is how you can add this to your CMakeLists.txt file: option(CMAKE_CODE_COVERAGE_CONFIG "Generate code coverage reporting for codecov.io" @@ -170,7 +170,7 @@ To enable codecov enabling you'll need to add this to your CMakeLists.txt file: target_link_libraries(coverage_config INTERFACE --coverage) endif() -Then you'll need to change the `target_link_libraries` command to turn on code coverage specifically for your project without propigating these settings to external dependencies: +Then you'll need to change the `target_link_libraries` command to turn on code coverage specifically for your project without propagating these settings to external dependencies: target_link_libraries( ${PROJECT_NAME} diff --git a/after_success.sh b/after_success.sh index 6b2a577e..bcd43c82 100644 --- a/after_success.sh +++ b/after_success.sh @@ -12,5 +12,6 @@ source .travis/util.sh if [[ "${TEST:=}" == *code-coverage* ]]; then echo -e $(colorize BOLD "Generating codecov.io report") + travis_run --title "changing ownership of build products" sudo chown -R $USER:$USER build/ travis_run --title "codecov.io report upload" bash <(curl -s https://codecov.io/bash) fi From dbf01a5a38c1a41632b17e78c8908a131d5fe2d0 Mon Sep 17 00:00:00 2001 From: Tyler Weaver Date: Sat, 2 Nov 2019 16:13:31 -0600 Subject: [PATCH 03/33] fixup! add codecov.io support --- README.md | 57 +++++++++++++++++------------------------------- after_success.sh | 17 --------------- travis.sh | 26 ++++++++++++++++------ 3 files changed, 39 insertions(+), 61 deletions(-) delete mode 100644 after_success.sh diff --git a/README.md b/README.md index 5fe09b04..79e7adc6 100644 --- a/README.md +++ b/README.md @@ -61,10 +61,6 @@ before_script: script: # Run the test script - .moveit_ci/travis.sh - -after_success: - # Report code coverage - - .travis/after_success.sh ``` ## Configurations @@ -151,36 +147,23 @@ It's also possible to run the script without using docker. To this end, issue th ## Enabling codecov.io reporting -For codecov to work you need to build and link your libraries with the coverage flag. Here is how you can add this to your CMakeLists.txt file: - - option(CMAKE_CODE_COVERAGE_CONFIG - "Generate code coverage reporting for codecov.io" - OFF - ) - - # Code coverage build settings - add_library(coverage_config INTERFACE) - if(CMAKE_CODE_COVERAGE_CONFIG) - # Add required flags (GCC & LLVM/Clang) - target_compile_options(coverage_config INTERFACE - -O0 # no optimization - -g # generate debug info - --coverage # sets all required flags - ) - target_link_libraries(coverage_config INTERFACE --coverage) - endif() - -Then you'll need to change the `target_link_libraries` command to turn on code coverage specifically for your project without propagating these settings to external dependencies: - - target_link_libraries( - ${PROJECT_NAME} - PUBLIC - ${catkin_LIBRARIES} - ${Boost_LIBRARIES} - ) - - target_link_libraries( - ${PROJECT_NAME} - PRIVATE - coverage_config - ) +For codecov to work you need to build and link your c++ code with the `--coverage` flag. We do this with a custom `Coverage` build type for cmake. To add support for Coverage build type add this [Coverage.cmake](https://raw.githubusercontent.com/Lectem/cpp-boilerplate/master/cmake/Coverage.cmake) file from the [cpp-boilerplate](https://github.com/Lectem/cpp-boilerplate/blob/master/CTestConfig.cmake) project to a `cmake` directory. Then update the minimum required version of cmake to `3.3` or higher to support features from that file: + + cmake_minimum_required(VERSION 3.3) + +Add These lines to your cmake file to include `Coverage`: + + # Custom modules and scripts + set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_CURRENT_LIST_DIR}/cmake") + include(Coverage) + +Lastly, Add a `.codecov.yml` file to your project to exclude test, external, main files, and anything else you don't want in your coverage report: + + ignore: + - "test" # test directory + - "external" # external directory + - "**/*_main.cpp" # any file ending in _main.cpp + +Then you can use the `code-coverage` test and it will run the script provided by [codecov.io](codecov.io) which runs `gcov` to generate the reports and then compiles them into a report and uploads them to their servers. + +If you are using this on a private github repo you will need to define the `CODECOV_TOKEN` enviroment variable in the `global` section of your `.travis.yml` file to the value you can find on the settings page of your project on codecov.io. diff --git a/after_success.sh b/after_success.sh deleted file mode 100644 index bcd43c82..00000000 --- a/after_success.sh +++ /dev/null @@ -1,17 +0,0 @@ -#!/bin/bash -u -# -*- indent-tabs-mode: nil -*- - -# Software License Agreement - BSD License -# -# This script runs after successful travis run -# -# Author: Tyler Weaver - -# Helper functions -source .travis/util.sh - -if [[ "${TEST:=}" == *code-coverage* ]]; then - echo -e $(colorize BOLD "Generating codecov.io report") - travis_run --title "changing ownership of build products" sudo chown -R $USER:$USER build/ - travis_run --title "codecov.io report upload" bash <(curl -s https://codecov.io/bash) -fi diff --git a/travis.sh b/travis.sh index 543b4cc8..012955b1 100755 --- a/travis.sh +++ b/travis.sh @@ -48,6 +48,16 @@ function docker_cp { function run_docker() { run_script BEFORE_DOCKER_SCRIPT + # get ci enviroment parameters to pass into docker for codecov + # this is a list of docker parameters to include enviroment variables + export CI_ENV_PARAMS=`bash <(curl -s https://codecov.io/env)` + # these two varaibles are needed for codecov to work locally + set +u # stop variable checking + # test if they are set before setting as travis sets them + [[ -z ${VCS_BRANCH_NAME} ]] && export VCS_BRANCH_NAME=$(git rev-parse --abbrev-ref HEAD) + [[ -z ${VCS_COMMIT_ID} ]] && export VCS_COMMIT_ID=$(git rev-parse HEAD) + set -u # resume variable checking + # Choose the docker container to use if [ -n "${ROS_REPO:=}" ] && [ -n "${DOCKER_IMAGE:=}" ]; then echo -e $(colorize YELLOW "DOCKER_IMAGE=$DOCKER_IMAGE overrides ROS_REPO=$ROS_REPO setting") @@ -61,9 +71,6 @@ function run_docker() { esac fi - # make build directory to copy build products into for code coverage reporting - [[ "${TEST:=}" == *code-coverage* ]] && mkdir -p $(pwd)/build - echo -e $(colorize BOLD "Starting Docker image: $DOCKER_IMAGE") travis_run docker pull $DOCKER_IMAGE @@ -88,6 +95,7 @@ function run_docker() { -e CXX=${CXX_FOR_BUILD:-${CXX:-c++}} \ -e CFLAGS \ -e CXXFLAGS \ + $CI_ENV_PARAMS \ -v $(pwd):/root/$REPOSITORY_NAME \ -v ${CCACHE_DIR:-$HOME/.ccache}:/root/.ccache \ -t \ @@ -170,8 +178,8 @@ function run_early_tests() { abi) # abi-checker requires debug symbols CMAKE_ARGS="$CMAKE_ARGS -DCMAKE_BUILD_TYPE=Debug -DCMAKE_CXX_FLAGS_DEBUG=\"-g -Og\"" ;; - code-coverage) # code coverage test requres special build instructions - CMAKE_ARGS="$CMAKE_ARGS -DCMAKE_CODE_COVERAGE_CONFIG=ON" + code-coverage) # code coverage test requres specific compiler and linker arguments + CMAKE_ARGS="$CMAKE_ARGS -DCMAKE_BUILD_TYPE=Coverage" ;; *) echo -e $(colorize RED "Unknown TEST: $t") @@ -317,9 +325,10 @@ function test_workspace() { # Show test results summary and throw error if necessary catkin_test_results || exit 2 + } - # Copy build products for code coverage reporting - [[ "${TEST:=}" == *code-coverage* ]] && travis_run_simple cp -r $ROS_WS/build /root/$REPOSITORY_NAME +function send_codecov_report() { + travis_run --title "codecov.io report upload" bash <(curl -s https://codecov.io/bash) -s $ROS_WS -R $ROS_WS/src/$REPOSITORY_NAME } ########################################################################################################### @@ -380,6 +389,9 @@ for t in $(unify_list " ,;" "$TEST") ; do (source ${MOVEIT_CI_DIR}/check_abi.sh) test $? -eq 0 || result=$(( ${result:-0} + 1 )) ;; + code-coverage) + send_codecov_report + ;; esac done # Run warnings check From 2750095a99cdae58bb6fa79982e94b7f994167b2 Mon Sep 17 00:00:00 2001 From: Tyler Weaver Date: Mon, 4 Nov 2019 18:17:12 -0700 Subject: [PATCH 04/33] fixup! add codecov.io support --- travis.sh | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/travis.sh b/travis.sh index 012955b1..345e93f4 100755 --- a/travis.sh +++ b/travis.sh @@ -50,7 +50,7 @@ function run_docker() { # get ci enviroment parameters to pass into docker for codecov # this is a list of docker parameters to include enviroment variables - export CI_ENV_PARAMS=`bash <(curl -s https://codecov.io/env)` + CI_ENV_PARAMS=`bash <(curl -s https://codecov.io/env)` # these two varaibles are needed for codecov to work locally set +u # stop variable checking # test if they are set before setting as travis sets them @@ -327,10 +327,6 @@ function test_workspace() { catkin_test_results || exit 2 } -function send_codecov_report() { - travis_run --title "codecov.io report upload" bash <(curl -s https://codecov.io/bash) -s $ROS_WS -R $ROS_WS/src/$REPOSITORY_NAME -} - ########################################################################################################### # main program @@ -390,7 +386,7 @@ for t in $(unify_list " ,;" "$TEST") ; do test $? -eq 0 || result=$(( ${result:-0} + 1 )) ;; code-coverage) - send_codecov_report + travis_run --title "codecov.io report upload" bash <(curl -s https://codecov.io/bash) -s $ROS_WS -R $ROS_WS/src/$REPOSITORY_NAME ;; esac done From f5e372522525e2a776db40ba5c9d04100509588f Mon Sep 17 00:00:00 2001 From: Robert Haschke Date: Sat, 9 Nov 2019 18:52:02 +0100 Subject: [PATCH 05/33] cleanup (#1) --- travis.sh | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/travis.sh b/travis.sh index 345e93f4..cd1c08e2 100755 --- a/travis.sh +++ b/travis.sh @@ -51,12 +51,9 @@ function run_docker() { # get ci enviroment parameters to pass into docker for codecov # this is a list of docker parameters to include enviroment variables CI_ENV_PARAMS=`bash <(curl -s https://codecov.io/env)` - # these two varaibles are needed for codecov to work locally - set +u # stop variable checking - # test if they are set before setting as travis sets them - [[ -z ${VCS_BRANCH_NAME} ]] && export VCS_BRANCH_NAME=$(git rev-parse --abbrev-ref HEAD) - [[ -z ${VCS_COMMIT_ID} ]] && export VCS_COMMIT_ID=$(git rev-parse HEAD) - set -u # resume variable checking + # The following two varaibles are needed for codecov to work locally + export ${VCS_BRANCH_NAME:=$(git rev-parse --abbrev-ref HEAD)} + export ${VCS_COMMIT_ID:=$(git rev-parse HEAD)} # Choose the docker container to use if [ -n "${ROS_REPO:=}" ] && [ -n "${DOCKER_IMAGE:=}" ]; then @@ -325,7 +322,7 @@ function test_workspace() { # Show test results summary and throw error if necessary catkin_test_results || exit 2 - } +} ########################################################################################################### # main program From 4e9301b88a2169a491e81183644f5de844d9cf7f Mon Sep 17 00:00:00 2001 From: Tyler Weaver Date: Fri, 15 Nov 2019 14:34:15 -0700 Subject: [PATCH 06/33] code build support from ros package --- README.md | 33 ++++++++++++++++++++++----------- travis.sh | 2 +- 2 files changed, 23 insertions(+), 12 deletions(-) diff --git a/README.md b/README.md index 79e7adc6..810a9544 100644 --- a/README.md +++ b/README.md @@ -147,22 +147,33 @@ It's also possible to run the script without using docker. To this end, issue th ## Enabling codecov.io reporting -For codecov to work you need to build and link your c++ code with the `--coverage` flag. We do this with a custom `Coverage` build type for cmake. To add support for Coverage build type add this [Coverage.cmake](https://raw.githubusercontent.com/Lectem/cpp-boilerplate/master/cmake/Coverage.cmake) file from the [cpp-boilerplate](https://github.com/Lectem/cpp-boilerplate/blob/master/CTestConfig.cmake) project to a `cmake` directory. Then update the minimum required version of cmake to `3.3` or higher to support features from that file: +For codecov to work you need to build and link your c++ code with the `--coverage`. We do this using the ros package [code_coverage](https://github.com/mikeferguson/code_coverage). - cmake_minimum_required(VERSION 3.3) +To to use the `code-coverage` do these two things (coppied from the linked repo's README.md): -Add These lines to your cmake file to include `Coverage`: +1. Add code_coverage as a test depend in your package.xml +1. Update your CMakeLists.txt, in the testing section add: - # Custom modules and scripts - set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_CURRENT_LIST_DIR}/cmake") - include(Coverage) +```cmake +if (CATKIN_ENABLE_TESTING) + find_package(code_coverage REQUIRED) -Lastly, Add a `.codecov.yml` file to your project to exclude test, external, main files, and anything else you don't want in your coverage report: + if(ENABLE_COVERAGE_TESTING) + include(CodeCoverage) + APPEND_COVERAGE_COMPILER_FLAGS() + endif() - ignore: - - "test" # test directory - - "external" # external directory - - "**/*_main.cpp" # any file ending in _main.cpp + # Add your tests here + + if(ENABLE_COVERAGE_TESTING) + set(COVERAGE_EXCLUDES "*/${PROJECT_NAME}/test*" "*/${PROJECT_NAME}/other_dir_i_dont_care_about*") + add_code_coverage( + NAME ${PROJECT_NAME}_coverage + DEPENDENCIES tests + ) + endif() +endif() +``` Then you can use the `code-coverage` test and it will run the script provided by [codecov.io](codecov.io) which runs `gcov` to generate the reports and then compiles them into a report and uploads them to their servers. diff --git a/travis.sh b/travis.sh index cd1c08e2..2b9c9305 100755 --- a/travis.sh +++ b/travis.sh @@ -176,7 +176,7 @@ function run_early_tests() { CMAKE_ARGS="$CMAKE_ARGS -DCMAKE_BUILD_TYPE=Debug -DCMAKE_CXX_FLAGS_DEBUG=\"-g -Og\"" ;; code-coverage) # code coverage test requres specific compiler and linker arguments - CMAKE_ARGS="$CMAKE_ARGS -DCMAKE_BUILD_TYPE=Coverage" + CMAKE_ARGS="$CMAKE_ARGS -DCMAKE_BUILD_TYPE=Debug -DENABLE_COVERAGE_TESTING=ON" ;; *) echo -e $(colorize RED "Unknown TEST: $t") From 89c267179b48a71a61f6751aef57185f72f7496f Mon Sep 17 00:00:00 2001 From: Tyler Weaver Date: Fri, 15 Nov 2019 15:19:51 -0700 Subject: [PATCH 07/33] travis test for code-coverage --- test_pkgs/valid/CMakeLists.txt | 9 ++++++++- test_pkgs/valid/package.xml | 1 + unit_tests.sh | 4 ++++ 3 files changed, 13 insertions(+), 1 deletion(-) diff --git a/test_pkgs/valid/CMakeLists.txt b/test_pkgs/valid/CMakeLists.txt index b8a8cc10..7f1e21a5 100644 --- a/test_pkgs/valid/CMakeLists.txt +++ b/test_pkgs/valid/CMakeLists.txt @@ -10,6 +10,13 @@ include_directories( ${catkin_INCLUDE_DIRS} ) -if(CATKIN_ENABLE_TESTING) +if (CATKIN_ENABLE_TESTING) + find_package(code_coverage REQUIRED) + + if(ENABLE_COVERAGE_TESTING) + include(CodeCoverage) + APPEND_COVERAGE_COMPILER_FLAGS() + endif() + catkin_add_gtest(${PROJECT_NAME} test.cpp) endif() diff --git a/test_pkgs/valid/package.xml b/test_pkgs/valid/package.xml index a401ade1..6e5a2ed1 100644 --- a/test_pkgs/valid/package.xml +++ b/test_pkgs/valid/package.xml @@ -11,6 +11,7 @@ catkin rosunit + code_coverage diff --git a/unit_tests.sh b/unit_tests.sh index 7610ad2c..0c39961b 100755 --- a/unit_tests.sh +++ b/unit_tests.sh @@ -120,6 +120,10 @@ for group in $test_groups ; do run_test 0 $0:$LINENO "clang-tidy-check on 'valid' package, warnings forbidden" TEST_PKG=valid TEST=clang-tidy-check WARNINGS_OK=false run_test 1 $0:$LINENO "clang-tidy-check on 'clang_tidy' package, warnings forbidden" TEST_PKG=clang_tidy TEST=clang-tidy-check WARNINGS_OK=false ;; + code-coverage) + run_test 0 $0:$LINENO "code-coverage on 'valid' package, warnings forbidden" TEST_PKG=valid TEST=code-coverage WARNINGS_OK=false + run_test 1 $0:$LINENO "code-coverage on 'warnings' package, warnings forbidden" TEST_PKG=warnings TEST=code-coverage WARNINGS_OK=false + ;; *) echo -e $(colorize YELLOW "Unknown test group '$group'.") echo "Known groups are: $all_groups" ;; esac From 0581d2ccd1c67ff6f0860d4cb80dddb09e86ce20 Mon Sep 17 00:00:00 2001 From: Tyler Weaver Date: Fri, 15 Nov 2019 15:39:14 -0700 Subject: [PATCH 08/33] fixup! travis test for code-coverage --- unit_tests.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/unit_tests.sh b/unit_tests.sh index 0c39961b..88ecaf6a 100755 --- a/unit_tests.sh +++ b/unit_tests.sh @@ -60,7 +60,7 @@ rosdep() { echo "Dummy rosdep $*" } -all_groups="sanity warnings catkin_lint clang-format clang-tidy-fix clang-tidy-check" +all_groups="sanity warnings catkin_lint clang-format clang-tidy-fix clang-tidy-check code-coverage" skip_groups="${SKIP:-}" # process options while true ; do From 93bb2a5317fa02d1d8c2702a5c86db8b9642495e Mon Sep 17 00:00:00 2001 From: Tyler Weaver Date: Fri, 15 Nov 2019 16:29:38 -0700 Subject: [PATCH 09/33] Update README.md --- README.md | 34 +++++++++++----------------------- 1 file changed, 11 insertions(+), 23 deletions(-) diff --git a/README.md b/README.md index 810a9544..b4eab01d 100644 --- a/README.md +++ b/README.md @@ -147,34 +147,22 @@ It's also possible to run the script without using docker. To this end, issue th ## Enabling codecov.io reporting -For codecov to work you need to build and link your c++ code with the `--coverage`. We do this using the ros package [code_coverage](https://github.com/mikeferguson/code_coverage). +For codecov to work you need to build and link your c++ code with specific parameters. To enable this we use the ros package [code_coverage](https://github.com/mikeferguson/code_coverage). To to use the `code-coverage` test in your repo make these two changes: -To to use the `code-coverage` do these two things (coppied from the linked repo's README.md): - -1. Add code_coverage as a test depend in your package.xml -1. Update your CMakeLists.txt, in the testing section add: +1. Add `code_coverage` to your package.xml +1. Add this to your `CMakeLists.txt`: ```cmake -if (CATKIN_ENABLE_TESTING) - find_package(code_coverage REQUIRED) - - if(ENABLE_COVERAGE_TESTING) - include(CodeCoverage) - APPEND_COVERAGE_COMPILER_FLAGS() - endif() - - # Add your tests here - - if(ENABLE_COVERAGE_TESTING) - set(COVERAGE_EXCLUDES "*/${PROJECT_NAME}/test*" "*/${PROJECT_NAME}/other_dir_i_dont_care_about*") - add_code_coverage( - NAME ${PROJECT_NAME}_coverage - DEPENDENCIES tests - ) - endif() +# to run: catkin_make -DENABLE_COVERAGE_TESTING=ON package_name_coverage +if(CATKIN_ENABLE_TESTING AND ENABLE_COVERAGE_TESTING) + find_package(code_coverage REQUIRED) # catkin package ros-*-code-coverage + include(CodeCoverage) + APPEND_COVERAGE_COMPILER_FLAGS() + set(COVERAGE_EXCLUDES "*/test/*") + add_code_coverage(NAME ${PROJECT_NAME}_coverage) endif() ``` Then you can use the `code-coverage` test and it will run the script provided by [codecov.io](codecov.io) which runs `gcov` to generate the reports and then compiles them into a report and uploads them to their servers. -If you are using this on a private github repo you will need to define the `CODECOV_TOKEN` enviroment variable in the `global` section of your `.travis.yml` file to the value you can find on the settings page of your project on codecov.io. +If you are using this on a private github repo you will need to set the `CODECOV_TOKEN` enviroment variable in the `global` section of your `.travis.yml` file to the value you can find on the settings page of your project on codecov.io. From a86024660ac04d553058aa97a0b9470210319b43 Mon Sep 17 00:00:00 2001 From: Tyler Weaver Date: Fri, 15 Nov 2019 17:49:16 -0700 Subject: [PATCH 10/33] Update README.md Co-Authored-By: Dave Coleman --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index b4eab01d..dfa1178f 100644 --- a/README.md +++ b/README.md @@ -147,7 +147,7 @@ It's also possible to run the script without using docker. To this end, issue th ## Enabling codecov.io reporting -For codecov to work you need to build and link your c++ code with specific parameters. To enable this we use the ros package [code_coverage](https://github.com/mikeferguson/code_coverage). To to use the `code-coverage` test in your repo make these two changes: +For codecov to work you need to build and link your C++ code with specific parameters. To enable this we use the ROS package [code_coverage](https://github.com/mikeferguson/code_coverage). To to use the `code-coverage` test in your repo make these two changes: 1. Add `code_coverage` to your package.xml 1. Add this to your `CMakeLists.txt`: From be93423566fcbbbc5ae173742ded41f4d25c4f40 Mon Sep 17 00:00:00 2001 From: Tyler Weaver Date: Sat, 16 Nov 2019 15:01:09 -0700 Subject: [PATCH 11/33] add support for TEST_WHITELIST --- travis.sh | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/travis.sh b/travis.sh index 2b9c9305..a238e205 100755 --- a/travis.sh +++ b/travis.sh @@ -86,6 +86,7 @@ function run_docker() { -e TEST_PKG \ -e TEST \ -e TEST_BLACKLIST \ + -e TEST_WHITELIST \ -e WARNINGS_OK \ -e ABI_BASE_URL \ -e CC=${CC_FOR_BUILD:-${CC:-cc}} \ @@ -301,6 +302,13 @@ function test_workspace() { echo -e $(colorize YELLOW Test blacklist: $(colorize THIN $TEST_BLACKLIST)) test -n "$TEST_BLACKLIST" && catkin config --blacklist $TEST_BLACKLIST &> /dev/null + # Consider TEST_WHITELIST + if [ -z "${TEST_WHITELIST:-}" ]; then + TEST_WHITELIST=$(unify_list " ,;" ${TEST_WHITELIST:-}) + echo -e $(colorize GREEN Test blacklist: $(colorize THIN $TEST_WHITELIST)) + test -n "$TEST_WHITELIST" && catkin config --whitelist $TEST_WHITELIST &> /dev/null + fi + # Also blacklist external packages local all_pkgs source_pkgs blacklist_pkgs all_pkgs=$(catkin_topological_order $ROS_WS/src --only-names) From a95ddd7cc5817c4f4704ee51e7ed397c27bd2dbb Mon Sep 17 00:00:00 2001 From: Tyler Weaver Date: Sat, 16 Nov 2019 15:21:48 -0700 Subject: [PATCH 12/33] fixup! add support for TEST_WHITELIST --- travis.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/travis.sh b/travis.sh index a238e205..94eb282c 100755 --- a/travis.sh +++ b/travis.sh @@ -305,7 +305,7 @@ function test_workspace() { # Consider TEST_WHITELIST if [ -z "${TEST_WHITELIST:-}" ]; then TEST_WHITELIST=$(unify_list " ,;" ${TEST_WHITELIST:-}) - echo -e $(colorize GREEN Test blacklist: $(colorize THIN $TEST_WHITELIST)) + echo -e $(colorize GREEN Test whitelist: $(colorize THIN $TEST_WHITELIST)) test -n "$TEST_WHITELIST" && catkin config --whitelist $TEST_WHITELIST &> /dev/null fi From 21a7ecb12c1bc022d652d9d7f1aacd0798da55a4 Mon Sep 17 00:00:00 2001 From: Tyler Weaver Date: Sat, 16 Nov 2019 15:24:22 -0700 Subject: [PATCH 13/33] fixup! add support for TEST_WHITELIST --- travis.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/travis.sh b/travis.sh index 94eb282c..9c749c0b 100755 --- a/travis.sh +++ b/travis.sh @@ -304,9 +304,9 @@ function test_workspace() { # Consider TEST_WHITELIST if [ -z "${TEST_WHITELIST:-}" ]; then - TEST_WHITELIST=$(unify_list " ,;" ${TEST_WHITELIST:-}) - echo -e $(colorize GREEN Test whitelist: $(colorize THIN $TEST_WHITELIST)) - test -n "$TEST_WHITELIST" && catkin config --whitelist $TEST_WHITELIST &> /dev/null + TEST_WHITELIST=$(unify_list " ,;" ${TEST_WHITELIST:-}) + echo -e $(colorize GREEN Test whitelist: $(colorize THIN $TEST_WHITELIST)) + test -n "$TEST_WHITELIST" && catkin config --whitelist $TEST_WHITELIST &> /dev/null fi # Also blacklist external packages From 244844093586eae66d1ca5b981e0f522138ad497 Mon Sep 17 00:00:00 2001 From: Tyler Weaver Date: Sat, 16 Nov 2019 16:13:54 -0700 Subject: [PATCH 14/33] fixup! add support for TEST_WHITELIST --- travis.sh | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/travis.sh b/travis.sh index 9c749c0b..54da0533 100755 --- a/travis.sh +++ b/travis.sh @@ -303,11 +303,10 @@ function test_workspace() { test -n "$TEST_BLACKLIST" && catkin config --blacklist $TEST_BLACKLIST &> /dev/null # Consider TEST_WHITELIST - if [ -z "${TEST_WHITELIST:-}" ]; then - TEST_WHITELIST=$(unify_list " ,;" ${TEST_WHITELIST:-}) - echo -e $(colorize GREEN Test whitelist: $(colorize THIN $TEST_WHITELIST)) - test -n "$TEST_WHITELIST" && catkin config --whitelist $TEST_WHITELIST &> /dev/null - fi + TEST_WHITELIST=$(unify_list " ,;" ${TEST_WHITELIST:-}) + echo -e $(colorize GREEN Test whitelist: $(colorize THIN $TEST_WHITELIST)) + test -n "$TEST_WHITELIST" && catkin config --whitelist $TEST_WHITELIST &> /dev/null + # Also blacklist external packages local all_pkgs source_pkgs blacklist_pkgs From 248c635c2b1963a9578d7801115aeed240a7bd9f Mon Sep 17 00:00:00 2001 From: Tyler Weaver Date: Sat, 16 Nov 2019 22:23:52 -0700 Subject: [PATCH 15/33] fixup! add support for TEST_WHITELIST --- travis.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/travis.sh b/travis.sh index 54da0533..cb2201be 100755 --- a/travis.sh +++ b/travis.sh @@ -304,7 +304,7 @@ function test_workspace() { # Consider TEST_WHITELIST TEST_WHITELIST=$(unify_list " ,;" ${TEST_WHITELIST:-}) - echo -e $(colorize GREEN Test whitelist: $(colorize THIN $TEST_WHITELIST)) + echo -e $(colorize YELLOW Test whitelist: $(colorize THIN $TEST_WHITELIST)) test -n "$TEST_WHITELIST" && catkin config --whitelist $TEST_WHITELIST &> /dev/null From 974df38245e4a4f60fe42ee056b7508c5b24d4fd Mon Sep 17 00:00:00 2001 From: Tyler Weaver Date: Sun, 17 Nov 2019 11:43:50 -0700 Subject: [PATCH 16/33] Update README.md Co-Authored-By: Robert Haschke --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index dfa1178f..31811ac6 100644 --- a/README.md +++ b/README.md @@ -147,7 +147,7 @@ It's also possible to run the script without using docker. To this end, issue th ## Enabling codecov.io reporting -For codecov to work you need to build and link your C++ code with specific parameters. To enable this we use the ROS package [code_coverage](https://github.com/mikeferguson/code_coverage). To to use the `code-coverage` test in your repo make these two changes: +For codecov to work you need to build and link your C++ code with specific parameters. To enable this we use the ROS package [code_coverage](https://github.com/mikeferguson/code_coverage). Using the `code-coverage` test in your repo requires the following two changes: 1. Add `code_coverage` to your package.xml 1. Add this to your `CMakeLists.txt`: From 522ed45939135894644254beeda17855326b91f3 Mon Sep 17 00:00:00 2001 From: Tyler Weaver Date: Sun, 17 Nov 2019 11:44:03 -0700 Subject: [PATCH 17/33] Update README.md Co-Authored-By: Robert Haschke --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 31811ac6..dfc7bee5 100644 --- a/README.md +++ b/README.md @@ -150,7 +150,7 @@ It's also possible to run the script without using docker. To this end, issue th For codecov to work you need to build and link your C++ code with specific parameters. To enable this we use the ROS package [code_coverage](https://github.com/mikeferguson/code_coverage). Using the `code-coverage` test in your repo requires the following two changes: 1. Add `code_coverage` to your package.xml -1. Add this to your `CMakeLists.txt`: +2. Add this to your `CMakeLists.txt`: ```cmake # to run: catkin_make -DENABLE_COVERAGE_TESTING=ON package_name_coverage From 5bd9305abe23a41feb10a9060427be948f9e0db0 Mon Sep 17 00:00:00 2001 From: Tyler Weaver Date: Sun, 17 Nov 2019 11:54:51 -0700 Subject: [PATCH 18/33] make unit test cmake match example in README --- test_pkgs/valid/CMakeLists.txt | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/test_pkgs/valid/CMakeLists.txt b/test_pkgs/valid/CMakeLists.txt index 7f1e21a5..3df5cc1a 100644 --- a/test_pkgs/valid/CMakeLists.txt +++ b/test_pkgs/valid/CMakeLists.txt @@ -11,12 +11,13 @@ include_directories( ) if (CATKIN_ENABLE_TESTING) - find_package(code_coverage REQUIRED) - - if(ENABLE_COVERAGE_TESTING) - include(CodeCoverage) - APPEND_COVERAGE_COMPILER_FLAGS() - endif() - catkin_add_gtest(${PROJECT_NAME} test.cpp) endif() + +# to run: catkin_make -DENABLE_COVERAGE_TESTING=ON package_name_coverage +if(CATKIN_ENABLE_TESTING AND ENABLE_COVERAGE_TESTING) + find_package(code_coverage REQUIRED) # catkin package ros-*-code-coverage + include(CodeCoverage) + APPEND_COVERAGE_COMPILER_FLAGS() + add_code_coverage(NAME ${PROJECT_NAME}_coverage) +endif() From bfe4b2fa529f54cf7549da6bdc59be779d0a4550 Mon Sep 17 00:00:00 2001 From: Tyler Weaver Date: Sun, 17 Nov 2019 16:48:49 -0700 Subject: [PATCH 19/33] respond to review --- README.md | 1 - test_pkgs/valid/CMakeLists.txt | 3 +-- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/README.md b/README.md index dfc7bee5..6e53faed 100644 --- a/README.md +++ b/README.md @@ -159,7 +159,6 @@ if(CATKIN_ENABLE_TESTING AND ENABLE_COVERAGE_TESTING) include(CodeCoverage) APPEND_COVERAGE_COMPILER_FLAGS() set(COVERAGE_EXCLUDES "*/test/*") - add_code_coverage(NAME ${PROJECT_NAME}_coverage) endif() ``` diff --git a/test_pkgs/valid/CMakeLists.txt b/test_pkgs/valid/CMakeLists.txt index 3df5cc1a..e6a7796e 100644 --- a/test_pkgs/valid/CMakeLists.txt +++ b/test_pkgs/valid/CMakeLists.txt @@ -16,8 +16,7 @@ endif() # to run: catkin_make -DENABLE_COVERAGE_TESTING=ON package_name_coverage if(CATKIN_ENABLE_TESTING AND ENABLE_COVERAGE_TESTING) - find_package(code_coverage REQUIRED) # catkin package ros-*-code-coverage + find_package(code_coverage REQUIRED) # catkin package ros-*-code-coverage include(CodeCoverage) APPEND_COVERAGE_COMPILER_FLAGS() - add_code_coverage(NAME ${PROJECT_NAME}_coverage) endif() From 54b8ba09d7fbd704bd3a2530f9a515de3382268d Mon Sep 17 00:00:00 2001 From: Tyler Weaver Date: Mon, 18 Nov 2019 07:08:26 -0700 Subject: [PATCH 20/33] add .codecov.yml back into readme --- README.md | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 6e53faed..eadee588 100644 --- a/README.md +++ b/README.md @@ -147,7 +147,7 @@ It's also possible to run the script without using docker. To this end, issue th ## Enabling codecov.io reporting -For codecov to work you need to build and link your C++ code with specific parameters. To enable this we use the ROS package [code_coverage](https://github.com/mikeferguson/code_coverage). Using the `code-coverage` test in your repo requires the following two changes: +For codecov to work you need to build and link your C++ code with specific parameters. To enable this we use the ROS package [code_coverage](https://github.com/mikeferguson/code_coverage). Using the `code-coverage` test in your repo requires the following three changes: 1. Add `code_coverage` to your package.xml 2. Add this to your `CMakeLists.txt`: @@ -158,10 +158,16 @@ if(CATKIN_ENABLE_TESTING AND ENABLE_COVERAGE_TESTING) find_package(code_coverage REQUIRED) # catkin package ros-*-code-coverage include(CodeCoverage) APPEND_COVERAGE_COMPILER_FLAGS() - set(COVERAGE_EXCLUDES "*/test/*") endif() ``` +3. Add a `.codecov.yml` file to your project root to specifiy what codecov.io's script should ignore: + +```yaml +ignore: + - "**/test/.*" +``` + Then you can use the `code-coverage` test and it will run the script provided by [codecov.io](codecov.io) which runs `gcov` to generate the reports and then compiles them into a report and uploads them to their servers. If you are using this on a private github repo you will need to set the `CODECOV_TOKEN` enviroment variable in the `global` section of your `.travis.yml` file to the value you can find on the settings page of your project on codecov.io. From 8515b98fc356bb2c67a5c146038df5156eaf9929 Mon Sep 17 00:00:00 2001 From: Tyler Weaver Date: Mon, 18 Nov 2019 15:57:33 -0700 Subject: [PATCH 21/33] Update test_pkgs/valid/CMakeLists.txt Co-Authored-By: Robert Haschke --- test_pkgs/valid/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test_pkgs/valid/CMakeLists.txt b/test_pkgs/valid/CMakeLists.txt index e6a7796e..a8d2629e 100644 --- a/test_pkgs/valid/CMakeLists.txt +++ b/test_pkgs/valid/CMakeLists.txt @@ -10,7 +10,7 @@ include_directories( ${catkin_INCLUDE_DIRS} ) -if (CATKIN_ENABLE_TESTING) +if(CATKIN_ENABLE_TESTING) catkin_add_gtest(${PROJECT_NAME} test.cpp) endif() From 1b4273f57f94f5ef5017345e28c5a4310db36e32 Mon Sep 17 00:00:00 2001 From: Tyler Weaver Date: Mon, 18 Nov 2019 15:57:43 -0700 Subject: [PATCH 22/33] Update test_pkgs/valid/CMakeLists.txt Co-Authored-By: Robert Haschke --- test_pkgs/valid/CMakeLists.txt | 1 - 1 file changed, 1 deletion(-) diff --git a/test_pkgs/valid/CMakeLists.txt b/test_pkgs/valid/CMakeLists.txt index a8d2629e..3ee6a1bc 100644 --- a/test_pkgs/valid/CMakeLists.txt +++ b/test_pkgs/valid/CMakeLists.txt @@ -14,7 +14,6 @@ if(CATKIN_ENABLE_TESTING) catkin_add_gtest(${PROJECT_NAME} test.cpp) endif() -# to run: catkin_make -DENABLE_COVERAGE_TESTING=ON package_name_coverage if(CATKIN_ENABLE_TESTING AND ENABLE_COVERAGE_TESTING) find_package(code_coverage REQUIRED) # catkin package ros-*-code-coverage include(CodeCoverage) From 28c9091b654667321f86795ddcfda7b7b4e505bd Mon Sep 17 00:00:00 2001 From: Tyler Weaver Date: Tue, 19 Nov 2019 11:56:17 -0700 Subject: [PATCH 23/33] gcov ignore files in test directory --- travis.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/travis.sh b/travis.sh index cb2201be..633757a6 100755 --- a/travis.sh +++ b/travis.sh @@ -390,7 +390,8 @@ for t in $(unify_list " ,;" "$TEST") ; do test $? -eq 0 || result=$(( ${result:-0} + 1 )) ;; code-coverage) - travis_run --title "codecov.io report upload" bash <(curl -s https://codecov.io/bash) -s $ROS_WS -R $ROS_WS/src/$REPOSITORY_NAME + travis_run --title "codecov.io report upload" bash <(curl -s https://codecov.io/bash) \ + -s $ROS_WS -R $ROS_WS/src/$REPOSITORY_NAME -g '*/test/*' ;; esac done From 098f5dd9a429761168f355f5ac3f7d46f78d9ef0 Mon Sep 17 00:00:00 2001 From: Tyler Weaver Date: Tue, 19 Nov 2019 13:22:57 -0700 Subject: [PATCH 24/33] remove codecov.yml instructions from README.md --- README.md | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/README.md b/README.md index eadee588..6d4c2c9f 100644 --- a/README.md +++ b/README.md @@ -147,7 +147,7 @@ It's also possible to run the script without using docker. To this end, issue th ## Enabling codecov.io reporting -For codecov to work you need to build and link your C++ code with specific parameters. To enable this we use the ROS package [code_coverage](https://github.com/mikeferguson/code_coverage). Using the `code-coverage` test in your repo requires the following three changes: +For codecov to work you need to build and link your C++ code with specific parameters. To enable this we use the ROS package [code_coverage](https://github.com/mikeferguson/code_coverage). Using the `code-coverage` test in your repo requires the following two changes: 1. Add `code_coverage` to your package.xml 2. Add this to your `CMakeLists.txt`: @@ -161,13 +161,6 @@ if(CATKIN_ENABLE_TESTING AND ENABLE_COVERAGE_TESTING) endif() ``` -3. Add a `.codecov.yml` file to your project root to specifiy what codecov.io's script should ignore: - -```yaml -ignore: - - "**/test/.*" -``` - Then you can use the `code-coverage` test and it will run the script provided by [codecov.io](codecov.io) which runs `gcov` to generate the reports and then compiles them into a report and uploads them to their servers. If you are using this on a private github repo you will need to set the `CODECOV_TOKEN` enviroment variable in the `global` section of your `.travis.yml` file to the value you can find on the settings page of your project on codecov.io. From 50302b74a2d86e98131344d8abbf3afa0932fa85 Mon Sep 17 00:00:00 2001 From: Tyler Weaver Date: Tue, 19 Nov 2019 15:06:02 -0700 Subject: [PATCH 25/33] test whitelist applied to build --- travis.sh | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/travis.sh b/travis.sh index 633757a6..6556ff4f 100755 --- a/travis.sh +++ b/travis.sh @@ -282,8 +282,14 @@ function build_workspace() { # Console output fix for: "WARNING: Could not encode unicode characters" export PYTHONIOENCODING=UTF-8 - # For a command that doesn’t produce output for more than 10 minutes, prefix it with travis_run_wait - travis_run_wait 60 --title "catkin build" catkin build --no-status --summarize + # If test whitelist is set, explicitly build that project + if [ "${TEST_WHITELIST:-:-}" ]; then + # For a command that doesn’t produce output for more than 10 minutes, prefix it with travis_run_wait + travis_run_wait 60 --title "catkin build ${TEST_WHITELIST}" catkin build $TEST_WHITELIST --no-status --summarize + else + # For a command that doesn’t produce output for more than 10 minutes, prefix it with travis_run_wait + travis_run_wait 60 --title "catkin build" catkin build --no-status --summarize + fi # Allow to verify ccache usage travis_run --title "ccache statistics" ccache -s From fa69f0a6fe773e5dd41caa87bff6232d67da6edb Mon Sep 17 00:00:00 2001 From: Tyler Weaver Date: Tue, 19 Nov 2019 15:28:31 -0700 Subject: [PATCH 26/33] fixup! test whitelist applied to build --- travis.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/travis.sh b/travis.sh index 6556ff4f..644451a0 100755 --- a/travis.sh +++ b/travis.sh @@ -283,7 +283,7 @@ function build_workspace() { export PYTHONIOENCODING=UTF-8 # If test whitelist is set, explicitly build that project - if [ "${TEST_WHITELIST:-:-}" ]; then + if [ "${TEST_WHITELIST:-}" ]; then # For a command that doesn’t produce output for more than 10 minutes, prefix it with travis_run_wait travis_run_wait 60 --title "catkin build ${TEST_WHITELIST}" catkin build $TEST_WHITELIST --no-status --summarize else From 81bac21fb138a5a15ed8baf704cebd2216b481ac Mon Sep 17 00:00:00 2001 From: Tyler Weaver Date: Tue, 19 Nov 2019 19:20:39 -0700 Subject: [PATCH 27/33] redirect output of codecov script to avoid filling logs --- travis.sh | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/travis.sh b/travis.sh index 644451a0..714d69af 100755 --- a/travis.sh +++ b/travis.sh @@ -396,8 +396,10 @@ for t in $(unify_list " ,;" "$TEST") ; do test $? -eq 0 || result=$(( ${result:-0} + 1 )) ;; code-coverage) - travis_run --title "codecov.io report upload" bash <(curl -s https://codecov.io/bash) \ - -s $ROS_WS -R $ROS_WS/src/$REPOSITORY_NAME -g '*/test/*' + # redirect output to avoid failures due to filling up logs + travis_run --title "codeco1v.io report upload" \ + bash <(curl -s https://codecov.io/bash) -s $ROS_WS \ + -R $ROS_WS/src/$REPOSITORY_NAME -g '*/test/*' 2> dev/null ;; esac done From 7a6be1e68127abe2143460d655e7caa25cf37e49 Mon Sep 17 00:00:00 2001 From: Tyler Weaver Date: Tue, 19 Nov 2019 20:35:14 -0700 Subject: [PATCH 28/33] fixup! redirect output of codecov script to avoid filling logs --- travis.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/travis.sh b/travis.sh index 714d69af..b4a76b28 100755 --- a/travis.sh +++ b/travis.sh @@ -399,7 +399,7 @@ for t in $(unify_list " ,;" "$TEST") ; do # redirect output to avoid failures due to filling up logs travis_run --title "codeco1v.io report upload" \ bash <(curl -s https://codecov.io/bash) -s $ROS_WS \ - -R $ROS_WS/src/$REPOSITORY_NAME -g '*/test/*' 2> dev/null + -R $ROS_WS/src/$REPOSITORY_NAME -g '*/test/*' 2> /dev/null ;; esac done From e370f5cca6cc581c0931ea6baa60881029f29a7f Mon Sep 17 00:00:00 2001 From: Tyler Weaver Date: Tue, 19 Nov 2019 21:48:38 -0700 Subject: [PATCH 29/33] fixup! redirect output of codecov script to avoid filling logs --- travis.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/travis.sh b/travis.sh index b4a76b28..95a3de2f 100755 --- a/travis.sh +++ b/travis.sh @@ -399,7 +399,7 @@ for t in $(unify_list " ,;" "$TEST") ; do # redirect output to avoid failures due to filling up logs travis_run --title "codeco1v.io report upload" \ bash <(curl -s https://codecov.io/bash) -s $ROS_WS \ - -R $ROS_WS/src/$REPOSITORY_NAME -g '*/test/*' 2> /dev/null + -R $ROS_WS/src/$REPOSITORY_NAME -g '*/test/*' > /dev/null ;; esac done From 6d04961410a12306b63058eb42a9a7f020eb9f3b Mon Sep 17 00:00:00 2001 From: Tyler Weaver Date: Tue, 19 Nov 2019 22:14:50 -0700 Subject: [PATCH 30/33] set compile flag to improve ccache hit rate --- travis.sh | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/travis.sh b/travis.sh index 95a3de2f..992b288c 100755 --- a/travis.sh +++ b/travis.sh @@ -282,6 +282,10 @@ function build_workspace() { # Console output fix for: "WARNING: Could not encode unicode characters" export PYTHONIOENCODING=UTF-8 + # Set compile flag to improve ccache hit rate + export CXXFLAGS="$CXXFLAGS -fdebug-prefix-map=$(pwd)=." + echo "CXXFLAGS = $CXXFLAGS" + # If test whitelist is set, explicitly build that project if [ "${TEST_WHITELIST:-}" ]; then # For a command that doesn’t produce output for more than 10 minutes, prefix it with travis_run_wait From 949b5ed9d9f7e907b5064e2ca1cb1c9ad40e2821 Mon Sep 17 00:00:00 2001 From: Tyler Weaver Date: Tue, 19 Nov 2019 22:25:05 -0700 Subject: [PATCH 31/33] add support for ccache enviroment variables --- travis.sh | 2 ++ 1 file changed, 2 insertions(+) diff --git a/travis.sh b/travis.sh index 992b288c..3d548f7a 100755 --- a/travis.sh +++ b/travis.sh @@ -93,6 +93,8 @@ function run_docker() { -e CXX=${CXX_FOR_BUILD:-${CXX:-c++}} \ -e CFLAGS \ -e CXXFLAGS \ + -e CCACHE_SLOPPINESS \ + -e CCACHE_MAXSIZE \ $CI_ENV_PARAMS \ -v $(pwd):/root/$REPOSITORY_NAME \ -v ${CCACHE_DIR:-$HOME/.ccache}:/root/.ccache \ From 09db83a29347c574e5f8c8d895034dca0b73276d Mon Sep 17 00:00:00 2001 From: Tyler Weaver Date: Wed, 20 Nov 2019 05:55:08 -0700 Subject: [PATCH 32/33] reduce complexity of catkin build line --- travis.sh | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/travis.sh b/travis.sh index 3d548f7a..758b121c 100755 --- a/travis.sh +++ b/travis.sh @@ -285,17 +285,12 @@ function build_workspace() { export PYTHONIOENCODING=UTF-8 # Set compile flag to improve ccache hit rate - export CXXFLAGS="$CXXFLAGS -fdebug-prefix-map=$(pwd)=." + export CXXFLAGS="${CXXFLAGS:-} -fdebug-prefix-map=$(pwd)=." echo "CXXFLAGS = $CXXFLAGS" # If test whitelist is set, explicitly build that project - if [ "${TEST_WHITELIST:-}" ]; then - # For a command that doesn’t produce output for more than 10 minutes, prefix it with travis_run_wait - travis_run_wait 60 --title "catkin build ${TEST_WHITELIST}" catkin build $TEST_WHITELIST --no-status --summarize - else - # For a command that doesn’t produce output for more than 10 minutes, prefix it with travis_run_wait - travis_run_wait 60 --title "catkin build" catkin build --no-status --summarize - fi + # For a command that doesn’t produce output for more than 10 minutes, prefix it with travis_run_wait + travis_run_wait 60 --title "catkin build ${TEST_WHITELIST:-}" catkin build ${TEST_WHITELIST:-} --no-status --summarize # Allow to verify ccache usage travis_run --title "ccache statistics" ccache -s From 38e96b4bd70d22bb1ce629a4f8ecec5a15ff1932 Mon Sep 17 00:00:00 2001 From: Tyler Weaver Date: Wed, 20 Nov 2019 06:27:45 -0700 Subject: [PATCH 33/33] set ccache base dir --- travis.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/travis.sh b/travis.sh index 758b121c..92123960 100755 --- a/travis.sh +++ b/travis.sh @@ -286,7 +286,7 @@ function build_workspace() { # Set compile flag to improve ccache hit rate export CXXFLAGS="${CXXFLAGS:-} -fdebug-prefix-map=$(pwd)=." - echo "CXXFLAGS = $CXXFLAGS" + export CCACHE_BASEDIR=$(pwd) # If test whitelist is set, explicitly build that project # For a command that doesn’t produce output for more than 10 minutes, prefix it with travis_run_wait