heroku_hatchet 5.0.3 → 6.0.0

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.
Files changed (44) hide show
  1. checksums.yaml +4 -4
  2. data/.circleci/config.yml +19 -1
  3. data/.gitignore +2 -0
  4. data/CHANGELOG.md +4 -0
  5. data/etc/ci_setup.rb +16 -12
  6. data/etc/setup_heroku.sh +0 -2
  7. data/hatchet.gemspec +4 -5
  8. data/hatchet.json +1 -1
  9. data/hatchet.lock +9 -9
  10. data/lib/hatchet/api_rate_limit.rb +7 -7
  11. data/lib/hatchet/test_run.rb +15 -9
  12. data/lib/hatchet/version.rb +1 -1
  13. data/{test → repo_fixtures}/different-folder-for-checked-in-repos/default_ruby/Gemfile +0 -0
  14. data/spec/hatchet/allow_failure_git_spec.rb +15 -0
  15. data/spec/hatchet/app_spec.rb +87 -0
  16. data/spec/hatchet/ci_spec.rb +58 -0
  17. data/spec/hatchet/config_spec.rb +34 -0
  18. data/spec/hatchet/edit_repo_spec.rb +17 -0
  19. data/spec/hatchet/git_spec.rb +9 -0
  20. data/spec/hatchet/heroku_api_spec.rb +30 -0
  21. data/spec/hatchet/local_repo_spec.rb +26 -0
  22. data/spec/hatchet/lock_spec.rb +19 -0
  23. data/spec/spec_helper.rb +25 -0
  24. metadata +35 -71
  25. data/test/fixtures/buildpacks/null-buildpack/bin/compile +0 -4
  26. data/test/fixtures/buildpacks/null-buildpack/bin/detect +0 -5
  27. data/test/fixtures/buildpacks/null-buildpack/bin/release +0 -3
  28. data/test/fixtures/buildpacks/null-buildpack/hatchet.json +0 -4
  29. data/test/fixtures/buildpacks/null-buildpack/readme.md +0 -41
  30. data/test/hatchet/allow_failure_git_test.rb +0 -16
  31. data/test/hatchet/app_test.rb +0 -96
  32. data/test/hatchet/ci_four_test.rb +0 -19
  33. data/test/hatchet/ci_test.rb +0 -11
  34. data/test/hatchet/ci_three_test.rb +0 -20
  35. data/test/hatchet/ci_too_test.rb +0 -19
  36. data/test/hatchet/config_test.rb +0 -51
  37. data/test/hatchet/edit_repo_test.rb +0 -20
  38. data/test/hatchet/git_test.rb +0 -16
  39. data/test/hatchet/heroku_api_test.rb +0 -30
  40. data/test/hatchet/labs_test.rb +0 -20
  41. data/test/hatchet/local_repo_test.rb +0 -26
  42. data/test/hatchet/lock_test.rb +0 -18
  43. data/test/hatchet/multi_cmd_runner_test.rb +0 -30
  44. data/test/test_helper.rb +0 -28
