heroku_hatchet 8.0.1 → 8.0.3

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: f4233a137df7685f1e411471db8c53a72c9c6e77e5b9a901d0d8bb1c0147f06a
4
- data.tar.gz: ffd93abf69b7a46ccbdda5148710e237b9c41171abef209ea56f187d7a52c501
3
+ metadata.gz: 55e330ebf3f600cecc72f6d26e2b213548af020bf5865d073a52445198d15ab8
4
+ data.tar.gz: b77b96b88f4601c5fc419f0e3418373a162e6037ad63bad1b969a1169bfc58f6
5
5
  SHA512:
6
- metadata.gz: 61cc153424acbdf88c61b41ef9b4206fbb1e59c171ad30fded428d40bfe2edc728cdb2db72ca95526d1d5c5225d38eacacb6794b8c811b40988cac58480b0e74
7
- data.tar.gz: 615e586767703298020a5d2a0172b9793a681a7cc681f45e6c6e42082e9db8c4a32f6e647fb006d8e9b7d8618b6c0dace7df6109cbca20e5e7fe0c34f991ed62
6
+ metadata.gz: 48530f31d678cea882ba4e383bee510daccdd048632c8fc900f6633ff88feef46c12c676a8dca41bc2cbf641dc27854cafbfd09e6ace0ece1efc9bb55cc7db1c
7
+ data.tar.gz: aaaf6b0ababd386ed3f27f9679714bc53859d76da5ec902da16d026fa2e41c04621e61d5233f622f04a5c8e67bdcada1b4c4e3394012af3ad510105dc9801533
@@ -0,0 +1 @@
1
+ * @heroku/languages
@@ -14,7 +14,7 @@ jobs:
14
14
  strategy:
15
15
  fail-fast: false
16
16
  matrix:
17
- ruby-version: ["2.7", "3.0", "3.1"]
17
+ ruby-version: ["2.7", "3.0", "3.1", "3.2", "3.3"]
18
18
  runs-on: ubuntu-22.04
19
19
  env:
20
20
  HATCHET_APP_LIMIT: 100
@@ -0,0 +1,31 @@
1
+ name: Hatchet app cleaner
2
+
3
+ on:
4
+ schedule:
5
+ # Daily at 6am UTC.
6
+ - cron: "0 6 * * *"
7
+ # Allow the workflow to be manually triggered too.
8
+ workflow_dispatch:
9
+
10
+ permissions:
11
+ contents: read
12
+
13
+ jobs:
14
+ hatchet-app-cleaner:
15
+ runs-on: ubuntu-latest
16
+ env:
17
+ HEROKU_API_KEY: ${{ secrets.HEROKU_API_KEY }}
18
+ HEROKU_API_USER: ${{ secrets.HEROKU_API_USER }}
19
+ HEROKU_DISABLE_AUTOUPDATE: 1
20
+ steps:
21
+ - name: Checkout
22
+ uses: actions/checkout@v3
23
+ - name: Install Ruby and dependencies
24
+ uses: ruby/setup-ruby@v1
25
+ with:
26
+ bundler-cache: true
27
+ ruby-version: "3.1"
28
+ - name: Run Hatchet destroy
29
+ # Only apps older than 10 minutes are destroyed, to ensure that any
30
+ # in progress CI runs are not interrupted.
31
+ run: bundle exec hatchet destroy --older-than 10
data/CHANGELOG.md CHANGED
@@ -1,5 +1,13 @@
1
1
  ## HEAD
2
2
 
