Skip to content

Commit

Permalink
Merge pull request ros-industrial#285 from ipa-mdl/feature/deprecation
Browse files Browse the repository at this point in the history
Deprecation utils
  • Loading branch information
130s authored Jul 11, 2018
2 parents a12a4ac + 19c44e7 commit 7b916f7
Show file tree
Hide file tree
Showing 6 changed files with 45 additions and 16 deletions.
3 changes: 1 addition & 2 deletions doc/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -200,14 +200,13 @@ Note that some of these currently tied only to a single option, but we still lea
* **PRERELEASE** (default: false): If `true`, run `Prerelease Test on docker that emulates ROS buildfarm <http://wiki.ros.org/bloom/Tutorials/PrereleaseTest/>`_. The usage of Prerelease Test feature is `explained more in this section <https://github.com/ros-industrial/industrial_ci/blob/master/doc/index.rst#run-ros-prerelease-test>`_.
* **PRERELEASE_DOWNSTREAM_DEPTH** (0 to 4, default: 0): Number of the levels of the package dependecies the Prerelease Test targets at. Range of the level is defined by ROS buildfarm (`<http://prerelease.ros.org>`_). NOTE: a job can run exponentially longer for the values greater than `0` depending on how many packages depend on your package (and remember a job on Travis CI can only run for up to 50 minutes).
* **PRERELEASE_REPONAME** (default: TARGET_REPO_NAME): The name of the target of Prerelease Test in rosdistro (that you select at `<http://prerelease.ros.org>`_). You can specify this if your repository name differs from the corresponding rosdisto entry. See `here <https://github.com/ros-industrial/industrial_ci/pull/145/files#r108062114>`_ for more usage.
* **PKGS_DOWNSTREAM** (default: explained): Packages in downstream to be tested. By default, `TARGET_PKGS` is used if set, if not then `BUILD_PKGS` is used.
* **PKGS_DOWNSTREAM** (default: explained): Packages in downstream to be tested. By default, `TARGET_PKGS` is used if set, if not then `BUILD_PKGS_WHITELIST` is used.
* **ROS_PARALLEL_JOBS** (default: -j8): Maximum number of packages to be built in parallel by the underlining build tool. As of Jan 2016, this is only enabled with `catkin_tools` (with `make` as an underlining builder).
* **ROS_PARALLEL_TEST_JOBS** (default: -j8): Maximum number of packages which could be examined in parallel during the test run by the underlining build tool. If not set it's filled by `ROS_PARALLEL_JOBS`. As of Jan 2016, this is only enabled with `catkin_tools` (with `make` as an underlining builder).
* **ROS_REPO** (default: ros-shadow-fixed): `ROS_REPO` can be used to set `ROS_REPOSITORY_PATH` based on known aliases: 'ros`/`main`, 'ros-shadow-fixed`/`testing` or `building`.
* **ROS_REPOSITORY_PATH**: Location of ROS' binary repositories where depended packages get installed from (typically both standard repo (`http://packages.ros.org/ros/ubuntu`) and `"Shadow-Fixed" repository <http://wiki.ros.org/ShadowRepository>`_ (`http://packages.ros.org/ros-shadow-fixed/ubuntu`)). Since version 0.3.4, `ROS_REPO` is recommended, and `ROS_REPOSITORY_PATH` is for more intermediate usage only (e.g. to specify your own binary repository (non-standard / in house)). Backward compatibility is preserved.
* **ROSDEP_SKIP_KEYS** (default: not set): space-separated list of keys that should get skipped by `rosdep install`.
* **ROSINSTALL_FILENAME** (default: .travis.rosinstall): Only used when `UPSTREAM_WORKSPACE` is set to `file`. See `UPSTREAM_WORKSPACE` description.
* **ROSWS** (default: wstool): Currently only `wstool` is available.
* **TARGET_PKGS** (default: not set): Used to fill `PKGS_DOWNSTREAM` if it is not set. If not set packages are set using the output of `catkin_topological_order` for the source space.
* **UPSTREAM_WORKSPACE** (default: debian): When set as `file`, the dependended packages that need to be built from source are downloaded based on a `.rosinstall` file in your repository. Use `$ROSINSTALL_FILENAME` to specify the file name. When set to a URL, downloads the rosinstall configuration from an ``http`` location. See more in `this section <https://github.com/ros-industrial/industrial_ci/blob/master/README.rst#optional-build-depended-packages-from-source>`_.
* **USE_DEB** (*DEPRECATED*: use `UPSTREAM_WORKSPACE` instead. default: true): if `true`, `UPSTREAM_WORKSPACE` will be set as `debian`. if `false`, `file` will be set. See `UPSTREAM_WORKSPACE` section for more info.
Expand Down
5 changes: 0 additions & 5 deletions industrial_ci/src/docker.env
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,12 @@ ABICHECK_VERSION
ADDITIONAL_DEBS
AFTER_SCRIPT
BEFORE_SCRIPT
BUILDER
BUILD_PKGS
BUILD_PKGS_WHITELIST
CATKIN_CONFIG
CATKIN_LINT
CATKIN_LINT_ARGS
CATKIN_PARALLEL_JOBS
CATKIN_PARALLEL_TEST_JOBS
CATKIN_TEST_RESULTS_CMD
CC
CFLAGS
CPPFLAGS
Expand All @@ -31,7 +28,6 @@ PRERELEASE_REPONAME
PYTHONUNBUFFERED
ROSDEP_SKIP_KEYS
ROSINSTALL_FILENAME
ROSWS
ROS_DISTRO
ROS_LOG_DIR
ROS_PARALLEL_JOBS
Expand All @@ -41,7 +37,6 @@ TARGET_REPO_NAME
TARGET_REPO_PATH
TERM
UPSTREAM_WORKSPACE
USE_DEB
USE_MOCKUP
VERBOSE_OUTPUT
VERBOSE_TESTS
2 changes: 2 additions & 0 deletions industrial_ci/src/env.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
# See the License for the specific language governing permissions and
# limitations under the License.

