From a47dd3d489d93ca3550364f63fe46d90e9293054 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mathias=20L=C3=BCdtke?= Date: Mon, 16 Jan 2017 01:50:26 +0100 Subject: [PATCH 01/16] do not source ci_main.sh --- industrial_ci/ci_main.sh | 1 - travis.sh | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/industrial_ci/ci_main.sh b/industrial_ci/ci_main.sh index a31213505..caefa73a4 100755 --- a/industrial_ci/ci_main.sh +++ b/industrial_ci/ci_main.sh @@ -66,5 +66,4 @@ fi cd $TARGET_REPO_PATH # cd back to the repository's home directory with travis pwd -if [ "$DEBUG_BASH" ] && [ "$DEBUG_BASH" == true ]; then set +x; fi # disable command printing at end of script, TODO: factor out into function # exit with code 0 diff --git a/travis.sh b/travis.sh index 9d9a4753a..47e1cfe64 100755 --- a/travis.sh +++ b/travis.sh @@ -39,5 +39,5 @@ export TARGET_REPO_NAME=${PWD##*/} # Call the "core" executable of this repo to run all kinds of tests. cd $DIR_THIS/industrial_ci -source ./ci_main.sh +./ci_main.sh || return $? cd $DIR_THIS # Moves back to the repository root dir. From da012db4f9d7c9b6fd0d11ab1cacca9ac81c54cd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mathias=20L=C3=BCdtke?= Date: Mon, 16 Jan 2017 03:00:06 +0100 Subject: [PATCH 02/16] bug fix for folding on errors --- industrial_ci/util.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/industrial_ci/util.sh b/industrial_ci/util.sh index b40fdbaa4..8619035ba 100644 --- a/industrial_ci/util.sh +++ b/industrial_ci/util.sh @@ -86,7 +86,7 @@ function _end_fold_script { color_wrap=${2:-32} if [ $exit_code -eq "1" ]; then color_wrap=31; fi # Red color - if [ -z $TRAVIS_FOLD_NAME ]; then + if ! [ -z $TRAVIS_FOLD_NAME ]; then ici_time_end $color_wrap else echo "Previous Travis fold name not found. It might be either successful termination of the script, or wrong call. Skipping 'ici_time_end' anyway." From 3cced8ac972f935bc4d24e2b8f33bec6241d30ac Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mathias=20L=C3=BCdtke?= Date: Mon, 16 Jan 2017 07:20:49 +0100 Subject: [PATCH 03/16] fixed folding color assignment --- industrial_ci/util.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/industrial_ci/util.sh b/industrial_ci/util.sh index 8619035ba..bd3299568 100644 --- a/industrial_ci/util.sh +++ b/industrial_ci/util.sh @@ -56,7 +56,7 @@ function ici_time_start { ####################################### function ici_time_end { if [ "$DEBUG_BASH" ] && [ "$DEBUG_BASH" == true ]; then set +x; fi - color_wrap=${2:-32} + color_wrap=${1:-32} if [ -z $TRAVIS_START_TIME ]; then echo '[ici_time_end] var TRAVIS_START_TIME is not set. You need to call `ici_time_start` in advance. Rerutning.'; return; fi TRAVIS_END_TIME=$(date +%s%N) From 5ec2966b8a3fb05cf1e03ae5344dc311dfa8e1fd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mathias=20L=C3=BCdtke?= Date: Mon, 16 Jan 2017 07:52:18 +0100 Subject: [PATCH 04/16] go back to $TARGET_REPO_PATH instead of $DIR_THIS --- travis.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/travis.sh b/travis.sh index 47e1cfe64..4338ca55c 100755 --- a/travis.sh +++ b/travis.sh @@ -40,4 +40,4 @@ export TARGET_REPO_NAME=${PWD##*/} # Call the "core" executable of this repo to run all kinds of tests. cd $DIR_THIS/industrial_ci ./ci_main.sh || return $? -cd $DIR_THIS # Moves back to the repository root dir. +cd $TARGET_REPO_PATH # Moves back to the repository root dir. From a3b6fb58602cedbbfc825a281b47e018e201acdf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mathias=20L=C3=BCdtke?= Date: Mon, 16 Jan 2017 08:13:57 +0100 Subject: [PATCH 05/16] do not source travis.sh, but keep it compatible to source --- .travis.yml | 2 +- README.rst | 20 ++++++++++---------- travis.sh | 13 +++++++++---- 3 files changed, 20 insertions(+), 15 deletions(-) diff --git a/.travis.yml b/.travis.yml index 1b410b0cd..f3f672a14 100644 --- a/.travis.yml +++ b/.travis.yml @@ -60,5 +60,5 @@ before_script: - if [ "${USE_CATKIN_MAKE}" == "true" ] ;then sed -i 's@catkin run_tests --no-deps --limit-status-rate 0.001@catkin_make run_tests@' $CI_DIR/travis.sh; fi - if [ "${USE_CATKIN_MAKE}" == "true" ] ;then export CATKIN_PARALLEL_JOBS="--no-color" ; fi script: - - source $CI_DIR/travis.sh + - $CI_DIR/travis.sh - if ! [ -z "$POST_PROCESS" ]; then $POST_PROCESS; fi diff --git a/README.rst b/README.rst index f4a0a9e81..6ebecc229 100644 --- a/README.rst +++ b/README.rst @@ -110,7 +110,7 @@ With the following few short steps, you can start in your client repository usin before_config: - git clone https://github.com/ros-industrial/industrial_ci.git .ci_config script: - - source .ci_config/travis.sh + - .ci_config/travis.sh * Note that `.ci_config` is the required name of the cloned folder; it is hardcoded so you need to use this name. * Example of entire file `.travis.yml` can be found in `industrial_core/.travis.yml `_. @@ -187,8 +187,8 @@ Sometimes CI config stored in `industrial_ci` repo may not be sufficient for you :: script: - - source .ci_config/travis.sh - - source ./travis.sh + - .ci_config/travis.sh + - ./travis.sh 2. Create `travis.sh` file and define the checks you wish to add. NOTE: this `.sh` file you add here is a normal shell script, so this shouldn't be written in `travis CI` grammar. @@ -220,8 +220,8 @@ This standard `git submodule` command: :: script: - - source .ci_config/travis.sh - #- source ./travis.sh # Optional. Explained later + - .ci_config/travis.sh + #- ./travis.sh # Optional. Explained later Also, the example of entire file `.travis.yml` can be found in `industrial_core/.travis.yml `_. @@ -287,16 +287,16 @@ You may want to add custom steps prior to the setup defined in `./travis.sh <./t * You want to run `ros_lint` (`thi discussion `_ may be of your interest). -In this case, add `source`d scripts before `travis.sh` gets called (see below for an example). +In this case, add scripts before `travis.sh` gets called (see below for an example). :: script: - - source ./your_custom_PREprocess.sh - - source .ci_config/travis.sh - - source ./your_custom_POSTprocess.sh + - ./your_custom_PREprocess.sh + - .ci_config/travis.sh + - ./your_custom_POSTprocess.sh -In the above case, in both `.ci_config/travis.sh` and `your_custom_POSTprocess.sh` the environment is kept from previous script(s), so whatever is done in previous scripts remains. +Please note: the environment is NOT kept from between script(s). (Optional) Build depended packages from source ---------------------------------------------- diff --git a/travis.sh b/travis.sh index 4338ca55c..ea42926cd 100755 --- a/travis.sh +++ b/travis.sh @@ -37,7 +37,12 @@ DIR_THIS="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" export TARGET_REPO_PATH=$(pwd) export TARGET_REPO_NAME=${PWD##*/} -# Call the "core" executable of this repo to run all kinds of tests. -cd $DIR_THIS/industrial_ci -./ci_main.sh || return $? -cd $TARGET_REPO_PATH # Moves back to the repository root dir. +function main { + # Call the "core" executable of this repo to run all kinds of tests. + cd $DIR_THIS/industrial_ci + local ret=0 + ./ci_main.sh || ret=$? + cd $TARGET_REPO_PATH # Moves back to the repository root dir. + return $ret +} +main # result of main function if resul of script \ No newline at end of file From afef7e999570f46c232cf113fc317bd9a3ca686f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mathias=20L=C3=BCdtke?= Date: Mon, 16 Jan 2017 08:25:26 +0100 Subject: [PATCH 06/16] introduced CATKIN_WORKSPACE variable --- industrial_ci/source_tests.sh | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/industrial_ci/source_tests.sh b/industrial_ci/source_tests.sh index 27cbbad7c..16fe0a645 100755 --- a/industrial_ci/source_tests.sh +++ b/industrial_ci/source_tests.sh @@ -153,8 +153,9 @@ ici_time_start setup_rosws ## BEGIN: travis' install: # Use this to install any prerequisites or dependencies necessary to run your build ## # Create workspace -mkdir -p ~/ros/ws_$TARGET_REPO_NAME/src -cd ~/ros/ws_$TARGET_REPO_NAME/src +CATKIN_WORKSPACE=~/catkin_ws +mkdir -p $CATKIN_WORKSPACE/src +cd $CATKIN_WORKSPACE/src case "$UPSTREAM_WORKSPACE" in debian) echo "Obtain deb binary for upstream packages." @@ -214,18 +215,19 @@ ici_time_end # before_script ici_time_start rosdep_install -sudo rosdep install -q --from-paths . --ignore-src --rosdistro $ROS_DISTRO -y +sudo rosdep install -q --from-paths $CATKIN_WORKSPACE --ignore-src --rosdistro $ROS_DISTRO -y ici_time_end # rosdep_install ici_time_start wstool_info $ROSWS --version -$ROSWS info -t . -cd ../ +$ROSWS info -t $CATKIN_WORKSPACE/src ici_time_end # wstool_info ici_time_start catkin_build +cd $CATKIN_WORKSPACE + ## BEGIN: travis' script: # All commands must exit with code 0 on success. Anything else is considered failure. source /opt/ros/$ROS_DISTRO/setup.bash # re-source setup.bash for setting environmet vairable for package installed via rosdep # for catkin @@ -304,7 +306,7 @@ PYTHONPATH=/usr/local/lib/python2.7/dist-packages:$PYTHONPATH if [ "${ROS_LOG_DIR// }" == "" ]; then export ROS_LOG_DIR=~/.ros/test_results; fi # http://wiki.ros.org/ROS/EnvironmentVariables#ROS_LOG_DIR if [ "$BUILDER" == catkin -a -e $ROS_LOG_DIR ]; then $CATKIN_TEST_RESULTS_CMD --all $ROS_LOG_DIR || error; fi -if [ "$BUILDER" == catkin -a -e ~/ros/ws_$TARGET_REPO_NAME/build/ ]; then $CATKIN_TEST_RESULTS_CMD --all ~/ros/ws_$TARGET_REPO_NAME/build/ || error; fi +if [ "$BUILDER" == catkin -a -e $CATKIN_WORKSPACE/build/ ]; then $CATKIN_TEST_RESULTS_CMD --all $CATKIN_WORKSPACE/build/ || error; fi if [ "$BUILDER" == catkin -a -e ~/.ros/test_results/ ]; then $CATKIN_TEST_RESULTS_CMD --all ~/.ros/test_results/ || error; fi ici_time_end # after_script From 55e302c836c857ba70b5657aa47df4eca69b2fe8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mathias=20L=C3=BCdtke?= Date: Mon, 16 Jan 2017 08:51:14 +0100 Subject: [PATCH 07/16] fix BEFORE_SCRIPT context, exit on errors --- .travis.yml | 2 +- industrial_ci/source_tests.sh | 5 ++++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index f3f672a14..02639df23 100644 --- a/.travis.yml +++ b/.travis.yml @@ -55,7 +55,7 @@ matrix: before_script: - CI_DIR=. - - export BEFORE_SCRIPT="rm -fr common_travis/CATKIN_IGNORE; ${BEFORE_SCRIPT}" + - "export BEFORE_SCRIPT='echo current dir: $(pwd)'" - if [ "${USE_CATKIN_MAKE}" == "true" ] ;then sed -i 's@catkin build -i -v --limit-status-rate 0.001@catkin_make@' $CI_DIR/travis.sh; fi - if [ "${USE_CATKIN_MAKE}" == "true" ] ;then sed -i 's@catkin run_tests --no-deps --limit-status-rate 0.001@catkin_make run_tests@' $CI_DIR/travis.sh; fi - if [ "${USE_CATKIN_MAKE}" == "true" ] ;then export CATKIN_PARALLEL_JOBS="--no-color" ; fi diff --git a/industrial_ci/source_tests.sh b/industrial_ci/source_tests.sh index 16fe0a645..bec66323f 100755 --- a/industrial_ci/source_tests.sh +++ b/industrial_ci/source_tests.sh @@ -209,7 +209,10 @@ ici_time_start before_script ## BEGIN: travis' before_script: # Use this to prepare your build for testing e.g. copy database configurations, environment variables, etc. source /opt/ros/$ROS_DISTRO/setup.bash # re-source setup.bash for setting environmet vairable for package installed via rosdep -if [ "${BEFORE_SCRIPT// }" != "" ]; then sh -c "${BEFORE_SCRIPT}"; fi + +# execute BEFORE_SCRIPT in repository, exit on errors +cd $TARGET_REPO_PATH +if [ "${BEFORE_SCRIPT// }" != "" ]; then sh -e -c "${BEFORE_SCRIPT}"; fi ici_time_end # before_script From f2f86efb8788c379209ff5f7b3b3a04c4669a0d8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mathias=20L=C3=BCdtke?= Date: Mon, 16 Jan 2017 09:04:03 +0100 Subject: [PATCH 08/16] added support for AFTER_SCRIPT --- .travis.yml | 2 +- README.rst | 14 +++++++++++++- industrial_ci/ci_main.sh | 8 +++++++- industrial_ci/docker.env | 1 + industrial_ci/source_tests.sh | 5 +++-- 5 files changed, 25 insertions(+), 5 deletions(-) diff --git a/.travis.yml b/.travis.yml index 02639df23..08281f132 100644 --- a/.travis.yml +++ b/.travis.yml @@ -43,7 +43,7 @@ env: - ROS_DISTRO=jade APTKEY_STORE_SKS=hkp://ha.pool.sks-keyservers.vet # Passing wrong SKS URL as a break test. Should still pass. - ROS_DISTRO=jade UPSTREAM_WORKSPACE=file ROSINSTALL_FILENAME=.ci.rosinstall # Testing arbitrary file name without ROS_DISTRO suffix. As of 6/3/2016 this fails due to https://github.com/ros-industrial/industrial_core/pull/144#issuecomment-223186764 - ROS_DISTRO=jade PRERELEASE=true PRERELEASE_REPONAME=i_do_not_exist PRERELEASE_DOWNSTREAM_DEPTH=1 # Intended to fail, to test the capability of capturing Prerelease Test failure. - - ROS_DISTRO=kinetic + - ROS_DISTRO=kinetic AFTER_SCRIPT='catkin --version' - ROS_DISTRO=kinetic NOT_TEST_BUILD='true' DEBUG_BASH='false' VERBOSE_OUTPUT='false' matrix: allow_failures: diff --git a/README.rst b/README.rst index 6ebecc229..b21cec818 100644 --- a/README.rst +++ b/README.rst @@ -147,6 +147,7 @@ Optional environment variables Note that some of these currently tied only to a single option, but we still leave them for the future when more options become available (e.g. ament with BUILDER). * `ADDITIONAL_DEBS` (default: not set): More DEBs to be used. List the name of DEB(s delimitted by whitespace if multiple DEBs specified). Needs to be full-qualified Ubuntu package name. E.g.: "ros-indigo-roslint ros-indigo-gazebo-ros" (without quotation). +* `AFTER_SCRIPT`: (default: not set): Used to specify shell commands that run after all source tests. * `BEFORE_SCRIPT`: (default: not set): Used to specify shell commands that run before building packages. * `BUILD_PKGS_WHITELIST` (default: not set): Packages to be built can be explicitly specified with this, in ROS package name format (i.e. using underscore. No hyphen). This is useful when your repo contains some packages that you don't want to be used upon testing. Downstream packages, if necessary, should be also specified using this. Also these packages are to be built when `NOT_TEST_INSTALL` is set. Finally, packages specified with this will be built together with those speicified using unimplmented `USE_DEB`. * `BUILDER` (default: catkin): Currently only `catkin` is implemented (and with that `catkin_tools` is used instead of `catkin_make`. See `this discussion `_). @@ -296,7 +297,18 @@ In this case, add scripts before `travis.sh` gets called (see below for an examp - .ci_config/travis.sh - ./your_custom_POSTprocess.sh -Please note: the environment is NOT kept from between script(s). +Please note: the environment is NOT kept between script(s). + +If code needs to be executed in `travis.sh` context, `BEFORE_SCRIPT` and `AFTER_SCRIPT` can be used: + +:: + + env: + global: + - BEFORE_SCRIPT:'./your_custom_PREprocess.sh' + - AFTER_SCRIPT:'./your_custom_POSTprocess.sh' + script: + - .ci_config/travis.sh (Optional) Build depended packages from source ---------------------------------------------- diff --git a/industrial_ci/ci_main.sh b/industrial_ci/ci_main.sh index caefa73a4..d00c05c25 100755 --- a/industrial_ci/ci_main.sh +++ b/industrial_ci/ci_main.sh @@ -63,7 +63,13 @@ else source ${ICI_PKG_PATH}/source_tests.sh fi +ici_time_start after_script + + cd $TARGET_REPO_PATH + if [ "${AFTER_SCRIPT// }" != "" ]; then sh -e -c "${AFTER_SCRIPT}"; fi + +ici_time_end # after_script + cd $TARGET_REPO_PATH # cd back to the repository's home directory with travis -pwd # exit with code 0 diff --git a/industrial_ci/docker.env b/industrial_ci/docker.env index 88b0461c1..774cdd75d 100644 --- a/industrial_ci/docker.env +++ b/industrial_ci/docker.env @@ -1,4 +1,5 @@ ADDITIONAL_DEBS +AFTER_SCRIPT APTKEY_STORE_HTTPS APTKEY_STORE_SKS BEFORE_SCRIPT diff --git a/industrial_ci/source_tests.sh b/industrial_ci/source_tests.sh index bec66323f..d5cb65950 100755 --- a/industrial_ci/source_tests.sh +++ b/industrial_ci/source_tests.sh @@ -57,6 +57,7 @@ if [[ "$ROS_DISTRO" == "kinetic" ]] && ! [ "$IN_DOCKER" ]; then /bin/bash -c "cd $docker_ici_pkg_path; source ./ci_main.sh;" docker cp ~/.ssh run-industrial-ci:/root/ # pass SSH settings to container docker start -a run-industrial-ci + unset AFTER_SCRIPT # do not run AFTER_SCRIPT again return fi @@ -301,7 +302,7 @@ if [ "$NOT_TEST_INSTALL" != "true" ]; then fi -ici_time_start after_script +ici_time_start test_results ## BEGIN: travis' after_script PATH=/usr/local/bin:$PATH # for installed catkin_test_results @@ -312,4 +313,4 @@ if [ "$BUILDER" == catkin -a -e $ROS_LOG_DIR ]; then $CATKIN_TEST_RESULTS_CMD -- if [ "$BUILDER" == catkin -a -e $CATKIN_WORKSPACE/build/ ]; then $CATKIN_TEST_RESULTS_CMD --all $CATKIN_WORKSPACE/build/ || error; fi if [ "$BUILDER" == catkin -a -e ~/.ros/test_results/ ]; then $CATKIN_TEST_RESULTS_CMD --all ~/.ros/test_results/ || error; fi -ici_time_end # after_script +ici_time_end # test_results From d9fb430f702d41e20aa9b7f775e8acccfa744dde Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mathias=20L=C3=BCdtke?= Date: Mon, 16 Jan 2017 19:54:32 +0100 Subject: [PATCH 09/16] added support for EXPECT_EXIT_CODE --- .travis.yml | 6 ++---- README.rst | 1 + industrial_ci/ci_main.sh | 2 +- industrial_ci/docker.env | 1 + industrial_ci/util.sh | 26 ++++++++++++++++++++++++-- 5 files changed, 29 insertions(+), 7 deletions(-) diff --git a/.travis.yml b/.travis.yml index 08281f132..1f6d0d370 100644 --- a/.travis.yml +++ b/.travis.yml @@ -39,18 +39,16 @@ env: - ROS_DISTRO=indigo USE_DEB=true # Checking backup compatibility with UPSTREAM_WORKSPACE - ROS_DISTRO=indigo USE_DEB=false # Checking backup compatibility with UPSTREAM_WORKSPACE - ROS_DISTRO=indigo ADDITIONAL_DEBS="ros-indigo-opencv3" VERBOSE_OUTPUT='false' - - ROS_DISTRO=indigo ADDITIONAL_DEBS="ros-hydro-opencv3" DEBUG_BASH='false' # This should fail (trying from a wrong distro). + - ROS_DISTRO=indigo ADDITIONAL_DEBS="ros-hydro-opencv3" DEBUG_BASH='false' EXPECT_EXIT_CODE=1 # This should fail (trying from a wrong distro). - ROS_DISTRO=jade APTKEY_STORE_SKS=hkp://ha.pool.sks-keyservers.vet # Passing wrong SKS URL as a break test. Should still pass. - ROS_DISTRO=jade UPSTREAM_WORKSPACE=file ROSINSTALL_FILENAME=.ci.rosinstall # Testing arbitrary file name without ROS_DISTRO suffix. As of 6/3/2016 this fails due to https://github.com/ros-industrial/industrial_core/pull/144#issuecomment-223186764 - - ROS_DISTRO=jade PRERELEASE=true PRERELEASE_REPONAME=i_do_not_exist PRERELEASE_DOWNSTREAM_DEPTH=1 # Intended to fail, to test the capability of capturing Prerelease Test failure. + - ROS_DISTRO=jade PRERELEASE=true PRERELEASE_REPONAME=i_do_not_exist EXPECT_EXIT_CODE=1 PRERELEASE_DOWNSTREAM_DEPTH=1 # Intended to fail, to test the capability of capturing Prerelease Test failure. - ROS_DISTRO=kinetic AFTER_SCRIPT='catkin --version' - ROS_DISTRO=kinetic NOT_TEST_BUILD='true' DEBUG_BASH='false' VERBOSE_OUTPUT='false' matrix: allow_failures: - env: ROS_DISTRO=indigo NOT_TEST_BUILD='true' NOT_TEST_INSTALL='true' POST_PROCESS='I_am_supposed_to_fail' - env: ROS_DISTRO=indigo UPSTREAM_WORKSPACE=file USE_DEB=true # Expected to fail. See https://github.com/ros-industrial/industrial_ci/pull/74 - - env: ROS_DISTRO=indigo ADDITIONAL_DEBS="ros-hydro-opencv3" DEBUG_BASH='false' # This should fail (trying from a wrong distro). - - env: ROS_DISTRO=jade PRERELEASE=true PRERELEASE_REPONAME=i_do_not_exist PRERELEASE_DOWNSTREAM_DEPTH=1 # Intended to fail (as of Apr 2016), to test the capability of capturing Prerelease Test failure. - env: ROS_DISTRO=jade UPSTREAM_WORKSPACE=file ROSINSTALL_FILENAME=.ci.rosinstall before_script: diff --git a/README.rst b/README.rst index b21cec818..287032061 100644 --- a/README.rst +++ b/README.rst @@ -154,6 +154,7 @@ Note that some of these currently tied only to a single option, but we still lea * `CATKIN_PARALLEL_JOBS` (default: -p4): Maximum number of packages to be built in parallel that is passed to underlining build tool. As of Jan 2016, this is only enabled with `catkin_tools`. See for more detail about `number of build jobs `_ and `documentation of catkin_tools `_ that this env variable is passed to internally in `catkin-tools`. * `CATKIN_PARALLEL_TEST_JOBS` (default: -p4): Maximum number of packages which could be examined in parallel during the test run. If not set it's filled by `ROS_PARALLEL_JOBS`. * `CI_PARENT_DIR` (default: .ci_config): (NOT recommended to specify) This is the folder name that is used in downstream repositories in order to point to this repo. +* `EXPECT_EXIT_CODE` (default: 0): exit code must match this value for test to succeed * `NOT_TEST_BUILD` (default: not set): If true, tests in `build` space won't be run. * `NOT_TEST_INSTALL` (default: not set): If true, tests in `install` space won't be run. * `PRERELEASE` (default: false): If `true`, run `Prerelease Test on docker that emulates ROS buildfarm `_. The usage of Prerelease Test feature is `explained more in this section `_. diff --git a/industrial_ci/ci_main.sh b/industrial_ci/ci_main.sh index d00c05c25..b2a19ea93 100755 --- a/industrial_ci/ci_main.sh +++ b/industrial_ci/ci_main.sh @@ -72,4 +72,4 @@ ici_time_end # after_script cd $TARGET_REPO_PATH # cd back to the repository's home directory with travis -# exit with code 0 +ici_exit 0 diff --git a/industrial_ci/docker.env b/industrial_ci/docker.env index 774cdd75d..042cf3562 100644 --- a/industrial_ci/docker.env +++ b/industrial_ci/docker.env @@ -10,6 +10,7 @@ CATKIN_PARALLEL_JOBS CATKIN_PARALLEL_TEST_JOBS CATKIN_TEST_RESULTS_CMD DEBUG_BASH +EXPECT_EXIT_CODE HASHKEY_SKS HAVE_MONGO_DB NOT_TEST_BUILD diff --git a/industrial_ci/util.sh b/industrial_ci/util.sh index bd3299568..358d17250 100644 --- a/industrial_ci/util.sh +++ b/industrial_ci/util.sh @@ -69,6 +69,29 @@ function ici_time_end { if [ "$DEBUG_BASH" ] && [ "$DEBUG_BASH" == true ]; then set -x; fi } +####################################### +# exit function with handling for EXPECT_EXIT_CODE +# +# Globals: +# (None) +# Arguments: +# _exit_code (default: $?) +# Returns: +# (None) +####################################### +function ici_exit { + _exit_code=${1:-$?} # If 1st arg is not passed, set last error code. + trap - ERR # Reset signal handler since the shell is about to exit. + + if [ "$_exit_code" == "${EXPECT_EXIT_CODE:-0}" ]; then + exit 0 + elif [ "$_exit_code" == "0" ]; then # 0 was not expected + exit 1 + fi + + exit $_exit_code +} + ####################################### # This private function can exit the shell process, as well as wrapping up the timer section on Travis CI. Internally this does: # @@ -92,9 +115,8 @@ function _end_fold_script { echo "Previous Travis fold name not found. It might be either successful termination of the script, or wrong call. Skipping 'ici_time_end' anyway." fi - if [ $exit_code -eq "1" ]; then trap - ERR; fi # Reset signal handler since the shell is about to exit. if [ "$DEBUG_BASH" ] && [ "$DEBUG_BASH" == true ]; then set -x; fi - if [ $exit_code -ne "-1" ]; then exit $exit_code; fi + if [ $exit_code -ne "-1" ]; then ici_exit $exit_code; fi } ####################################### From 4a8cacd14ec87f7bc09e756770dd03c90f26cdb7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mathias=20L=C3=BCdtke?= Date: Tue, 17 Jan 2017 01:49:16 +0100 Subject: [PATCH 10/16] trap error on EXIT --- industrial_ci/ci_main.sh | 2 +- industrial_ci/util.sh | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/industrial_ci/ci_main.sh b/industrial_ci/ci_main.sh index b2a19ea93..7807605a7 100755 --- a/industrial_ci/ci_main.sh +++ b/industrial_ci/ci_main.sh @@ -52,7 +52,7 @@ export HIT_ENDOFSCRIPT=false source ${ICI_PKG_PATH}/util.sh -trap error ERR +trap error EXIT trap success SIGTERM # So that this script won't terminate without verifying that all necessary steps are done. # Start prerelease, and once it finishs then finish this script too. diff --git a/industrial_ci/util.sh b/industrial_ci/util.sh index 358d17250..cc6ec6418 100644 --- a/industrial_ci/util.sh +++ b/industrial_ci/util.sh @@ -81,7 +81,7 @@ function ici_time_end { ####################################### function ici_exit { _exit_code=${1:-$?} # If 1st arg is not passed, set last error code. - trap - ERR # Reset signal handler since the shell is about to exit. + trap - EXIT # Reset signal handler since the shell is about to exit. if [ "$_exit_code" == "${EXPECT_EXIT_CODE:-0}" ]; then exit 0 From b42f79f4957cb81644c14cf7036a8108ca915eaa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mathias=20L=C3=BCdtke?= Date: Tue, 17 Jan 2017 14:43:31 +0100 Subject: [PATCH 11/16] print exit code at end of fold --- industrial_ci/util.sh | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/industrial_ci/util.sh b/industrial_ci/util.sh index cc6ec6418..7135910db 100644 --- a/industrial_ci/util.sh +++ b/industrial_ci/util.sh @@ -51,19 +51,21 @@ function ici_time_start { # (None) # Arguments: # color_wrap (default: 32): Color code for the section delimitter text. +# exit_code (default: $?): Exit code for display # Returns: # (None) ####################################### function ici_time_end { if [ "$DEBUG_BASH" ] && [ "$DEBUG_BASH" == true ]; then set +x; fi - color_wrap=${1:-32} + local color_wrap=${1:-32} + local exit_code=${2:-$?} if [ -z $TRAVIS_START_TIME ]; then echo '[ici_time_end] var TRAVIS_START_TIME is not set. You need to call `ici_time_start` in advance. Rerutning.'; return; fi TRAVIS_END_TIME=$(date +%s%N) TIME_ELAPSED_SECONDS=$(( ($TRAVIS_END_TIME - $TRAVIS_START_TIME)/1000000000 )) echo -e "ici_time:end:$TRAVIS_TIME_ID:start=$TRAVIS_START_TIME,finish=$TRAVIS_END_TIME,duration=$(($TRAVIS_END_TIME - $TRAVIS_START_TIME))\e[0K" echo -e "ici_fold:end:$TRAVIS_FOLD_NAME\e[${color_wrap}m<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<\e[0m" - echo -e "\e[0K\e[${color_wrap}mFunction $TRAVIS_FOLD_NAME took $(( $TIME_ELAPSED_SECONDS / 60 )) min $(( $TIME_ELAPSED_SECONDS % 60 )) sec\e[0m" + echo -e "\e[0K\e[${color_wrap}mFunction $TRAVIS_FOLD_NAME returned with code '${exit_code}' after $(( $TIME_ELAPSED_SECONDS / 60 )) min $(( $TIME_ELAPSED_SECONDS % 60 )) sec \e[0m" unset $TRAVIS_FOLD_NAME if [ "$DEBUG_BASH" ] && [ "$DEBUG_BASH" == true ]; then set -x; fi From f0ecc038dd2b6adcf096bb5ffff129fd53c496c1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mathias=20L=C3=BCdtke?= Date: Tue, 17 Jan 2017 14:46:10 +0100 Subject: [PATCH 12/16] use ici_exit as exit handler --- .travis.yml | 2 +- industrial_ci/ci_main.sh | 2 +- industrial_ci/util.sh | 16 +++++++++++----- 3 files changed, 13 insertions(+), 7 deletions(-) diff --git a/.travis.yml b/.travis.yml index 1f6d0d370..81b31b417 100644 --- a/.travis.yml +++ b/.travis.yml @@ -39,7 +39,7 @@ env: - ROS_DISTRO=indigo USE_DEB=true # Checking backup compatibility with UPSTREAM_WORKSPACE - ROS_DISTRO=indigo USE_DEB=false # Checking backup compatibility with UPSTREAM_WORKSPACE - ROS_DISTRO=indigo ADDITIONAL_DEBS="ros-indigo-opencv3" VERBOSE_OUTPUT='false' - - ROS_DISTRO=indigo ADDITIONAL_DEBS="ros-hydro-opencv3" DEBUG_BASH='false' EXPECT_EXIT_CODE=1 # This should fail (trying from a wrong distro). + - ROS_DISTRO=indigo ADDITIONAL_DEBS="ros-hydro-opencv3" DEBUG_BASH='false' EXPECT_EXIT_CODE=100 # This should fail (trying from a wrong distro). - ROS_DISTRO=jade APTKEY_STORE_SKS=hkp://ha.pool.sks-keyservers.vet # Passing wrong SKS URL as a break test. Should still pass. - ROS_DISTRO=jade UPSTREAM_WORKSPACE=file ROSINSTALL_FILENAME=.ci.rosinstall # Testing arbitrary file name without ROS_DISTRO suffix. As of 6/3/2016 this fails due to https://github.com/ros-industrial/industrial_core/pull/144#issuecomment-223186764 - ROS_DISTRO=jade PRERELEASE=true PRERELEASE_REPONAME=i_do_not_exist EXPECT_EXIT_CODE=1 PRERELEASE_DOWNSTREAM_DEPTH=1 # Intended to fail, to test the capability of capturing Prerelease Test failure. diff --git a/industrial_ci/ci_main.sh b/industrial_ci/ci_main.sh index 7807605a7..4a21614be 100755 --- a/industrial_ci/ci_main.sh +++ b/industrial_ci/ci_main.sh @@ -52,7 +52,7 @@ export HIT_ENDOFSCRIPT=false source ${ICI_PKG_PATH}/util.sh -trap error EXIT +trap ici_exit EXIT # install industrial_ci exit handler trap success SIGTERM # So that this script won't terminate without verifying that all necessary steps are done. # Start prerelease, and once it finishs then finish this script too. diff --git a/industrial_ci/util.sh b/industrial_ci/util.sh index 7135910db..98e1b5e78 100644 --- a/industrial_ci/util.sh +++ b/industrial_ci/util.sh @@ -77,21 +77,27 @@ function ici_time_end { # Globals: # (None) # Arguments: -# _exit_code (default: $?) +# exit_code (default: $?) # Returns: # (None) ####################################### function ici_exit { - _exit_code=${1:-$?} # If 1st arg is not passed, set last error code. + local exit_code=${1:-$?} # If 1st arg is not passed, set last error code. trap - EXIT # Reset signal handler since the shell is about to exit. - if [ "$_exit_code" == "${EXPECT_EXIT_CODE:-0}" ]; then + # end fold if needed + if [ -n "$TRAVIS_FOLD_NAME" ]; then + if [ $exit_code -ne "0" ]; then color_wrap=31; fi # Red color for errors + ici_time_end "$color_wrap" "$exit_code" + fi + + if [ "$exit_code" == "${EXPECT_EXIT_CODE:-0}" ]; then exit 0 - elif [ "$_exit_code" == "0" ]; then # 0 was not expected + elif [ "$exit_code" == "0" ]; then # 0 was not expected exit 1 fi - exit $_exit_code + exit $exit_code } ####################################### From a650d3d9249278b3e942782e51a9a6fab6e6763f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mathias=20L=C3=BCdtke?= Date: Tue, 17 Jan 2017 14:50:47 +0100 Subject: [PATCH 13/16] refactored error function to print a message and to not end the fold --- industrial_ci/ros_pre-release.sh | 8 ++------ industrial_ci/source_tests.sh | 18 +++++++++--------- industrial_ci/util.sh | 14 +++++++++++--- 3 files changed, 22 insertions(+), 18 deletions(-) diff --git a/industrial_ci/ros_pre-release.sh b/industrial_ci/ros_pre-release.sh index 2a58ac5a9..9cd601a46 100755 --- a/industrial_ci/ros_pre-release.sh +++ b/industrial_ci/ros_pre-release.sh @@ -53,9 +53,6 @@ case "$ROS_DISTRO" in esac if [ ! "$PRERELEASE_OS_CODENAME" ]; then PRERELEASE_OS_CODENAME=$os_code_name; fi -# File-global vars and -RESULT_PRERELEASE=-1 - function setup_environment() { # ROS Buildfarm for prerelease http://wiki.ros.org/regression_tests#How_do_I_setup_my_system_to_run_a_prerelease.3F sudo -E sh -c 'echo "deb http://packages.ros.org/ros/ubuntu $(lsb_release -sc) main" > /etc/apt/sources.list.d/ros-latest.list' @@ -86,11 +83,10 @@ function run_ros_prerelease() { ici_time_end # run_prerelease ici_time_start show_testresult - catkin_test_results --verbose && { echo 'ROS Prerelease Test went successful.'; RESULT_PRERELEASE=0; } || { RESULT_PRERELEASE=1; error; } + catkin_test_results --verbose || error 'ROS Prerelease Test failed' + echo 'ROS Prerelease Test went successful.' ici_time_end # show_testresult cd $TRAVIS_BUILD_DIR # cd back to the repository's home directory with travis pwd - - return $RESULT_PRERELEASE } diff --git a/industrial_ci/source_tests.sh b/industrial_ci/source_tests.sh index d5cb65950..3036b5992 100755 --- a/industrial_ci/source_tests.sh +++ b/industrial_ci/source_tests.sh @@ -97,19 +97,20 @@ ici_time_start setup_ros echo "Testing branch $TRAVIS_BRANCH of $TARGET_REPO_NAME" # $TARGET_REPO_NAME is the repo where this job is triggered from, and the variable is expected to be passed externally (industrial_ci/travis.sh should be taking care of it) # Set apt repo +lsb_release -a sudo -E sh -c 'echo "deb $ROS_REPOSITORY_PATH `lsb_release -cs` main" > /etc/apt/sources.list.d/ros-latest.list' # Common ROS install preparation # apt key acquisition. Since keyserver may often become accessible, backup method is added. -sudo apt-key adv --keyserver $APTKEY_STORE_SKS --recv-key $HASHKEY_SKS || ((echo 'Fetching apt key from SKS keyserver somehow failed. Trying to get one from alternative.\n'; wget $APTKEY_STORE_HTTPS -O - | sudo apt-key add -) || (echo 'Fetching apt key by an alternative method failed too. Exiting since ROS cannot be installed.'; error)) -lsb_release -a -sudo apt-get -qq update || (echo "ERROR: apt server not responding. This is a rare situation, and usually just waiting for a while clears this. See https://github.com/ros-industrial/industrial_ci/pull/56 for more of the discussion"; error) +sudo apt-key adv --keyserver $APTKEY_STORE_SKS --recv-key $HASHKEY_SKS \ + || { echo 'Fetching apt key from SKS keyserver somehow failed. Trying to get one from alternative.\n'; wget $APTKEY_STORE_HTTPS -O - | sudo apt-key add -; } \ + || error 'Fetching apt key by an alternative method failed too. Exiting since ROS cannot be installed.' + +sudo apt-get -qq update || error "ERROR: apt server not responding. This is a rare situation, and usually just waiting for a while clears this. See https://github.com/ros-industrial/industrial_ci/pull/56 for more of the discussion" + sudo apt-get -qq install -y python-catkin-tools python-rosdep python-wstool ros-$ROS_DISTRO-rosbash ros-$ROS_DISTRO-rospack # If more DEBs needed during preparation, define ADDITIONAL_DEBS variable where you list the name of DEB(S, delimitted by whitespace) if [ "$ADDITIONAL_DEBS" ]; then - sudo apt-get install -q -qq -y $ADDITIONAL_DEBS - if [[ $? > 0 ]]; then - echo "One or more additional deb installation is failed. Exiting."; error - fi + sudo apt-get install -q -qq -y $ADDITIONAL_DEBS || error "One or more additional deb installation is failed. Exiting." fi # MongoDB hack - I don't fully understand this but its for moveit_warehouse dpkg -s mongodb || echo "ok"; export HAVE_MONGO_DB=$? @@ -189,8 +190,7 @@ ln -s $TARGET_REPO_PATH . if [ "${USE_MOCKUP// }" != "" ]; then if [ ! -d "$TARGET_REPO_PATH/$USE_MOCKUP" ]; then - echo "mockup directory '$USE_MOCKUP' does not exist" - error + error "mockup directory '$USE_MOCKUP' does not exist" fi ln -s "$TARGET_REPO_PATH/$USE_MOCKUP" . fi diff --git a/industrial_ci/util.sh b/industrial_ci/util.sh index 98e1b5e78..b801dfaa3 100644 --- a/industrial_ci/util.sh +++ b/industrial_ci/util.sh @@ -128,7 +128,7 @@ function _end_fold_script { } ####################################### -# This calls "exit 1", along with the following. When your script on Travis CI already uses other functions from this file (util.sh), using this is recommended over calling directly "exit 1". +# Print an error message and calls "exit" # # * wraps the section that is started by ici_time_start function with the echo color red (31). # * reset signal handler for ERR to the bash default one. Subsequent signal handlers for ERR if any are unaffected by any handlers defined prior. @@ -136,12 +136,20 @@ function _end_fold_script { # Globals: # (None) # Arguments: -# (None) +# message (optional) +# exit_code (default: $?) # Returns: # (None) ####################################### function error { - _end_fold_script 1 31 + local exit_code=${2:-$?} # + if [ -n $1 ]; then + echo "\e[31m$1\e0m" # print error in red + fi + if [ "$exit_code" == "0" ]; then # 0 is not error + exit 1 + fi + ici_exit $exit_code } ####################################### From 7bf1ecd925f44aa70b7ede44280a57416a0a7fc4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mathias=20L=C3=BCdtke?= Date: Tue, 17 Jan 2017 14:52:13 +0100 Subject: [PATCH 14/16] removed unused success and _end_fold_script functions --- industrial_ci/ci_main.sh | 1 - industrial_ci/util.sh | 55 ---------------------------------------- 2 files changed, 56 deletions(-) diff --git a/industrial_ci/ci_main.sh b/industrial_ci/ci_main.sh index 4a21614be..8f07ec339 100755 --- a/industrial_ci/ci_main.sh +++ b/industrial_ci/ci_main.sh @@ -53,7 +53,6 @@ export HIT_ENDOFSCRIPT=false source ${ICI_PKG_PATH}/util.sh trap ici_exit EXIT # install industrial_ci exit handler -trap success SIGTERM # So that this script won't terminate without verifying that all necessary steps are done. # Start prerelease, and once it finishs then finish this script too. if [ "$PRERELEASE" == true ]; then diff --git a/industrial_ci/util.sh b/industrial_ci/util.sh index b801dfaa3..e39f9a441 100644 --- a/industrial_ci/util.sh +++ b/industrial_ci/util.sh @@ -100,33 +100,6 @@ function ici_exit { exit $exit_code } -####################################### -# This private function can exit the shell process, as well as wrapping up the timer section on Travis CI. Internally this does: -# -# * wraps the section that is started by ici_time_start function. -# * resets signal handler for ERR to the bash default one, when `exit_code` is any error code that exits the shell. This allows subsequent signal handlers for ERR if any to be unaffected by any handlers defined beforehand. -# * exits the process if non -1 value is passed to `exit_code`. -# -# Arguments: -# exit_code (default: -1): Unix signal. If -1 then the process continues without exiting. -# color_wrap (default: 32): Color code for the section delimitter text. -####################################### -function _end_fold_script { - if [ "$DEBUG_BASH" ] && [ "$DEBUG_BASH" == true ]; then set +x; fi - exit_code=${1:--1} # If 1st arg is not passed, set -1. - color_wrap=${2:-32} - - if [ $exit_code -eq "1" ]; then color_wrap=31; fi # Red color - if ! [ -z $TRAVIS_FOLD_NAME ]; then - ici_time_end $color_wrap - else - echo "Previous Travis fold name not found. It might be either successful termination of the script, or wrong call. Skipping 'ici_time_end' anyway." - fi - - if [ "$DEBUG_BASH" ] && [ "$DEBUG_BASH" == true ]; then set -x; fi - if [ $exit_code -ne "-1" ]; then ici_exit $exit_code; fi -} - ####################################### # Print an error message and calls "exit" # @@ -151,31 +124,3 @@ function error { fi ici_exit $exit_code } - -####################################### -# Similar to `error` function, this lets you "exit 0" and take care of other things as following, when your script on Travis CI already uses other functions from this file (util.sh). -# -# * wraps the section that is started by ici_time_start function with the echo color green. -# * reset signal handler for ERR to the bash default one. Subsequent signal handlers for ERR if any are unaffected by any handlers defined prior. -# -# Globals: -# (None) -# Arguments: -# _exit_code (default: 0): Unix signal. If -1 passed then the process continues without exiting. -# Returns: -# (None) -####################################### -function success { - _FUNC_MSG_PREFIX="[fuction success]" - _exit_code=${1:-0} # If 1st arg is not passed, set 0. - HIT_ENDOFSCRIPT=${HIT_ENDOFSCRIPT:-false} - if [ $HIT_ENDOFSCRIPT = false ]; then - if [ $_exit_code -eq 0 ]; then - echo "${_FUNC_MSG_PREFIX} Arg HIT_ENDOFSCRIPT must be true when this function exit with 0. Turn _exit_code to 1."; _exit_code=1; - else - echo "${_FUNC_MSG_PREFIX} _exit_code cannot be 0 for this func. Make sure you are calling this in a right context."; _exit_code=1; - fi - fi - if [ $_exit_code -ne "-1" ] && [ $_exit_code -ne "0" ]; then echo "${_FUNC_MSG_PREFIX} error: arg _exit_code must be either empty, -1 or 0. Returning."; return; fi - _end_fold_script $_exit_code -} From 90763296f215f7dc166d6d9b9a02c639ccd19789 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mathias=20L=C3=BCdtke?= Date: Tue, 17 Jan 2017 19:02:44 +0100 Subject: [PATCH 15/16] fixed catkin_test_results compatibility check --- industrial_ci/source_tests.sh | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/industrial_ci/source_tests.sh b/industrial_ci/source_tests.sh index 3036b5992..042ab71e9 100755 --- a/industrial_ci/source_tests.sh +++ b/industrial_ci/source_tests.sh @@ -65,9 +65,6 @@ ici_time_start init_ici_environment # Define more env vars BUILDER=catkin ROSWS=wstool -# For compatibilility with hydro catkin, which has no --verbose flag -CATKIN_TEST_RESULTS_CMD="catkin_test_results" -if [ catkin_test_results --verbose 1>/dev/null 2>/dev/null; then CATKIN_TEST_RESULTS_CMD="catkin_test_results --verbose"; fi if [ ! "$CATKIN_PARALLEL_JOBS" ]; then export CATKIN_PARALLEL_JOBS="-p4"; fi if [ ! "$CATKIN_PARALLEL_TEST_JOBS" ]; then export CATKIN_PARALLEL_TEST_JOBS="$CATKIN_PARALLEL_JOBS"; fi @@ -112,6 +109,11 @@ sudo apt-get -qq install -y python-catkin-tools python-rosdep python-wstool ros- if [ "$ADDITIONAL_DEBS" ]; then sudo apt-get install -q -qq -y $ADDITIONAL_DEBS || error "One or more additional deb installation is failed. Exiting." fi + +# For compatibilility with hydro catkin, which has no --verbose flag +CATKIN_TEST_RESULTS_CMD="catkin_test_results" +if catkin_test_results --verbose 1>/dev/null 2>/dev/null; then CATKIN_TEST_RESULTS_CMD="catkin_test_results --verbose"; fi + # MongoDB hack - I don't fully understand this but its for moveit_warehouse dpkg -s mongodb || echo "ok"; export HAVE_MONGO_DB=$? if [ $HAVE_MONGO_DB == 0 ]; then From 7baca92ded60f70438ef064db668e6c214857e80 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mathias=20L=C3=BCdtke?= Date: Wed, 18 Jan 2017 00:06:33 +0100 Subject: [PATCH 16/16] added more documentation for utils.sh --- industrial_ci/util.sh | 30 +++++++++++++++++++++++++----- 1 file changed, 25 insertions(+), 5 deletions(-) diff --git a/industrial_ci/util.sh b/industrial_ci/util.sh index e39f9a441..289149f3e 100644 --- a/industrial_ci/util.sh +++ b/industrial_ci/util.sh @@ -34,6 +34,21 @@ ## util.sh ## This is a script where the functions commonly used within the industrial_ci repo are defined. +####################################### +# Starts a timer section on Travis CI +# +# Globals: +# DEBUG_BASH (read-only) +# TRAVIS_FOLD_NAME (write-only) +# TRAVIS_TIME_ID (write-only) +# TRAVIS_START_TIME (write-only) +# Arguments: +# color_wrap (default: 32): Color code for the section delimitter text. +# exit_code (default: $?): Exit code for display +# Returns: +# (None) +####################################### + function ici_time_start { if [ "$DEBUG_BASH" ] && [ "$DEBUG_BASH" == true ]; then set +x; fi TRAVIS_START_TIME=$(date +%s%N) @@ -48,7 +63,10 @@ function ici_time_start { # Wraps up the timer section on Travis CI (that's started mostly by ici_time_start function). # # Globals: -# (None) +# DEBUG_BASH (read-only) +# TRAVIS_FOLD_NAME (from ici_time_start, read-write) +# TRAVIS_TIME_ID (from ici_time_start, read-only) +# TRAVIS_START_TIME (from ici_time_start, read-only) # Arguments: # color_wrap (default: 32): Color code for the section delimitter text. # exit_code (default: $?): Exit code for display @@ -72,10 +90,11 @@ function ici_time_end { } ####################################### -# exit function with handling for EXPECT_EXIT_CODE +# exit function with handling for EXPECT_EXIT_CODE, ends the current fold if necessary # # Globals: -# (None) +# EXPECT_EXIT_CODE (read-only) +# TRAVIS_FOLD_NAME (from ici_time_start, read-only) # Arguments: # exit_code (default: $?) # Returns: @@ -103,8 +122,9 @@ function ici_exit { ####################################### # Print an error message and calls "exit" # -# * wraps the section that is started by ici_time_start function with the echo color red (31). -# * reset signal handler for ERR to the bash default one. Subsequent signal handlers for ERR if any are unaffected by any handlers defined prior. +# * Wraps the section that is started by ici_time_start function with the echo color red (31). +# * exit_code is taken from second argument or from the previous comman. +# * If the final exit_code is 0, this function will exit 1 instead to enforce a test failure # # Globals: # (None)