heroku_hatchet 7.3.3 → 7.3.4

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
  SHA256:
3
- metadata.gz: 38e2cd43133aeb405a133834284c026c0e4a1347e33f84e805ed7b9fd2674fc9
4
- data.tar.gz: b1f88b0a62250a4cb2d9e22a89fe101356c5360aa37d786a51faebb2fac23824
3
+ metadata.gz: a45ee1ab2021838074b4f288d70aab769a71961cbae7cd12af67866e5558bb64
4
+ data.tar.gz: 0c99b826bfc797632924e151b796590f1ddbd07ff50e9eea2dc816b9991fb69d
5
5
  SHA512:
6
- metadata.gz: b36428d7f0e5288ac434d3fa66c3bf70b067742f4e150ebc4208d2e1e9b23761c7fd94cee0c8713909e07c63845014b7b139dd86f82d0118a53978b0033a83f7
7
- data.tar.gz: 3250c42cdd66bfbcfc4b129a0cf4083b30b94308614bf5ae4c765ced438522e814a6205dde298b51132eb6057581329054fde9d7bbd49208dda2d9cf89bd3e8d
6
+ metadata.gz: 940afbe59938c35c5bee92ac43dabe66e0e68f7cefbc35b662667eaecec343f04cc83e93418e7302a47ce2f955b2d7269073e167614a475dc91d69e6bee94d82
7
+ data.tar.gz: 204098d3744d64717141ca4d8f754324e761981b3d2d3bc9710e3b18e5532c97a1028813e1d7e2d295d35fb36e1b09ab78761a370af6490849de991ca50045ce
data/CHANGELOG.md CHANGED
@@ -1,5 +1,15 @@
1
1
  ## HEAD
2
2
 