ici_mark_deprecated USE_DEB "Please migrate to UPSTREAM_WORKSPACE."
ici_mark_deprecated UBUNTU_OS_CODE_NAME "Was renamed to OS_CODE_NAME."
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
if [ ! "$ROS_PARALLEL_JOBS" ]; then export ROS_PARALLEL_JOBS="-j8"; fi
Expand Down
2 changes: 1 addition & 1 deletion industrial_ci/src/tests/abi_check.sh
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ function run_abi_check() {
elif [ "$ret" -eq "1" ]; then
links -dump "$reports_dir/$l.html"
broken+=("$l")
ici_time_end 33 "$ret" # abi_check_*, yellow
ici_time_end ${ANSI_YELLOW} "$ret" # abi_check_*, yellow
else
ici_exit "$ret"
fi
Expand Down
4 changes: 2 additions & 2 deletions industrial_ci/src/tests/source_tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -227,9 +227,9 @@ if [ "$NOT_TEST_INSTALL" != "true" ]; then
echo "[$pkg] Testing $test_file"
$CATKIN_WORKSPACE/install/env.sh rostest $test_file || EXIT_STATUS=$?
if [ $EXIT_STATUS != 0 ]; then
echo -e "[$pkg] Testing again the failed test: $test_file.\e[31m>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>\e[0m"
echo -e "[$pkg] Testing again the failed test: $test_file.\e[${ANSI_RED}m>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>\e[0m"
$CATKIN_WORKSPACE/install/env.sh rostest --text $test_file
echo -e "[$pkg] Testing again the failed test: $test_file.\e[31m<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<\e[0m"
echo -e "[$pkg] Testing again the failed test: $test_file.\e[${ANSI_RED}m<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<\e[0m"
fi
done
done
Expand Down
45 changes: 39 additions & 6 deletions industrial_ci/src/util.sh
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,17 @@
## util.sh
## This is a script where the functions commonly used within the industrial_ci repo are defined.

ANSI_RED=31
ANSI_GREEN=32
ANSI_YELLOW=33
ANSI_BLUE=34

function ici_color_output {
local c=$1
shift
echo -e "\e[${c}m$*\e[0m"
}

#######################################
# Starts a timer section on Travis CI
#
Expand All @@ -44,7 +55,7 @@ function ici_time_start {
echo -e "\e[0Kici_fold:start:$ICI_FOLD_NAME"
echo -en "\e[0Kici_time:start:$ICI_TIME_ID"
fi
echo -e "\e[34m>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>\e[0m"
ici_color_output $ANSI_BLUE ">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>"
if [ "$DEBUG_BASH" ] && [ "$DEBUG_BASH" == true ]; then set -x; fi
}

Expand All @@ -64,7 +75,7 @@ function ici_time_start {
#######################################
function ici_time_end {
if [ "$DEBUG_BASH" ] && [ "$DEBUG_BASH" == true ]; then set +x; fi
local color_wrap=${1:-32}
local color_wrap=${1:-${ANSI_GREEN}}
local exit_code=${2:-$?}

if [ -z $ICI_START_TIME ]; then echo '[ici_time_end] var ICI_START_TIME is not set. You need to call `ici_time_start` in advance. Rerutning.'; return; fi
Expand All @@ -74,7 +85,7 @@ function ici_time_end {
echo -e "ici_time:end:$ICI_TIME_ID:start=$ICI_START_TIME,finish=$end_time,duration=$(($end_time - $ICI_START_TIME))\e[0K"
echo -en "ici_fold:end:$ICI_FOLD_NAME"
fi
echo -e "\e[${color_wrap}m<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<\e[0m"
ici_color_output "$color_wrap" "<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<"
echo -e "\e[0K\e[${color_wrap}mFunction $ICI_FOLD_NAME returned with code '${exit_code}' after $(( $elapsed_seconds / 60 )) min $(( $elapsed_seconds % 60 )) sec \e[0m"

unset ICI_FOLD_NAME
Expand All @@ -98,7 +109,7 @@ function ici_exit {

# end fold if needed
if [ -n "$ICI_FOLD_NAME" ]; then
if [ $exit_code -ne "0" ]; then color_wrap=31; fi # Red color for errors
if [ $exit_code -ne "0" ]; then color_wrap=${ANSI_RED}; fi # Red color for errors
ici_time_end "$color_wrap" "$exit_code"
fi

Expand All @@ -111,10 +122,24 @@ function ici_exit {
exit $exit_code
}

function ici_warn {
ici_color_output ${ANSI_YELLOW} "$*"
}

function ici_mark_deprecated {
if ! [ "$IN_DOCKER" ]; then
local e=$1
shift
if [ "${!e}" ]; then
ici_warn "'$e' is deprecated. $*"
fi
fi
}

#######################################
# Print an error message and calls "exit"
#
# * Wraps the section that is started by ici_time_start function with the echo color red (31).
# * Wraps the section that is started by ici_time_start function with the echo color red (${ANSI_RED}).
# * 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
#
Expand All @@ -129,14 +154,22 @@ function ici_exit {
function error {
local exit_code=${2:-$?} #
if [ -n "$1" ]; then
echo -e "\e[31m$1\e[0m" # print error in red
ici_color_output ${ANSI_RED} "$1"
fi
if [ "$exit_code" == "0" ]; then # 0 is not error
ici_exit 1
fi
ici_exit $exit_code
}

function ici_enforce_deprecated {
local e=$1
shift
if [ "${!e}" ]; then
error "'$e' is not used anymore. $*"
fi
}

if ! which sudo > /dev/null; then
function sudo {
"$@"
Expand Down

0 comments on commit 7b916f7

Please sign in to comment.