@@ -0,0 +1,17 @@
1
+ require("spec_helper")
2
+ describe "EditRepoTest" do
3
+ it "can deploy git app" do
4
+ Hatchet::GitApp.new("default_ruby").in_directory do |app|
5
+ `touch foo`
6
+ expect($?.success?).to(eq(true))
7
+
8
+ `git add .; git commit -m foo`
9
+ expect($?.success?).to(eq(true))
10
+ expect(`ls`).to(match("foo"))
11
+ end
12
+
13
+ Hatchet::GitApp.new("default_ruby").in_directory do |app|
14
+ expect(`ls`).to_not match(/foo/)
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,9 @@
1
+ require "spec_helper"
2
+
3
+ describe "GitAppTest" do
4
+ it "can deploy git app" do
5
+ Hatchet::GitApp.new("rails5_ruby_schema_format").deploy do |app|
6
+ expect(app.run("ruby -v")).to match("2.6.6")
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,30 @@
1
+ require("spec_helper")
2
+ describe "HerokuApiTest" do
3
+ it "config vars" do
4
+ begin
5
+ runner = Hatchet::Runner.new("no_lockfile").setup!
6
+ actual = runner.get_config
7
+ actual.delete("BUILDPACK_URL")
8
+ expect(actual).to eq({})
9
+
10
+ runner.set_config("foo" => "bar")
11
+
12
+ actual = runner.get_config
13
+ actual.delete("BUILDPACK_URL")
14
+ expect(actual).to eq({ "foo" => "bar" })
15
+ ensure
16
+ runner.teardown! if runner
17
+ end
18
+ end
19
+
20
+ it "config vars in init" do
21
+ begin
22
+ runner = Hatchet::Runner.new("no_lockfile", config: { foo: "bar" }).setup!
23
+ actual = runner.get_config
24
+
25
+ expect(actual).to eq({ "foo" => "bar" })
26
+ ensure
27
+ runner.teardown! if runner
28
+ end
29
+ end
30
+ end
@@ -0,0 +1,26 @@
1
+ require("spec_helper")
2
+ describe "LocalRepoTest" do
3
+ it "in directory fork" do
4
+ env_name = SecureRandom.hex
5
+ ENV[env_name] = env_name
6
+ Hatchet::App.new("default_ruby").in_directory_fork do
7
+ ENV.delete(env_name) # Does not affect parent env
8
+ expect(ENV[env_name]).to be_nil
9
+ end
10
+
11
+ expect(ENV[env_name]).to eq(env_name)
12
+ end
13
+
14
+ it "repos checked into git" do
15
+ begin
16
+ app = Hatchet::App.new("repo_fixtures/different-folder-for-checked-in-repos/default_ruby")
17
+ app.in_directory do
18
+ expect(Dir.exist?(".git")).to eq(false)
19
+ app.setup!
20
+ expect(Dir.exist?(".git")).to eq(true)
21
+ end
22
+ ensure
23
+ app.teardown! if app
24
+ end
25
+ end
26
+ end
@@ -0,0 +1,19 @@
1
+ require "spec_helper"
2
+ require 'yaml'
3
+
4
+ describe "LockTest" do
5
+ it "app with failure can be locked to prior commit" do
6
+ Hatchet::GitApp.new("lock_fail").deploy do |app|
7
+ expect(app.deployed?).to be_truthy
8
+ end
9
+ end
10
+
11
+ it "app with failure can be locked to master" do
12
+ puts(`bundle exec hatchet lock`)
13
+ lock = YAML.load_file("hatchet.lock")
14
+ name, branch = lock.select { |k, v| k.end_with?("lock_fail_master") }.first
15
+
16
+ expect(name).to eq("repo_fixtures/repos/lock/lock_fail_master")
17
+ expect(branch).to eq("master")
18
+ end
19
+ end
@@ -0,0 +1,25 @@
1
+ $LOAD_PATH.unshift File.expand_path('../../lib', __FILE__)
2
+ require 'hatchet'
3
+ require 'rspec/retry'
4
+ require "bundler/setup"
5
+
6
+ RSpec.configure do |config|
7
+ # Enable flags like --only-failures and --next-failure
8
+ config.example_status_persistence_file_path = ".rspec_status"
9
+ config.verbose_retry = true # show retry status in spec process
10
+ config.default_retry_count = 2 if ENV['IS_RUNNING_ON_CI'] # retry all tests that fail again
11
+
12
+ config.expect_with :rspec do |c|
13
+ c.syntax = :expect
14
+ end
15
+ end
16
+
17
+ ENV['HATCHET_BUILDPACK_BRANCH'] = "master"
18
+
19
+ require 'parallel_tests/test/runtime_logger' if ENV['RECORD_RUNTIME']
20
+
21
+ def run!(cmd)
22
+ out = `#{cmd}`
23
+ raise "Error running #{cmd}, output: #{out}" unless $?.success?
24
+ out
25
+ end
metadata CHANGED
@@ -1,29 +1,29 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: heroku_hatchet
3
3
  version: !ruby/object:Gem::Version
4
- version: 5.0.3
4
+ version: 6.0.0
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-04-27 00:00:00.000000000 Z
11
+ date: 2020-05-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: platform-api
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - "~>"
17
+ - - '='
18
18
  - !ruby/object:Gem::Version
19
- version: '2'
19
+ version: 3.0.0.pre.1
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - "~>"
24
+ - - '='
25
25
  - !ruby/object:Gem::Version
26
- version: '2'
26
+ version: 3.0.0.pre.1
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: rrrretry
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -95,33 +95,19 @@ dependencies:
95
95
  - !ruby/object:Gem::Version
96
96
  version: '0'
97
97
  - !ruby/object:Gem::Dependency
