Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Format code with shfmt #598

Draft
wants to merge 4 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Empty file modified .github/action.sh
Whitespace-only changes.
8 changes: 8 additions & 0 deletions .github/workflows/main.yml
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -14,6 +14,14 @@ jobs:
- uses: docker://koalaman/shellcheck-alpine - uses: docker://koalaman/shellcheck-alpine
with: with:
args: /bin/sh -c "shellcheck -x *.sh industrial_ci/scripts/*_ci industrial_ci/src/*.sh industrial_ci/src/*/*.sh" args: /bin/sh -c "shellcheck -x *.sh industrial_ci/scripts/*_ci industrial_ci/src/*.sh industrial_ci/src/*/*.sh"
shfmt:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- uses: docker://mvdan/shfmt
with:
args: -d -i 4 .
- run: "! grep -rEo 'function +[a-zA-Z_]+ +\\{' *"
industrial_ci: industrial_ci:
strategy: strategy:
matrix: matrix:
Expand Down
Empty file modified bitbucket.sh
Whitespace-only changes.
Empty file modified ci.sh
Whitespace-only changes.
6 changes: 5 additions & 1 deletion gitlab.sh
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -35,7 +35,11 @@ if [ -n "$SSH_PRIVATE_KEY" ]; then
# shellcheck disable=SC2046 # shellcheck disable=SC2046
eval $(ssh-agent -s) eval $(ssh-agent -s)
# add key to agent # add key to agent
ssh-add <(echo "$SSH_PRIVATE_KEY") || { res=$?; echo "could not add ssh key"; exit $res; } ssh-add <(echo "$SSH_PRIVATE_KEY") || {
res=$?
echo "could not add ssh key"
exit $res
}


if [ -n "$SSH_SERVER_HOSTKEYS" ]; then if [ -n "$SSH_SERVER_HOSTKEYS" ]; then
mkdir -p ~/.ssh mkdir -p ~/.ssh
Expand Down
3 changes: 1 addition & 2 deletions industrial_ci/scripts/rerun_ci
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@


script_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" script_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"


function show_help { function show_help() {
cat - <<'EOF' cat - <<'EOF'
Usage: Usage:
rerun_ci --list rerun_ci --list
Expand Down Expand Up @@ -63,7 +63,6 @@ elif [ "$clean" ]; then
docker rmi "$DOCKER_COMMIT" docker rmi "$DOCKER_COMMIT"
fi fi



force_env=("DOCKER_COMMIT=$DOCKER_COMMIT" "DOCKER_COMMIT_MSG=$DOCKER_COMMIT_MSG") force_env=("DOCKER_COMMIT=$DOCKER_COMMIT" "DOCKER_COMMIT_MSG=$DOCKER_COMMIT_MSG")
keep_env=("DOCKER_PORT=$DOCKER_PORT" "HOME=$HOME" "SSH_AUTH_SOCK=$SSH_AUTH_SOCK" "TERM=$TERM") keep_env=("DOCKER_PORT=$DOCKER_PORT" "HOME=$HOME" "SSH_AUTH_SOCK=$SSH_AUTH_SOCK" "TERM=$TERM")


Expand Down
5 changes: 4 additions & 1 deletion industrial_ci/scripts/run_ci
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -39,7 +39,10 @@ if [ -f "$script_dir/../src/ci_main.sh" ]; then # devel space
elif [ -f "$script_dir/../../share/industrial_ci/src/ci_main.sh" ]; then # install space elif [ -f "$script_dir/../../share/industrial_ci/src/ci_main.sh" ]; then # install space
ci_dir="$script_dir/../../share/industrial_ci/" ci_dir="$script_dir/../../share/industrial_ci/"
else else
ci_dir=$(python2 -c "import rospkg; print rospkg.RosPack().get_path('industrial_ci')" 2>/dev/null) || { echo "could not find ci_main.sh"; exit 1; } ci_dir=$(python2 -c "import rospkg; print rospkg.RosPack().get_path('industrial_ci')" 2>/dev/null) || {
echo "could not find ci_main.sh"
exit 1
}
fi fi


env "$@" /bin/bash "$ci_dir/src/ci_main.sh" env "$@" /bin/bash "$ci_dir/src/ci_main.sh"
Expand Down
26 changes: 16 additions & 10 deletions industrial_ci/src/builders/catkin_make.sh
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -24,28 +24,34 @@ function _append_job_opts() {
fi fi
} }


function builder_setup { function builder_setup() {
ici_install_pkgs_for_command catkin_make "ros-${ROS_DISTRO}-catkin" ici_install_pkgs_for_command catkin_make "ros-${ROS_DISTRO}-catkin"
} }


function builder_run_build { function builder_run_build() {
local extend=$1; shift local extend=$1
local ws=$1; shift shift
local ws=$1
shift
local opts=() local opts=()
_append_job_opts opts PARALLEL_BUILDS 0 _append_job_opts opts PARALLEL_BUILDS 0
ici_exec_in_workspace "$extend" "$ws" catkin_make --make-args install "${opts[@]}" "$@" ici_exec_in_workspace "$extend" "$ws" catkin_make --make-args install "${opts[@]}" "$@"
} }


function builder_run_tests { function builder_run_tests() {
local extend=$1; shift local extend=$1
local ws=$1; shift shift
local ws=$1
shift
local opts=() local opts=()
_append_job_opts opts PARALLEL_TESTS 1 _append_job_opts opts PARALLEL_TESTS 1
ici_exec_in_workspace "$extend" "$ws" catkin_make --make-args run_tests "${opts[@]}" "$@" ici_exec_in_workspace "$extend" "$ws" catkin_make --make-args run_tests "${opts[@]}" "$@"
} }


function builder_test_results { function builder_test_results() {
local extend=$1; shift local extend=$1
local ws=$1; shift shift
local ws=$1
shift
ici_exec_in_workspace "$extend" "$ws" catkin_test_results --verbose ici_exec_in_workspace "$extend" "$ws" catkin_test_results --verbose
} }
23 changes: 14 additions & 9 deletions industrial_ci/src/builders/catkin_make_isolated.sh
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -25,30 +25,35 @@ function _append_job_opts() {
} }