3
+ ## 7.3.4
4
+
5
+ - Memoize `Hatchet::App.default_buildpack` (https://github.com/heroku/hatchet/pull/183)
6
+ - Fix repository path lookup when custom Hatchet directory set (https://github.com/heroku/hatchet/issues/181)
7
+ - Handle additional variations of rate limit error messages (https://github.com/heroku/hatchet/pull/182)
8
+ - Add `HATCHET_DEFAULT_STACK` for configuring the default stack (https://github.com/heroku/hatchet/pull/184)
9
+ - Fix typo in the reaper `"Duplicate destroy attempted"` message (https://github.com/heroku/hatchet/pull/175)
10
+ - Set `init.defaultBranch` in ci:setup to suppress `git init` warning in Git 2.30+ (https://github.com/heroku/hatchet/issues/172)
11
+ - Switch `heroku ci:install_heroku` to the Heroku CLI standalone installer rather than the APT install method (https://github.com/heroku/hatchet/issues/171)
12
+
3
13
  ## 7.3.3
4
14
 
5
15
  - Quiet personal tokens (https://github.com/heroku/hatchet/pull/148)
@@ -344,7 +354,6 @@
344
354
 
345
355
  after_script: bundle exec rake hatchet:teardown_travis
346
356
 
347
-
348
357
  ## 0.1.1
349
358
 
350
359
  - Allow auto retries of pushes by setting environment variable `HATCHET_RETRIES=3`
data/README.md CHANGED
@@ -504,7 +504,7 @@ The `Hatchet::Runner.new` takes several arguments.
504
504
 
505
505
  ### Init options
506
506
 
507
- - stack (String): The stack you want to deploy to on Heroku.
507
+ - stack (String): The Heroku [stack](https://devcenter.heroku.com/articles/stack) to use for the app. If this is not set, the stack will be determined from `HATCHET_DEFAULT_STACK`, or else the Heroku platform's [default stack](https://devcenter.heroku.com/articles/stack#default-stack).
508
508
 
509
509
  ```ruby
510
510
  Hatchet::Runner.new("default_ruby", stack: "heroku-16").deploy do |app|
@@ -598,6 +598,7 @@ app.get_config("DEPLOY_TASKS") # => "run:bloop"
598
598
 
599
599
  - `app.set_lab()`: Enables the specified lab/feature on the app
600
600
  - `app.add_database()`: adds a database to the app, defaults to the "dev" database
601
+ - `app.update_stack()`: Change the app's stack to that specified (for example `"heroku-20"`). Will take effect on the next build.
601
602
  - `app.run()`: Runs a `heroku run bash` session with the arguments, covered above.
602
603
  - `app.run_multi()`: Runs a `heroku run bash` session in the background and yields the results. This requires the `run_multi` flag of the app to be set to `true`, which will charge your application (the `HATCHET_EXPENSIVE_MODE` env var must also be set to use this feature). Example above.
603
604
  - `app.create_app`: Can be used to manually create the app without deploying it (You probably want `setup!` though)
@@ -727,6 +728,7 @@ HATCHET_ALIVE_TTL_MINUTES=7
727
728
  - `HATCHET_APP_LIMIT`: The maximum number of **hatchet** apps that Hatchet will allow in the given account before running the reaper. For local execution, keep this low as you don't want your account dominated by hatchet apps. For CI, you want it to be much larger, 80-100 since it's not competing with non-hatchet apps. Your test runner account needs to be a dedicated account.
728
729
  - `HEROKU_API_KEY`: The API key of your test account user. If you run locally without this set, it will use your personal credentials.
729
730
  - `HEROKU_API_USER`: The email address of your user account. If you run locally without this set, it will use your personal credentials.
731
+ - `HATCHET_DEFAULT_STACK`: The default Heroku stack to be used when an explicit `stack` is not passed to `App.new`. If this is not set, apps will instead use Heroku platform's [default stack](https://devcenter.heroku.com/articles/stack#default-stack).
730
732
  - `HATCHET_RUN_MULTI`: If enabled, this will scale up deployed apps to "standard-1x" once deployed instead of running on the free tier. This enables the `run_multi` method capability, however scaling up is not free. WARNING: Setting this env var will incur charges to your Heroku account. We recommended never to enable this setting unless you work for Heroku. To use this you must also set `HATCHET_EXPENSIVE_MODE=1`
731
733
  - `HATCHET_EXPENSIVE_MODE`: This is intended to be a "safety" environment variable. If it is not set, Hatchet will prevent you from using the `run_multi: true` setting or the `HATCHET_RUN_MULTI` environment variables. There are still ways to incur charges without this feature, but unless you're absolutely confident your test setup will not leave "orphan" apps that are billing you, do not enable this setting. Even then, only set this value if you work for Heroku. To recap WARNING: setting this is expensive.
732
734
 
data/etc/ci_setup.rb CHANGED
@@ -30,6 +30,8 @@ run_cmd "bundle exec hatchet ci:install_heroku"
30
30
  run_cmd "bundle exec hatchet install"
31
31
  run_cmd "git config --get user.email > /dev/null || git config --global user.email #{ENV.fetch('HEROKU_API_USER').shellescape}"
32
32
  run_cmd "git config --get user.name > /dev/null || git config --global user.name 'BuildpackTester'"
33
+ # Suppress the `git init` warning in Git 2.30+ when no default branch name is set.
34
+ run_cmd "git config --global init.defaultBranch main"
33
35
 
34
36
  puts "== Done =="
35
37
 
data/etc/setup_heroku.sh CHANGED
@@ -1,4 +1,4 @@
1
1
  #!/usr/bin/env bash
2
2
 
3
3
  set -euo pipefail
4
- curl --fail --retry 3 --retry-delay 1 --connect-timeout 3 --max-time 30 https://cli-assets.heroku.com/install-ubuntu.sh | sh
4
+ curl --fail --retry 3 --retry-delay 1 --connect-timeout 3 --max-time 30 https://cli-assets.heroku.com/install.sh | sh
data/lib/hatchet/app.rb CHANGED
@@ -49,7 +49,7 @@ module Hatchet
49
49
  DEFAULT_REPO_NAME = Object.new
50
50
 
51
51
  def initialize(repo_name = DEFAULT_REPO_NAME,
52
- stack: "",
52
+ stack: ENV["HATCHET_DEFAULT_STACK"],
53
53
  name: default_name,
54
54
  debug: nil,
55
55
  debugging: nil,
@@ -112,8 +112,9 @@ module Hatchet
112
112
  @directory
113
113
  end
114
114
 
115
+ @default_buildpack = nil
115
116
  def self.default_buildpack
116
- [HATCHET_BUILDPACK_BASE.call, HATCHET_BUILDPACK_BRANCH.call].join("#")
117
+ @default_buildpack ||= [HATCHET_BUILDPACK_BASE.call, HATCHET_BUILDPACK_BRANCH.call].join("#")
117
118
  end
118
119
 
119
120
  def allow_failure?
@@ -44,7 +44,7 @@ module Hatchet
44
44
 
45
45
  # use this method to turn "codetriage" into repos/rails3/codetriage
46
46
  def path_for_name(name)
47
- possible_paths = [repos[name.to_s], "repos/#{name}", name].compact
47
+ possible_paths = [repos[name.to_s], "#{repo_directory_path}/#{name}", name].compact
48
48
  path = possible_paths.detect do |path|
49
49
  !(Dir[path] && Dir[path].empty?)
50
50
  end
@@ -13,7 +13,7 @@ module Hatchet
13
13
  output = git_push_heroku_yall
14
14
  rescue FailedDeploy => e
15
15
  case e.output
16
- when /reached the API rate limit/, /429 Too Many Requests/
16
+ when /reached the API rate limit/, /429 Too Many Requests/, /HTTP 429/, /HTTP code = 429/
17
17
  throw(:throttle)
18
18
  else
19
19
  raise e unless @allow_failure
@@ -170,14 +170,14 @@ module Hatchet
170
170
  body = e.response.body
171
171
  request_id = e.response.headers["Request-Id"]
172
172
  if body =~ /Couldn\'t find that app./
173
- io.puts "Duplicate destoy attempted #{name.inspect}: #{id}, status: 404, request_id: #{request_id}"
173
+ io.puts "Duplicate destroy attempted #{name.inspect}: #{id}, status: 404, request_id: #{request_id}"
174
174
  raise AlreadyDeletedError.new
175
175
  else
176
176
  raise e
177
177
  end
178
178
  rescue Excon::Error::Forbidden => e
179
179
  request_id = e.response.headers["Request-Id"]
180
- io.puts "Duplicate destoy attempted #{name.inspect}: #{id}, status: 403, request_id: #{request_id}"
180
+ io.puts "Duplicate destroy attempted #{name.inspect}: #{id}, status: 403, request_id: #{request_id}"
181
181
  raise AlreadyDeletedError.new
182
182
  end
183
183
 
@@ -1,4 +1,4 @@
1
- version: 1
1
+ version: 2
2
2
  updates:
3
3
  - package-ecosystem: "bundler"
4
4
  directory: "/"
@@ -1,3 +1,3 @@
1
1
  module Hatchet
2
- VERSION = "7.3.3"
2
+ VERSION = "7.3.4"
3
3
  end
@@ -58,6 +58,10 @@ describe "AppTest" do
58
58
  expect(app.buildpacks.first).to match("https://github.com/heroku/heroku-buildpack-ruby")
59
59
  end
60
60
 
61
+ it "default_buildpack is only computed once" do
62
+ expect(Hatchet::App.default_buildpack.object_id).to eq(Hatchet::App.default_buildpack.object_id)
63
+ end
64
+
61
65
  it "create app with stack" do
62
66
  stack = "heroku-16"
63
67
  app = Hatchet::App.new("default_ruby", stack: stack)
@@ -65,6 +69,19 @@ describe "AppTest" do
65
69
  expect(app.platform_api.app.info(app.name)["build_stack"]["name"]).to eq(stack)
66
70
  end
67
71
 
72
+ it "create app with HATCHET_DEFAULT_STACK set" do
73
+ begin
74
+ original_default_stack = ENV["HATCHET_DEFAULT_STACK"]
75
+ default_stack = "heroku-18"
76
+ ENV["HATCHET_DEFAULT_STACK"] = default_stack
77
+ app = Hatchet::App.new("default_ruby")
78
+ app.create_app
79
+ expect(app.platform_api.app.info(app.name)["build_stack"]["name"]).to eq(default_stack)
80
+ ensure
81
+ ENV["HATCHET_DEFAULT_STACK"] = original_default_stack
82
+ end
83
+ end
84
+
68
85
  it "marks itself 'finished' when done in block mode" do
69
86
  app = Hatchet::Runner.new("default_ruby")
70
87
 
@@ -28,7 +28,7 @@ describe "CIFourTest" do
28
28
 
29
29
  it "error with bad app" do
30
30
  expect {
31
- Hatchet::GitApp.new("rails5_ci_fails_no_database").run_ci { }
31
+ Hatchet::GitApp.new("rails5_ci_fails_no_database", stack: "heroku-18").run_ci { }
32
32
  }.to raise_error(/PG::ConnectionBad: could not connect to server/)
33
33
  end
34
34
 
@@ -41,7 +41,7 @@ describe "CIFourTest" do
41
41
  @before_deploy_dir_pwd = Dir.pwd
42
42
  end
43
43
 
44
- Hatchet::GitApp.new("rails5_ci_fails_no_database", allow_failure: true, before_deploy: before_deploy).run_ci do |test_run|
44
+ Hatchet::GitApp.new("rails5_ci_fails_no_database", stack: "heroku-18", allow_failure: true, before_deploy: before_deploy).run_ci do |test_run|
45
45
  expect(test_run.status).to eq(:errored)
46
46
  expect(@before_deploy_dir_pwd).to eq(Dir.pwd)
47
47
  expect(@before_deploy_called).to be_truthy
@@ -6,6 +6,10 @@ describe "ConfigTest" do
6
6
  expect(@config.path_for_name("rails3_mri_193")).to(eq("repo_fixtures/repos/rails3/rails3_mri_193"))
7
7
  end
8
8
 
9
+ it("config path for name with full repo name") do
10
+ expect(@config.path_for_name("rails3/rails3_mri_193")).to(eq("repo_fixtures/repos/rails3/rails3_mri_193"))
11
+ end
12
+
9
13
  it("config dirs") do
10
14
  { "repo_fixtures/repos/bundler/no_lockfile" => "https://github.com/sharpstone/no_lockfile.git", "repo_fixtures/repos/default/default_ruby" => "https://github.com/sharpstone/default_ruby.git", "repo_fixtures/repos/rails2/rails2blog" => "https://github.com/sharpstone/rails2blog.git", "repo_fixtures/repos/rails3/rails3_mri_193" => "https://github.com/sharpstone/rails3_mri_193.git" }.each do |key, value|
11
15
  assert_include(key, value, @config.dirs)
@@ -43,7 +43,7 @@ describe "ShellThrottle" do
43
43
  end
44
44
 
45
45
  describe "git push throttle" do
46
- it "rate throttles `git push` " do
46
+ it "rate throttles `git push` with output variation 1" do
47
47
  app = Hatchet::GitApp.new("default_ruby")
48
48
  def app.git_push_heroku_yall
49
49
  @_git_push_heroku_yall_call_count ||= 0
@@ -67,7 +67,7 @@ describe "ShellThrottle" do
67
67
  expect(app.what_is_git_push_heroku_yall_call_count).to be(2)
68
68
  end
69
69
 
70
- it "rate throttles `git push` with different output" do
70
+ it "rate throttles `git push` with output variation 2" do
71
71
  app = Hatchet::GitApp.new("default_ruby")
72
72
  def app.git_push_heroku_yall
73
73
  @_git_push_heroku_yall_call_count ||= 0
@@ -90,5 +90,53 @@ describe "ShellThrottle" do
90
90
 
91
91
  expect(app.what_is_git_push_heroku_yall_call_count).to be(2)
92
92
  end
93
+
94
+ it "rate throttles `git push` with output variation 3" do
95
+ app = Hatchet::GitApp.new("default_ruby")
96
+ def app.git_push_heroku_yall
97
+ @_git_push_heroku_yall_call_count ||= 0
98
+ @_git_push_heroku_yall_call_count += 1
99
+ if @_git_push_heroku_yall_call_count >= 2
100
+ "Success"
101
+ else
102
+ raise Hatchet::App::FailedDeployError.new(
103
+ self,
104
+ "message",
105
+ output: "error: RPC failed; HTTP 429 curl 22 The requested URL returned error: 429"
106
+ )
107
+ end
108
+ end
109
+
110
+ def app.sleep_called?; @sleep_called; end
111
+ def app.what_is_git_push_heroku_yall_call_count; @_git_push_heroku_yall_call_count; end
112
+
113
+ app.push_without_retry!
114
+
115
+ expect(app.what_is_git_push_heroku_yall_call_count).to be(2)
116
+ end
117
+
118
+ it "rate throttles `git push` with output variation 4" do
119
+ app = Hatchet::GitApp.new("default_ruby")
120
+ def app.git_push_heroku_yall
121
+ @_git_push_heroku_yall_call_count ||= 0
122
+ @_git_push_heroku_yall_call_count += 1
123
+ if @_git_push_heroku_yall_call_count >= 2
124
+ "Success"
125
+ else
126
+ raise Hatchet::App::FailedDeployError.new(
127
+ self,
128
+ "message",
129
+ output: "error: RPC failed; result=22, HTTP code = 429"
130
+ )
131
+ end
132
+ end
133
+
134
+ def app.sleep_called?; @sleep_called; end
135
+ def app.what_is_git_push_heroku_yall_call_count; @_git_push_heroku_yall_call_count; end
136
+
137
+ app.push_without_retry!
138
+
139
+ expect(app.what_is_git_push_heroku_yall_call_count).to be(2)
140
+ end
93
141
  end
94
142
  end
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: 7.3.3
4
+ version: 7.3.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Richard Schneeman
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-10-16 00:00:00.000000000 Z
11
+ date: 2021-02-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: platform-api
@@ -230,7 +230,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
230
230
  - !ruby/object:Gem::Version
231
231
  version: '0'
232
232
  requirements: []
233
- rubygems_version: 3.1.4
233
+ rubygems_version: 3.2.3
234
234
  signing_key:
235
235
  specification_version: 4
236
236
  summary: Hatchet is a an integration testing library for developing Heroku buildpacks.