feat: flesh out git plugin further

- add `report` and `set` subcommands to the git plugin
- move configuring the DOKKU_DEPLOY_BRANCH to the git plugin
- implement configurable GIT_REV support
- migrate DOKKU_DEPLOY_BRANCH settings
- add a golang-compatible, shell based method of setting plugin configuration variables

Deprecates the community dokku-git-rev plugin.

Closes #2621
Refs dokku-community/dokku-git-rev#9
This commit is contained in:
Jose Diaz-Gonzalez
2018-03-11 20:03:11 -04:00
parent 776226d0d8
commit d67e883e13
14 changed files with 425 additions and 71 deletions

89
tests/unit/10_git.bats Normal file
View File

@@ -0,0 +1,89 @@
#!/usr/bin/env bats
load test_helper
setup() {
global_setup
create_app
}
teardown() {
destroy_app
global_teardown
}
@test "(git) deploy specific branch" {
run bash -c "dokku git:set --global deploy-branch global-branch"
echo "output: "$output
echo "status: "$status
assert_success
GIT_REMOTE_BRANCH=global-branch deploy_app
echo "output: "$output
echo "status: "$status
assert_success
run bash -c "dokku ps:rebuild $TEST_APP"
echo "output: "$output
echo "status: "$status
assert_success
run bash -c "dokku git:set $TEST_APP deploy-branch app-branch"
GIT_REMOTE_BRANCH=app-branch deploy_app
echo "output: "$output
echo "status: "$status
assert_success
run bash -c "dokku ps:rebuild $TEST_APP"
echo "output: "$output
echo "status: "$status
assert_success
run bash -c "dokku git:set --global deploy-branch"
}
@test "(git) ensure GIT_REV env var is set" {
deploy_app
echo "output: "$output
echo "status: "$status
assert_success
run bash -c "dokku config:get $TEST_APP GIT_REV"
echo "output: "$output
echo "status: "$status
assert_output_exists
}
@test "(git) disable GIT_REV" {
run bash -c "dokku git:set $TEST_APP rev-env-var"
echo "output: "$output
echo "status: "$status
assert_success
deploy_app
echo "output: "$output
echo "status: "$status
assert_success
run bash -c "dokku config:get $TEST_APP GIT_REV"
echo "output: "$output
echo "status: "$status
assert_output_empty
}
@test "(git) customize the GIT_REV environment variable" {
run bash -c "dokku git:set $TEST_APP rev-env-var GIT_REV_ALT"
echo "output: "$output
echo "status: "$status
assert_success
deploy_app
echo "output: "$output
echo "status: "$status
assert_success
run bash -c "dokku config:get $TEST_APP GIT_REV_ALT"
echo "output: "$output
echo "status: "$status
assert_output_exists
}

View File

@@ -145,27 +145,3 @@ teardown() {
echo "status: "$status
assert_success
}
@test "(config) deploy specific DOKKU_DEPLOY_BRANCH" {
run ssh dokku@dokku.me config:set --global DOKKU_DEPLOY_BRANCH=global-branch
GIT_REMOTE_BRANCH=global-branch deploy_app
echo "output: "$output
echo "status: "$status
assert_success
run ssh dokku@dokku.me ps:rebuild $TEST_APP
echo "output: "$output
echo "status: "$status
assert_success
run ssh dokku@dokku.me config:set $TEST_APP DOKKU_DEPLOY_BRANCH=app-branch
GIT_REMOTE_BRANCH=app-branch deploy_app
echo "output: "$output
echo "status: "$status
assert_success
run ssh dokku@dokku.me ps:rebuild $TEST_APP
echo "output: "$output
echo "status: "$status
assert_success
}

View File

@@ -71,6 +71,18 @@ assert_output() {
assert_equal "$expected" "$output"
}
# ShellCheck doesn't know about $output from Bats
# shellcheck disable=SC2154
assert_output_exists() {
[[ -n "$output" ]] || flunk "expected output, found none"
}
# ShellCheck doesn't know about $output from Bats
# shellcheck disable=SC2154
assert_output_empty() {
[[ -z "$output" ]] || flunk "expected no output, found $output"
}
# ShellCheck doesn't know about $output from Bats
# shellcheck disable=SC2154
assert_output_contains() {