heroku_hatchet 0.1.0 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 27c6dcf4b94d7ffa2ff13c22681fb82ce164743f
4
- data.tar.gz: a5184d0c3128783bb2b3eb8dbd7ba86e0197d57b
3
+ metadata.gz: bf055d51d17efef64a57f9d7cc5ba0efdfe29b3a
4
+ data.tar.gz: b51a1720cf9e6eebf7d0280ebca26efe68f431ac
5
5
  SHA512:
6
- metadata.gz: 12b6562ee9a6b76be96cba750285c8d7674452ff50ba6f07beeef0898ba941ec1a0124b0ec47235cdeb41b41bab44c4c5c08f7ea50030d8bf8cf1d714b7b6ab5
7
- data.tar.gz: 9f5efa38ed5b0d8a03e161ebab5acf0758b24f8c14cc2348b911eae83db68d4572d304e7014660b7860f2a36eaaa2e1759a4d18a911124221fd948b161ae473a
6
+ metadata.gz: 57a539206481a90f0118242f5af0587fd448abaf45dbcedf2fdf3be6e998d78d22feea5f80e7d7a5f4b652f167ea5467cfffdbbe6020e9b93686c1b1fa3c9000
7
+ data.tar.gz: 0af1e3c1a8c9a957d6dab4b987da269fef9a69c44adcebc647f4e8ee4965c184472c506ed0bb9e1516dc5ac33692d5335202d35f14bcef2d547ea361d3d19c91
data/.travis.yml CHANGED
@@ -8,6 +8,7 @@ script: bundle exec parallel_test test/hatchet -n 6
8
8
 
9
9
  env:
10
10
  global:
11
+ - HATCHET_RETRIES=3
11
12
  - secure: |-
12
13
  SfUgPagZILPjm4rjkYlEck76PUE47dimpNZgUtUf7wTAbe6EE83QmnRl6uDT
13
14
  eSdxuY9uNFoTwNLC0J+mRiDAJtAQxBsst8wFoc3diK2o8Ojnor5yd3cxddBv
data/CHANGELOG.md CHANGED
@@ -1,6 +1,10 @@
1
+ ## 0.1.1
2
+
3
+ - Allow auto retries of pushes by setting environment variable `HATCHET_RETRIES=3`
4
+
1
5
  ## 0.1.0
2
6
 
3
- - Failed deploys now raise an exception
7
+ - Failed deploys now raise an exception, to ignore set `allow_failure: true` in the `Hatchet::App`
4
8
 
5
9
  ## 0.0.2
6
10
 
data/README.md CHANGED
@@ -169,6 +169,9 @@ the command by going to the source code directory and running:
169
169
  $ ./bin/hatchet --help
170
170
 
171
171
 
172
+ ## Retries
173
+
174
+ Phantom errors happen. To auto retry deploy failures set the environment variable `HATCHET_RETRIES=3` which will auto retry deploys 3 times. By default deploys will not be retried. Once the number of retries has occurred the last exception will be raised.
172
175
 
173
176
  ## The Future
174
177
 
data/hatchet.gemspec CHANGED
@@ -20,11 +20,13 @@ Gem::Specification.new do |gem|
20
20
 
21
21
  gem.add_dependency "heroku-api"
22
22
  gem.add_dependency "activesupport"
23
+ gem.add_dependency "rrrretry"
23
24
  gem.add_dependency "anvil-cli"
24
25
  gem.add_dependency "excon"
25
26
  gem.add_dependency "thor"
26
27
 
27
28
  gem.add_development_dependency "rake"
29
+ gem.add_development_dependency "mocha"
28
30
  gem.add_development_dependency "parallel_tests"
29
31
  end
30
32
 
data/lib/hatchet/app.rb CHANGED
@@ -1,4 +1,5 @@
1
1
  module Hatchet
2
+ RETRIES = Integer(ENV['HATCHET_RETRIES'] || 1)
2
3
  class App
3
4
  attr_reader :name, :directory
4
5
 
@@ -72,16 +73,36 @@ module Hatchet
72
73
  # creates a new app on heroku, "pushes" via anvil or git
73
74
  # then yields to self so you can call self.run or
74
75
  # self.deployed?
