From a7d7fd461b51dc826e3aa315a64ae0760188c8d5 Mon Sep 17 00:00:00 2001 From: Tim Swast Date: Wed, 13 Jul 2016 09:46:38 -0700 Subject: [PATCH] Add shellcheck to Travis tests and fix existing shell lint errors. --- .travis.yml | 5 +++++ speech/grpc/bin/speech-sample-async.sh | 2 +- speech/grpc/bin/speech-sample-streaming.sh | 2 +- speech/grpc/bin/speech-sample-sync.sh | 2 +- travis.sh | 8 ++++++-- 5 files changed, 14 insertions(+), 5 deletions(-) diff --git a/.travis.yml b/.travis.yml index c8816ff3f2b..924cec2e7fe 100644 --- a/.travis.yml +++ b/.travis.yml @@ -17,8 +17,13 @@ jdk: - oraclejdk8 addons: apt: + sources: + # Grab shellcheck from the Debian repo. + # https://github.com/koalaman/shellcheck/wiki/TravisCI + - debian-sid packages: - expect + - shellcheck before_install: - openssl aes-256-cbc -K $encrypted_d17a6ce39290_key -iv $encrypted_d17a6ce39290_iv -in gae-firebase-secrets.json.enc -out appengine/firebase-event-proxy/gae-firebase-event-proxy/src/main/webapp/gae-firebase-secrets.json diff --git a/speech/grpc/bin/speech-sample-async.sh b/speech/grpc/bin/speech-sample-async.sh index 259d5b658ac..7f801efb0de 100755 --- a/speech/grpc/bin/speech-sample-async.sh +++ b/speech/grpc/bin/speech-sample-async.sh @@ -14,5 +14,5 @@ # limitations under the License. SRC_DIR=$(cd "$(dirname "$0")/.."; pwd) -java -cp ${SRC_DIR}/target/grpc-sample-1.0-jar-with-dependencies.jar \ +java -cp "${SRC_DIR}/target/grpc-sample-1.0-jar-with-dependencies.jar" \ com.examples.cloud.speech.AsyncRecognizeClient "$@" diff --git a/speech/grpc/bin/speech-sample-streaming.sh b/speech/grpc/bin/speech-sample-streaming.sh index 5f89612210c..2360014bc9f 100755 --- a/speech/grpc/bin/speech-sample-streaming.sh +++ b/speech/grpc/bin/speech-sample-streaming.sh @@ -14,5 +14,5 @@ # limitations under the License. SRC_DIR=$(cd "$(dirname "$0")/.."; pwd) -java -cp ${SRC_DIR}/target/grpc-sample-1.0-jar-with-dependencies.jar \ +java -cp "${SRC_DIR}/target/grpc-sample-1.0-jar-with-dependencies.jar" \ com.examples.cloud.speech.StreamingRecognizeClient "$@" diff --git a/speech/grpc/bin/speech-sample-sync.sh b/speech/grpc/bin/speech-sample-sync.sh index 139cbdd10cf..b962a022a28 100755 --- a/speech/grpc/bin/speech-sample-sync.sh +++ b/speech/grpc/bin/speech-sample-sync.sh @@ -14,5 +14,5 @@ # limitations under the License. SRC_DIR=$(cd "$(dirname "$0")/.."; pwd) -java -cp ${SRC_DIR}/target/grpc-sample-1.0-jar-with-dependencies.jar \ +java -cp "${SRC_DIR}/target/grpc-sample-1.0-jar-with-dependencies.jar" \ com.examples.cloud.speech.SyncRecognizeClient "$@" diff --git a/travis.sh b/travis.sh index b6b95215f20..d9487993774 100755 --- a/travis.sh +++ b/travis.sh @@ -17,9 +17,10 @@ set -e set -x # Set pipefail so that `egrep` does not eat the exit code. set -o pipefail +shopt -s globstar SKIP_TESTS=false -if [ -z "$GOOGLE_APPLICATION_CREDENTIALS"]; then +if [ -z "$GOOGLE_APPLICATION_CREDENTIALS" ] ; then SKIP_TESTS=true fi mvn --batch-mode clean verify -DskipTests=$SKIP_TESTS | egrep -v "(^\[INFO\] Download|^\[INFO\].*skipping)" @@ -32,7 +33,10 @@ devserver_tests=( appengine/datastore/indexes-exploding appengine/datastore/indexes-perfect ) -for testdir in ${devserver_tests[@]} ; do +for testdir in "${devserver_tests[@]}" ; do ./java-repo-tools/scripts/test-localhost.sh appengine "${testdir}" done +# Check that all shell scripts in this repo (including this one) pass the +# Shell Check linter. +shellcheck ./**/*.sh