3
+ ## 8.0.3
4
+
5
+ - Add support for Ruby 3.2 and 3.3 (https://github.com/heroku/hatchet/pull/203 and https://github.com/heroku/hatchet/pull/208)
6
+
7
+ ## 8.0.2
8
+
9
+ - Bugfix: Allow nested deploy blocks with new teardown logic (https://github.com/heroku/hatchet/pull/201)
10
+
3
11
  ## 8.0.1
4
12
 
5
13
  - Bugfix: Lock and sleep and refresh API when duplicate app deletion detected (https://github.com/heroku/hatchet/pull/198)
data/etc/ci_setup.rb CHANGED
@@ -12,7 +12,7 @@ end
12
12
  puts "== Setting Up CI =="
13
13
 
14
14
  netrc_file = "#{ENV['HOME']}/.netrc"
15
- unless File.exists?(netrc_file)
15
+ unless File.exist?(netrc_file)
16
16
  File.open(netrc_file, 'w') do |file|
17
17
  file.write <<-EOF
18
18
  machine git.heroku.com
data/lib/hatchet/app.rb CHANGED
@@ -77,6 +77,7 @@ module Hatchet
77
77
  @buildpacks.map! {|b| b == :default ? self.class.default_buildpack : b}
78
78
  @run_multi = run_multi
79
79
  @max_retries_count = retries
80
+ @outer_deploy_block = nil
80
81
 
81
82
  if run_multi && !ENV["HATCHET_EXPENSIVE_MODE"]
82
83
  raise "You're attempting to enable `run_multi: true` mode, but have not enabled `HATCHET_EXPENSIVE_MODE=1` env var to verify you understand the risks"
@@ -424,13 +425,14 @@ module Hatchet
424
425
  def deploy(&block)
425
426
  in_directory do
426
427
  annotate_failures do
428
+ @outer_deploy_block ||= block # deploy! can be called multiple times. Only teardown once
427
429
  in_dir_setup!
428
- self.push_with_retry!
430
+ push_with_retry!
429
431
  block.call(self, api_rate_limit.call, output) if block_given?
430
432
  end
431
433
  end
432
434
  ensure
433
- self.teardown! if block_given?
435
+ self.teardown! if block_given? && @outer_deploy_block == block
434
436
  end
435
437
 
436
438
  def push
@@ -1,3 +1,3 @@
1
1
  module Hatchet
2
- VERSION = "8.0.1"
2
+ VERSION = "8.0.3"
3
3
  end
@@ -1,20 +1,6 @@
1
1
  require("spec_helper")
2
2
 
3
3
  describe "AppTest" do
4
- it "annotates rspec expectation failures" do
5
- app = Hatchet::Runner.new("default_ruby")
6
- error = nil
7
- begin
8
- app.annotate_failures do
9
- expect(true).to eq(false)
10
- end
11
- rescue RSpec::Expectations::ExpectationNotMetError => e
12
- error = e
13
- end
14
-
15
- expect(error.message).to include(app.name)
16
- end
17
-
18
4
  it "does not modify local files by mistake" do
19
5
  Dir.mktmpdir do |dir_1|
20
6
  app = Hatchet::Runner.new(dir_1)
@@ -29,7 +15,6 @@ describe "AppTest" do
29
15
  entries_array -= ["..", ".", "foo.txt"]
30
16
  expect(entries_array).to be_empty
31
17
 
32
-
33
18
  entries_array = Dir.entries(dir_1)
34
19
  entries_array -= ["..", ".", "foo.txt"]
35
20
  expect(entries_array).to be_empty
@@ -37,51 +22,13 @@ describe "AppTest" do
37
22
  end
38
23
  end
39
24
 
40
- it "calls reaper if cannot create an app" do
41
- app = Hatchet::App.new("default_ruby", buildpacks: [:default])
42
- def app.heroku_api_create_app(*args); raise StandardError.new("made you look"); end
43
-
44
- reaper = app.reaper
45
-
46
- def reaper.destroy_older_apps(*args, **kwargs, &block); @app_exception_message = true; end
47
- def reaper.clean_old_was_called?; @app_exception_message; end
48
-
49
- expect {
50
- app.create_app
51
- }.to raise_error("made you look")
52
-
53
- expect(reaper.clean_old_was_called?).to be_truthy
54
- end
55
-
56
- it "app with default" do
57
- app = Hatchet::App.new("default_ruby", buildpacks: [:default])
58
- expect(app.buildpacks.first).to match("https://github.com/heroku/heroku-buildpack-ruby")
59
- end
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
-
65
25
  it "create app with stack" do
66
- stack = "heroku-18"
26
+ stack = "heroku-20"
67
27
  app = Hatchet::App.new("default_ruby", stack: stack)
68
28
  app.create_app
69
29
  expect(app.platform_api.app.info(app.name)["build_stack"]["name"]).to eq(stack)
70
30
  end
71
31
 
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
-
85
32
  describe "before deploy" do
86
33
  it "dir" do
87
34
  @called = false
@@ -1,7 +1,7 @@
1
1
  require "spec_helper"
2
2
 
3
- describe "CIFourTest" do
4
- it "error with bad app" do
3
+ describe "CI" do
4
+ it "runs rakefile contents" do
5
5
  string = SecureRandom.hex
6
6
 
7
7
  app = Hatchet::GitApp.new("default_ruby")
@@ -17,47 +17,4 @@ describe "CIFourTest" do
17
17
  expect(test_run.output).to_not match("Installing rake")
18
18
  end
19
19
  end
20
-
21
- it "error with bad app" do
22
- pending("upgrade rails 5 app to newer")
23
-
24
- expect {
25
- Hatchet::GitApp.new("rails5_ci_fails_no_database", stack: "heroku-18").run_ci { }
26
- }.to raise_error(/PG::ConnectionBad: could not connect to server/)
27
- end
28
-
29
- it "error with bad app" do
30
- @before_deploy_called = false
31
- @before_deploy_dir_pwd = nil
32
-
33
- before_deploy = -> do
34
- @before_deploy_called = true
35
- @before_deploy_dir_pwd = Dir.pwd
36
- end
37
-
38
- Hatchet::GitApp.new("rails5_ci_fails_no_database", stack: "heroku-18", allow_failure: true, before_deploy: before_deploy).run_ci do |test_run|
39
- expect(test_run.status).to eq(:errored)
40
- expect(@before_deploy_dir_pwd).to eq(Dir.pwd)
41
- expect(@before_deploy_called).to be_truthy
42
- end
43
-
44
- expect(@before_deploy_dir_pwd).to_not eq(Dir.pwd)
45
- end
46
-
47
- it "ci create app with stack" do
48
- pending("upgrade rails 5 app to newer")
49
-
50
- app = Hatchet::GitApp.new("rails5_ruby_schema_format")
51
- app.run_ci do |test_run|
52
- expect(test_run.output).to match("Ruby buildpack tests completed successfully")
53
- expect(test_run.status).to eq(:succeeded)
54
- expect(app.pipeline_id).to_not be_nil
55
-
56
- api_rate_limit = app.api_rate_limit.call
57
- couplings = api_rate_limit.pipeline_coupling.list_by_pipeline(app.pipeline_id)
58
- coupled_app = api_rate_limit.app.info(couplings.first["app"]["id"])
59
- expect(coupled_app["name"]).to eq(app.name)
60
- end
61
- expect(app.pipeline_id).to be_nil
62
- end
63
20
  end
@@ -0,0 +1,65 @@
1
+ require "spec_helper"
2
+
3
+ # Tests in this file do not deploy to Heroku
4
+ describe "App unit tests" do
5
+ it "annotates rspec expectation failures" do
6
+ app = Hatchet::Runner.new("default_ruby")
7
+ error = nil
8
+ begin
9
+ app.annotate_failures do
10
+ expect(true).to eq(false)
11
+ end
12
+ rescue RSpec::Expectations::ExpectationNotMetError => e
13
+ error = e
14
+ end
15
+
16
+ expect(error.message).to include(app.name)
17
+ end
18
+
19
+ it "calls reaper if cannot create an app" do
20
+ app = Hatchet::App.new("default_ruby", buildpacks: [:default])
21
+ def app.heroku_api_create_app(*args); raise StandardError.new("made you look"); end
22
+
23
+ reaper = app.reaper
24
+
25
+ def reaper.destroy_older_apps(*args, **kwargs, &block); @app_exception_message = true; end
26
+ def reaper.clean_old_was_called?; @app_exception_message; end
27
+
28
+ expect {
29
+ app.create_app
30
+ }.to raise_error("made you look")
31
+
32
+ expect(reaper.clean_old_was_called?).to be_truthy
33
+ end
34
+
35
+ it "app with default" do
36
+ app = Hatchet::App.new("default_ruby", buildpacks: [:default])
37
+ expect(app.buildpacks.first).to match("https://github.com/heroku/heroku-buildpack-ruby")
38
+ end
39
+
40
+ it "default_buildpack is only computed once" do
41
+ expect(Hatchet::App.default_buildpack.object_id).to eq(Hatchet::App.default_buildpack.object_id)
42
+ end
43
+
44
+ it "nested deploy block only calls teardown once" do
45
+ @deploy = 0
46
+ app = Hatchet::App.new("default_ruby", buildpacks: [:default])
47
+ def app.in_dir_setup!; ;end # Don't create an app
48
+ def app.push_with_retry!; end # Don't try pushing to it
49
+ def app.teardown!; @teardown ||=0; @teardown += 1 end
50
+ def app.get_teardown_count; @teardown; end
51
+
52
+ app.deploy do |app|
53
+ @deploy += 1
54
+ app.deploy do |app|
55
+ @deploy += 1
56
+ end
57
+ app.deploy do |app|
58
+ @deploy += 1
59
+ end
60
+ end
61
+
62
+ expect(app.get_teardown_count).to eq(1)
63
+ expect(@deploy).to eq(3)
64
+ end
65
+ 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: 8.0.1
4
+ version: 8.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Richard Schneeman
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-03-01 00:00:00.000000000 Z
11
+ date: 2024-03-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: platform-api
@@ -158,8 +158,10 @@ executables:
158
158
  extensions: []
159
159
  extra_rdoc_files: []
160
160
  files:
161
+ - ".github/CODEOWNERS"
161
162
  - ".github/workflows/check_changelog.yml"
162
163
  - ".github/workflows/ci.yml"
164
+ - ".github/workflows/hatchet_app_cleaner.yml"
163
165
  - ".gitignore"
164
166
  - CHANGELOG.md
165
167
  - Gemfile
@@ -206,6 +208,7 @@ files:
206
208
  - spec/hatchet/local_repo_spec.rb
207
209
  - spec/hatchet/lock_spec.rb
208
210
  - spec/spec_helper.rb
211
+ - spec/unit/app_spec.rb
209
212
  - spec/unit/default_ci_branch_spec.rb
210
213
  - spec/unit/heroku_run_spec.rb
211
214
  - spec/unit/init_spec.rb
@@ -231,7 +234,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
231
234
  - !ruby/object:Gem::Version
232
235
  version: '0'
233
236
  requirements: []
234
- rubygems_version: 3.3.26
237
+ rubygems_version: 3.5.6
235
238
  signing_key:
236
239
  specification_version: 4
237
240
  summary: Hatchet is a an integration testing library for developing Heroku buildpacks.
@@ -246,6 +249,7 @@ test_files:
246
249
  - spec/hatchet/local_repo_spec.rb
247
250
  - spec/hatchet/lock_spec.rb
248
251
  - spec/spec_helper.rb
252
+ - spec/unit/app_spec.rb
249
253
  - spec/unit/default_ci_branch_spec.rb
250
254
  - spec/unit/heroku_run_spec.rb
251
255
  - spec/unit/init_spec.rb