98
- name: minitest-retry
99
- requirement: !ruby/object:Gem::Requirement
100
- requirements:
101
- - - "~>"
102
- - !ruby/object:Gem::Version
103
- version: 0.1.9
104
- type: :runtime
105
- prerelease: false
106
- version_requirements: !ruby/object:Gem::Requirement
107
- requirements:
108
- - - "~>"
109
- - !ruby/object:Gem::Version
110
- version: 0.1.9
111
- - !ruby/object:Gem::Dependency
112
- name: minitest
98
+ name: rspec
113
99
  requirement: !ruby/object:Gem::Requirement
114
100
  requirements:
115
101
  - - ">="
116
102
  - !ruby/object:Gem::Version
117
- version: '5.1'
103
+ version: '0'
118
104
  type: :development
119
105
  prerelease: false
120
106
  version_requirements: !ruby/object:Gem::Requirement
121
107
  requirements:
122
108
  - - ">="
123
109
  - !ruby/object:Gem::Version
124
- version: '5.1'
110
+ version: '0'
125
111
  - !ruby/object:Gem::Dependency
126
112
  name: rake
127
113
  requirement: !ruby/object:Gem::Requirement
@@ -151,19 +137,19 @@ dependencies:
151
137
  - !ruby/object:Gem::Version
152
138
  version: '1'
153
139
  - !ruby/object:Gem::Dependency
154
- name: parallel_tests
140
+ name: parallel_split_test
155
141
  requirement: !ruby/object:Gem::Requirement
156
142
  requirements:
157
143
  - - ">="
158
144
  - !ruby/object:Gem::Version
159
- version: '2'
145
+ version: '0'
160
146
  type: :development
161
147
  prerelease: false
162
148
  version_requirements: !ruby/object:Gem::Requirement
163
149
  requirements:
164
150
  - - ">="
165
151
  - !ruby/object:Gem::Version
166
- version: '2'
152
+ version: '0'
167
153
  - !ruby/object:Gem::Dependency
168
154
  name: travis
169
155
  requirement: !ruby/object:Gem::Requirement
@@ -179,7 +165,7 @@ dependencies:
179
165
  - !ruby/object:Gem::Version
180
166
  version: '1'
181
167
  - !ruby/object:Gem::Dependency
182
- name: m
168
+ name: rspec-retry
183
169
  requirement: !ruby/object:Gem::Requirement
184
170
  requirements:
185
171
  - - ">="
@@ -224,28 +210,18 @@ files:
224
210
  - lib/hatchet/tasks.rb
225
211
  - lib/hatchet/test_run.rb
226
212
  - lib/hatchet/version.rb
227
- - test/different-folder-for-checked-in-repos/default_ruby/Gemfile
228
- - test/different-folder-for-checked-in-repos/default_ruby/Gemfile.lock
229
- - test/fixtures/buildpacks/null-buildpack/bin/compile
230
- - test/fixtures/buildpacks/null-buildpack/bin/detect
231
- - test/fixtures/buildpacks/null-buildpack/bin/release
232
- - test/fixtures/buildpacks/null-buildpack/hatchet.json
233
- - test/fixtures/buildpacks/null-buildpack/readme.md
234
- - test/hatchet/allow_failure_git_test.rb
235
- - test/hatchet/app_test.rb
236
- - test/hatchet/ci_four_test.rb
237
- - test/hatchet/ci_test.rb
238
- - test/hatchet/ci_three_test.rb
239
- - test/hatchet/ci_too_test.rb
240
- - test/hatchet/config_test.rb
241
- - test/hatchet/edit_repo_test.rb
242
- - test/hatchet/git_test.rb
243
- - test/hatchet/heroku_api_test.rb
244
- - test/hatchet/labs_test.rb
245
- - test/hatchet/local_repo_test.rb
246
- - test/hatchet/lock_test.rb
247
- - test/hatchet/multi_cmd_runner_test.rb
248
- - test/test_helper.rb
213
+ - repo_fixtures/different-folder-for-checked-in-repos/default_ruby/Gemfile
214
+ - repo_fixtures/different-folder-for-checked-in-repos/default_ruby/Gemfile.lock
215
+ - spec/hatchet/allow_failure_git_spec.rb
216
+ - spec/hatchet/app_spec.rb
217
+ - spec/hatchet/ci_spec.rb
218
+ - spec/hatchet/config_spec.rb
219
+ - spec/hatchet/edit_repo_spec.rb
220
+ - spec/hatchet/git_spec.rb
221
+ - spec/hatchet/heroku_api_spec.rb
222
+ - spec/hatchet/local_repo_spec.rb
223
+ - spec/hatchet/lock_spec.rb
224
+ - spec/spec_helper.rb
249
225
  - tmp/parallel_runtime_test.log
