aboutsummaryrefslogtreecommitdiffhomepage
path: root/tools
diff options
context:
space:
mode:
authorGravatar Mehrdad Afshari <mmx@google.com>2018-01-18 10:48:56 -0800
committerGravatar Mehrdad Afshari <mmx@google.com>2018-01-25 09:08:37 -0800
commit448cf1e3bba2e5eb452c6353ce8bb189a83ec985 (patch)
treed130ee48501a533a525f4e9f180d1cf16431ec79 /tools
parentb7f88cfd7f3c4190df38f71d9b2a9534d72d850d (diff)
Make build_docker_and_run_tests.sh pass shellcheck (with suppressions)
Diffstat (limited to 'tools')
-rwxr-xr-xtools/run_tests/dockerize/build_docker_and_run_tests.sh29
1 files changed, 16 insertions, 13 deletions
diff --git a/tools/run_tests/dockerize/build_docker_and_run_tests.sh b/tools/run_tests/dockerize/build_docker_and_run_tests.sh
index 32de3fa977..8dca05ea35 100755
--- a/tools/run_tests/dockerize/build_docker_and_run_tests.sh
+++ b/tools/run_tests/dockerize/build_docker_and_run_tests.sh
@@ -18,7 +18,7 @@
set -ex
-cd $(dirname $0)/../../..
+cd "$(dirname "$0")/../../.."
git_root=$(pwd)
cd -
@@ -35,15 +35,15 @@ mkdir -p /tmp/xdg-cache-home
# DOCKERHUB_ORGANIZATION - If set, pull a prebuilt image from given dockerhub org.
# Use image name based on Dockerfile location checksum
-DOCKER_IMAGE_NAME=$(basename $DOCKERFILE_DIR)_$(sha1sum $DOCKERFILE_DIR/Dockerfile | cut -f1 -d\ )
+DOCKER_IMAGE_NAME=$(basename "$DOCKERFILE_DIR")_$(sha1sum "$DOCKERFILE_DIR/Dockerfile" | cut -f1 -d\ )
if [ "$DOCKERHUB_ORGANIZATION" != "" ]
then
DOCKER_IMAGE_NAME=$DOCKERHUB_ORGANIZATION/$DOCKER_IMAGE_NAME
- time docker pull $DOCKER_IMAGE_NAME
+ time docker pull "$DOCKER_IMAGE_NAME"
else
# Make sure docker image has been built. Should be instantaneous if so.
- docker build -t $DOCKER_IMAGE_NAME $DOCKERFILE_DIR
+ docker build -t "$DOCKER_IMAGE_NAME" "$DOCKERFILE_DIR"
fi
# Choose random name for docker container
@@ -54,6 +54,8 @@ docker_instance_git_root=/var/local/jenkins/grpc
# Run tests inside docker
DOCKER_EXIT_CODE=0
+# TODO: silence complaint about $TTY_FLAG expansion in some other way
+# shellcheck disable=SC2086
docker run \
-e "RUN_TESTS_COMMAND=$RUN_TESTS_COMMAND" \
-e "config=$config" \
@@ -61,7 +63,7 @@ docker run \
-e CCACHE_DIR=/tmp/ccache \
-e XDG_CACHE_HOME=/tmp/xdg-cache-home \
-e THIS_IS_REALLY_NEEDED='see https://github.com/docker/docker/issues/14203 for why docker is awful' \
- -e HOST_GIT_ROOT=$git_root \
+ -e HOST_GIT_ROOT="$git_root" \
-e LOCAL_GIT_ROOT=$docker_instance_git_root \
-e "BUILD_ID=$BUILD_ID" \
-e "BUILD_URL=$BUILD_URL" \
@@ -70,7 +72,8 @@ docker run \
-e "KOKORO_BUILD_NUMBER=$KOKORO_BUILD_NUMBER" \
-e "KOKORO_BUILD_URL=$KOKORO_BUILD_URL" \
-e "KOKORO_JOB_NAME=$KOKORO_JOB_NAME" \
- -i $TTY_FLAG \
+ -i \
+ $TTY_FLAG \
--sysctl net.ipv6.conf.all.disable_ipv6=0 \
-v ~/.config/gcloud:/root/.config/gcloud \
-v "$git_root:$docker_instance_git_root" \
@@ -78,18 +81,18 @@ docker run \
-v /tmp/npm-cache:/tmp/npm-cache \
-v /tmp/xdg-cache-home:/tmp/xdg-cache-home \
-w /var/local/git/grpc \
- --name=$CONTAINER_NAME \
- $DOCKER_IMAGE_NAME \
+ --name="$CONTAINER_NAME" \
+ "$DOCKER_IMAGE_NAME" \
bash -l "/var/local/jenkins/grpc/$DOCKER_RUN_SCRIPT" || DOCKER_EXIT_CODE=$?
# use unique name for reports.zip to prevent clash between concurrent
# run_tests.py runs
-TEMP_REPORTS_ZIP=`mktemp`
-docker cp "$CONTAINER_NAME:/var/local/git/grpc/reports.zip" ${TEMP_REPORTS_ZIP} || true
-unzip -o ${TEMP_REPORTS_ZIP} -d $git_root || true
-rm -f ${TEMP_REPORTS_ZIP}
+TEMP_REPORTS_ZIP=$(mktemp)
+docker cp "$CONTAINER_NAME:/var/local/git/grpc/reports.zip" "${TEMP_REPORTS_ZIP}" || true
+unzip -o "${TEMP_REPORTS_ZIP}" -d "$git_root" || true
+rm -f "${TEMP_REPORTS_ZIP}"
# remove the container, possibly killing it first
-docker rm -f $CONTAINER_NAME || true
+docker rm -f "$CONTAINER_NAME" || true
exit $DOCKER_EXIT_CODE