function _run_catkin_make_isolated() { function _run_catkin_make_isolated() {
local target=$1; shift local target=$1
local extend=$1; shift shift
local ws=$1; shift local extend=$1
shift
local ws=$1
shift
ici_exec_in_workspace "$extend" "$ws" catkin_make_isolated --build-space "$ws/build" --install-space "$ws/install" --make-args "$target" "$@" ici_exec_in_workspace "$extend" "$ws" catkin_make_isolated --build-space "$ws/build" --install-space "$ws/install" --make-args "$target" "$@"
} }


function builder_setup { function builder_setup() {
ici_install_pkgs_for_command catkin_make_isolated "ros-${ROS_DISTRO}-catkin" ici_install_pkgs_for_command catkin_make_isolated "ros-${ROS_DISTRO}-catkin"
} }


function builder_run_build { function builder_run_build() {
local opts=() local opts=()
_append_job_opts opts PARALLEL_BUILDS 0 _append_job_opts opts PARALLEL_BUILDS 0
_run_catkin_make_isolated install "${opts[@]}" "$@" _run_catkin_make_isolated install "${opts[@]}" "$@"
} }


function builder_run_tests { function builder_run_tests() {
local opts=() local opts=()
_append_job_opts opts PARALLEL_TESTS 1 _append_job_opts opts PARALLEL_TESTS 1
_run_catkin_make_isolated run_tests "$1" "$2" "${opts[@]}" _run_catkin_make_isolated run_tests "$1" "$2" "${opts[@]}"
} }


function builder_test_results { function builder_test_results() {
local extend=$1; shift local extend=$1
local ws=$1; shift shift
local ws=$1
shift
ici_exec_in_workspace "$extend" "$ws" catkin_test_results --verbose ici_exec_in_workspace "$extend" "$ws" catkin_test_results --verbose
} }
26 changes: 16 additions & 10 deletions industrial_ci/src/builders/catkin_tools.sh
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -26,13 +26,15 @@ function _append_job_opts() {
fi fi
} }


function builder_setup { function builder_setup() {
ici_install_pkgs_for_command catkin "${PYTHON_VERSION_NAME}-catkin-tools" "ros-$ROS_DISTRO-catkin" ici_install_pkgs_for_command catkin "${PYTHON_VERSION_NAME}-catkin-tools" "ros-$ROS_DISTRO-catkin"
} }


