Permalink
Browse files

Deploying to an annotated tag

Fixes #113, #117
  • Loading branch information...
1 parent a05ce39 commit bd4750edc50644a8e7895a5d9dd4e8d073fd9b4c Ken committed Jan 22, 2013
Showing with 60 additions and 30 deletions.
  1. +2 −1 cucumber.yml
  2. +22 −0 features/issue_113.feature
  3. +1 −1 features/remote.feature
  4. +30 −23 features/step_definitions/remote_steps.rb
  5. +1 −1 features/support/env.rb
  6. +1 −1 lib/git.rb
  7. +3 −3 spec/git_spec.rb
View
@@ -1,2 +1,3 @@
default: --tags ~@slow_process --no-source
-remote: --tags @slow_process --no-source
+remote: --tags @slow_process --tags ~@issue --no-source
+issues: --tags @issue --no-source
@@ -0,0 +1,22 @@
+@slow_process @announce-cmd @issue
+Feature: github issues
+ Given there are bugs
+ And everyone wants defect-free software
+ When the bugs are fixed
+ Then these tests should be green
+
+# https://github.com/fastestforward/heroku_san/issues/113
+# https://github.com/fastestforward/heroku_san/issues/117
+ Scenario: Deploying to an annotated tag fails with 'error: Trying to write non-commit object'
+ Given I have a new Rails project
+ When I am in the project directory
+ And I commit any changes with "Initial commit"
+ And I add heroku_san to the Gemfile
+ And I run bundle install
+ And I generate a new config file
+ And I create my project on Heroku
+ And I generate a scaffold
+ And I commit any changes with "Added droids"
+ And I tag the commit with "v1.0" annotated by "I am annotated"
+ And I deploy to tag "v1.0"
+ Then issue 113 has been fixed
@@ -5,7 +5,7 @@ Feature: heroku_san can control a project on Heroku
this test; otherwise it will probably hang the first
time it tries to do anything with Heroku itself.
- Scenario: Installing on a project
+ Scenario: Installs a project
Given I have a new Rails project
When I am in the project directory
And I add heroku_san to the Gemfile
@@ -47,6 +47,10 @@
run_clean "git commit -m '#{message}'"
end
+When /^I tag the commit with "([^"]*)" annotated by "([^"]*)"$/ do |tag, annotation|
+ run_clean "git tag -a '#{tag}' -m '#{annotation}' HEAD"
+end
+
When /^I add heroku_san to the Gemfile$/ do
append_to_file 'Gemfile', <<EOT.strip_heredoc
group :development, :test do
@@ -60,15 +64,15 @@ def run_clean(cmd)
ENV['NOEXEC_DISABLE'] = '1'
run_simple cmd
end
+ stdout_from cmd
end
When /^I run bundle install$/ do
run_clean "bundle install"
end
Then /^rake reports that the heroku: tasks are available$/ do
- run_clean 'rake -T heroku:'
- output = stdout_from 'rake -T heroku:'
+ output = run_clean 'rake -T heroku:'
assert_partial_output 'rake heroku:apps', output
end
@@ -80,17 +84,15 @@ def run_clean(cmd)
end
When /^I create a new config\/heroku\.yml file$/ do
- run_clean 'rake heroku:create_config'
- output = stdout_from 'rake heroku:create_config'
+ output = run_clean 'rake heroku:create_config'
assert_matching_output %q{Copied example config to ".*.config.heroku.yml"}, output
assert_matching_output %q{Please edit ".*.config.heroku.yml" with your application's settings.}, output
overwrite_simple_config_file
end
When /^I create my project on Heroku$/ do
cmd = 'rake test_app heroku:create'
- run_clean unescape(cmd)
- output = stdout_from cmd
+ output = run_clean unescape(cmd)
assert_matching_output %q{test_app: Created ([\w-]+)}, output
@app = output.match(/test_app: Created ([\w-]+)/)[1]
@@ -103,7 +105,7 @@ def run_clean(cmd)
end
When /^I curl the app home page$/ do
- Godot.match("#{@app}.herokuapp.com", 80, %r{<h1><strong>Heroku | Welcome to your new app!</strong></h1>}).should be, "Heroku didn't spin up a new app"
+ vladimir.match(%r{<h1><strong>Heroku | Welcome to your new app!</strong></h1>}).should be, "Heroku didn't spin up a new app"
end
When /^I configure my project$/ do
@@ -116,29 +118,25 @@ def run_clean(cmd)
EOT
cmd = 'rake test_app heroku:config'
- run_clean cmd
- output = stdout_from cmd
+ output = run_clean cmd
assert_partial_output 'DROIDS: marvin', output
end
When /^I turn maintenance on$/ do
- run_clean 'rake test_app heroku:maintenance_on'
- output = stdout_from 'rake test_app heroku:maintenance_on'
+ output = run_clean 'rake test_app heroku:maintenance_on'
assert_partial_output 'test_app: Maintenance mode enabled.', output
- Godot.match("#{@app}.herokuapp.com", 80, %r{<title>Offline for Maintenance</title>}).should be, "App is not offline"
+ vladimir.match(%r{<title>Offline for Maintenance</title>}).should be, "App is not offline"
end
When /^I turn maintenance off$/ do
- run_clean 'rake test_app heroku:maintenance_off'
- output = stdout_from 'rake test_app heroku:maintenance_off'
+ output = run_clean 'rake test_app heroku:maintenance_off'
assert_partial_output 'test_app: Maintenance mode disabled.', output
assert_app_is_running
end
When /^I restart my project$/ do
- run_clean 'rake test_app heroku:restart'
- output = stdout_from 'rake test_app heroku:restart'
+ output = run_clean 'rake test_app heroku:restart'
assert_partial_output 'test_app: Restarted.', output
assert_app_is_running
end
@@ -162,12 +160,16 @@ def run_clean(cmd)
assert_partial_output "http://#{@app}.herokuapp.com deployed to Heroku", all_output
end
+When /^I deploy to tag "([^"]*)"$/ do |tag|
+ run_clean "rake test_app deploy[#{tag}]"
+ assert_partial_output "http://#{@app}.herokuapp.com deployed to Heroku", all_output
+end
+
When /^I list all apps on Heroku$/ do
sha = in_current_dir do
`git rev-parse HEAD`.chomp
end
- run_clean 'rake heroku:apps'
- output = stdout_from 'rake heroku:apps'
+ output = run_clean 'rake heroku:apps'
assert_partial_output "test_app is shorthand for the Heroku app #{@app} located at:", output
assert_partial_output "git@heroku.com:#{@app}.git", output
assert_partial_output "@ #{sha} master", output
@@ -183,24 +185,29 @@ def run_clean(cmd)
END_CONFIG
- run_clean 'rake test_app heroku:addons'
- output = stdout_from 'rake test_app heroku:addons'
+ output = run_clean 'rake test_app heroku:addons'
# The output should show the new one ...
assert_partial_output "deployhooks:campfire", output
# ... with a note about needing to configure it.
assert_partial_output "https://api.heroku.com/myapps/#{@app}/addons/deployhooks:campfire", output
end
-Then /^heroku_san is green$/ do
+Then /^(?:heroku_san|issue \d+) (?:is green|has been fixed)$/ do
run_clean "heroku apps:destroy #{@app} --confirm #{@app}"
end
def assert_app_is_running
- vladimir = Godot.new("#{@app}.herokuapp.com", 80)
- vladimir.timeout = 30
vladimir.match(%r{<code>marvin</code>}, 'droids').should be, "http://#{@app}.herokuapp.com/droids are not the droids I'm looking for"
end
+def vladimir
+ @vladimir ||= begin
+ Godot.new("#{@app}.herokuapp.com", 80).tap do |vladimir|
+ vladimir.timeout = 60
+ end
+ end
+end
+
def overwrite_simple_config_file
overwrite_file 'config/heroku.yml', <<EOT.strip_heredoc
---
@@ -12,6 +12,6 @@
end
Before('@slow_process') do
- @aruba_timeout_seconds = 180
+ @aruba_timeout_seconds = 5 * 60
# @aruba_io_wait_seconds = 15
end
View
@@ -18,7 +18,7 @@ def git_push(commit, repo, options = [])
commit ||= "HEAD"
options ||= []
begin
- sh "git update-ref refs/heroku_san/deploy #{commit}"
+ sh "git update-ref refs/heroku_san/deploy #{commit}^{commit}"
sh "git push #{repo} #{options.join(' ')} refs/heroku_san/deploy:refs/heads/master"
ensure
sh "git update-ref -d refs/heroku_san/deploy"
View
@@ -6,21 +6,21 @@ class GitTest; include Git; end
describe GitTest do
describe "#git_push" do
it "pushes to heroku" do
- subject.should_receive(:sh).with("git update-ref refs/heroku_san/deploy HEAD")
+ subject.should_receive(:sh).with("git update-ref refs/heroku_san/deploy HEAD^{commit}")
subject.should_receive(:sh).with("git push git@heroku.com:awesomeapp.git refs/heroku_san/deploy:refs/heads/master")
subject.should_receive(:sh).with("git update-ref -d refs/heroku_san/deploy")
subject.git_push(nil, 'git@heroku.com:awesomeapp.git')
end
it "pushes a specific commit to heroku" do
- subject.should_receive(:sh).with("git update-ref refs/heroku_san/deploy kommit")
+ subject.should_receive(:sh).with("git update-ref refs/heroku_san/deploy kommit^{commit}")
subject.should_receive(:sh).with("git push git@heroku.com:awesomeapp.git refs/heroku_san/deploy:refs/heads/master")
subject.should_receive(:sh).with("git update-ref -d refs/heroku_san/deploy")
subject.git_push('kommit', 'git@heroku.com:awesomeapp.git')
end
it "includes options, too" do
- subject.should_receive(:sh).with("git update-ref refs/heroku_san/deploy HEAD")
+ subject.should_receive(:sh).with("git update-ref refs/heroku_san/deploy HEAD^{commit}")
subject.should_receive(:sh).with("git push git@heroku.com:awesomeapp.git --force -v refs/heroku_san/deploy:refs/heads/master")
subject.should_receive(:sh).with("git update-ref -d refs/heroku_san/deploy")
subject.git_push(nil, 'git@heroku.com:awesomeapp.git', %w[--force -v])

0 comments on commit bd4750e

Please sign in to comment.