250
226
  homepage: https://github.com/heroku/hatchet
251
227
  licenses:
@@ -271,25 +247,13 @@ signing_key:
271
247
  specification_version: 4
272
248
  summary: Hatchet is a an integration testing library for developing Heroku buildpacks.
273
249
  test_files:
274
- - test/different-folder-for-checked-in-repos/default_ruby/Gemfile
275
- - test/different-folder-for-checked-in-repos/default_ruby/Gemfile.lock
276
- - test/fixtures/buildpacks/null-buildpack/bin/compile
277
- - test/fixtures/buildpacks/null-buildpack/bin/detect
278
- - test/fixtures/buildpacks/null-buildpack/bin/release
279
- - test/fixtures/buildpacks/null-buildpack/hatchet.json
280
- - test/fixtures/buildpacks/null-buildpack/readme.md
281
- - test/hatchet/allow_failure_git_test.rb
282
- - test/hatchet/app_test.rb
283
- - test/hatchet/ci_four_test.rb
284
- - test/hatchet/ci_test.rb
285
- - test/hatchet/ci_three_test.rb
286
- - test/hatchet/ci_too_test.rb
287
- - test/hatchet/config_test.rb
288
- - test/hatchet/edit_repo_test.rb
289
- - test/hatchet/git_test.rb
290
- - test/hatchet/heroku_api_test.rb
291
- - test/hatchet/labs_test.rb
292
- - test/hatchet/local_repo_test.rb
293
- - test/hatchet/lock_test.rb
294
- - test/hatchet/multi_cmd_runner_test.rb
295
- - test/test_helper.rb
250
+ - spec/hatchet/allow_failure_git_spec.rb
251
+ - spec/hatchet/app_spec.rb
252
+ - spec/hatchet/ci_spec.rb
253
+ - spec/hatchet/config_spec.rb
254
+ - spec/hatchet/edit_repo_spec.rb
255
+ - spec/hatchet/git_spec.rb
256
+ - spec/hatchet/heroku_api_spec.rb
257
+ - spec/hatchet/local_repo_spec.rb
258
+ - spec/hatchet/lock_spec.rb
259
+ - spec/spec_helper.rb
@@ -1,4 +0,0 @@
1
- #!/usr/bin/env bash
2
- # bin/compile <build-dir> <cache-dir>
3
-
4
- echo "-----> Nothing to do."
@@ -1,5 +0,0 @@
1
- #!/usr/bin/env bash
2
- # bin/detect <build-dir>
3
-
4
- echo "Null"
5
- exit 0
@@ -1,3 +0,0 @@
1
- #!/usr/bin/env bash
2
-
3
- echo "--- {}"
@@ -1,4 +0,0 @@
1
- {
2
- "hatchet": {"directory": "../.."},
3
- "rails3": ["sharpstone/rails3_mri_193"]
4
- }
@@ -1,41 +0,0 @@
1
- # Heroku Buildpack: Ø
2
-
3
- Use Ø if you need Heroku to execute a binary.
4
-
5
- ## Usage
6
-
7
- Create a directory for our Heroku app:
8
-
9
- ```bash
10
- $ mkdir -p myapp/bin
11
- $ cd myapp
12
- ```
13
-
14
- Here is an example of an executable that will run on 64bit linux machine:
15
-
16
- ```bash
17
- $ echo -e "#\!/usr/bin/env bash\n echo hello world" > ./bin/program
18
- $ echo -e "program: bin/program" > Procfile
19
- $ chmod +x ./bin/program
20
- $ ./bin/program
21
- hello world
22
- ```
23
-
24
- Push the app to Heroku and run our executable:
25
-
26
- ```bash
27
- $ git init; git add .; git commit -am 'init'
28
- $ heroku create --buildpack http://github.com/ryandotsmith/null-buildpack.git
29
- $ git push heroku master
30
- $ heroku run program
31
- Running `program` attached to terminal... up, run.8663
32
- hello world
33
- ```
34
-
35
- ## Motivation
36
-
37
- I wanted to run various executables (e.g. [log-shuttle](https://github.com/ryandotsmith/log-shuttle)) on Heroku without compiling them on Heroku. Thus, I compile programs on my linux 64 machine, or fetch the binary from the project, commit them to a repo and then run them on Heroku with the Ø buildpack.
38
-
39
- ## Issues
40
-
41
- You will need to make sure that a 64bit linux machine can execute the binary.
@@ -1,16 +0,0 @@
1
- require 'test_helper'
2
-
3
- class AllowFailureGitTest < Minitest::Test
4
- def test_allowed_failure
5
- Hatchet::GitApp.new("no_lockfile", allow_failure: true).deploy do |app|
6
- refute app.deployed?
7
- assert_match "Gemfile.lock required", app.output
8
- end
9
- end
10
-
11
- def test_failure_with_no_flag
12
- assert_raise(Hatchet::App::FailedDeploy) do
13
- Hatchet::GitApp.new("no_lockfile").deploy
14
- end
15
- end
16
- end
@@ -1,96 +0,0 @@
1
- require 'test_helper'
2
-
3
- class AppTest < Minitest::Test
4
- def test_app_with_default
5
- app = Hatchet::App.new("default_ruby", buildpacks: [:default])
6
- assert_match "https://github.com/heroku/heroku-buildpack-ruby", app.buildpacks.first
7
- end
8
-
9
- def test_create_app_with_stack
10
- stack = "heroku-16"
11
- app = Hatchet::App.new("default_ruby", stack: stack)
12
- app.create_app
13
- assert_equal stack, app.platform_api.app.info(app.name)["build_stack"]["name"]
14
- end
15
-
16
- def test_before_deploy
17
- @called = false
18
- @dir = false
19
-
20
- app = Hatchet::App.new("default_ruby")
21
- def app.push_with_retry!; end # Don't actually deploy
22
-
23
- app.before_deploy do
24
- @called = true
25
- @dir = Dir.pwd
26
- end
27
-
28
- app.deploy do
29
- assert_equal true, @called
30
- assert_equal Dir.pwd, @dir
31
- end
32
-
33
- refute_equal Dir.pwd, @dir
34
- end
35
-
36
- def test_auto_commits_code
37
- string = "foo#{SecureRandom.hex}"
38
-
39
- app = Hatchet::App.new("default_ruby")
40
- def app.push_with_retry!; end # Don't actually deploy
41
-
42
- app.before_deploy do |app|
43
- assert_equal false, app.send(:needs_commit?)
44
- `echo "#{string}" > Gemfile`
45
- assert_equal true, app.send(:needs_commit?)
46
- end
47
- app.deploy do
48
- assert_equal string, File.read("Gemfile").chomp
49
- assert_equal false, app.send(:needs_commit?)
50
- end
51
- end
52
-
53
-
54
- def test_nested_in_directory
55
- string = "foo#{SecureRandom.hex}"
56
-
57
- app = Hatchet::App.new("default_ruby")
58
- def app.push_with_retry!; end # Don't actually deploy
59
-
60
- app.in_directory do
61
- `echo "#{string}" > Gemfile`
62
- dir = Dir.pwd
63
-
64
- app.deploy do
65
- assert_equal string, File.read("Gemfile").chomp
66
- assert_equal Dir.pwd, dir
67
- end
68
- end
69
- end
70
-
71
- def test_run
72
- app = Hatchet::GitApp.new("default_ruby")
73
- app.deploy do
74
- assert_match(/ls: cannot access 'foo bar #baz': No such file or directory\s+Gemfile/, app.run("ls -a Gemfile 'foo bar #baz'"))
75
- assert (0 != $?.exitstatus) # $? is from the app.run use of backticks
76
- sleep(4) # Dynos don't exit right away and free dynos can't have more than one running at a time, wait before calling `run` again
77
-
78
- app.run("ls erpderp", { :heroku => { "exit-code" => Hatchet::App::SkipDefaultOption } } )
79
- assert (0 == $?.exitstatus) # $? is from the app.run use of backticks, but we asked the CLI not to return the program exit status by skipping the default "exit-code" option
80
- sleep(4)
81
-
82
- app.run("ls erpderp", { :heroku => { "no-tty" => nil } } )
83
- assert (0 != $?.exitstatus) # $? is from the app.run use of backticks
84
- sleep(4)
85
-
86
- assert_match(/ohai world/, app.run('echo \$HELLO \$NAME', { raw: true, :heroku => { "env" => "HELLO=ohai;NAME=world" } } ))
87
- sleep(4)
88
-
89
- refute_match(/ohai world/, app.run('echo \$HELLO \$NAME', { raw: true, :heroku => { "env" => "" } } ))
90
- sleep(4)
91
-
92
- random_name = SecureRandom.hex
93
- assert_match(/#{random_name}/, app.run("mkdir foo; touch foo/#{random_name}; ls foo/"))
94
- end
95
- end
96
- end