cleanup shellcheck SC2086

This commit is contained in:
Michael Hobbs
2016-02-22 10:16:57 -08:00
committed by Test Robot
parent ff9bb2cbd7
commit d1b87bd7b7
75 changed files with 521 additions and 629 deletions

View File

@@ -1,2 +1,2 @@
#!/usr/bin/env bash
set -e; sleep 5; output="$(curl -s -S $1)"; echo $output; test "$output" == "Hello World!"
set -e; sleep 5; output="$(curl -s -S "$1")"; echo "$output"; test "$output" == "Hello World!"

View File

@@ -1,2 +1,2 @@
#!/usr/bin/env bash
set -e; output="$(curl -s -S $1)"; echo $output; test "$output" == "Hello World!"
set -e; output="$(curl -s -S "$1")"; echo "$output"; test "$output" == "Hello World!"

View File

@@ -1,2 +1,2 @@
#!/usr/bin/env bash
set -e; output="$(curl -s -S $1)"; echo $output; test "$output" == "Hello World!"
set -e; output="$(curl -s -S "$1")"; echo "$output"; test "$output" == "Hello World!"

View File

@@ -1,2 +1,2 @@
#!/usr/bin/env bash
set -e; output="$(curl -s -S $1)"; echo $output; test "$output" == "Hello World!"
set -e; output="$(curl -s -S "$1")"; echo "$output"; test "$output" == "Hello World!"

View File

@@ -1,2 +1,2 @@
#!/usr/bin/env bash
set -e; output="$(curl -s -S $1)"; echo $output; test "$output" == "Hello from Java!"
set -e; output="$(curl -s -S "$1")"; echo "$output"; test "$output" == "Hello from Java!"

View File

@@ -1,2 +1,2 @@
#!/usr/bin/env bash
set -e; output="$(curl -s -S $1)"; echo $output; test "$output" == "Hello from Scala!"
set -e; output="$(curl -s -S "$1")"; echo "$output"; test "$output" == "Hello from Scala!"

View File