function builder_run_build { function builder_run_build() {
local extend=$1; shift local extend=$1
local ws=$1; shift shift
local ws=$1
shift
local opts=() local opts=()
if [ "${VERBOSE_OUTPUT:-false}" != false ]; then if [ "${VERBOSE_OUTPUT:-false}" != false ]; then
opts+=("-vi") opts+=("-vi")
Expand All @@ -42,9 +44,11 @@ function builder_run_build {
ici_exec_in_workspace "$extend" "$ws" catkin build "${opts[@]}" --summarize --no-status "$@" ici_exec_in_workspace "$extend" "$ws" catkin build "${opts[@]}" --summarize --no-status "$@"
} }


function builder_run_tests { function builder_run_tests() {
local extend=$1; shift local extend=$1
local ws=$1; shift shift
local ws=$1
shift
local opts=() local opts=()
if [ "${VERBOSE_TESTS:-false}" != false ]; then if [ "${VERBOSE_TESTS:-false}" != false ]; then
opts+=(-v) opts+=(-v)
Expand All @@ -56,8 +60,10 @@ function builder_run_tests {
ici_exec_in_workspace "$extend" "$ws" catkin build --catkin-make-args run_tests -- "${opts[@]}" --no-status ici_exec_in_workspace "$extend" "$ws" catkin build --catkin-make-args run_tests -- "${opts[@]}" --no-status
} }


function builder_test_results { function builder_test_results() {
local extend=$1; shift local extend=$1
local ws=$1; shift shift
local ws=$1
shift
ici_exec_in_workspace "$extend" "$ws" catkin_test_results --verbose ici_exec_in_workspace "$extend" "$ws" catkin_test_results --verbose
} }
26 changes: 16 additions & 10 deletions industrial_ci/src/builders/colcon.sh
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -17,17 +17,19 @@


_colcon_event_handlers=(desktop_notification- status- terminal_title-) _colcon_event_handlers=(desktop_notification- status- terminal_title-)


function builder_setup { function builder_setup() {
ici_install_pkgs_for_command colcon python3-colcon-common-extensions ici_install_pkgs_for_command colcon python3-colcon-common-extensions
if [ "$ROS_DISTRO" = "kinetic" ] || [ "$ROS_DISTRO" = "ardent" ]; then if [ "$ROS_DISTRO" = "kinetic" ] || [ "$ROS_DISTRO" = "ardent" ]; then
ici_install_pkgs_for_command pip3 python3-pip ici_install_pkgs_for_command pip3 python3-pip
ici_asroot pip3 install -U setuptools ici_asroot pip3 install -U setuptools
fi fi
} }


function builder_run_build { function builder_run_build() {
local extend=$1; shift local extend=$1
local ws=$1; shift shift
local ws=$1
shift
local opts=(--event-handlers "${_colcon_event_handlers[@]}") local opts=(--event-handlers "${_colcon_event_handlers[@]}")
local jobs local jobs
ici_parse_jobs jobs PARALLEL_BUILDS 0 ici_parse_jobs jobs PARALLEL_BUILDS 0
Expand All @@ -39,9 +41,11 @@ function builder_run_build {
ici_exec_in_workspace "$extend" "$ws" colcon build "${opts[@]}" "$@" ici_exec_in_workspace "$extend" "$ws" colcon build "${opts[@]}" "$@"
} }


function builder_run_tests { function builder_run_tests() {
local extend=$1; shift local extend=$1
local ws=$1; shift shift
local ws=$1
shift
local output_handler local output_handler
if [ "$IMMEDIATE_TEST_OUTPUT" == true ]; then if [ "$IMMEDIATE_TEST_OUTPUT" == true ]; then
output_handler="console_direct+" output_handler="console_direct+"
Expand All @@ -59,8 +63,10 @@ function builder_run_tests {
ici_exec_in_workspace "$extend" "$ws" colcon test "${opts[@]}" ici_exec_in_workspace "$extend" "$ws" colcon test "${opts[@]}"
} }


function builder_test_results { function builder_test_results() {
local extend=$1; shift local extend=$1
local ws=$1; shift shift
local ws=$1
shift
ici_exec_in_workspace "$extend" "$ws" colcon test-result --verbose ici_exec_in_workspace "$extend" "$ws" colcon test-result --verbose
} }
3 changes: 2 additions & 1 deletion industrial_ci/src/ci_main.sh
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@
set -e # exit script on errors set -e # exit script on errors
[[ "${BASH_VERSINFO[0]}_${BASH_VERSINFO[1]}" < "4_4" ]] || set -u [[ "${BASH_VERSINFO[0]}_${BASH_VERSINFO[1]}" < "4_4" ]] || set -u


export ICI_SRC_PATH; ICI_SRC_PATH="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" # The path on CI service (e.g. Travis CI) to industrial_ci src dir. export ICI_SRC_PATH
ICI_SRC_PATH="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" # The path on CI service (e.g. Travis CI) to industrial_ci src dir.
_CLEANUP="" _CLEANUP=""


# shellcheck source=industrial_ci/src/env.sh # shellcheck source=industrial_ci/src/env.sh
Expand Down
Empty file modified industrial_ci/src/deprecated.sh
Whitespace-only changes.
Empty file modified industrial_ci/src/env.sh
Whitespace-only changes.
Whitespace-only changes.
12 changes: 8 additions & 4 deletions industrial_ci/src/folding/gitlab.sh
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -17,15 +17,19 @@


function ici_start_fold() { function ici_start_fold() {
shift shift
local name=$1; shift local name=$1
local start=$1; shift shift
local start=$1
shift
ici_ansi_cleared_line "section_start:${start::-9}:$name" ici_ansi_cleared_line "section_start:${start::-9}:$name"
} }


function ici_end_fold() { function ici_end_fold() {
shift shift
local name=$1; shift local name=$1
shift
shift
local end=$1
shift shift
local end=$1; shift
ici_ansi_cleared_line "section_end:${end::-9}:$name" ici_ansi_cleared_line "section_end:${end::-9}:$name"
} }
Empty file modified industrial_ci/src/folding/none.sh
Whitespace-only changes.
21 changes: 14 additions & 7 deletions industrial_ci/src/folding/travis.sh
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -16,19 +16,26 @@
# limitations under the License. # limitations under the License.


function ici_start_fold() { function ici_start_fold() {
local tag=$1; shift local tag=$1
local name=$1; shift shift
local start=$1; shift local name=$1
shift
local start=$1
shift
ici_ansi_cleared_line "travis_fold:start:$name" ici_ansi_cleared_line "travis_fold:start:$name"
ici_ansi_cleared_line "travis_time:start:$tag" ici_ansi_cleared_line "travis_time:start:$tag"


} }


function ici_end_fold() { function ici_end_fold() {
local tag=$1; shift local tag=$1
local name=$1; shift shift
local start=$1; shift local name=$1
local end=$1; shift shift
local start=$1
shift
local end=$1
shift
ici_ansi_cleared_line "travis_time:end:$tag:start=$start,finish=$end,duration=$((end - start))" ici_ansi_cleared_line "travis_time:end:$tag:start=$start,finish=$end,duration=$((end - start))"
ici_ansi_cleared_line "travis_fold:end:$name" ici_ansi_cleared_line "travis_fold:end:$name"
} }
7 changes: 4 additions & 3 deletions industrial_ci/src/isolation/docker.sh
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -61,7 +61,8 @@ function ici_forward_variable() {
# (None) # (None)
####################################### #######################################
function ici_isolate() { function ici_isolate() {
local file=${1}; shift local file=${1}
shift


if [ "${DOCKER_IMAGE-x}" = "" ]; then if [ "${DOCKER_IMAGE-x}" = "" ]; then
ici_error "Empty string passed to DOCKER_IMAGE. Specify a valid docker image or unset the environment variable to use the default image." ici_error "Empty string passed to DOCKER_IMAGE. Specify a valid docker image or unset the environment variable to use the default image."
Expand Down Expand Up @@ -89,7 +90,7 @@ function ici_isolate() {
local tmp_src local tmp_src
ici_make_temp_dir tmp_src ici_make_temp_dir tmp_src
cp -a "$TARGET_REPO_PATH" "$tmp_src/" cp -a "$TARGET_REPO_PATH" "$tmp_src/"
export TARGET_REPO_PATH; export TARGET_REPO_PATH
TARGET_REPO_PATH="$tmp_src/$(basename "$TARGET_REPO_PATH")" TARGET_REPO_PATH="$tmp_src/$(basename "$TARGET_REPO_PATH")"
fi fi


Expand Down Expand Up @@ -184,7 +185,7 @@ function ici_run_cmd_in_docker() {


# work-around for https://github.com/moby/moby/issues/34096 # work-around for https://github.com/moby/moby/issues/34096
# ensures that copied files are owned by the target user # ensures that copied files are owned by the target user
function docker_cp { function docker_cp() {
set -o pipefail set -o pipefail
tar --numeric-owner --owner="${3:-root}" --group="${4:-root}" -c -f - -C "$(dirname "$1")" "$(basename "$1")" | docker cp - "$2" tar --numeric-owner --owner="${3:-root}" --group="${4:-root}" -c -f - -C "$(dirname "$1")" "$(basename "$1")" | docker cp - "$2"
set +o pipefail set +o pipefail
Expand Down
2 changes: 1 addition & 1 deletion industrial_ci/src/isolation/shell.sh
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ function ici_forward_variable() {
fi fi
} }


function ici_isolate { function ici_isolate() {
if [ "${CI:-}" != true ]; then if [ "${CI:-}" != true ]; then
ici_error 'ISOLATION=shell needs CI=true' ici_error 'ISOLATION=shell needs CI=true'
fi fi
Expand Down
8 changes: 4 additions & 4 deletions industrial_ci/src/ros.sh
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
# See the License for the specific language governing permissions and # See the License for the specific language governing permissions and
# limitations under the License. # limitations under the License.


function _ros1_defaults { function _ros1_defaults() {
export OS_CODE_NAME=${OS_CODE_NAME:-$1} export OS_CODE_NAME=${OS_CODE_NAME:-$1}
export ROS1_DISTRO=${ROS1_DISTRO:-$ROS_DISTRO} export ROS1_DISTRO=${ROS1_DISTRO:-$ROS_DISTRO}
export BUILDER=${BUILDER:-catkin_tools} export BUILDER=${BUILDER:-catkin_tools}
Expand All @@ -25,7 +25,7 @@ function _ros1_defaults {
export ROS_PYTHON_VERSION=${ROS_PYTHON_VERSION:-2} export ROS_PYTHON_VERSION=${ROS_PYTHON_VERSION:-2}
} }


function _ros2_defaults { function _ros2_defaults() {
export OS_CODE_NAME=${OS_CODE_NAME:-$1} export OS_CODE_NAME=${OS_CODE_NAME:-$1}
export ROS2_DISTRO=${ROS2_DISTRO:-$ROS_DISTRO} export ROS2_DISTRO=${ROS2_DISTRO:-$ROS_DISTRO}
export BUILDER=${BUILDER:-colcon} export BUILDER=${BUILDER:-colcon}
Expand All @@ -34,7 +34,7 @@ function _ros2_defaults {
export ROS_PYTHON_VERSION=3 export ROS_PYTHON_VERSION=3
} }


function _set_ros_defaults { function _set_ros_defaults() {
case "$ROS_DISTRO" in case "$ROS_DISTRO" in
"indigo" | "jade") "indigo" | "jade")
_ros1_defaults "trusty" _ros1_defaults "trusty"
Expand Down Expand Up @@ -118,7 +118,7 @@ function _get_prefix() {
fi fi
} }


function _set_ros_package_path { function _set_ros_package_path() {
if [ -z "${ROS_REPOSITORY_PATH}" ]; then if [ -z "${ROS_REPOSITORY_PATH}" ]; then
case "$ROS_REPO" in case "$ROS_REPO" in
"building") "building")
Expand Down
3 changes: 2 additions & 1 deletion industrial_ci/src/run.sh
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -59,7 +59,8 @@ if [ -z "${CPPFLAGS:-}" ]; then unset CPPFLAGS; fi
if [ -z "${CXX:-}" ]; then unset CXX; fi if [ -z "${CXX:-}" ]; then unset CXX; fi
if [ -z "${CXXFLAGS:-}" ]; then unset CXXLAGS; fi if [ -z "${CXXFLAGS:-}" ]; then unset CXXLAGS; fi


TEST=$1; shift TEST=$1
shift
ici_source_component TEST tests ici_source_component TEST tests


ici_run "init" ici_init_apt ici_run "init" ici_init_apt
Expand Down
Loading