diff --git a/circle.yml b/circle.yml index affa9b308..90468d67f 100644 --- a/circle.yml +++ b/circle.yml @@ -18,9 +18,8 @@ dependencies: - sudo -E make -e setup-deploy-tests post: - sudo -E make -e lint -test: - pre: - sudo -E make -e unit-tests +test: override: ### deploy tests (against buildstep release) #### - sudo -E make -e deploy-tests: { timeout: 1800 } diff --git a/plugins/git/commands b/plugins/git/commands index ec5a452be..621c59202 100755 --- a/plugins/git/commands +++ b/plugins/git/commands @@ -6,14 +6,13 @@ git_archive_all() { TMP_WORK_DIR=$(mktemp -d) chmod 755 $TMP_WORK_DIR unset GIT_DIR GIT_WORK_TREE - git clone -q $DOKKU_ROOT/$APP $TMP_WORK_DIR &> /dev/null pushd $TMP_WORK_DIR > /dev/null + git clone -q $DOKKU_ROOT/$APP $TMP_WORK_DIR &> /dev/null git config advice.detachedHead false git checkout $REV &> /dev/null git submodule update --init --recursive &> /dev/null find -name .git -prune -exec rm -rf {} \; > /dev/null tar c . - popd > /dev/null rm -rf $TMP_WORK_DIR > /dev/null } @@ -26,7 +25,7 @@ case "$1" in # Only run this script for the master branch. You can remove this # if block if you wish to run it for others as well. if [[ $refname = "refs/heads/master" ]] ; then - git_archive_all $APP $newrev | dokku receive $APP | sed -u "s/^/"$'\e[1G'"/" + dokku git-build $APP $newrev else echo $'\e[1G\e[K'"-----> WARNING: deploy did not complete, you must push to master." echo $'\e[1G\e[K'"-----> for example, try 'git push ${refname/refs\/heads\/}:master'" @@ -41,6 +40,25 @@ case "$1" in pluginhook git-post-pull $APP ;; + git-build) + APP="$2"; APP_BUILD_LOCK="$DOKKU_ROOT/$APP/.build.lock" + APP_BUILD_LOCK_MSG="$APP is currently being deployed or locked. Waiting..." + [[ $(flock -n "$APP_BUILD_LOCK" true &>/dev/null ; echo $?) -ne 0 ]] && echo "$APP_BUILD_LOCK_MSG" + + shift 1 + flock -o "$APP_BUILD_LOCK" dokku git-build-locked "$@" + ;; + + git-build-locked) + APP="$2" + if [[ $# -ge 3 ]];then + REF="$3" + else + REF=$(< "$DOKKU_ROOT/$APP/refs/heads/master") + fi + git_archive_all $APP $REF | dokku receive $APP | sed -u "s/^/"$'\e[1G'"/" + ;; + git-*) APP="$(echo $2 | perl -pe 's/(? List processes running in app container(s) ps:start Start app container(s) ps:stop Stop app container(s) + ps:rebuild Rebuild an app + ps:rebuildall Rebuild all apps ps:restart Restart app container(s) ps:restartall Restart all deployed app containers EOF diff --git a/tests/unit/ps.bats b/tests/unit/ps.bats index 53efb0b35..915563a61 100644 --- a/tests/unit/ps.bats +++ b/tests/unit/ps.bats @@ -57,3 +57,14 @@ teardown() { echo "status: "$status assert_success } + +@test "ps:rebuild" { + run bash -c "dokku ps:rebuild $TEST_APP" + echo "output: "$output + echo "status: "$status + assert_success + run bash -c "docker ps -q --no-trunc | grep -q $(< $DOKKU_ROOT/$TEST_APP/CONTAINER)" + echo "output: "$output + echo "status: "$status + assert_success +}