Merge pull request #433 from nschonni/shellcheck

Add Shellcheck to Travis and fix existing checks
This commit is contained in:
Hans Kristian Flaatten 2017-06-15 18:19:19 +02:00 committed by GitHub
commit 61336a7bb2
4 changed files with 27 additions and 17 deletions

View File

@ -3,7 +3,15 @@ sudo: required
services: services:
- docker - docker
addons:
apt:
sources:
- debian-sid
packages:
- shellcheck
script: script:
- shellcheck *.sh
- ./test-build.sh $NODE_VERSION - ./test-build.sh $NODE_VERSION
env: env:

View File

@ -3,13 +3,17 @@ set -e
hash git 2>/dev/null || { echo >&2 "git not found, exiting."; } hash git 2>/dev/null || { echo >&2 "git not found, exiting."; }
# Used dynamically: print "$array_" $1
# shellcheck disable=SC2034
array_4_8='4 argon'; array_4_8='4 argon';
# shellcheck disable=SC2034
array_6_11='6 boron'; array_6_11='6 boron';
# shellcheck disable=SC2034
array_8_1='8 latest'; array_8_1='8 latest';
cd $(cd ${0%/*} && pwd -P); cd "$(cd "${0%/*}" && pwd -P)";
self="$(basename "$BASH_SOURCE")" self="$(basename "${BASH_SOURCE[0]}")"
versions=( */ ) versions=( */ )
versions=( "${versions[@]%/}" ) versions=( "${versions[@]%/}" )
@ -40,7 +44,7 @@ for version in "${versions[@]}"; do
# Skip "docs" and other non-docker directories # Skip "docs" and other non-docker directories
[ -f "$version/Dockerfile" ] || continue [ -f "$version/Dockerfile" ] || continue
eval stub=$(echo "$version" | awk -F. '{ print "$array_" $1 "_" $2 }'); eval stub="$(echo "$version" | awk -F. '{ print "$array_" $1 "_" $2 }')";
commit="$(fileCommit "$version")" commit="$(fileCommit "$version")"
fullVersion="$(grep -m1 'ENV NODE_VERSION ' "$version/Dockerfile" | cut -d' ' -f3)" fullVersion="$(grep -m1 'ENV NODE_VERSION ' "$version/Dockerfile" | cut -d' ' -f3)"
@ -51,7 +55,7 @@ for version in "${versions[@]}"; do
echo "Directory: ${version}" echo "Directory: ${version}"
echo echo
variants=$(echo $version/*/ | xargs -n1 basename) variants=$(echo "$version"/*/ | xargs -n1 basename)
for variant in $variants; do for variant in $variants; do
# Skip non-docker directories # Skip non-docker directories
[ -f "$version/$variant/Dockerfile" ] || continue [ -f "$version/$variant/Dockerfile" ] || continue

View File

@ -16,7 +16,7 @@ fatal() {
exit 1 exit 1
} }
cd $(cd ${0%/*} && pwd -P); cd "$(cd "${0%/*}" && pwd -P)" || exit;
versions=( "$@" ) versions=( "$@" )
if [ ${#versions[@]} -eq 0 ]; then if [ ${#versions[@]} -eq 0 ]; then
@ -28,40 +28,38 @@ for version in "${versions[@]}"; do
# Skip "docs" and other non-docker directories # Skip "docs" and other non-docker directories
[ -f "$version/Dockerfile" ] || continue [ -f "$version/Dockerfile" ] || continue
tag=$(cat $version/Dockerfile | grep "ENV NODE_VERSION" | cut -d' ' -f3) tag=$(grep "ENV NODE_VERSION" "$version/Dockerfile" | cut -d' ' -f3)
info "Building $tag..." info "Building $tag..."
docker build -t node:$tag $version
if [[ $? -gt 0 ]]; then if ! docker build -t node:"$tag" "$version"; then
fatal "Build of $tag failed!" fatal "Build of $tag failed!"
else else
info "Build of $tag succeeded." info "Build of $tag succeeded."
fi fi
OUTPUT=$(docker run --rm -it node:$tag node -e "process.stdout.write(process.versions.node)") OUTPUT=$(docker run --rm -it node:"$tag" node -e "process.stdout.write(process.versions.node)")
if [ "$OUTPUT" != "$tag" ]; then if [ "$OUTPUT" != "$tag" ]; then
fatal "Test of $tag failed!" fatal "Test of $tag failed!"
else else
info "Test of $tag succeeded." info "Test of $tag succeeded."
fi fi
variants=$(echo $version/*/ | xargs -n1 basename) variants=$(echo "$version"/*/ | xargs -n1 basename)
for variant in $variants; do for variant in $variants; do
# Skip non-docker directories # Skip non-docker directories
[ -f "$version/$variant/Dockerfile" ] || continue [ -f "$version/$variant/Dockerfile" ] || continue
info "Building $tag-$variant variant..."
docker build -t node:$tag-$variant $version/$variant
if [[ $? -gt 0 ]]; then info "Building $tag-$variant variant..."
if ! docker build -t node:"$tag-$variant" "$version/$variant"; then
fatal "Build of $tag-$variant failed!" fatal "Build of $tag-$variant failed!"
else else
info "Build of $tag-$variant succeeded." info "Build of $tag-$variant succeeded."
fi fi
OUTPUT=$(docker run --rm -it node:$tag-$variant node -e "process.stdout.write(process.versions.node)") OUTPUT=$(docker run --rm -it node:"$tag-$variant" node -e "process.stdout.write(process.versions.node)")
if [ "$OUTPUT" != "$tag" ]; then if [ "$OUTPUT" != "$tag" ]; then
fatal "Test of $tag-$variant failed!" fatal "Test of $tag-$variant failed!"
else else

View File

@ -1,7 +1,7 @@
#!/bin/bash #!/bin/bash
set -e set -e
cd $(cd ${0%/*} && pwd -P); cd "$(cd "${0%/*}" && pwd -P)";
versions=( "$@" ) versions=( "$@" )
if [ ${#versions[@]} -eq 0 ]; then if [ ${#versions[@]} -eq 0 ]; then
@ -39,7 +39,7 @@ for version in "${versions[@]}"; do
update_node_version update_node_version
variants=$(echo $version/*/ | xargs -n1 basename) variants=$(echo "$version"/*/ | xargs -n1 basename)
for variant in $variants; do for variant in $variants; do
# Skip non-docker directories # Skip non-docker directories