heroku_hatchet 8.0.1 → 8.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: f4233a137df7685f1e411471db8c53a72c9c6e77e5b9a901d0d8bb1c0147f06a
4
- data.tar.gz: ffd93abf69b7a46ccbdda5148710e237b9c41171abef209ea56f187d7a52c501
3
+ metadata.gz: c72d006f643f893a0347e7c7ce5fae2e128d4a94fea501d957afb6738cc9374f
4
+ data.tar.gz: a507cd401042cf6e245b63824b9cbb30b79aa56541bc604f2c92b54d23413cbd
5
5
  SHA512:
6
- metadata.gz: 61cc153424acbdf88c61b41ef9b4206fbb1e59c171ad30fded428d40bfe2edc728cdb2db72ca95526d1d5c5225d38eacacb6794b8c811b40988cac58480b0e74
7
- data.tar.gz: 615e586767703298020a5d2a0172b9793a681a7cc681f45e6c6e42082e9db8c4a32f6e647fb006d8e9b7d8618b6c0dace7df6109cbca20e5e7fe0c34f991ed62
6
+ metadata.gz: 6ba49829178ac76fe6a62faf32afbef57a828dc4fd390d50887f2b2c50f30a8359ad6f9639ad34b258a2594a885333e8a704b59f93e3bdf80cb87ce897f5a4c1
7
+ data.tar.gz: a54f637129f9b57f296f405e374082573b584b3c960bab387723f19f87bf8ee63562022a94ee08aa9e75bf3badffd63fdeec805897b71db30e15b74aaf5384c6
@@ -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,9 @@
1
1
  ## HEAD
2
2
 
3
+ ## 8.0.2
4
+
5
+ - Bugfix: Allow nested deploy blocks with new teardown logic (https://github.com/heroku/hatchet/pull/201)
6
+
3
7
  ## 8.0.1
4
8
 
5
9
  - Bugfix: Lock and sleep and refresh API when duplicate app deletion detected (https://github.com/heroku/hatchet/pull/198)
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.2"
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,33 +22,8 @@ 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)
@@ -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.2
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: 2023-03-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: platform-api
@@ -160,6 +160,7 @@ extra_rdoc_files: []
160
160
  files:
161
161
  - ".github/workflows/check_changelog.yml"
162
162
  - ".github/workflows/ci.yml"
163
+ - ".github/workflows/hatchet_app_cleaner.yml"
163
164
  - ".gitignore"
164
165
  - CHANGELOG.md
165
166
  - Gemfile
@@ -206,6 +207,7 @@ files:
206
207
  - spec/hatchet/local_repo_spec.rb
207
208
  - spec/hatchet/lock_spec.rb
208
209
  - spec/spec_helper.rb
210
+ - spec/unit/app_spec.rb
209
211
  - spec/unit/default_ci_branch_spec.rb
210
212
  - spec/unit/heroku_run_spec.rb
211
213
  - spec/unit/init_spec.rb
@@ -246,6 +248,7 @@ test_files:
246
248
  - spec/hatchet/local_repo_spec.rb
247
249
  - spec/hatchet/lock_spec.rb
248
250
  - spec/spec_helper.rb
251
+ - spec/unit/app_spec.rb
249
252
  - spec/unit/default_ci_branch_spec.rb
250
253
  - spec/unit/heroku_run_spec.rb
251
254
  - spec/unit/init_spec.rb