test with wercker
This commit is contained in:
1 parent
ab7c313411
commit
3706392e65
34 files changed
+379
-62
No files matched your search
@@ -9,3 +9,6 @@ indent_size = 2
|
|||||||
insert_final_newline = true
|
insert_final_newline = true
|
||||||
indent_style = tab
|
indent_style = tab
|
||||||
indent_size = 4
|
indent_size = 4
|
||||||
|
|
||||||
|
[*.mk]
|
||||||
|
indent_style = tab
|
||||||
@@ -17,6 +17,8 @@ endif
|
|||||||
|
|
||||||
.PHONY: all install copyfiles version plugins dependencies sshcommand pluginhook docker aufs stack count dokku-installer vagrant-acl-add vagrant-dokku
|
.PHONY: all install copyfiles version plugins dependencies sshcommand pluginhook docker aufs stack count dokku-installer vagrant-acl-add vagrant-dokku
|
||||||
|
|
||||||
|
include tests.mk
|
||||||
|
|
||||||
all:
|
all:
|
||||||
# Type "make install" to install.
|
# Type "make install" to install.
|
||||||
|
|
||||||
@@ -27,10 +29,10 @@ copyfiles: addman
|
|||||||
mkdir -p ${PLUGINS_PATH}
|
mkdir -p ${PLUGINS_PATH}
|
||||||
find ${PLUGINS_PATH} -mindepth 2 -maxdepth 2 -name '.core' -printf '%h\0' | xargs -0 rm -Rf
|
find ${PLUGINS_PATH} -mindepth 2 -maxdepth 2 -name '.core' -printf '%h\0' | xargs -0 rm -Rf
|
||||||
find plugins/ -mindepth 1 -maxdepth 1 -type d -printf '%f\n' | while read plugin; do \
|
find plugins/ -mindepth 1 -maxdepth 1 -type d -printf '%f\n' | while read plugin; do \
|
||||||
rm -Rf ${PLUGINS_PATH}/$$plugin && \
|
rm -Rf ${PLUGINS_PATH}/$$plugin && \
|
||||||
cp -R plugins/$$plugin ${PLUGINS_PATH} && \
|
cp -R plugins/$$plugin ${PLUGINS_PATH} && \
|
||||||
touch ${PLUGINS_PATH}/$$plugin/.core; \
|
touch ${PLUGINS_PATH}/$$plugin/.core; \
|
||||||
done
|
done
|
||||||
|
|
||||||
addman:
|
addman:
|
||||||
mkdir -p /usr/local/share/man/man1
|
mkdir -p /usr/local/share/man/man1
|
||||||
@@ -72,7 +74,9 @@ endif
|
|||||||
sleep 2 # give docker a moment i guess
|
sleep 2 # give docker a moment i guess
|
||||||
|
|
||||||
aufs:
|
aufs:
|
||||||
|
ifndef CI
|
||||||
lsmod | grep aufs || modprobe aufs || apt-get install -qq -y linux-image-extra-`uname -r` > /dev/null
|
lsmod | grep aufs || modprobe aufs || apt-get install -qq -y linux-image-extra-`uname -r` > /dev/null
|
||||||
|
endif
|
||||||
|
|
||||||
stack:
|
stack:
|
||||||
@echo "Start building buildstep"
|
@echo "Start building buildstep"
|
||||||
@@ -106,3 +110,4 @@ vagrant-acl-add:
|
|||||||
|
|
||||||
vagrant-dokku:
|
vagrant-dokku:
|
||||||
vagrant ssh -- "sudo -H -u root bash -c 'dokku $(RUN_ARGS)'"
|
vagrant ssh -- "sudo -H -u root bash -c 'dokku $(RUN_ARGS)'"
|
||||||
|
|
||||||
+3
-2
@@ -16,9 +16,10 @@ fi
|
|||||||
apt-get update
|
apt-get update
|
||||||
apt-get install -qq -y git make curl software-properties-common man-db
|
apt-get install -qq -y git make curl software-properties-common man-db
|
||||||
|
|
||||||
[[ `lsb_release -sr` == "12.04" ]] && apt-get install -qq -y python-software-properties
|
[[ $(lsb_release -sr) == "12.04" ]] && apt-get install -qq -y python-software-properties
|
||||||
|
|
||||||
cd ~ && test -d dokku || git clone $DOKKU_REPO
|
cd ~
|
||||||
|
test -d dokku || git clone $DOKKU_REPO
|
||||||
cd dokku
|
cd dokku
|
||||||
git fetch origin
|
git fetch origin
|
||||||
|
|
||||||
|
|||||||
@@ -44,13 +44,13 @@ case "$1" in
|
|||||||
build)
|
build)
|
||||||
APP="$2"; IMAGE="dokku/$APP"; CACHE_DIR="$DOKKU_ROOT/$APP/cache"
|
APP="$2"; IMAGE="dokku/$APP"; CACHE_DIR="$DOKKU_ROOT/$APP/cache"
|
||||||
id=$(cat | docker run -i -a stdin $DOKKU_IMAGE /bin/bash -c "mkdir -p /app && tar -xC /app")
|
id=$(cat | docker run -i -a stdin $DOKKU_IMAGE /bin/bash -c "mkdir -p /app && tar -xC /app")
|
||||||
test $(docker wait $id) -eq 0
|
test "$(docker wait $id)" -eq 0
|
||||||
docker commit $id $IMAGE > /dev/null
|
docker commit $id $IMAGE > /dev/null
|
||||||
[[ -d $CACHE_DIR ]] || mkdir $CACHE_DIR
|
[[ -d $CACHE_DIR ]] || mkdir $CACHE_DIR
|
||||||
pluginhook pre-build $APP
|
pluginhook pre-build $APP
|
||||||
id=$(docker run -d -v $CACHE_DIR:/cache $IMAGE /build/builder)
|
id=$(docker run -d -v $CACHE_DIR:/cache $IMAGE /build/builder)
|
||||||
docker attach $id
|
docker attach $id
|
||||||
test $(docker wait $id) -eq 0
|
test "$(docker wait $id)" -eq 0
|
||||||
docker commit $id $IMAGE > /dev/null
|
docker commit $id $IMAGE > /dev/null
|
||||||
pluginhook post-build $APP
|
pluginhook post-build $APP
|
||||||
;;
|
;;
|
||||||
@@ -59,8 +59,8 @@ case "$1" in
|
|||||||
APP="$2"; IMAGE="dokku/$APP"
|
APP="$2"; IMAGE="dokku/$APP"
|
||||||
pluginhook pre-release $APP
|
pluginhook pre-release $APP
|
||||||
if [[ -f "$DOKKU_ROOT/$APP/ENV" ]]; then
|
if [[ -f "$DOKKU_ROOT/$APP/ENV" ]]; then
|
||||||
id=$(cat "$DOKKU_ROOT/$APP/ENV" | docker run -i -a stdin $IMAGE /bin/bash -c "mkdir -p /app/.profile.d && cat > /app/.profile.d/app-env.sh")
|
id=$(docker run -i -a stdin $IMAGE /bin/bash -c "mkdir -p /app/.profile.d && cat > /app/.profile.d/app-env.sh" < "$DOKKU_ROOT/$APP/ENV")
|
||||||
test $(docker wait $id) -eq 0
|
test "$(docker wait $id)" -eq 0
|
||||||
docker commit $id $IMAGE > /dev/null
|
docker commit $id $IMAGE > /dev/null
|
||||||
fi
|
fi
|
||||||
pluginhook post-release $APP
|
pluginhook post-release $APP
|
||||||
@@ -143,8 +143,8 @@ case "$1" in
|
|||||||
|
|
||||||
# temporary hack for https://github.com/progrium/dokku/issues/82
|
# temporary hack for https://github.com/progrium/dokku/issues/82
|
||||||
deploy:all)
|
deploy:all)
|
||||||
for app in $(ls -d $DOKKU_ROOT/*/CONTAINER); do
|
for app in $DOKKU_ROOT/*/CONTAINER; do
|
||||||
APP=$(basename $(dirname $app));
|
APP=$(basename "$(dirname $app)");
|
||||||
dokku deploy $APP
|
dokku deploy $APP
|
||||||
done
|
done
|
||||||
;;
|
;;
|
||||||
@@ -163,7 +163,7 @@ EOF
|
|||||||
|
|
||||||
*)
|
*)
|
||||||
implemented=0
|
implemented=0
|
||||||
for script in $(ls -d $PLUGIN_PATH/*/commands); do
|
for script in $PLUGIN_PATH/*/commands; do
|
||||||
set +e; $script "$@" ; exit_code=$? ; set -e
|
set +e; $script "$@" ; exit_code=$? ; set -e
|
||||||
if [ "$exit_code" -eq "$DOKKU_NOT_IMPLEMENTED_EXIT" ]; then
|
if [ "$exit_code" -eq "$DOKKU_NOT_IMPLEMENTED_EXIT" ]; then
|
||||||
continue
|
continue
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ TARGET_DIR="$3"
|
|||||||
[[ -f $IMPORT_DIR/.sshcommand ]] && mv $IMPORT_DIR/.sshcommand $TARGET_DIR/.sshcommand
|
[[ -f $IMPORT_DIR/.sshcommand ]] && mv $IMPORT_DIR/.sshcommand $TARGET_DIR/.sshcommand
|
||||||
if [[ -f $IMPORT_DIR/.ssh/authorized_keys ]]; then
|
if [[ -f $IMPORT_DIR/.ssh/authorized_keys ]]; then
|
||||||
mkdir -p $TARGET_DIR/.ssh
|
mkdir -p $TARGET_DIR/.ssh
|
||||||
cat $IMPORT_DIR/.ssh/authorized_keys $TARGET_DIR/.ssh/authorized_keys | uniq > $TARGET_DIR/.ssh/authorized_keys
|
cat $IMPORT_DIR/.ssh/authorized_keys $TARGET_DIR/.ssh/authorized_keys | uniq > tmpfile && mv tmpfile $TARGET_DIR/.ssh/authorized_keys
|
||||||
chmod 0700 $TARGET_DIR/.ssh
|
chmod 0700 $TARGET_DIR/.ssh
|
||||||
chmod 0600 $TARGET_DIR/.ssh/*
|
chmod 0600 $TARGET_DIR/.ssh/*
|
||||||
fi
|
fi
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
|
set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
|
||||||
|
|
||||||
if [[ ! -f "$DOKKU_ROOT/HOSTNAME" ]]; then
|
if [[ ! -f "$DOKKU_ROOT/HOSTNAME" ]]; then
|
||||||
echo $(hostname -f) > $DOKKU_ROOT/HOSTNAME
|
hostname -f > $DOKKU_ROOT/HOSTNAME
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ ! -f "$DOKKU_ROOT/VHOST" ]]; then
|
if [[ ! -f "$DOKKU_ROOT/VHOST" ]]; then
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ case "$1" in
|
|||||||
: | pluginhook backup-export 1 $BACKUP_DIR | tar -cf $BACKUP_TMP_FILE --files-from -
|
: | pluginhook backup-export 1 $BACKUP_DIR | tar -cf $BACKUP_TMP_FILE --files-from -
|
||||||
|
|
||||||
pushd $BACKUP_DIR > /dev/null
|
pushd $BACKUP_DIR > /dev/null
|
||||||
ls -d */ | grep -oE '[^/]+' > "$BACKUP_TMP_DIR/.dokku_backup_apps"
|
find . -maxdepth 1 -type d -not -name . | sed 's:./::g' > "$BACKUP_TMP_DIR/.dokku_backup_apps"
|
||||||
popd > /dev/null
|
popd > /dev/null
|
||||||
|
|
||||||
# we want to insert the files in the root of the tar
|
# we want to insert the files in the root of the tar
|
||||||
|
|||||||
@@ -56,15 +56,15 @@ sleep $WAIT
|
|||||||
# --location Follow redirects
|
# --location Follow redirects
|
||||||
CURL_OPTIONS="-q --compressed --fail --location --max-time 30"
|
CURL_OPTIONS="-q --compressed --fail --location --max-time 30"
|
||||||
|
|
||||||
cat "$FILENAME" | while read PATHNAME EXPECTED ; do
|
while read PATHNAME EXPECTED < "$FILENAME"; do
|
||||||
# Ignore empty lines and lines starting with #
|
# Ignore empty lines and lines starting with #
|
||||||
[[ -z "$PATHNAME" || "$PATHNAME" =~ ^\# ]] && continue
|
[[ -z "$PATHNAME" || "$PATHNAME" =~ ^# ]] && continue
|
||||||
|
|
||||||
URL="http://$HOSTNAME:$PORT$PATHNAME"
|
URL="http://$HOSTNAME:$PORT$PATHNAME"
|
||||||
|
|
||||||
echo "checking with: curl $CURL_OPTIONS $URL"
|
echo "checking with: curl $CURL_OPTIONS $URL"
|
||||||
HTML=$(curl $CURL_OPTIONS $URL)
|
HTML=$(curl $CURL_OPTIONS $URL)
|
||||||
if [[ -n "$EXPECTED" && ! "$HTML" =~ "$EXPECTED" ]] ; then
|
if [[ -n "$EXPECTED" && ! "$HTML" =~ $EXPECTED ]] ; then
|
||||||
echo -e "\033[31m\033[1m$URL: expected to but did not find: \"$EXPECTED\"\033[0m"
|
echo -e "\033[31m\033[1m$URL: expected to but did not find: \"$EXPECTED\"\033[0m"
|
||||||
exit 1
|
exit 1
|
||||||
else
|
else
|
||||||
|
|||||||
+10
-10
@@ -15,21 +15,21 @@ config_styled_hash () {
|
|||||||
|
|
||||||
longest=""
|
longest=""
|
||||||
while read -r word; do
|
while read -r word; do
|
||||||
KEY=`echo $word | cut -d"=" -f1`
|
KEY=$(echo $word | cut -d"=" -f1)
|
||||||
if [ ${#KEY} -gt ${#longest} ]; then
|
if [ ${#KEY} -gt ${#longest} ]; then
|
||||||
longest=$KEY
|
longest=$KEY
|
||||||
fi
|
fi
|
||||||
done <<< "$vars"
|
done <<< "$vars"
|
||||||
|
|
||||||
while read -r word; do
|
while read -r word; do
|
||||||
KEY=`echo $word | cut -d"=" -f1`
|
KEY=$(echo $word | cut -d"=" -f1)
|
||||||
VALUE=`echo $word | cut -d"=" -f2- | sed -e "s/^'//" -e "s/'$//"`
|
VALUE=$(echo $word | cut -d"=" -f2- | sed -e "s/^'//" -e "s/'$//")
|
||||||
|
|
||||||
num_zeros=$((${#longest} - ${#KEY}))
|
num_zeros=$((${#longest} - ${#KEY}))
|
||||||
zeros=" "
|
zeros=" "
|
||||||
while [ $num_zeros -gt 0 ]; do
|
while [ $num_zeros -gt 0 ]; do
|
||||||
zeros="$zeros "
|
zeros="$zeros "
|
||||||
num_zeros=$(($num_zeros - 1))
|
num_zeros=$((num_zeros - 1))
|
||||||
done
|
done
|
||||||
echo "$prefix$KEY:$zeros$VALUE"
|
echo "$prefix$KEY:$zeros$VALUE"
|
||||||
done <<< "$vars"
|
done <<< "$vars"
|
||||||
@@ -68,7 +68,7 @@ case "$1" in
|
|||||||
config_create
|
config_create
|
||||||
[[ ! -s $ENV_FILE ]] && echo "$APP has no config vars" && exit 1
|
[[ ! -s $ENV_FILE ]] && echo "$APP has no config vars" && exit 1
|
||||||
|
|
||||||
VARS=`cat $ENV_FILE | grep -Eo "export ([a-zA-Z_][a-zA-Z0-9_]*=.*)" | cut -d" " -f2-`
|
VARS=$(grep -Eo "export ([a-zA-Z_][a-zA-Z0-9_]*=.*)" $ENV_FILE | cut -d" " -f2-)
|
||||||
|
|
||||||
for var in "$@"; do
|
for var in "$@"; do
|
||||||
if [[ "$var" == "--shell" ]]; then
|
if [[ "$var" == "--shell" ]]; then
|
||||||
@@ -99,7 +99,7 @@ case "$1" in
|
|||||||
|
|
||||||
KEY="$3"
|
KEY="$3"
|
||||||
|
|
||||||
cat $ENV_FILE | grep -Eo "export ([a-zA-Z_][a-zA-Z0-9_]*=.*)" | grep "^export $KEY=" | cut -d"=" -f2- | sed -e "s/^'//" -e "s/'$//"
|
grep -Eo "export ([a-zA-Z_][a-zA-Z0-9_]*=.*)" $ENV_FILE | grep "^export $KEY=" | cut -d"=" -f2- | sed -e "s/^'//" -e "s/'$//"
|
||||||
;;
|
;;
|
||||||
|
|
||||||
config:set)
|
config:set)
|
||||||
@@ -115,7 +115,7 @@ case "$1" in
|
|||||||
|
|
||||||
config_create
|
config_create
|
||||||
ENV_ADD=""
|
ENV_ADD=""
|
||||||
ENV_TEMP=`cat "${ENV_FILE}"`
|
ENV_TEMP=$(cat "${ENV_FILE}")
|
||||||
RESTART_APP=false
|
RESTART_APP=false
|
||||||
shift 2
|
shift 2
|
||||||
|
|
||||||
@@ -128,8 +128,8 @@ case "$1" in
|
|||||||
done
|
done
|
||||||
|
|
||||||
for var; do
|
for var; do
|
||||||
KEY=`echo ${var} | cut -d"=" -f1`
|
KEY=$(echo ${var} | cut -d"=" -f1)
|
||||||
VALUE=`echo ${var} | cut -d"=" -f2-`
|
VALUE=$(echo ${var} | cut -d"=" -f2-)
|
||||||
|
|
||||||
if [[ $KEY =~ [a-zA-Z_][a-zA-Z0-9_]* ]]; then
|
if [[ $KEY =~ [a-zA-Z_][a-zA-Z0-9_]* ]]; then
|
||||||
RESTART_APP=true
|
RESTART_APP=true
|
||||||
@@ -162,7 +162,7 @@ ${var}"
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
config_create
|
config_create
|
||||||
ENV_TEMP=`cat "${ENV_FILE}"`
|
ENV_TEMP=$(cat "${ENV_FILE}")
|
||||||
VARS="${*:3}"
|
VARS="${*:3}"
|
||||||
|
|
||||||
for var in $VARS; do
|
for var in $VARS; do
|
||||||
|
|||||||
@@ -57,7 +57,7 @@ EOF
|
|||||||
chmod +x $PRERECEIVE_HOOK
|
chmod +x $PRERECEIVE_HOOK
|
||||||
fi
|
fi
|
||||||
|
|
||||||
args=$@
|
args=$*
|
||||||
git-shell -c "$args"
|
git-shell -c "$args"
|
||||||
;;
|
;;
|
||||||
|
|
||||||
|
|||||||
@@ -9,6 +9,6 @@ TARGET_DIR="$3"
|
|||||||
cd $IMPORT_DIR
|
cd $IMPORT_DIR
|
||||||
|
|
||||||
for file in */tls/server.*; do
|
for file in */tls/server.*; do
|
||||||
mkdir -p $(dirname $TARGET_DIR$file)
|
mkdir -p "$(dirname $TARGET_DIR$file)"
|
||||||
cp $file $TARGET_DIR$file
|
cp $file $TARGET_DIR$file
|
||||||
done
|
done
|
||||||
@@ -95,7 +95,7 @@ EOF
|
|||||||
[[ -t 0 ]] && echo "Tar archive containing server.crt and server.key expected on stdin" && exit 1
|
[[ -t 0 ]] && echo "Tar archive containing server.crt and server.key expected on stdin" && exit 1
|
||||||
APP="$2"
|
APP="$2"
|
||||||
|
|
||||||
TEMP_DIR=`mktemp -d`
|
TEMP_DIR=$(mktemp -d)
|
||||||
cd $TEMP_DIR
|
cd $TEMP_DIR
|
||||||
tar xvf - <&0
|
tar xvf - <&0
|
||||||
[[ ! -f "$TEMP_DIR/server.crt" ]] && echo "Tar archive missing server.crt" && exit 1
|
[[ ! -f "$TEMP_DIR/server.crt" ]] && echo "Tar archive missing server.crt" && exit 1
|
||||||
|
|||||||
@@ -0,0 +1,63 @@
|
|||||||
|
shellcheck:
|
||||||
|
ifeq ($(shell shellcheck > /dev/null 2>&1 ; echo $$?),127)
|
||||||
|
ifeq ($(shell uname),Darwin)
|
||||||
|
brew install shellcheck
|
||||||
|
else
|
||||||
|
sudo add-apt-repository 'deb http://archive.ubuntu.com/ubuntu trusty-backports main restricted universe multiverse'
|
||||||
|
sudo apt-get update && sudo apt-get install -y shellcheck
|
||||||
|
endif
|
||||||
|
endif
|
||||||
|
|
||||||
|
ci-dependencies: shellcheck bats
|
||||||
|
|
||||||
|
setup-deploy-tests:
|
||||||
|
# echo "-----> Enabling tracing"
|
||||||
|
# mkdir -p /home/dokku
|
||||||
|
# echo "export DOKKU_TRACE=1" >> /home/dokku/dokkurc
|
||||||
|
@echo "Setting dokku.me in /etc/hosts"
|
||||||
|
sudo /bin/bash -c "[[ `ping -c1 dokku.me > /dev/null 2>&1; echo $$?` -eq 0 ]] || echo \"127.0.0.1 dokku.me *.dokku.me\" >> /etc/hosts"
|
||||||
|
|
||||||
|
@echo "-----> Generating keypair..."
|
||||||
|
mkdir -p /root/.ssh
|
||||||
|
rm -f /root/.ssh/dokku_test_rsa*
|
||||||
|
echo -e "y\n" | ssh-keygen -f /root/.ssh/dokku_test_rsa -t rsa -N ''
|
||||||
|
chmod 600 /root/.ssh/dokku_test_rsa*
|
||||||
|
|
||||||
|
@echo "-----> Setting up ssh config..."
|
||||||
|
ifeq ($(shell ls /root/.ssh/config > /dev/null 2>&1 ; echo $$?),0)
|
||||||
|
ifeq ($(shell grep dokku.me /root/.ssh/config),)
|
||||||
|
echo "Host dokku.me \\r\\n RequestTTY yes \\r\\n IdentityFile /root/.ssh/dokku_test_rsa" >> /root/.ssh/config
|
||||||
|
endif
|
||||||
|
else
|
||||||
|
echo "Host dokku.me \\r\\n RequestTTY yes \\r\\n IdentityFile /root/.ssh/dokku_test_rsa" >> /root/.ssh/config
|
||||||
|
endif
|
||||||
|
|
||||||
|
@echo "-----> Installing SSH public key..."
|
||||||
|
sudo sshcommand acl-remove dokku test
|
||||||
|
cat /root/.ssh/dokku_test_rsa.pub | sudo sshcommand acl-add dokku test
|
||||||
|
|
||||||
|
@echo "-----> Intitial SSH connection to populate known_hosts..."
|
||||||
|
ssh -o StrictHostKeyChecking=no dokku@dokku.me help > /dev/null
|
||||||
|
|
||||||
|
bats:
|
||||||
|
git clone https://github.com/sstephenson/bats.git /tmp/bats
|
||||||
|
cd /tmp/bats && sudo ./install.sh /usr/local
|
||||||
|
rm -rf /tmp/bats
|
||||||
|
|
||||||
|
lint:
|
||||||
|
# these are disabled due to their expansive existence in the codebase. we should clean it up though
|
||||||
|
# SC2034: VAR appears unused - https://github.com/koalaman/shellcheck/wiki/SC2034
|
||||||
|
# SC2086: Double quote to prevent globbing and word splitting - https://github.com/koalaman/shellcheck/wiki/SC2086
|
||||||
|
@echo linting...
|
||||||
|
@$(QUIET) find . -not -path '*/\.*' | xargs file | egrep "shell|bash" | awk '{ print $$1 }' | sed 's/://g' | xargs shellcheck -e SC2034,SC2086
|
||||||
|
|
||||||
|
unit-tests:
|
||||||
|
@echo running unit tests...
|
||||||
|
@$(QUIET) bats tests/unit
|
||||||
|
|
||||||
|
deploy-tests:
|
||||||
|
@echo running deploy tests...
|
||||||
|
# @$(QUIET) bats tests/deploy
|
||||||
|
cd tests && ./test_deploy ./apps/go dokku.me
|
||||||
|
|
||||||
|
test: lint setup-deploy-tests unit-tests deploy-tests
|
||||||
@@ -9,7 +9,7 @@ test_url () {
|
|||||||
path="$1"
|
path="$1"
|
||||||
expected_output="$2"
|
expected_output="$2"
|
||||||
url="$base_url$path"
|
url="$base_url$path"
|
||||||
output="$(curl -s $url)"
|
output="$(curl -s "$url")"
|
||||||
echo $output
|
echo "$output"
|
||||||
test "$output" == "$expected_output"
|
test "$output" == "$expected_output"
|
||||||
}
|
}
|
||||||
@@ -4,5 +4,5 @@ set -ex;
|
|||||||
REMOTE=$1
|
REMOTE=$1
|
||||||
REPO=$2
|
REPO=$2
|
||||||
|
|
||||||
ssh $REMOTE config:set $REPO CONFTEST=config-test HELLO=\"Hello world\"
|
ssh "$REMOTE" config:set "$REPO" CONFTEST=config-test HELLO=\"Hello world\"
|
||||||
|
|
||||||
@@ -1 +1 @@
|
|||||||
web: node node-js-sample/web.js
|
web: node node-js-sample/index.js
|
||||||
@@ -1,2 +1,5 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
set -e; output="$(curl -s $1)"; echo $output; test "$output" == "Hello World!"
|
set -ex
|
||||||
|
echo "curl -s $1"
|
||||||
|
curl -s -S $1
|
||||||
|
output="$(curl -s $1)"; echo $output; test "$output" == "Hello World!"
|
||||||
@@ -1,2 +1,2 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
set -e; test "$(curl -s $1)" == "go"
|
set -e; test "$(curl -s "$1")" == "go"
|
||||||
@@ -1,2 +1,2 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
set -e; curl -s $1 | grep -q "Heroku Multi Buildpack on Dokku"
|
set -e; curl -s "$1" | grep -q "Heroku Multi Buildpack on Dokku"
|
||||||
@@ -1,2 +1,2 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
set -e; output="$(curl -s $1)"; echo $output; test "$output" == "nodejs/express"
|
set -e; output="$(curl -s "$1")"; echo "$output"; test "$output" == "nodejs/express"
|
||||||
@@ -1,2 +1,2 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
set -e; output="$(curl -s $1)"; echo $output; test "$output" == "<html><h3>php</h3></html>"
|
set -e; output="$(curl -s "$1")"; echo "$output"; test "$output" == "<html><h3>php</h3></html>"
|
||||||
@@ -1,2 +1,2 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
set -e; output="$(curl -s $1)"; echo $output; test "$output" == "python/flask"
|
set -e; output="$(curl -s "$1")"; echo "$output"; test "$output" == "python/flask"
|
||||||
@@ -1,2 +1,2 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
set -e; output="$(curl -s $1)"; echo $output; test "$output" == "<html><h3>Static Page</h3></html>"
|
set -e; output="$(curl -s "$1")"; echo "$output"; test "$output" == "<html><h3>Static Page</h3></html>"
|
||||||
+2
-1
@@ -22,7 +22,8 @@ if [[ $2 == *dokku* ]]; then
|
|||||||
echo "-----> Generating keypair..."
|
echo "-----> Generating keypair..."
|
||||||
echo -e "y\n" | ssh-keygen -f /root/.ssh/id_rsa -t rsa -N ''
|
echo -e "y\n" | ssh-keygen -f /root/.ssh/id_rsa -t rsa -N ''
|
||||||
echo "-----> Installing SSH public key..."
|
echo "-----> Installing SSH public key..."
|
||||||
cat /root/.ssh/id_rsa.pub | sudo sshcommand acl-add dokku test
|
PUBLIC_KEY=$(< /root/.ssh/id_rsa.pub)
|
||||||
|
echo $PUBLIC_KEY | sudo sshcommand acl-add dokku test
|
||||||
echo "-----> Intitial SSH connection to populate known_hosts..."
|
echo "-----> Intitial SSH connection to populate known_hosts..."
|
||||||
ssh -o StrictHostKeyChecking=no dokku@dokku.me help > /dev/null
|
ssh -o StrictHostKeyChecking=no dokku@dokku.me help > /dev/null
|
||||||
echo "-----> Running tests"
|
echo "-----> Running tests"
|
||||||
|
|||||||
@@ -0,0 +1,11 @@
|
|||||||
|
#!/usr/bin/env bats
|
||||||
|
|
||||||
|
load ../unit/test_helper
|
||||||
|
|
||||||
|
@test "deploy config app" {
|
||||||
|
skip "ssh is doing something odd with quoting... ref: #820"
|
||||||
|
run bash -c "cd tests && ./test_deploy ./apps/config dokku.me"
|
||||||
|
echo "output: "$output
|
||||||
|
echo "status: "$status
|
||||||
|
assert_success
|
||||||
|
}
|
||||||
@@ -0,0 +1,10 @@
|
|||||||
|
#!/usr/bin/env bats
|
||||||
|
|
||||||
|
load ../unit/test_helper
|
||||||
|
|
||||||
|
@test "deploy gitsubmodules app" {
|
||||||
|
run bash -c "cd tests && ./test_deploy ./apps/gitsubmodules dokku.me"
|
||||||
|
echo "output: "$output
|
||||||
|
echo "status: "$status
|
||||||
|
assert_success
|
||||||
|
}
|
||||||
+4
-3
@@ -4,7 +4,7 @@ KEYNAME="$1"
|
|||||||
indent() { sed "s/^/ /"; }
|
indent() { sed "s/^/ /"; }
|
||||||
echo "-----> Booting EC2 instance..."
|
echo "-----> Booting EC2 instance..."
|
||||||
start=$(ec2-run-instances -k $1 ami-f3d1bb9a 2>&1 )
|
start=$(ec2-run-instances -k $1 ami-f3d1bb9a 2>&1 )
|
||||||
if [[ $? > 0 ]]; then
|
if [[ $? -gt 0 ]]; then
|
||||||
echo "$start" | indent
|
echo "$start" | indent
|
||||||
exit 3
|
exit 3
|
||||||
fi
|
fi
|
||||||
@@ -34,9 +34,10 @@ while [[ ! $(echo | nc $PUBLIC_IP 22) ]]; do
|
|||||||
done
|
done
|
||||||
set -e
|
set -e
|
||||||
echo "-----> Connecting and running bootstrap script..."
|
echo "-----> Connecting and running bootstrap script..."
|
||||||
cat ../bootstrap.sh | ssh -o "StrictHostKeyChecking=no" ubuntu@$PUBLIC_IP "HOSTNAME=$PUBLIC_IP sudo bash" 2>&1 | indent
|
ssh -o "StrictHostKeyChecking=no" ubuntu@$PUBLIC_IP "HOSTNAME=\$PUBLIC_IP sudo bash" < ../bootstrap.sh 2>&1 | indent
|
||||||
echo "-----> Installing SSH public keys..."
|
echo "-----> Installing SSH public keys..."
|
||||||
cat ~/.ssh/id_rsa.pub | ssh -o "StrictHostKeyChecking=no" ubuntu@$PUBLIC_IP "sudo sshcommand acl-add dokku test" > /dev/null
|
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
|
for app_path in apps/*; do
|
||||||
app=$(basename $app_path)
|
app=$(basename $app_path)
|
||||||
echo "-----> Running test deploy of $app..."
|
echo "-----> Running test deploy of $app..."
|
||||||
|
|||||||
+10
-7
@@ -1,23 +1,26 @@
|
|||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
set -eo pipefail
|
set -eo pipefail
|
||||||
SELF=`which $0`
|
SELF=$(which $0)
|
||||||
VAGRANT_SSH_PORT=${VAGRANT_SSH_PORT:-"2222"}
|
VAGRANT_SSH_PORT=${VAGRANT_SSH_PORT:-"2222"}
|
||||||
PUBLIC_KEY=${PUBLIC_KEY:-"$HOME/.ssh/id_rsa.pub"}
|
PUBLIC_KEY=${PUBLIC_KEY:-"$HOME/.ssh/id_rsa.pub"}
|
||||||
FORWARDED_PORT=${FORWARDED_PORT:-":8080"}
|
FORWARDED_PORT=${FORWARDED_PORT:-":8080"}
|
||||||
indent() { sed "s/^/ /"; }
|
indent() { sed "s/^/ /"; }
|
||||||
if [[ ! $(cat ~/.ssh/config 2>/dev/null | grep dokku.me) ]]; then
|
if ! grep dokku.me ~/.ssh/config 2>/dev/null; then
|
||||||
echo "-----> Configuring SSH to use $VAGRANT_SSH_PORT for dokku.me..."
|
echo "-----> Configuring SSH to use $VAGRANT_SSH_PORT for dokku.me..."
|
||||||
touch ~/.ssh/config
|
touch ~/.ssh/config
|
||||||
echo "Host dokku.me" >> ~/.ssh/config
|
{
|
||||||
echo " Port $VAGRANT_SSH_PORT" >> ~/.ssh/config
|
echo "Host dokku.me"
|
||||||
echo " RequestTTY yes" >> ~/.ssh/config
|
echo " Port $VAGRANT_SSH_PORT"
|
||||||
|
echo " RequestTTY yes"
|
||||||
|
} >> ~/.ssh/config
|
||||||
fi
|
fi
|
||||||
echo "-----> Ensuring Vagrant is running..."
|
echo "-----> Ensuring Vagrant is running..."
|
||||||
|
pushd $PWD > /dev/null
|
||||||
cd "$(dirname $SELF)/.." && vagrant up | indent
|
cd "$(dirname $SELF)/.." && vagrant up | indent
|
||||||
cd "$(dirname $SELF)"
|
popd > /dev/null
|
||||||
|
|
||||||
echo "-----> Installing SSH public keys..."
|
echo "-----> Installing SSH public keys..."
|
||||||
cat $PUBLIC_KEY | ssh -o "StrictHostKeyChecking=no" -i ~/.vagrant.d/insecure_private_key vagrant@dokku.me "sudo sshcommand acl-add dokku test"
|
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
|
for app_path in apps/*; do
|
||||||
app=$(basename $app_path)
|
app=$(basename $app_path)
|
||||||
|
|||||||
+26
-8
@@ -1,12 +1,22 @@
|
|||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
set -exo pipefail
|
set -exo pipefail
|
||||||
SELF=`which $0`; APP="$1"; TARGET="$2"; FORWARDED_PORT="$3"
|
|
||||||
|
SELF=$(which $0); APP="$1"; TARGET="$2"; FORWARDED_PORT="$3"
|
||||||
REMOTE="dokku@$TARGET"
|
REMOTE="dokku@$TARGET"
|
||||||
REPO="test-$(basename $APP)-$RANDOM"
|
REPO="test-$(basename $APP)-$RANDOM"
|
||||||
|
|
||||||
|
destroy_app(){
|
||||||
|
echo $REPO | ssh $REMOTE apps:destroy $REPO
|
||||||
|
}
|
||||||
|
|
||||||
|
failed(){
|
||||||
|
echo "************ $1 failed ************"
|
||||||
|
# destroy_app
|
||||||
|
exit 1
|
||||||
|
}
|
||||||
|
|
||||||
TMP=$(mktemp -d -t "$TARGET.XXXXX")
|
TMP=$(mktemp -d -t "$TARGET.XXXXX")
|
||||||
trap "rm -rf $TMP" EXIT
|
rmdir $TMP && cp -r "$(dirname "$SELF")"/$APP $TMP
|
||||||
rmdir $TMP && cp -r $(dirname $SELF)/$APP $TMP
|
|
||||||
cd $TMP
|
cd $TMP
|
||||||
git init
|
git init
|
||||||
git config user.email "robot@example.com"
|
git config user.email "robot@example.com"
|
||||||
@@ -19,13 +29,21 @@ git add .
|
|||||||
[[ -x pre-commit ]] && ./pre-commit $REMOTE $REPO
|
[[ -x pre-commit ]] && ./pre-commit $REMOTE $REPO
|
||||||
git commit -m 'initial commit'
|
git commit -m 'initial commit'
|
||||||
git push target master
|
git push target master
|
||||||
[[ -x post-deploy ]] && ./post-deploy $REMOTE $REPO
|
if [[ -x post-deploy ]]; then
|
||||||
|
./post-deploy $REMOTE $REPO || failed post-deploy
|
||||||
|
fi
|
||||||
|
|
||||||
URL=$(ssh $REMOTE url $REPO)$FORWARDED_PORT
|
URL=$(ssh $REMOTE url $REPO)$FORWARDED_PORT
|
||||||
sleep 2
|
sleep 2
|
||||||
./check_deploy $URL && echo "-----> Deploy success!" || {
|
if (./check_deploy $URL); then
|
||||||
|
echo "-----> Deploy success!"
|
||||||
|
else
|
||||||
sleep 4
|
sleep 4
|
||||||
./check_deploy $URL && echo "-----> Deploy success!"
|
if (./check_deploy $URL); then
|
||||||
}
|
echo "-----> Deploy success!"
|
||||||
|
else
|
||||||
|
failed check-deploy
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
ssh $REMOTE delete $REPO
|
destroy_app
|
||||||
Executable
+26
@@ -0,0 +1,26 @@
|
|||||||
|
#!/usr/bin/env bats
|
||||||
|
|
||||||
|
load test_helper
|
||||||
|
|
||||||
|
APP=lifecycle-app
|
||||||
|
|
||||||
|
@test "apps:create" {
|
||||||
|
run dokku apps:create $APP
|
||||||
|
echo "output: "$output
|
||||||
|
echo "status: "$status
|
||||||
|
assert_success
|
||||||
|
}
|
||||||
|
|
||||||
|
@test "apps" {
|
||||||
|
run bash -c "dokku apps | grep $APP"
|
||||||
|
echo "output: "$output
|
||||||
|
echo "status: "$status
|
||||||
|
assert_output $APP
|
||||||
|
}
|
||||||
|
|
||||||
|
@test "apps:destroy" {
|
||||||
|
run bash -c "echo $APP | dokku apps:destroy $APP"
|
||||||
|
echo "output: "$output
|
||||||
|
echo "status: "$status
|
||||||
|
assert_success
|
||||||
|
}
|
||||||
@@ -0,0 +1,20 @@
|
|||||||
|
#!/usr/bin/env bats
|
||||||
|
|
||||||
|
# load test_helper
|
||||||
|
|
||||||
|
# setup() {
|
||||||
|
# create_app
|
||||||
|
# backup_file=$(mktemp /tmp/backup.XXXXXX)
|
||||||
|
# rm $backup_file
|
||||||
|
# }
|
||||||
|
|
||||||
|
# teardown() {
|
||||||
|
# destroy_app
|
||||||
|
# }
|
||||||
|
|
||||||
|
# @test "backup:export" {
|
||||||
|
# run dokku backup:export $backup_file
|
||||||
|
# echo "output: "$output
|
||||||
|
# echo "status: "$status
|
||||||
|
# assert_success
|
||||||
|
# }
|
||||||
@@ -0,0 +1,44 @@
|
|||||||
|
#!/usr/bin/env bats
|
||||||
|
|
||||||
|
load test_helper
|
||||||
|
|
||||||
|
setup() {
|
||||||
|
create_app
|
||||||
|
}
|
||||||
|
|
||||||
|
teardown() {
|
||||||
|
destroy_app
|
||||||
|
}
|
||||||
|
|
||||||
|
@test "config:set" {
|
||||||
|
run dokku config:set $TEST_APP test_var=true test_var2='hello world'
|
||||||
|
echo "output: "$output
|
||||||
|
echo "status: "$status
|
||||||
|
assert_success
|
||||||
|
}
|
||||||
|
|
||||||
|
@test "config:get" {
|
||||||
|
run dokku config:set $TEST_APP test_var=true test_var2='hello world'
|
||||||
|
echo "output: "$output
|
||||||
|
echo "status: "$status
|
||||||
|
run dokku config:get $TEST_APP test_var2
|
||||||
|
echo "output: "$output
|
||||||
|
echo "status: "$status
|
||||||
|
assert_output 'hello world'
|
||||||
|
}
|
||||||
|
|
||||||
|
@test "config:unset" {
|
||||||
|
run dokku config:set $TEST_APP test_var=true test_var2='hello world'
|
||||||
|
echo "output: "$output
|
||||||
|
echo "status: "$status
|
||||||
|
run dokku config:get $TEST_APP test_var
|
||||||
|
echo "output: "$output
|
||||||
|
echo "status: "$status
|
||||||
|
run dokku config:unset $TEST_APP test_var
|
||||||
|
echo "output: "$output
|
||||||
|
echo "status: "$status
|
||||||
|
run dokku config:get $TEST_APP test_var
|
||||||
|
echo "output: "$output
|
||||||
|
echo "status: "$status
|
||||||
|
assert_output ""
|
||||||
|
}
|
||||||
@@ -0,0 +1,86 @@
|
|||||||
|
# constants
|
||||||
|
TEST_APP=my-cool-guy-test-app
|
||||||
|
|
||||||
|
# test functions
|
||||||
|
flunk() {
|
||||||
|
{ if [ "$#" -eq 0 ]; then cat -
|
||||||
|
else echo "$@"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
return 1
|
||||||
|
}
|
||||||
|
|
||||||
|
assert_success() {
|
||||||
|
if [ "$status" -ne 0 ]; then
|
||||||
|
flunk "command failed with exit status $status"
|
||||||
|
elif [ "$#" -gt 0 ]; then
|
||||||
|
assert_output "$1"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
assert_failure() {
|
||||||
|
if [ "$status" -eq 0 ]; then
|
||||||
|
flunk "expected failed exit status"
|
||||||
|
elif [ "$#" -gt 0 ]; then
|
||||||
|
assert_output "$1"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
assert_equal() {
|
||||||
|
if [ "$1" != "$2" ]; then
|
||||||
|
{ echo "expected: $1"
|
||||||
|
echo "actual: $2"
|
||||||
|
} | flunk
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
assert_output() {
|
||||||
|
local expected
|
||||||
|
if [ $# -eq 0 ]; then expected="$(cat -)"
|
||||||
|
else expected="$1"
|
||||||
|
fi
|
||||||
|
assert_equal "$expected" "$output"
|
||||||
|
}
|
||||||
|
|
||||||
|
assert_line() {
|
||||||
|
if [ "$1" -ge 0 ] 2>/dev/null; then
|
||||||
|
assert_equal "$2" "${lines[$1]}"
|
||||||
|
else
|
||||||
|
local line
|
||||||
|
for line in "${lines[@]}"; do
|
||||||
|
if [ "$line" = "$1" ]; then return 0; fi
|
||||||
|
done
|
||||||
|
flunk "expected line \`$1'"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
refute_line() {
|
||||||
|
if [ "$1" -ge 0 ] 2>/dev/null; then
|
||||||
|
local num_lines="${#lines[@]}"
|
||||||
|
if [ "$1" -lt "$num_lines" ]; then
|
||||||
|
flunk "output has $num_lines lines"
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
local line
|
||||||
|
for line in "${lines[@]}"; do
|
||||||
|
if [ "$line" = "$1" ]; then
|
||||||
|
flunk "expected to not find line \`$line'"
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
assert() {
|
||||||
|
if ! "$@"; then
|
||||||
|
flunk "failed: $@"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
# dokku functions
|
||||||
|
create_app() {
|
||||||
|
dokku apps:create $TEST_APP
|
||||||
|
}
|
||||||
|
|
||||||
|
destroy_app() {
|
||||||
|
echo $TEST_APP | dokku apps:destroy $TEST_APP
|
||||||
|
}
|
||||||
+22
@@ -0,0 +1,22 @@
|
|||||||
|
# box: ruudk/ubuntu14.04@1.0.0
|
||||||
|
# box: jparyani/docker@1.0.1
|
||||||
|
box: wercker-labs/docker
|
||||||
|
build:
|
||||||
|
steps:
|
||||||
|
- script:
|
||||||
|
name: install os requirements
|
||||||
|
code: |-
|
||||||
|
sudo apt-get update
|
||||||
|
sudo apt-get install -y make software-properties-common git wget man-db
|
||||||
|
docker version
|
||||||
|
- script:
|
||||||
|
name: ci dependencies
|
||||||
|
code: make -e ci-dependencies
|
||||||
|
- script:
|
||||||
|
name: install dokku
|
||||||
|
code: sudo -E CI=true DOCKER_VERSION=1.4.0 make -e install
|
||||||
|
- script:
|
||||||
|
name: test dokku
|
||||||
|
code: |-
|
||||||
|
docker version
|
||||||
|
sudo -E make -e test
|
||||||
Reference in new issue
Block a user