@@ -1,38 +0,0 @@
#!/usr/bin/env bash
set -eo pipefail
export PATH=/usr/local/sbin:/usr/sbin:/sbin:/bin:/usr/bin:/usr/local/bin
unset GIT_DIR
if [[ $2 == *dokku* ]]; then
date -uIseconds
rm -rf /tmp/build
mkdir /tmp/build
cd /tmp/build
tar -xf -
echo "-----> Installing dependencies"
DEBIAN_FRONTEND=noninteractive apt-get install -qq -y git make curl software-properties-common
echo "-----> Set hostname to dokku.me"
hostname dokku.me
echo "-----> Enabling tracing"
mkdir -p /home/dokku
echo "export DOKKU_TRACE=1" >> /home/dokku/dokkurc
echo "-----> Running make install"
DEBIAN_FRONTEND=noninteractive make install
echo "-----> Generating keypair..."
echo -e "y\n" | ssh-keygen -f /root/.ssh/id_rsa -t rsa -N ''
echo "-----> Installing SSH public key..."
PUBLIC_KEY=$(< /root/.ssh/id_rsa.pub)
echo $PUBLIC_KEY | sudo sshcommand acl-add dokku test
echo "-----> Intitial SSH connection to populate known_hosts..."
ssh -o StrictHostKeyChecking=no dokku@dokku.me help > /dev/null
echo "-----> Running tests"
cd tests
for app_path in apps/*; do
app=$(basename $app_path)
echo "-----> Running test deploy of $app..."
./test_deploy $app_path dokku.me $FORWARDED_PORT
done
else
echo "-----> Repository invalid."
fi

View File

@@ -1,27 +0,0 @@
#!/usr/bin/env bash
set -eo pipefail
export DEBIAN_FRONTEND=noninteractive
apt-get install -qq -y git make curl
cd /tmp
wget http://j.mp/godeb
tar -zxvf ./godeb
./godeb install 1.1.2
export GOPATH=/root/go
git clone https://github.com/flynn/gitreceive-next.git
cd gitreceive-next && make install
ssh-keygen -f $HOME/.ssh/id_rsa -t rsa -N ''
cat<<EOF > /etc/init/gitreceived.conf
start on runlevel [2345]
exec /usr/local/bin/gitreceived -p 2022 -n /root/.ssh/id_rsa /tmp/receiver
EOF
cat<<EOF > /etc/rc.local
curl https://raw.githubusercontent.com/dokku/dokku/master/tests/ci/receiver -s > /tmp/receiver
chmod +x /tmp/receiver
EOF

View File

@@ -15,8 +15,9 @@ usage() {
}
BATCH_NUM="$1"
is_number $BATCH_NUM || usage
is_number "$BATCH_NUM" || usage
TESTS=$(find "$(dirname $0)"/../unit -maxdepth 1 -name "${BATCH_NUM}0*.bats" | sort -n | xargs)
TESTS=$(find "$(dirname "$0")/../unit" -maxdepth 1 -name "${BATCH_NUM}0*.bats" | sort -n | xargs)
echo "running the following tests $TESTS"
# shellcheck disable=SC2086
bats $TESTS

View File

@@ -1,45 +0,0 @@
#!/usr/bin/env bash
set -eo pipefail
KEYNAME="$1"
indent() { sed "s/^/ /"; }
echo "-----> Booting EC2 instance..."
start=$(ec2-run-instances -k $1 ami-f3d1bb9a 2>&1 )
if [[ $? -gt 0 ]]; then
echo "$start" | indent
exit 3
fi
INSTANCE=$(echo "$start" | awk '/^INSTANCE/ {print $2}')
terminate() {
echo "-----> Terminating $INSTANCE..."
ec2-terminate-instances $INSTANCE &>/dev/null && echo " Shutting down"
}
[[ $NOCLEANUP ]] || trap "terminate" EXIT
sleep 30
status=""
while [[ "$status" != "running" ]]; do
info=$(ec2-describe-instances 2>/dev/null | grep $INSTANCE)
status=$(echo "$info" | cut -f 6 | grep run)
echo " Waiting..."
sleep 5
if [[ $status == "running" ]]; then
echo "-----> $INSTANCE has succesfully booted!"
break
fi
done
PUBLIC_IP=$(echo "$info" | awk '{print $14}')
echo "-----> Waiting for SSH at $PUBLIC_IP..."
while [[ ! $(echo | nc $PUBLIC_IP 22) ]]; do
sleep 5
echo " Waiting..."
done
set -e
echo "-----> Connecting and running bootstrap script..."
ssh -o "StrictHostKeyChecking=no" ubuntu@$PUBLIC_IP "HOSTNAME=\$PUBLIC_IP sudo bash" < ../bootstrap.sh 2>&1 | indent
echo "-----> Installing SSH public keys..."
PUBLIC_KEY=$(< ~/.ssh/id_rsa.pub)
echo $PUBLIC_KEY | ssh -o "StrictHostKeyChecking=no" ubuntu@$PUBLIC_IP "sudo sshcommand acl-add dokku test" > /dev/null
for app_path in apps/*; do
app=$(basename $app_path)
echo "-----> Running test deploy of $app..."
./test_deploy $app_path $PUBLIC_IP
done

View File

@@ -1,29 +0,0 @@
#!/usr/bin/env bash
set -eo pipefail
SELF=$(which $0)
VAGRANT_SSH_PORT=${VAGRANT_SSH_PORT:-"2222"}
PUBLIC_KEY=${PUBLIC_KEY:-"$HOME/.ssh/id_rsa.pub"}
FORWARDED_PORT=${FORWARDED_PORT:-":8080"}
indent() { sed "s/^/ /"; }
if ! grep dokku.me ~/.ssh/config 2>/dev/null; then
echo "-----> Configuring SSH to use $VAGRANT_SSH_PORT for dokku.me..."
touch ~/.ssh/config
{
echo "Host dokku.me"
echo " Port $VAGRANT_SSH_PORT"
echo " RequestTTY yes"
} >> ~/.ssh/config
fi
echo "-----> Ensuring Vagrant is running..."
pushd $PWD > /dev/null
cd "$(dirname $SELF)/.." && vagrant up | indent
popd > /dev/null
echo "-----> Installing SSH public keys..."
ssh -o "StrictHostKeyChecking=no" -i ~/.vagrant.d/insecure_private_key vagrant@dokku.me "sudo sshcommand acl-add dokku test" < $PUBLIC_KEY
for app_path in apps/*; do
app=$(basename $app_path)
echo "-----> Running test deploy of $app..."
./test_deploy $app_path dokku.me $FORWARDED_PORT
done

View File

@@ -1,12 +1,13 @@
#!/usr/bin/env bash
set -xeo pipefail
SELF=$(which $0); APP="$1"; TARGET="$2"; FORWARDED_PORT="$3"; SHOULD_FAIL="$4"
SELF=$(which "$0"); APP="$1"; TARGET="$2"; FORWARDED_PORT="$3"; SHOULD_FAIL="$4"
REMOTE="dokku@$TARGET"
REPO="test-$(basename $APP)-$RANDOM"
REPO="test-$(basename "$APP")-$RANDOM"
destroy_app() {
echo $REPO | ssh $REMOTE apps:destroy $REPO
# shellcheck disable=SC2029
echo "$REPO" | ssh "$REMOTE" apps:destroy "$REPO"
}
failed() {
@@ -22,17 +23,17 @@ succeeded() {
}
TMP=$(mktemp -d -t "$TARGET.XXXXX")
rmdir $TMP && cp -r "$(dirname "$SELF")"/$APP $TMP
cd $TMP
rmdir "$TMP" && cp -r "$(dirname "$SELF")/$APP" "$TMP"
cd "$TMP"
git init
git config user.email "robot@example.com"
git config user.name "Test Robot"
git remote add target $REMOTE:$REPO
git remote add target "${REMOTE}:${REPO}"
[[ -f gitignore ]] && mv gitignore .gitignore
git add .
[[ -x pre-commit ]] && ./pre-commit $REMOTE $REPO
[[ -x pre-commit ]] && ./pre-commit "$REMOTE" "$REPO"
git commit -m 'initial commit'
if [[ "$SHOULD_FAIL" == true ]]; then
git push target master && succeeded git-push
@@ -40,7 +41,7 @@ else
git push target master || failed git-push
fi
if [[ -x post-deploy ]]; then
./post-deploy $REMOTE $REPO || failed post-deploy
./post-deploy "$REMOTE" "$REPO" || failed post-deploy
fi
if [[ "$SHOULD_FAIL" == true ]]; then
@@ -49,13 +50,13 @@ if [[ "$SHOULD_FAIL" == true ]]; then
exit 0
fi
URL=$(dokku url $REPO)$FORWARDED_PORT
URL=$(dokku url "$REPO")$FORWARDED_PORT
sleep 2
if (./check_deploy $URL); then
if (./check_deploy "$URL"); then
echo "-----> Deploy success!"
else
sleep 4
if (./check_deploy $URL); then
if (./check_deploy "$URL"); then
echo "-----> Deploy success!"
else
failed check-deploy

View File

@@ -11,6 +11,7 @@ teardown() {
rm -rf /home/dokku/$TEST_APP/tls /home/dokku/tls
destroy_app
dokku config:unset --global DOKKU_RM_CONTAINER
rm -f "$DOCKERFILE"
}
assert_urls() {

View File

@@ -13,8 +13,11 @@ teardown() {
deploy_app_tar() {
APP_TYPE="$1"; APP_TYPE=${APP_TYPE:="nodejs-express"}
TMP=$(mktemp -d -t "dokku.me.XXXXX")
rmdir $TMP && cp -r ./tests/apps/$APP_TYPE $TMP
cd $TMP
rmdir "$TMP" && cp -r "./tests/apps/$APP_TYPE" "$TMP"
pushd "$TMP" &> /dev/null || exit 1
trap 'popd &> /dev/null || true; rm -rf "$TMP"' RETURN INT TERM
shift 1
tar c . $* | ssh dokku@dokku.me tar:in $TEST_APP || destroy_app $?
sleep 5 # nginx needs some time to itself...

View File

@@ -67,7 +67,7 @@ assert_output_contains() {
input="${input/$expected/}"
let found+=1
done
assert_equal $count $found
assert_equal "$count" "$found"
}
# ShellCheck doesn't know about $lines from Bats
@@ -118,27 +118,27 @@ create_app() {
destroy_app() {
local RC="$1"; local RC=${RC:=0}
dokku --force apps:destroy $TEST_APP
return $RC
return "$RC"
}
add_domain() {
dokku domains:add $TEST_APP $1
dokku domains:add $TEST_APP "$1"
}
# shellcheck disable=SC2119
check_urls() {
local PATTERN="$1"
run bash -c "dokku --quiet urls $TEST_APP | egrep \"${1}\""
echo "output: "$output
echo "status: "$status
echo "output: $output"
echo "status: $status"
assert_success
}
assert_http_success() {
local url=$1
run curl -kSso /dev/null -w "%{http_code}" "${url}"
echo "output: "$output
echo "status: "$status
echo "output: $output"
echo "status: $status"
assert_output "200"
}
@@ -158,8 +158,8 @@ assert_nonssl_domain() {
assert_app_domain() {
local domain=$1
run /bin/bash -c "dokku domains $TEST_APP | grep -xF ${domain}"
echo "output: "$output
echo "status: "$status
echo "output: $output"
echo "status: $status"
assert_output "${domain}"
}
@@ -167,8 +167,8 @@ assert_http_redirect() {
local from=$1
local to=$2
run curl -kSso /dev/null -w "%{redirect_url}" "${from}"
echo "output: "$output
echo "status: "$status
echo "output: $output"
echo "status: $status"
assert_output "${to}"
}
@@ -178,14 +178,19 @@ deploy_app() {
local CUSTOM_TEMPLATE="$3"; local TMP=$(mktemp -d -t "dokku.me.XXXXX")
local CUSTOM_PATH="$4"
rmdir $TMP && cp -r ./tests/apps/$APP_TYPE $TMP
cd $TMP || exit 1
rmdir "$TMP" && cp -r "./tests/apps/$APP_TYPE" "$TMP"
# shellcheck disable=SC2086
[[ -n "$CUSTOM_TEMPLATE" ]] && $CUSTOM_TEMPLATE $TEST_APP $TMP/$CUSTOM_PATH
pushd "$TMP" &> /dev/null || exit 1
trap 'popd &> /dev/null || true; rm -rf "$TMP"' RETURN INT TERM
git init
git config user.email "robot@example.com"
git config user.name "Test Robot"
echo "setting up remote: $GIT_REMOTE"
git remote add target $GIT_REMOTE
git remote add target "$GIT_REMOTE"
[[ -f gitignore ]] && mv gitignore .gitignore
git add .
@@ -195,8 +200,8 @@ deploy_app() {
setup_client_repo() {
local TMP=$(mktemp -d -t "dokku.me.XXXXX")
rmdir $TMP && cp -r ./tests/apps/nodejs-express $TMP
cd $TMP || exit 1
rmdir "$TMP" && cp -r ./tests/apps/nodejs-express "$TMP"
cd "$TMP" || exit 1
git init
git config user.email "robot@example.com"
git config user.name "Test Robot"
@@ -221,14 +226,14 @@ setup_test_tls() {
local TLS_ARCHIVE=server_ssl.tar
;;
esac
tar xf $BATS_TEST_DIRNAME/$TLS_ARCHIVE -C $TLS
tar xf "$BATS_TEST_DIRNAME/$TLS_ARCHIVE" -C $TLS
sudo chown -R dokku:dokku ${TLS}/..
}
custom_ssl_nginx_template() {
local APP="$1"; local APP_REPO_DIR="$2"
[[ -z "$APP" ]] && local APP="$TEST_APP"
mkdir -p $APP_REPO_DIR
mkdir -p "$APP_REPO_DIR"
echo "injecting custom_ssl_nginx_template -> $APP_REPO_DIR/nginx.conf.sigil"
cat<<EOF > "$APP_REPO_DIR/nginx.conf.sigil"
@@ -276,7 +281,7 @@ EOF
custom_nginx_template() {
local APP="$1"; local APP_REPO_DIR="$2"
[[ -z "$APP" ]] && local APP="$TEST_APP"
mkdir -p $APP_REPO_DIR
mkdir -p "$APP_REPO_DIR"
echo "injecting custom_nginx_template -> $APP_REPO_DIR/nginx.conf.sigil"
cat<<EOF > "$APP_REPO_DIR/nginx.conf.sigil"