Skip to content
This repository has been archived by the owner on Jun 8, 2019. It is now read-only.

Commit

Permalink
Heroku removes the deploy branch if the deploy fails
Browse files Browse the repository at this point in the history
  • Loading branch information
bryan-ash committed Oct 14, 2011
1 parent 3729169 commit ae06473
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 27 deletions.
16 changes: 3 additions & 13 deletions lib/kumade/deployer.rb
Expand Up @@ -14,16 +14,9 @@ def initialize
end

def deploy
begin
heroku.pre_deploy
pre_deploy
heroku.deploy
rescue Kumade::DeploymentError
raise
rescue
ensure
post_deploy
end
heroku.pre_deploy
pre_deploy
heroku.deploy
end

def pre_deploy
Expand All @@ -40,9 +33,6 @@ def sync_origin
git.push(@branch)
end

def post_deploy
end

def ensure_clean_git
git.ensure_clean_git
end
Expand Down
12 changes: 9 additions & 3 deletions lib/kumade/heroku.rb
Expand Up @@ -16,9 +16,15 @@ def pre_deploy
end

def deploy
sync
migrate_database
post_deploy
begin
sync
migrate_database
rescue Kumade::DeploymentError
raise
rescue
ensure
post_deploy
end
end

def post_deploy
Expand Down
15 changes: 4 additions & 11 deletions spec/kumade/deployer_spec.rb
Expand Up @@ -17,15 +17,6 @@
subject.heroku.expects(:pre_deploy)
subject.expects(:pre_deploy)
subject.heroku.expects(:deploy)
subject.expects(:post_deploy)

subject.deploy
end

it "calls post_deploy if deploy fails" do
subject.heroku.stubs(:ensure_heroku_remote_exists).raises(RuntimeError)

subject.expects(:post_deploy)

subject.deploy
end
Expand Down Expand Up @@ -53,11 +44,13 @@
end

describe Kumade::Deployer, "packaging" do
let(:git) { stub("git", :current_branch => "awesome", :delete => true) }
let(:packager) { stub("packager", :run => true) }
let(:git) { stub_everything("git") }
let(:heroku) { stub_everything("heroku") }
let(:packager) { stub_everything("packager") }

before do
Kumade::Git.stubs(:new => git)
Kumade::Heroku.stubs(:new => heroku)
Kumade::Packager.stubs(:new => packager)
end

Expand Down
13 changes: 13 additions & 0 deletions spec/kumade/heroku_spec.rb
Expand Up @@ -20,6 +20,19 @@
subject.expects(:post_deploy)
subject.deploy
end

it "calls post_deploy if the deploy fails" do
subject.stubs(:sync).raises(RuntimeError)
subject.expects(:post_deploy)
subject.deploy
end

it "reraises Kumade::DeploymentError's" do
subject.stubs(:sync).raises(Kumade::DeploymentError)
subject.expects(:post_deploy)

expect { subject.deploy }.to raise_error(Kumade::DeploymentError)
end
end

describe Kumade::Heroku, "#post_deploy" do
Expand Down

0 comments on commit ae06473

Please sign in to comment.