heroku_hatchet 4.0.7 → 4.0.8
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 +5 -5
- data/CHANGELOG.md +8 -0
- data/README.md +46 -1
- data/bin/hatchet +2 -1
- data/lib/hatchet.rb +1 -0
- data/lib/hatchet/app.rb +2 -2
- data/lib/hatchet/reaper.rb +18 -6
- data/lib/hatchet/test_run.rb +1 -1
- data/lib/hatchet/version.rb +1 -1
- metadata +4 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 2757fc3e39814bfab066c368f2dd365e5252f4b9
|
4
|
+
data.tar.gz: 86bb1d5c5ed24462ccd99556420f327c8baceeac
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: bd74e5705b78273eb133189a1c807133a0840c1161ce478deb4a699a5641a69c81bd072f62b3531245780a421d0d127cd5f3643fe6e41aab38e7f8ea93e8ac38
|
7
|
+
data.tar.gz: de5f809bcd7b0f4ac6f121ebbb852057eb73b89e6370398e43635a5de6edee2cbffb05ece7b76d50751479152a7b1850fa54c765e787c004fb43067e1a57c670
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,13 @@
|
|
1
1
|
## HEAD
|
2
2
|
|
3
|
+
## 4.0.8
|
4
|
+
|
5
|
+
- Fix `hatchet destroy` calling class from wrong module
|
6
|
+
- Fix `hatchet destroy` not passing rate limited API to Reaper
|
7
|
+
- Fix undeclared variable in `App#create_app` rescue block
|
8
|
+
- Fix race condition in `Reaper#cycle` triggering 403s in API, causing test failures
|
9
|
+
- Allow configurable app name prefix (default "hatchet-t-") via `HATCHET_APP_PREFIX` env var
|
10
|
+
|
3
11
|
## 4.0.7
|
4
12
|
|
5
13
|
- Exit code is now returned from `app.run` commands (https://github.com/heroku/hatchet/pull/58)
|
data/README.md
CHANGED
@@ -130,6 +130,12 @@ Hatchet::Runner.new('no_lockfile')
|
|
130
130
|
|
131
131
|
If you have conflicting names, use full paths.
|
132
132
|
|
133
|
+
If you woud like to test with fixtures that are checked in locally, that is also possible by passing in the path to the fixture directory and skipping the `hatchet install`:
|
134
|
+
|
135
|
+
```
|
136
|
+
Hatchet::Runner.new("spec/fixtures/repos/node-10-metrics")
|
137
|
+
```
|
138
|
+
|
133
139
|
A word of warning on including repos inside of your test
|
134
140
|
directory, if you're using a runner that looks for patterns such as
|
135
141
|
`*_test.rb` to run your hatchet tests, it may incorrectly think you want
|
@@ -254,7 +260,46 @@ Hatchet::Runner.new("rails3_mri_193").deploy do |app|
|
|
254
260
|
end
|
255
261
|
```
|
256
262
|
|
257
|
-
Please read the docs on [repl_runner](http://github.com/schneems/repl_runner) for more info. The only interactive commands that are supported out of the box are `rails console`, `bash`, and `irb` it is fairly easy to add your own though
|
263
|
+
Please read the docs on [repl_runner](http://github.com/schneems/repl_runner) for more info. The only interactive commands that are supported out of the box are `rails console`, `bash`, and `irb` it is fairly easy to add your own though.
|
264
|
+
|
265
|
+
## Modify Application Files on Disk
|
266
|
+
|
267
|
+
While template apps provided from your `hatchet.json` can provide a wide array of different test cases, it's likely that you'll want to test minor varriations of an app. To do this you can use the `before_deploy` hook to modify files on disk inside of an app in a way that is threadsafe and will only affect the local instance of the app:
|
268
|
+
|
269
|
+
```ruby
|
270
|
+
Hatchet::App.new("default_ruby", before_deploy: { FileUtils.touch("foo.txt")}).deploy do
|
271
|
+
# Assert stuff
|
272
|
+
end
|
273
|
+
```
|
274
|
+
|
275
|
+
After the `before_deploy` block fires, the results will be committed to git automatically before the app deploys.
|
276
|
+
|
277
|
+
You can also manually call the `before_deploy` method:
|
278
|
+
|
279
|
+
```ruby
|
280
|
+
app = Hatchet::App.new("default_ruby")
|
281
|
+
app.before_deploy do
|
282
|
+
FileUtils.touch("foo.txt")
|
283
|
+
end
|
284
|
+
app.deploy do
|
285
|
+
# Assert stuff
|
286
|
+
end
|
287
|
+
```
|
288
|
+
|
289
|
+
Note: If you're going to shell out in this `before_deploy` section, you should check the success of your command, for example:
|
290
|
+
|
291
|
+
```ruby
|
292
|
+
before_deploy = Proc.new do
|
293
|
+
cmd = "bundle update"
|
294
|
+
output = `#{cmd}`
|
295
|
+
raise "Command #{cmd.inspect} failed unexpectedly with output: #{output}"
|
296
|
+
end
|
297
|
+
Hatchet::App.new("default_ruby", before_deploy: before_deploy).deploy do
|
298
|
+
# Assert stuff
|
299
|
+
end
|
300
|
+
```
|
301
|
+
|
302
|
+
It's helpful to make a helper function in your library if this pattern happens a lot in your app.
|
258
303
|
|
259
304
|
## Heroku CI
|
260
305
|
|
data/bin/hatchet
CHANGED
@@ -98,7 +98,8 @@ class HatchetCLI < Thor
|
|
98
98
|
def destroy(name=nil)
|
99
99
|
api_key = ENV['HEROKU_API_KEY'] || bundle_exec {`heroku auth:token`.chomp }
|
100
100
|
platform_api = PlatformAPI.connect_oauth(api_key, cache: Moneta.new(:Null))
|
101
|
-
|
101
|
+
api_rate_limit = ApiRateLimit.new(platform_api)
|
102
|
+
reaper = Hatchet::Reaper.new(api_rate_limit: api_rate_limit)
|
102
103
|
|
103
104
|
if options[:all]
|
104
105
|
reaper.destroy_all
|
data/lib/hatchet.rb
CHANGED
data/lib/hatchet/app.rb
CHANGED
@@ -148,7 +148,7 @@ module Hatchet
|
|
148
148
|
hash = { name: name, stack: stack }
|
149
149
|
hash.delete_if { |k,v| v.nil? }
|
150
150
|
api_rate_limit.call.app.create(hash)
|
151
|
-
rescue
|
151
|
+
rescue => e
|
152
152
|
@reaper.cycle
|
153
153
|
raise e
|
154
154
|
end
|
@@ -347,7 +347,7 @@ module Hatchet
|
|
347
347
|
end
|
348
348
|
|
349
349
|
private def default_name
|
350
|
-
"
|
350
|
+
"#{Hatchet::APP_PREFIX}#{SecureRandom.hex(5)}"
|
351
351
|
end
|
352
352
|
|
353
353
|
private def call_before_deploy
|
data/lib/hatchet/reaper.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
require 'tmpdir'
|
2
|
+
|
1
3
|
module Hatchet
|
2
4
|
# Hatchet apps are useful after the tests run for debugging purposes
|
3
5
|
# the reaper is designed to allow the most recent apps to stay alive
|
@@ -7,10 +9,9 @@ module Hatchet
|
|
7
9
|
class Reaper
|
8
10
|
HEROKU_APP_LIMIT = Integer(ENV["HEROKU_APP_LIMIT"] || 100) # the number of apps heroku allows you to keep
|
9
11
|
HATCHET_APP_LIMT = Integer(ENV["HATCHET_APP_LIMIT"] || 20) # the number of apps hatchet keeps around
|
10
|
-
DEFAULT_REGEX =
|
12
|
+
DEFAULT_REGEX = /^#{Regexp.escape(Hatchet::APP_PREFIX)}[a-f0-9]+/
|
11
13
|
attr_accessor :apps
|
12
14
|
|
13
|
-
|
14
15
|
def initialize(api_rate_limit: , regex: DEFAULT_REGEX)
|
15
16
|
@api_rate_limit = api_rate_limit
|
16
17
|
@regex = regex
|
@@ -24,16 +25,24 @@ module Hatchet
|
|
24
25
|
end
|
25
26
|
|
26
27
|
def cycle
|
28
|
+
# we don't want multiple Hatchet processes (e.g. when using rspec-parallel) to delete apps at the same time
|
29
|
+
# this could otherwise result in race conditions in API causing errors other than 404s, making tests fail
|
30
|
+
mutex = File.open("#{Dir.tmpdir()}/hatchet_reaper_mutex", File::CREAT)
|
31
|
+
mutex.flock(File::LOCK_EX)
|
32
|
+
|
33
|
+
# update list of apps once
|
27
34
|
get_apps
|
28
|
-
|
35
|
+
|
36
|
+
return unless over_limit?
|
37
|
+
|
38
|
+
while over_limit?
|
29
39
|
if @hatchet_apps.count > 1
|
40
|
+
# remove our own apps until we are below limit
|
30
41
|
destroy_oldest
|
31
|
-
cycle
|
32
42
|
else
|
33
43
|
puts "Warning: Reached Heroku app limit of #{HEROKU_APP_LIMIT}."
|
44
|
+
break
|
34
45
|
end
|
35
|
-
else
|
36
|
-
# do nothing
|
37
46
|
end
|
38
47
|
|
39
48
|
# If the app is already deleted an exception
|
@@ -46,6 +55,9 @@ module Hatchet
|
|
46
55
|
retry
|
47
56
|
end
|
48
57
|
raise e
|
58
|
+
ensure
|
59
|
+
# don't forget to close the mutex; this also releases our lock
|
60
|
+
mutex.close
|
49
61
|
end
|
50
62
|
|
51
63
|
def destroy_oldest
|
data/lib/hatchet/test_run.rb
CHANGED
@@ -30,7 +30,7 @@ module Hatchet
|
|
30
30
|
commit_message: "commit",
|
31
31
|
organization: nil
|
32
32
|
)
|
33
|
-
@pipeline = pipeline || "
|
33
|
+
@pipeline = pipeline || "#{Hatchet::APP_PREFIX}#{SecureRandom.hex(5)}"
|
34
34
|
@timeout = timeout
|
35
35
|
@pause = pause
|
36
36
|
@organization = organization
|
data/lib/hatchet/version.rb
CHANGED
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: 4.0.
|
4
|
+
version: 4.0.8
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Richard Schneeman
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-03
|
11
|
+
date: 2019-04-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: platform-api
|
@@ -247,7 +247,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
247
247
|
- !ruby/object:Gem::Version
|
248
248
|
version: '0'
|
249
249
|
requirements: []
|
250
|
-
|
250
|
+
rubyforge_project:
|
251
|
+
rubygems_version: 2.6.14
|
251
252
|
signing_key:
|
252
253
|
specification_version: 4
|
253
254
|
summary: Hatchet is a an integration testing library for developing Heroku buildpacks.
|