76
+ # Allow deploy failures on CI server by setting ENV['HATCHET_RETRIES']
75
77
  def deploy(&block)
76
78
  Dir.chdir(directory) do
77
79
  self.setup!
78
- @output = self.push!
80
+ self.push_with_retry!
79
81
  block.call(self, heroku, output) if block.present?
80
82
  end
81
83
  ensure
82
84
  self.teardown!
83
85
  end
84
86
 
87
+
88
+ def push_with_retry!
89
+ RETRIES.times.retry do |attempt|
90
+ begin
91
+ @output = self.push!
92
+ rescue StandardError => error
93
+ puts retry_error_message(error, attempt)
94
+ raise error
95
+ end
96
+ end
97
+ end
98
+
99
+ def retry_error_message(error, attempt)
100
+ attempt += 1
101
+ return "" if attempt == RETRIES
102
+ msg = "\nRetrying failed Attempt ##{attempt}/#{RETRIES} to push for '#{name}' due to error: \n"<<
103
+ "#{error.class} #{error.message}\n #{error.backtrace.join("\n ")}"
104
+ end
105
+
85
106
  def output
86
107
  @output
87
108
  end
@@ -1,3 +1,3 @@
1
1
  module Hatchet
2
- VERSION = "0.1.0"
2
+ VERSION = "0.1.1"
3
3
  end
data/lib/hatchet.rb CHANGED
@@ -1,6 +1,7 @@
1
1
  require 'heroku/api'
2
2
  require 'anvil/engine'
3
3
  require 'active_support/core_ext/object/blank'
4
+ require 'rrrretry'
4
5
 
5
6
  require 'json'
6
7
  require 'stringio'
@@ -18,4 +18,15 @@ class AllowFailureAnvilTest < Test::Unit::TestCase
18
18
  Hatchet::AnvilApp.new("no_lockfile", buildpack: @buildpack_path).deploy
19
19
  end
20
20
  end
21
+
22
+ def test_retries
23
+ Hatchet::App.const_set(:RETRIES, 2)
24
+ assert_raise(Anvil::Builder::BuildError) do
25
+ app = Hatchet::AnvilApp.new("no_lockfile", buildpack: @buildpack_path)
26
+ app.expects(:push!).twice.raises(Anvil::Builder::BuildError)
27
+ app.deploy
28
+ end
29
+ ensure
30
+ Hatchet::App.const_set(:RETRIES, 1)
31
+ end
21
32
  end
@@ -1,8 +1,6 @@
1
1
  require 'test_helper'
2
2
 
3
3
  class AnvilTest < Test::Unit::TestCase
4
-
5
-
6
4
  def setup
7
5
  @buildpack_path = File.expand_path 'test/fixtures/buildpacks/heroku-buildpack-ruby'
8
6
  end
data/test/test_helper.rb CHANGED
@@ -3,6 +3,7 @@ Bundler.require
3
3
 
4
4
  require 'hatchet'
5
5
  require 'test/unit'
6
+ require "mocha/setup"
6
7
 
7
8
 
8
9
  def assert_tests_run
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: heroku_hatchet
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Richard Schneeman
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-05-22 00:00:00.000000000 Z
11
+ date: 2013-05-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: heroku-api
@@ -38,6 +38,20 @@ dependencies:
38
38
  - - '>='
39
39
  - !ruby/object:Gem::Version
40
40
  version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rrrretry
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - '>='
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - '>='
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
41
55
  - !ruby/object:Gem::Dependency
42
56
  name: anvil-cli
43
57
  requirement: !ruby/object:Gem::Requirement
@@ -94,6 +108,20 @@ dependencies:
94
108
  - - '>='
95
109
  - !ruby/object:Gem::Version
96
110
  version: '0'
111
+ - !ruby/object:Gem::Dependency
112
+ name: mocha
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - '>='
116
+ - !ruby/object:Gem::Version
117
+ version: '0'
118
+ type: :development
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - '>='
123
+ - !ruby/object:Gem::Version
124
+ version: '0'
97
125
  - !ruby/object:Gem::Dependency
98
126
  name: parallel_tests
99
127
  requirement: !ruby/object:Gem::Requirement