Skip to content

Commit cbc0190

Browse files
deployment lifecycle: deploy, halt on error
1 parent 5a8eba6 commit cbc0190

4 files changed

Lines changed: 24 additions & 3 deletions

File tree

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@
22

33
Versions before 2.0 were only available on internal repository, before open-sourcing the project.
44

5+
## 2.7
6+
7+
* deployment lifecycle: deploy, halt on error
8+
59
## 2.6
610

711
* helpers: aws_cf_distribution

test/fake/lib/ecs-deploy

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,8 @@
22

33
source "${BASH_SOURCE%/*}/../common"
44

5-
fake_log_in "$( basename "$0" ) $@"
5+
fake_log_in "$( basename "$0" ) $@"
6+
[[ ! -z "$YOKE_FAKES_ECSDEPLOY_EXIT" ]] && exit $YOKE_FAKES_ECSDEPLOY_EXIT
7+
8+
# success
9+
exit 0

test/unit/deployment.bats

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ last_execution_output() {
164164
assert_equal "$family" "Hello"
165165
}
166166

167-
@test 'lifecycle - post-deploy' {
167+
@test 'lifecycle - post-deploy executed on success' {
168168
run ./yoke install -c any -s any -t 12345 -w test/deployments/lifecycle_post_deploy
169169
assert_equal $status 0 || fail "${lines[@]}"
170170

@@ -173,6 +173,15 @@ last_execution_output() {
173173
[[ $output =~ $expected ]] || fail "not matching. expected: \"$expected\", actual: \"$output\""
174174
}
175175

176+
@test 'lifecycle - post-deploy skipped on failure' {
177+
YOKE_FAKES_ECSDEPLOY_EXIT=55 run ./yoke install -c any -s any -t 12345 -w test/deployments/lifecycle_post_deploy
178+
assert_equal $status 55 || fail "${lines[@]}"
179+
180+
local unexpected='On post-deploy'
181+
local output=$( last_execution_output )
182+
[[ ! $output =~ $unexpected ]] || fail "unexpected: \"$unexpected\", actual: \"$output\""
183+
}
184+
176185
@test 'lifecycle - post-deploy, with ECS environment variables' {
177186
run ./yoke install -c my-cluster -s my-service -t 12345 -w test/deployments/lifecycle_post_deploy
178187
assert_equal $status 0 || fail "${lines[@]}"

yoke

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -182,6 +182,11 @@ function do_deploy() {
182182

183183
[[ "$DEBUG" != "false" ]] && log "[deploy] executing (${#command_line[@]} params): ecs-deploy ${command_line[@]}"
184184
ecs-deploy ${command_line[@]}
185+
186+
local ecs_deploy_result=$?
187+
[[ $ecs_deploy_result -eq 0 ]] || {
188+
echo "Could not deploy"; exit $ecs_deploy_result;
189+
}
185190
}
186191

187192
# skip when sourcing the script
@@ -253,6 +258,5 @@ if [ "$0" = "$BASH_SOURCE" ] ; then
253258

254259
do_initialize
255260
do_deploy
256-
257261
on_post_deploy
258262
fi

0 commit comments

Comments
 (0)