From 92187c94649c33041acf4aaf6dc8a467840b279f Mon Sep 17 00:00:00 2001 From: Fatih Degirmenci Date: Wed, 4 Dec 2019 10:59:44 +0100 Subject: [PATCH] engine: Enable shellcheck Change-Id: I675c46943022b5656d1347855a97c3334e2213eb --- .../scripts/cloud-infra-shellcheck.sh | 29 ++++++++++++++++--- 1 file changed, 25 insertions(+), 4 deletions(-) diff --git a/jjb/cloud-infra/scripts/cloud-infra-shellcheck.sh b/jjb/cloud-infra/scripts/cloud-infra-shellcheck.sh index db8fba239..1144f14a9 100644 --- a/jjb/cloud-infra/scripts/cloud-infra-shellcheck.sh +++ b/jjb/cloud-infra/scripts/cloud-infra-shellcheck.sh @@ -18,11 +18,32 @@ # SPDX-License-Identifier: Apache-2.0 # ============LICENSE_END========================================================= -set -o errexit -set -o nounset -set -o pipefail +# install dependencies +sudo apt update > /dev/null 2>&1 +sudo apt install -y -q=3 shellcheck > /dev/null 2>&1 cd $WORKSPACE -echo "Hello, World!" +echo "Info: Run shellcheck on bash scripts" +echo "----------------------------------------------------" + +# set exit_code so we exit ourselves rather than shellcheck bailing out without +# verifying all the bash scripts +declare -i exit_code=0 + +# lint the bash scripts +for shell_script in $(find ${WORKSPACE}/ -type f -name *.sh); do + echo "--> Checking '${shell_script}' shell script..." + shellcheck --color=never ${shell_script} + lint_exit_code=$? + if [[ $lint_exit_code != 0 ]]; then + exit_code=$lint_exit_code + else + echo [OK] + fi + echo +done +echo "----------------------------------------------------" +echo "Info: Done" +exit $exit_code # vim: set ts=2 sw=2 expandtab: -- 2.25.1