From d488d7c1b6ad803edd1a28411aca684808a13b6b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pawe=C5=82=20Krupa?= Date: Mon, 18 Jun 2018 14:28:34 +0200 Subject: [PATCH] add shellcheck to travis CI pipeline (#3297) Add checking shell scripts (files with extension `.sh`). --- .travis.yml | 7 +++++++ buildvars.sh | 4 ++-- modules/bootkube/resources/bootkube.sh | 12 ++++++------ 3 files changed, 15 insertions(+), 8 deletions(-) diff --git a/.travis.yml b/.travis.yml index 08347cc676..ca567cf03f 100644 --- a/.travis.yml +++ b/.travis.yml @@ -20,6 +20,13 @@ jobs: quay.io/coreos/yamllint --config-data '{extends: default, rules: {line-length: {level: warning, max: 120}}}' ./examples/ ./installer/ + # shellcheck + - script: > + docker run -v $(pwd):/workdir:ro + --entrypoint sh quay.io/coreos/shellcheck-alpine:v0.5.0 + -c 'for file in $(find /workdir/ -type f -name "*.sh"); do + if ! shellcheck --format=gcc $file; then export FAILED=true; fi; done; + if [ "$FAILED" != "" ]; then exit 1; fi' # Go vet - script: "docker run -v $PWD:/go/src/github.com/coreos/tectonic-installer -w /go/src/github.com/coreos/tectonic-installer quay.io/coreos/golang-testing go vet ./installer/..." # Go lint diff --git a/buildvars.sh b/buildvars.sh index ffcf2fb025..80951d8bea 100755 --- a/buildvars.sh +++ b/buildvars.sh @@ -1,5 +1,5 @@ #!/bin/bash -e # Vars exported to the build info -echo TECTONIC_VERSION ${TECTONIC_VERSION} -echo BUILD_TIME $(date -u '+%Y-%m-%dT%H:%M:%S%z') +echo TECTONIC_VERSION "${TECTONIC_VERSION}" +echo BUILD_TIME "$(date -u '+%Y-%m-%dT%H:%M:%S%z')" diff --git a/modules/bootkube/resources/bootkube.sh b/modules/bootkube/resources/bootkube.sh index c2cf607eee..a26503af2a 100644 --- a/modules/bootkube/resources/bootkube.sh +++ b/modules/bootkube/resources/bootkube.sh @@ -19,8 +19,8 @@ set -e --render-output=/assets/tnc-bootstrap mkdir -p /etc/kubernetes/manifests/ -cp $(pwd)/tnc-bootstrap/tectonic-node-controller-pod.yaml /etc/kubernetes/manifests/ -cp $(pwd)/tnc-bootstrap/tectonic-node-controller-config.yaml /etc/kubernetes/tnc-config +cp "$(pwd)/tnc-bootstrap/tectonic-node-controller-pod.yaml" /etc/kubernetes/manifests/ +cp "$(pwd)/tnc-bootstrap/tectonic-node-controller-config.yaml" /etc/kubernetes/tnc-config # We originally wanted to run the etcd cert signer as # a static pod, but kubelet could't remove static pod @@ -28,7 +28,7 @@ cp $(pwd)/tnc-bootstrap/tectonic-node-controller-config.yaml /etc/kubernetes/tnc # docker container. # See https://github.com/kubernetes/kubernetes/issues/43292 -# shellcheck disable=SC2154 +# shellcheck disable=SC2154,SC2034 signer_id=$(/usr/bin/docker run -d \ --tmpfs /tmp \ --volume /opt/tectonic/tls:/opt/tectonic/tls:ro \ @@ -45,8 +45,8 @@ signer_id=$(/usr/bin/docker run -d \ --servercertdur=26280h) # Wait for the etcd cluster to come up. -# shellcheck disable=SC2154 export ETCDCTL_API=3 +# shellcheck disable=SC2154,SC2086 /usr/bin/etcdctl \ --dial-timeout=10m \ --cacert=/opt/tectonic/tls/etcd-client-ca.crt \ @@ -56,11 +56,11 @@ export ETCDCTL_API=3 endpoint health export ETCDCTL_API= -# shellcheck disable=SC2154 +# shellcheck disable=SC2154,SC1083 /usr/bin/docker kill $${signer_id} rm /etc/kubernetes/manifests/tectonic-node-controller-pod.yaml -cp -r $(pwd)/bootstrap-configs /etc/kubernetes/bootstrap-configs +cp -r "$(pwd)/bootstrap-configs" /etc/kubernetes/bootstrap-configs # shellcheck disable=SC2154 /usr/bin/docker run \