Merge pull request #4297 from dokku/git-sync
Add support for cloning/syncing from a remote repository
This commit is contained in:
@@ -3,9 +3,12 @@
|
||||
> Subcommands new as of 0.12.0
|
||||
|
||||
```
|
||||
git:initialize <app> # Initialize a git repository for an app
|
||||
git:report [<app>] [<flag>] # Displays a git report for one or more apps
|
||||
git:set <app> <key> (<value>) # Set or clear a git property for an app
|
||||
git:allow-host <host> # Adds a host to known_hosts
|
||||
git:sync [--build] <app> <repository> [<git-ref>] # Clone or fetch an app from remote git repo
|
||||
git:initialize <app> # Initialize a git repository for an app
|
||||
git:public-key # Outputs the dokku public deploy key
|
||||
git:report [<app>] [<flag>] # Displays a git report for one or more apps
|
||||
git:set <app> <key> (<value>) # Set or clear a git property for an app
|
||||
```
|
||||
|
||||
Git-based deployment has been the traditional method of deploying applications in Dokku. As of v0.12.0, Dokku introduces a few ways to customize the experience of deploying via `git push`. A Git-based deployment currently supports building applications via:
|
||||
@@ -105,3 +108,50 @@ dokku git:set node-js-app keep-git-dir false
|
||||
# delete the .git directory during builds (default)
|
||||
dokku git:set node-js-app keep-git-dir ""
|
||||
```
|
||||
|
||||
### Initializing an app repository from a remote repository
|
||||
|
||||
> The application must exist before the repository can be initialized
|
||||
|
||||
A Dokku app repository can be initialized or updated from a remote git repository via the `git:sync` command. This command will either clone or fetch updates from a remote repository and has undefined behavior if the history cannot be fast-fowarded to the referenced repository reference. Any repository that can be cloned by the `dokku` user can be specified.
|
||||
|
||||
```shell
|
||||
dokku git:sync node-js-app https://github.com/heroku/node-js-getting-started.git
|
||||
```
|
||||
|
||||
The `git:sync` command optionally takes an optional third parameter containing a git reference, which may be a branch, tag, or specific commit.
|
||||
|
||||
```shell
|
||||
# specify a branch
|
||||
dokku git:sync node-js-app https://github.com/heroku/node-js-getting-started.git main
|
||||
|
||||
# specify a tag
|
||||
dokku git:sync node-js-app https://github.com/heroku/node-js-getting-started.git 1
|
||||
|
||||
# specify a commit
|
||||
dokku git:sync node-js-app https://github.com/heroku/node-js-getting-started.git 97e6c72491c7531507bfc5413903e0e00e31e1b0
|
||||
```
|
||||
|
||||
By default, this command does not trigger an application build. To do so during a `git:sync`, specify the `--build` flag.
|
||||
|
||||
```shell
|
||||
dokku git:sync --build node-js-app https://github.com/heroku/node-js-getting-started.git
|
||||
```
|
||||
|
||||
### Allowing remote repository hosts
|
||||
|
||||
By default, the Dokku host may not have access to a server containing the remote repository. This can be initialized via the `git:allow-host` command.
|
||||
|
||||
```shell
|
||||
dokku git:allow-host github.com
|
||||
```
|
||||
|
||||
Note that this command is currently not idempotent and may add duplicate entries to the `~dokku/.ssh/known_hosts` file.
|
||||
|
||||
### Verifying the cloning public key
|
||||
|
||||
In order to clone a remote repository, the remote server should have the Dokku host's public key configured. This plugin does not currently create this key, but if there is one available, it can be shown via the `git:public-key` command.
|
||||
|
||||
```shell
|
||||
dokku git:public-key
|
||||
```
|
||||
|
||||
@@ -234,22 +234,3 @@ cmd-git-glob() {
|
||||
fi
|
||||
git-shell -c "$args"
|
||||
}
|
||||
|
||||
fn-git-create-hook() {
|
||||
declare APP="$1"
|
||||
local APP_PATH="$DOKKU_ROOT/$APP"
|
||||
local PRERECEIVE_HOOK="$APP_PATH/hooks/pre-receive"
|
||||
|
||||
if [[ ! -d "$APP_PATH/refs" ]]; then
|
||||
git init --bare "$APP_PATH" >/dev/null
|
||||
fi
|
||||
|
||||
cat >"$PRERECEIVE_HOOK" <<EOF
|
||||
#!/usr/bin/env bash
|
||||
set -e
|
||||
set -o pipefail
|
||||
|
||||
cat | DOKKU_ROOT="$DOKKU_ROOT" dokku git-hook $APP
|
||||
EOF
|
||||
chmod +x "$PRERECEIVE_HOOK"
|
||||
}
|
||||
|
||||
@@ -27,7 +27,10 @@ help_desc
|
||||
fn-help-content() {
|
||||
declare desc="return help content"
|
||||
cat <<help_content
|
||||
git:allow-host <host>, Adds a host to known_hosts
|
||||
git:sync [--build] <app> <repository> [<git-ref>], Clone or fetch an app from remote git repo
|
||||
git:initialize <app>, Initialize a git repository for an app
|
||||
git:public-key, Outputs the dokku public deploy key
|
||||
git:report [<app>] [<flag>], Displays a git report for one or more apps
|
||||
git:set <app> <property> (<value>), Set or clear a git property for an app
|
||||
help_content
|
||||
|
||||
@@ -9,6 +9,9 @@ trigger-git-install() {
|
||||
declare desc="installs the git plugin"
|
||||
declare trigger="install"
|
||||
|
||||
mkdir -p "${DOKKU_LIB_ROOT}/data/git"
|
||||
chown -R "${DOKKU_SYSTEM_USER}:${DOKKU_SYSTEM_GROUP}" "${DOKKU_LIB_ROOT}/data/git"
|
||||
|
||||
fn-plugin-property-setup "git"
|
||||
migrate_git_vars_0_12_0 "$@"
|
||||
}
|
||||
|
||||
@@ -4,6 +4,72 @@ source "$PLUGIN_CORE_AVAILABLE_PATH/common/property-functions"
|
||||
set -eo pipefail
|
||||
[[ $DOKKU_TRACE ]] && set -x
|
||||
|
||||
cmd-git-allow-host() {
|
||||
declare desc="adds a host to known_hosts"
|
||||
local cmd="git:allow-host"
|
||||
[[ "$1" == "$cmd" ]] && shift 1
|
||||
declare HOST="$1"
|
||||
[[ -z "$HOST" ]] && dokku_log_fail "Please supply a git host"
|
||||
|
||||
ssh-keyscan -t rsa "$HOST" >> "$DOKKU_ROOT/.ssh/known_hosts"
|
||||
dokku_log_info1 "$HOST added to known hosts"
|
||||
}
|
||||
|
||||
cmd-git-sync() {
|
||||
declare desc="clone or fetch an app from remote git repo"
|
||||
local cmd="git:sync"
|
||||
[[ "$1" == "$cmd" ]] && shift 1
|
||||
declare APP GIT_REMOTE GIT_REF FLAG
|
||||
|
||||
ARGS=()
|
||||
for arg in "$@"; do
|
||||
if [[ "$arg" == "--build" ]]; then
|
||||
FLAG="--build"
|
||||
continue
|
||||
fi
|
||||
|
||||
ARGS+=("$arg")
|
||||
done
|
||||
|
||||
APP="${ARGS[0]}"
|
||||
GIT_REMOTE="${ARGS[1]}"
|
||||
GIT_REF="${ARGS[2]}"
|
||||
|
||||
verify_app_name "$APP"
|
||||
|
||||
if [[ -z "$GIT_REMOTE" ]]; then
|
||||
dokku_log_fail "Missing GIT_REMOTE parameter"
|
||||
return
|
||||
fi
|
||||
|
||||
local APP_ROOT="$DOKKU_ROOT/$APP"
|
||||
if [[ "$(git -C "$APP_ROOT" count-objects)" == "0 objects, 0 kilobytes" ]]; then
|
||||
fn-git-clone "$APP" "$GIT_REMOTE" "$GIT_REF"
|
||||
else
|
||||
fn-git-fetch "$APP" "$GIT_REMOTE" "$GIT_REF"
|
||||
fi
|
||||
|
||||
if [[ "$FLAG" == "--build" ]]; then
|
||||
if [[ -n "$GIT_REF" ]]; then
|
||||
GIT_REF="$(git -C "/home/dokku/$APP" rev-parse "$GIT_REF")"
|
||||
plugn trigger receive-app "$APP" "$GIT_REF"
|
||||
else
|
||||
plugn trigger receive-app "$APP"
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
cmd-git-public-key() {
|
||||
declare desc="outputs the dokku public deploy key"
|
||||
local cmd="git:public-key"
|
||||
[[ "$1" == "$cmd" ]] && shift 1
|
||||
|
||||
if [[ ! -f "$DOKKU_ROOT/.ssh/id_rsa.pub" ]]; then
|
||||
dokku_log_fail "There is no deploy key"
|
||||
fi
|
||||
cat "$DOKKU_ROOT/.ssh/id_rsa.pub"
|
||||
}
|
||||
|
||||
cmd-git-report() {
|
||||
declare desc="displays a git report for one or more apps"
|
||||
declare cmd="git:report"
|
||||
@@ -41,7 +107,7 @@ cmd-git-report-single() {
|
||||
"--git-global-deploy-branch: $(fn-plugin-property-get "git" "--global" "deploy-branch" "master")"
|
||||
"--git-keep-git-dir: $(fn-plugin-property-get "git" "$APP" "keep-git-dir" "false")"
|
||||
"--git-rev-env-var: $(fn-plugin-property-get "git" "$APP" "rev-env-var" "GIT_REV")"
|
||||
"--git-sha: $(GIT_DIR="$APP_DIR" git rev-parse --short HEAD 2>/dev/null || false)"
|
||||
"--git-sha: $(git -C "$APP_DIR" rev-parse --short HEAD 2>/dev/null || false)"
|
||||
"--git-last-updated-at: $(fn-git-last-updated-at "$APP")"
|
||||
)
|
||||
|
||||
@@ -71,11 +137,105 @@ cmd-git-report-single() {
|
||||
fi
|
||||
}
|
||||
|
||||
fn-git-create-hook() {
|
||||
declare APP="$1"
|
||||
local APP_PATH="$DOKKU_ROOT/$APP"
|
||||
local PRERECEIVE_HOOK="$APP_PATH/hooks/pre-receive"
|
||||
|
||||
if [[ ! -d "$APP_PATH/refs" ]]; then
|
||||
git init -q --bare "$APP_PATH" >/dev/null
|
||||
fi
|
||||
|
||||
cat >"$PRERECEIVE_HOOK" <<EOF
|
||||
#!/usr/bin/env bash
|
||||
set -e
|
||||
set -o pipefail
|
||||
|
||||
cat | DOKKU_ROOT="$DOKKU_ROOT" dokku git-hook $APP
|
||||
EOF
|
||||
chmod +x "$PRERECEIVE_HOOK"
|
||||
}
|
||||
|
||||
fn-git-clone() {
|
||||
declare desc="creates an app from remote git repo"
|
||||
declare APP="$1" GIT_REMOTE="$2" GIT_REF="$3"
|
||||
local APP_CLONE_ROOT="$DOKKU_LIB_ROOT/data/git/$APP"
|
||||
local APP_ROOT="$DOKKU_ROOT/$APP"
|
||||
[[ -z "$APP" ]] && dokku_log_fail "Please specify an app to run the command on"
|
||||
|
||||
if [[ "$(git -C "$APP_ROOT" count-objects)" != "0 objects, 0 kilobytes" ]]; then
|
||||
dokku_log_fail "The clone subcommand can only be executed for new applications"
|
||||
fi
|
||||
|
||||
if [[ -d "$APP_CLONE_ROOT" ]]; then
|
||||
dokku_log_fail "Clone in progress"
|
||||
fi
|
||||
|
||||
if [[ -z "$GIT_REF" ]]; then
|
||||
GIT_REF="$(fn-git-deploy-branch "$APP")"
|
||||
fi
|
||||
|
||||
dokku_log_info1_quiet "Cloning $APP from $GIT_REMOTE#$GIT_REF"
|
||||
trap 'rm -rf $APP_CLONE_ROOT > /dev/null' RETURN INT TERM EXIT
|
||||
|
||||
is_ref=true
|
||||
git clone --depth 1 -n -qq --branch "$GIT_REF" "$GIT_REMOTE" "$APP_CLONE_ROOT" 2>/dev/null && is_ref=false
|
||||
rm -rf "$APP_CLONE_ROOT"
|
||||
|
||||
if [[ "$is_ref" == "true" ]]; then
|
||||
git clone -n -qq "$GIT_REMOTE" "$APP_CLONE_ROOT" 2>/dev/null
|
||||
git -C "$APP_CLONE_ROOT" checkout -qq "$GIT_REF"
|
||||
else
|
||||
git clone -n -qq --branch "$GIT_REF" "$GIT_REMOTE" "$APP_CLONE_ROOT" 2>/dev/null
|
||||
if git -C "$APP_CLONE_ROOT" show-ref --verify "refs/heads/$GIT_REF" >/dev/null 2>&1; then
|
||||
dokku_log_verbose "Detected branch, setting deploy-branch to $GIT_REF"
|
||||
fn-plugin-property-write "git" "$APP" "deploy-branch" "$GIT_REF"
|
||||
fi
|
||||
fi
|
||||
|
||||
DOKKU_DEPLOY_BRANCH="$(fn-git-deploy-branch "$APP")"
|
||||
if [[ "$GIT_REF" != "$DOKKU_DEPLOY_BRANCH" ]]; then
|
||||
if [[ "$is_ref" == "true" ]]; then
|
||||
git -C "$APP_CLONE_ROOT" branch -qq -D "$DOKKU_DEPLOY_BRANCH" 2>/dev/null || true
|
||||
fi
|
||||
git -C "$APP_CLONE_ROOT" checkout -qq -b "$DOKKU_DEPLOY_BRANCH"
|
||||
fi
|
||||
|
||||
rsync -a "$APP_CLONE_ROOT/.git/" "$APP_ROOT"
|
||||
fn-git-create-hook "$APP"
|
||||
}
|
||||
|
||||
fn-git-fetch() {
|
||||
declare APP="$1" GIT_REMOTE="$2" GIT_REF="$3"
|
||||
local DOKKU_DEPLOY_BRANCH
|
||||
local APP_ROOT="$DOKKU_ROOT/$APP"
|
||||
|
||||
if [[ "$(git -C "$APP_ROOT" count-objects)" == "0 objects, 0 kilobytes" ]]; then
|
||||
dokku_log_fail "The fetch subcommand can only be executed for existing applications"
|
||||
fi
|
||||
|
||||
DOKKU_DEPLOY_BRANCH="$(fn-git-deploy-branch "$APP")"
|
||||
if ! git -C "$APP_ROOT" check-ref-format --branch "$DOKKU_DEPLOY_BRANCH" >/dev/null 2>&1; then
|
||||
echo $'\e[1G\e[K'"-----> WARNING: Invalid branch name '$DOKKU_DEPLOY_BRANCH' specified via DOKKU_DEPLOY_BRANCH."
|
||||
echo $'\e[1G\e[K'"-----> For more details, please see the man page for 'git-check-ref-format.'"
|
||||
return
|
||||
fi
|
||||
|
||||
git -C "$APP_ROOT" remote rm remote > /dev/null 2>&1 || true
|
||||
git -C "$APP_ROOT" remote add --mirror=fetch --no-tags remote "$GIT_REMOTE"
|
||||
if [[ -z "$GIT_REF" ]]; then
|
||||
git -C "$APP_ROOT" fetch --update-head-ok remote "$DOKKU_DEPLOY_BRANCH"
|
||||
else
|
||||
git -C "$APP_ROOT" fetch --update-head-ok remote
|
||||
git -C "$APP_ROOT" update-ref "refs/heads/$DOKKU_DEPLOY_BRANCH" "$GIT_REF"
|
||||
fi
|
||||
}
|
||||
|
||||
fn-git-last-updated-at() {
|
||||
declare desc="retrieve the deploy branch for a given application"
|
||||
declare APP="$1"
|
||||
local DOKKU_DEPLOY_BRANCH="$(fn-git-deploy-branch "$APP")"
|
||||
local HEAD_FILE="/home/dokku/test/refs/heads/$DOKKU_DEPLOY_BRANCH"
|
||||
local HEAD_FILE="/home/dokku/$APP/refs/heads/$DOKKU_DEPLOY_BRANCH"
|
||||
|
||||
if [[ -f "$HEAD_FILE" ]]; then
|
||||
stat -c %Y "$HEAD_FILE"
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#!/usr/bin/env bash
|
||||
source "$PLUGIN_CORE_AVAILABLE_PATH/common/property-functions"
|
||||
set -eo pipefail
|
||||
[[ $DOKKU_TRACE ]] && set -x
|
||||
source "$PLUGIN_CORE_AVAILABLE_PATH/common/property-functions"
|
||||
|
||||
trigger-git-post-app-clone-setup() {
|
||||
declare desc="modifies git-hook"
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#!/usr/bin/env bash
|
||||
source "$PLUGIN_CORE_AVAILABLE_PATH/common/property-functions"
|
||||
set -eo pipefail
|
||||
[[ $DOKKU_TRACE ]] && set -x
|
||||
source "$PLUGIN_CORE_AVAILABLE_PATH/common/property-functions"
|
||||
|
||||
trigger-git-post-app-rename-setup() {
|
||||
declare desc="modifies git-hook"
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#!/usr/bin/env bash
|
||||
source "$PLUGIN_AVAILABLE_PATH/git/internal-functions"
|
||||
set -eo pipefail
|
||||
[[ $DOKKU_TRACE ]] && set -x
|
||||
source "$PLUGIN_AVAILABLE_PATH/git/functions"
|
||||
|
||||
trigger-git-post-create() {
|
||||
declare desc="initializes an app with the correct git repository structure"
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#!/usr/bin/env bash
|
||||
source "$PLUGIN_CORE_AVAILABLE_PATH/common/property-functions"
|
||||
set -eo pipefail
|
||||
[[ $DOKKU_TRACE ]] && set -x
|
||||
source "$PLUGIN_CORE_AVAILABLE_PATH/common/property-functions"
|
||||
|
||||
trigger-git-post-delete() {
|
||||
declare desc="destroys the git properties for a given app"
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
#!/usr/bin/env bash
|
||||
source "$PLUGIN_AVAILABLE_PATH/git/functions"
|
||||
set -eo pipefail
|
||||
[[ $DOKKU_TRACE ]] && set -x
|
||||
source "$PLUGIN_AVAILABLE_PATH/git/functions"
|
||||
|
||||
git_receive_app "$@"
|
||||
|
||||
6
plugins/git/subcommands/allow-host
Executable file
6
plugins/git/subcommands/allow-host
Executable file
@@ -0,0 +1,6 @@
|
||||
#!/usr/bin/env bash
|
||||
source "$PLUGIN_AVAILABLE_PATH/git/internal-functions"
|
||||
set -eo pipefail
|
||||
[[ $DOKKU_TRACE ]] && set -x
|
||||
|
||||
cmd-git-allow-host "$@"
|
||||
@@ -1,6 +1,6 @@
|
||||
#!/usr/bin/env bash
|
||||
source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions"
|
||||
source "$PLUGIN_AVAILABLE_PATH/git/functions"
|
||||
source "$PLUGIN_AVAILABLE_PATH/git/internal-functions"
|
||||
set -eo pipefail
|
||||
[[ $DOKKU_TRACE ]] && set -x
|
||||
|
||||
|
||||
6
plugins/git/subcommands/public-key
Executable file
6
plugins/git/subcommands/public-key
Executable file
@@ -0,0 +1,6 @@
|
||||
#!/usr/bin/env bash
|
||||
source "$PLUGIN_AVAILABLE_PATH/git/internal-functions"
|
||||
set -eo pipefail
|
||||
[[ $DOKKU_TRACE ]] && set -x
|
||||
|
||||
cmd-git-public-key "$@"
|
||||
6
plugins/git/subcommands/sync
Executable file
6
plugins/git/subcommands/sync
Executable file
@@ -0,0 +1,6 @@
|
||||
#!/usr/bin/env bash
|
||||
source "$PLUGIN_AVAILABLE_PATH/git/internal-functions"
|
||||
set -eo pipefail
|
||||
[[ $DOKKU_TRACE ]] && set -x
|
||||
|
||||
cmd-git-sync "$@"
|
||||
@@ -27,7 +27,7 @@ teardown() {
|
||||
}
|
||||
|
||||
@test "(git) ensure GIT_REV env var is set" {
|
||||
deploy_app
|
||||
run deploy_app
|
||||
echo "output: $output"
|
||||
echo "status: $status"
|
||||
assert_success
|
||||
@@ -44,7 +44,7 @@ teardown() {
|
||||
echo "status: $status"
|
||||
assert_success
|
||||
|
||||
deploy_app
|
||||
run deploy_app
|
||||
echo "output: $output"
|
||||
echo "status: $status"
|
||||
assert_success
|
||||
@@ -61,7 +61,7 @@ teardown() {
|
||||
echo "status: $status"
|
||||
assert_success
|
||||
|
||||
deploy_app
|
||||
run deploy_app
|
||||
echo "output: $output"
|
||||
echo "status: $status"
|
||||
assert_success
|
||||
|
||||
292
tests/unit/git_3.bats
Normal file
292
tests/unit/git_3.bats
Normal file
@@ -0,0 +1,292 @@
|
||||
#!/usr/bin/env bats
|
||||
|
||||
load test_helper
|
||||
|
||||
setup() {
|
||||
global_setup
|
||||
create_app
|
||||
touch /home/dokku/.ssh/known_hosts
|
||||
chown dokku:dokku /home/dokku/.ssh/known_hosts
|
||||
}
|
||||
|
||||
teardown() {
|
||||
rm -f /home/dokku/.ssh/id_rsa.pub || true
|
||||
destroy_app
|
||||
global_teardown
|
||||
}
|
||||
|
||||
@test "(git) git:allow-host" {
|
||||
run /bin/bash -c "dokku git:allow-host"
|
||||
echo "output: $output"
|
||||
echo "status: $status"
|
||||
assert_failure
|
||||
|
||||
run /bin/bash -c "cat /home/dokku/.ssh/known_hosts | wc -l"
|
||||
echo "output: $output"
|
||||
echo "status: $status"
|
||||
assert_success
|
||||
start_lines=$output
|
||||
|
||||
run /bin/bash -c "dokku git:allow-host github.com"
|
||||
echo "output: $output"
|
||||
echo "status: $status"
|
||||
assert_success
|
||||
|
||||
run /bin/bash -c "cat /home/dokku/.ssh/known_hosts | wc -l"
|
||||
echo "output: $output"
|
||||
echo "status: $status"
|
||||
assert_success
|
||||
|
||||
run /bin/bash -c "test -f /home/dokku/.ssh/known_hosts"
|
||||
echo "output: $output"
|
||||
echo "status: $status"
|
||||
assert_success
|
||||
|
||||
run /bin/bash -c "cat /home/dokku/.ssh/known_hosts | wc -l"
|
||||
echo "output: $output"
|
||||
echo "status: $status"
|
||||
assert_success
|
||||
assert_equal "$output" "$((start_lines + 1))"
|
||||
|
||||
run /bin/bash -c "dokku git:allow-host github.com"
|
||||
echo "output: $output"
|
||||
echo "status: $status"
|
||||
assert_success
|
||||
|
||||
run /bin/bash -c "cat /home/dokku/.ssh/known_hosts | wc -l"
|
||||
echo "output: $output"
|
||||
echo "status: $status"
|
||||
assert_success
|
||||
assert_equal "$output" "$((start_lines + 2))"
|
||||
}
|
||||
|
||||
@test "(git) git:sync new [errors]" {
|
||||
run /bin/bash -c "dokku git:sync"
|
||||
echo "output: $output"
|
||||
echo "status: $status"
|
||||
assert_failure
|
||||
|
||||
run /bin/bash -c "dokku git:sync $TEST_APP-non-existent"
|
||||
echo "output: $output"
|
||||
echo "status: $status"
|
||||
assert_failure
|
||||
|
||||
run create_app "$TEST_APP-non-existent"
|
||||
echo "output: $output"
|
||||
echo "status: $status"
|
||||
assert_success
|
||||
|
||||
run /bin/bash -c "dokku git:sync $TEST_APP-non-existent"
|
||||
echo "output: $output"
|
||||
echo "status: $status"
|
||||
assert_failure
|
||||
|
||||
run destroy_app 0 "$TEST_APP-non-existent"
|
||||
echo "output: $output"
|
||||
echo "status: $status"
|
||||
assert_success
|
||||
}
|
||||
|
||||
@test "(git) git:sync new [--no-build noarg]" {
|
||||
run /bin/bash -c "dokku git:sync $TEST_APP https://github.com/dokku/smoke-test-app.git"
|
||||
echo "output: $output"
|
||||
echo "status: $status"
|
||||
assert_success
|
||||
}
|
||||
|
||||
@test "(git) git:sync new [--no-build branch]" {
|
||||
run /bin/bash -c "dokku git:sync $TEST_APP https://github.com/dokku/smoke-test-app.git another-branch"
|
||||
echo "output: $output"
|
||||
echo "status: $status"
|
||||
assert_success
|
||||
}
|
||||
|
||||
@test "(git) git:sync new [--no-build tag]" {
|
||||
run /bin/bash -c "dokku git:sync $TEST_APP https://github.com/dokku/smoke-test-app.git 1.0.0"
|
||||
echo "output: $output"
|
||||
echo "status: $status"
|
||||
assert_success
|
||||
}
|
||||
|
||||
@test "(git) git:sync new [--no-build commit]" {
|
||||
run /bin/bash -c "dokku git:sync $TEST_APP https://github.com/dokku/smoke-test-app.git 5c8a5e42bbd7fae98bd657fb17f41c6019b303f9"
|
||||
echo "output: $output"
|
||||
echo "status: $status"
|
||||
assert_success
|
||||
}
|
||||
|
||||
@test "(git) git:sync new [--build noarg]" {
|
||||
run /bin/bash -c "dokku git:sync --build $TEST_APP https://github.com/dokku/smoke-test-app.git"
|
||||
echo "output: $output"
|
||||
echo "status: $status"
|
||||
assert_success
|
||||
assert_output_contains "Application deployed"
|
||||
}
|
||||
|
||||
@test "(git) git:sync new [--build branch]" {
|
||||
run /bin/bash -c "dokku git:sync --build $TEST_APP https://github.com/dokku/smoke-test-app.git another-branch"
|
||||
echo "output: $output"
|
||||
echo "status: $status"
|
||||
assert_success
|
||||
assert_output_contains "Application deployed"
|
||||
}
|
||||
|
||||
@test "(git) git:sync new [--build tag]" {
|
||||
run /bin/bash -c "dokku git:sync --build $TEST_APP https://github.com/dokku/smoke-test-app.git 1.0.0"
|
||||
echo "output: $output"
|
||||
echo "status: $status"
|
||||
assert_success
|
||||
assert_output_contains "Application deployed"
|
||||
}
|
||||
|
||||
@test "(git) git:sync new [--build commit]" {
|
||||
run /bin/bash -c "dokku git:sync --build $TEST_APP https://github.com/dokku/smoke-test-app.git 5c8a5e42bbd7fae98bd657fb17f41c6019b303f9"
|
||||
echo "output: $output"
|
||||
echo "status: $status"
|
||||
assert_success
|
||||
assert_output_contains "Application deployed"
|
||||
}
|
||||
|
||||
@test "(git) git:sync existing [errors]" {
|
||||
run /bin/bash -c "dokku git:sync"
|
||||
echo "output: $output"
|
||||
echo "status: $status"
|
||||
assert_failure
|
||||
|
||||
run /bin/bash -c "dokku git:sync $TEST_APP-non-existent"
|
||||
echo "output: $output"
|
||||
echo "status: $status"
|
||||
assert_failure
|
||||
|
||||
run create_app "$TEST_APP-non-existent"
|
||||
echo "output: $output"
|
||||
echo "status: $status"
|
||||
assert_success
|
||||
|
||||
run /bin/bash -c "dokku git:sync $TEST_APP-non-existent"
|
||||
echo "output: $output"
|
||||
echo "status: $status"
|
||||
assert_failure
|
||||
|
||||
run destroy_app 0 "$TEST_APP-non-existent"
|
||||
echo "output: $output"
|
||||
echo "status: $status"
|
||||
assert_success
|
||||
}
|
||||
|
||||
@test "(git) git:sync existing [--no-build noarg]" {
|
||||
run /bin/bash -c "dokku git:sync $TEST_APP https://github.com/dokku/smoke-test-app.git 1.0.0"
|
||||
echo "output: $output"
|
||||
echo "status: $status"
|
||||
assert_success
|
||||
|
||||
run /bin/bash -c "dokku git:sync $TEST_APP https://github.com/dokku/smoke-test-app.git"
|
||||
echo "output: $output"
|
||||
echo "status: $status"
|
||||
assert_success
|
||||
}
|
||||
|
||||
@test "(git) git:sync existing [--no-build branch]" {
|
||||
run /bin/bash -c "dokku git:sync $TEST_APP https://github.com/dokku/smoke-test-app.git 1.0.0"
|
||||
echo "output: $output"
|
||||
echo "status: $status"
|
||||
assert_success
|
||||
|
||||
run /bin/bash -c "dokku git:sync $TEST_APP https://github.com/dokku/smoke-test-app.git another-branch"
|
||||
echo "output: $output"
|
||||
echo "status: $status"
|
||||
assert_success
|
||||
}
|
||||
|
||||
@test "(git) git:sync existing [--no-build tag]" {
|
||||
run /bin/bash -c "dokku git:sync $TEST_APP https://github.com/dokku/smoke-test-app.git 1.0.0"
|
||||
echo "output: $output"
|
||||
echo "status: $status"
|
||||
assert_success
|
||||
|
||||
run /bin/bash -c "dokku git:sync $TEST_APP https://github.com/dokku/smoke-test-app.git 2.0.0"
|
||||
echo "output: $output"
|
||||
echo "status: $status"
|
||||
assert_success
|
||||
}
|
||||
|
||||
@test "(git) git:sync existing [--no-build commit]" {
|
||||
run /bin/bash -c "dokku git:sync $TEST_APP https://github.com/dokku/smoke-test-app.git 1.0.0"
|
||||
echo "output: $output"
|
||||
echo "status: $status"
|
||||
assert_success
|
||||
|
||||
run /bin/bash -c "dokku git:sync $TEST_APP https://github.com/dokku/smoke-test-app.git 5c8a5e42bbd7fae98bd657fb17f41c6019b303f9"
|
||||
echo "output: $output"
|
||||
echo "status: $status"
|
||||
assert_success
|
||||
}
|
||||
|
||||
@test "(git) git:sync existing [--build noarg]" {
|
||||
run /bin/bash -c "dokku git:sync $TEST_APP https://github.com/dokku/smoke-test-app.git 1.0.0"
|
||||
echo "output: $output"
|
||||
echo "status: $status"
|
||||
assert_success
|
||||
|
||||
run /bin/bash -c "dokku git:sync --build $TEST_APP https://github.com/dokku/smoke-test-app.git"
|
||||
echo "output: $output"
|
||||
echo "status: $status"
|
||||
assert_success
|
||||
assert_output_contains "Application deployed"
|
||||
}
|
||||
|
||||
@test "(git) git:sync existing [--build branch]" {
|
||||
run /bin/bash -c "dokku git:sync $TEST_APP https://github.com/dokku/smoke-test-app.git 2.0.0"
|
||||
echo "output: $output"
|
||||
echo "status: $status"
|
||||
assert_success
|
||||
|
||||
run /bin/bash -c "dokku git:sync --build $TEST_APP https://github.com/dokku/smoke-test-app.git another-branch"
|
||||
echo "output: $output"
|
||||
echo "status: $status"
|
||||
assert_success
|
||||
assert_output_contains "Application deployed"
|
||||
}
|
||||
|
||||
@test "(git) git:sync existing [--build tag]" {
|
||||
run /bin/bash -c "dokku git:sync $TEST_APP https://github.com/dokku/smoke-test-app.git 1.0.0"
|
||||
echo "output: $output"
|
||||
echo "status: $status"
|
||||
assert_success
|
||||
|
||||
run /bin/bash -c "dokku git:sync --build $TEST_APP https://github.com/dokku/smoke-test-app.git 2.0.0"
|
||||
echo "output: $output"
|
||||
echo "status: $status"
|
||||
assert_success
|
||||
assert_output_contains "Application deployed"
|
||||
}
|
||||
|
||||
@test "(git) git:sync existing [--build commit]" {
|
||||
run /bin/bash -c "dokku git:sync $TEST_APP https://github.com/dokku/smoke-test-app.git 1.0.0"
|
||||
echo "output: $output"
|
||||
echo "status: $status"
|
||||
assert_success
|
||||
|
||||
run /bin/bash -c "dokku git:sync --build $TEST_APP https://github.com/dokku/smoke-test-app.git 5c8a5e42bbd7fae98bd657fb17f41c6019b303f9"
|
||||
echo "output: $output"
|
||||
echo "status: $status"
|
||||
assert_success
|
||||
assert_output_contains "Application deployed"
|
||||
}
|
||||
|
||||
@test "(git) git:public-key" {
|
||||
run /bin/bash -c "dokku git:public-key"
|
||||
echo "output: $output"
|
||||
echo "status: $status"
|
||||
assert_failure
|
||||
|
||||
run /bin/bash -c "cp /root/.ssh/dokku_test_rsa.pub /home/dokku/.ssh/id_rsa.pub"
|
||||
echo "output: $output"
|
||||
echo "status: $status"
|
||||
assert_success
|
||||
|
||||
run /bin/bash -c "dokku git:public-key"
|
||||
echo "output: $output"
|
||||
echo "status: $status"
|
||||
assert_success
|
||||
}
|
||||
Reference in New Issue
Block a user