Skip to content

Commit 6fb9ee6

Browse files
implement and use true/false helpers
1 parent d02886f commit 6fb9ee6

11 files changed

Lines changed: 58 additions & 28 deletions

File tree

gitlab.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ export TARGET_REPO_NAME=$CI_PROJECT_NAME
2626
export _FOLDING_TYPE=gitlab
2727

2828
if [ -n "$SSH_PRIVATE_KEY" ]; then
29-
if [ "$CI_DISPOSABLE_ENVIRONMENT" != true ] && ! [ -f /.dockerenv ] ; then
29+
if ici_is_false_or_unset "$CI_DISPOSABLE_ENVIRONMENT" && ! [ -f /.dockerenv ] ; then
3030
echo "SSH auto set-up cannot be used in non-disposable environments"
3131
exit 1
3232
fi

industrial_ci/src/builders/catkin_make.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ function builder_run_tests {
2929
local extend=$1; shift
3030
local ws=$1; shift
3131
local -a opts
32-
if [ "$PARALLEL_TESTS" == false ]; then
32+
if ici_is_false_or_unset "$PARALLEL_TESTS"; then
3333
opts+=(-j1)
3434
fi
3535
ici_exec_in_workspace "$extend" "$ws" catkin_make --make-args run_tests "${opts[@]}" "$@"

industrial_ci/src/builders/catkin_make_isolated.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ function builder_run_build {
3232

3333
function builder_run_tests {
3434
local -a opts
35-
if [ "$PARALLEL_TESTS" == false ]; then
35+
if ici_is_false_or_unset "$PARALLEL_TESTS"; then
3636
opts+=(-j1)
3737
fi
3838
_run_catkin_make_isolated run_tests "$1" "$2" "${opts[@]}"

industrial_ci/src/builders/catkin_tools.sh

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ function builder_run_build {
2323
local extend=$1; shift
2424
local ws=$1; shift
2525
local -a opts
26-
if [ "$VERBOSE_OUTPUT" != false ]; then
26+
if ici_is_true"$VERBOSE_OUTPUT"; then
2727
opts+=("-vi")
2828
fi
2929
ici_exec_in_workspace "$extend" "$ws" catkin config --install
@@ -34,13 +34,13 @@ function builder_run_tests {
3434
local extend=$1; shift
3535
local ws=$1; shift
3636
local -a opts
37-
if [ "$VERBOSE_TESTS" != false ]; then
37+
if ici_is_true"$VERBOSE_TESTS"; then
3838
opts+=(-v)
3939
fi
40-
if [ "$IMMEDIATE_TEST_OUTPUT" == true ]; then
40+
if ici_is_true"$IMMEDIATE_TEST_OUTPUT"; then
4141
opts+=(-i)
4242
fi
43-
if [ "$PARALLEL_TESTS" == false ]; then
43+
if ici_is_false_or_unset "$PARALLEL_TESTS"; then
4444
opts+=(-j1 -p1)
4545
fi
4646
ici_exec_in_workspace "$extend" "$ws" catkin build --catkin-make-args run_tests -- "${opts[@]}" --no-status

industrial_ci/src/builders/colcon.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,13 +35,13 @@ function builder_run_tests {
3535
local extend=$1; shift
3636
local ws=$1; shift
3737
local output_handler
38-
if [ "$IMMEDIATE_TEST_OUTPUT" == true ]; then
38+
if ici_is_true "$IMMEDIATE_TEST_OUTPUT"; then
3939
output_handler="console_direct+"
4040
else
4141
output_handler="console_cohesion+"
4242
fi
4343
local opts=(--event-handlers "${_colcon_event_handlers[@]}" "${output_handler}")
44-
if [ "$PARALLEL_TESTS" == false ]; then
44+
if ici_is_false_or_unset "$PARALLEL_TESTS"; then
4545
opts+=(--executor sequential --ctest-args -j1)
4646
else
4747
opts+=(--executor parallel)

industrial_ci/src/ci_main.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ source "${ICI_SRC_PATH}/env.sh"
3838
trap ici_exit EXIT # install industrial_ci exit handler
3939

4040
# Start prerelease, and once it finishs then finish this script too.
41-
if [ "$PRERELEASE" == true ]; then
41+
if ici_is_true "$PRERELEASE"; then
4242
# shellcheck source=industrial_ci/src/tests/ros_prerelease.sh
4343
source "${ICI_SRC_PATH}/tests/ros_prerelease.sh"
4444
run_ros_prerelease

industrial_ci/src/docker.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -145,15 +145,15 @@ function docker_cp {
145145
function ici_docker_build() {
146146
local -a build_opts
147147
ici_parse_env_array build_opts DOCKER_BUILD_OPTS
148-
if [ "$DOCKER_PULL" != false ]; then
148+
if ici_is_true_or_unset "$DOCKER_PULL"; then
149149
build_opts+=("--pull")
150150
fi
151151
docker build -t "$DOCKER_IMAGE" "${build_opts[@]}" "$@"
152152
}
153153

154154
function ici_docker_try_pull {
155155
local image=$1
156-
if [ "$DOCKER_PULL" != false ]; then
156+
if ici_is_true_or_unset "$DOCKER_PULL"; then
157157
echo "Pulling Docker image '$image'..."
158158
ici_quiet docker pull "$image"
159159
fi

industrial_ci/src/env.sh

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ ici_enforce_deprecated CATKIN_CONFIG "Explicit catkin configuration is not avail
2121
ici_enforce_deprecated INJECT_QEMU "Please check https://github.com/ros-industrial/industrial_ci/blob/master/doc/migration_guide.md#inject_qemu"
2222

2323
if [ -n "$NOT_TEST_INSTALL" ]; then
24-
if [ "$NOT_TEST_INSTALL" != true ]; then
24+
if ici_is_false "$NOT_TEST_INSTALL"; then
2525
ici_enforce_deprecated NOT_TEST_INSTALL "testing installed test files has been removed."
2626
else
2727
ici_mark_deprecated NOT_TEST_INSTALL "testing installed test files has been removed, NOT_TEST_INSTALL=false is superfluous"
@@ -80,7 +80,7 @@ function use_snapshot() {
8080
}
8181

8282
function use_repo_or_final_snapshot() {
83-
if [ "$ROS_VERSION_EOL" = true ]; then
83+
if ici_is_true "$ROS_VERSION_EOL"; then
8484
use_snapshot final
8585
if [ -n "$ROS_REPO" ]; then
8686
ici_warn "'$ROS_DISTRO' is in end-of-life state, ROS_REPO='$ROS_REPO' gets ignored"
@@ -242,20 +242,20 @@ if [ "$UPSTREAM_WORKSPACE" = "debian" ]; then
242242
unset UPSTREAM_WORKSPACE
243243
fi
244244

245-
if [ "$USE_DEB" = true ]; then
245+
if ici_is_true "$USE_DEB"; then
246246
if [ "${UPSTREAM_WORKSPACE:-debian}" != "debian" ]; then
247247
ici_error "USE_DEB and UPSTREAM_WORKSPACE are in conflict"
248248
fi
249249
ici_warn "Setting 'USE_DEB=true' is superfluous"
250250
fi
251251

252-
if [ "$UPSTREAM_WORKSPACE" = "file" ] || [ "${USE_DEB:-true}" != true ]; then
252+
if [ "$UPSTREAM_WORKSPACE" = "file" ] || ici_is_false "$USE_DEB"; then
253253
ROSINSTALL_FILENAME="${ROSINSTALL_FILENAME:-.travis.rosinstall}"
254254
if [ -f "$TARGET_REPO_PATH/$ROSINSTALL_FILENAME.$ROS_DISTRO" ]; then
255255
ROSINSTALL_FILENAME="$ROSINSTALL_FILENAME.$ROS_DISTRO"
256256
fi
257257

258-
if [ "${USE_DEB:-true}" != true ]; then # means UPSTREAM_WORKSPACE=file
258+
if ici_is_false "$USE_DEB"; then # means UPSTREAM_WORKSPACE=file
259259
if [ "${UPSTREAM_WORKSPACE:-file}" != "file" ]; then
260260
ici_error "USE_DEB and UPSTREAM_WORKSPACE are in conflict"
261261
fi

industrial_ci/src/tests/abi_check.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ function abi_process_workspace() {
8989
}
9090

9191
function abi_configure() {
92-
if [ "$ABICHECK_MERGE" = true ]; then
92+
if ici_is_true "$ABICHECK_MERGE"; then
9393
local ref_list
9494
if ici_split_array ref_list "$(cd "$TARGET_REPO_PATH" && git rev-list --parents -n 1 HEAD)" && [ "${#ref_list[@]}" -gt 2 ]; then
9595
ABICHECK_VERSION="${ref_list[1]}"

industrial_ci/src/tests/source_tests.sh

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ function run_source_tests {
106106
target_ws=~/target_ws
107107
downstream_ws=~/downstream_ws
108108

109-
if [ "$CCACHE_DIR" ]; then
109+
if [ -n "$CCACHE_DIR" ]; then
110110
ici_run "setup_ccache" ici_asroot apt-get install -qq -y ccache
111111
export PATH="/usr/lib/ccache:$PATH"
112112
fi
@@ -122,16 +122,16 @@ function run_source_tests {
122122
extend="$upstream_ws/install"
123123
fi
124124

125-
if [ "${CLANG_TIDY:-false}" != false ]; then
125+
if ! ici_is_false_or_unset "$CLANG_TIDY"; then
126126
TARGET_CMAKE_ARGS="$TARGET_CMAKE_ARGS -DCMAKE_EXPORT_COMPILE_COMMANDS=ON"
127127
fi
128128
ici_with_ws "$target_ws" ici_build_workspace "target" "$extend" "$target_ws"
129129

130-
if [ "$NOT_TEST_BUILD" != "true" ]; then
130+
if ici_is_false_or_unset "$NOT_TEST_BUILD"; then
131131
ici_with_ws "$target_ws" ici_test_workspace "target" "$extend" "$target_ws"
132132
fi
133133

134-
if [ "$CATKIN_LINT" == "true" ] || [ "$CATKIN_LINT" == "pedantic" ]; then
134+
if ici_is_true "$CATKIN_LINT" || [ "$CATKIN_LINT" == "pedantic" ]; then
135135
ici_run "install_catkin_lint" install_catkin_lint
136136
local -a catkin_lint_args
137137
ici_parse_env_array catkin_lint_args CATKIN_LINT_ARGS
@@ -141,7 +141,7 @@ function run_source_tests {
141141
ici_with_ws "$target_ws" ici_run "catkin_lint" ici_exec_in_workspace "$extend" "$target_ws" catkin_lint --explain "${catkin_lint_args[@]}" src
142142

143143
fi
144-
if [ "${CLANG_TIDY:-false}" != false ]; then
144+
if ! ici_is_false_or_unset "$CLANG_TIDY"; then
145145
run_clang_tidy_check "$target_ws"
146146
fi
147147

@@ -150,7 +150,7 @@ function run_source_tests {
150150
ici_with_ws "$downstream_ws" ici_build_workspace "downstream" "$extend" "$downstream_ws"
151151
#extend="$downstream_ws/install"
152152

153-
if [ "$NOT_TEST_DOWNSTREAM" != "true" ]; then
153+
if ici_is_true_or_unset "$NOT_TEST_DOWNSTREAM"; then
154154
ici_with_ws "$downstream_ws" ici_test_workspace "downstream" "$extend" "$downstream_ws"
155155
fi
156156
fi

0 commit comments

Comments
 (0)