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
@@ -1,19 +0,0 @@
1
- require 'test_helper'
2
-
3
- class CIFourTest < Minitest::Test
4
- def test_error_with_bad_app
5
- string = SecureRandom.hex
6
- Hatchet::GitApp.new("default_ruby").run_ci do |test_run|
7
- refute_match(string, test_run.output)
8
- assert_match("Installing rake" , test_run.output)
9
-
10
- run!(%Q{echo 'puts "#{string}"' >> Rakefile})
11
- test_run.run_again
12
-
13
- assert_match(string, test_run.output)
14
- assert_match("Using rake" , test_run.output)
15
-
16
- refute_match("Installing rake" , test_run.output)
17
- end
18
- end
19
- end
@@ -1,11 +0,0 @@
1
- require 'test_helper'
2
-
3
- class CITest < Minitest::Test
4
- def test_error_with_bad_app
5
- error = assert_raise(Hatchet::FailedTestError) do
6
- Hatchet::GitApp.new("rails5_ci_fails_no_database").run_ci {}
7
- end
8
-
9
- assert_match "PG::ConnectionBad: could not connect to server", error.message
10
- end
11
- end
@@ -1,20 +0,0 @@
1
- require 'test_helper'
2
-
3
- class CIThreeTest < Minitest::Test
4
- def test_error_with_bad_app
5
- @before_deploy_called = false
6
- @before_deploy_dir_pwd = nil
7
- before_deploy = -> {
8
- @before_deploy_called = true
9
- @before_deploy_dir_pwd = Dir.pwd
10
- }
11
- Hatchet::GitApp.new("rails5_ci_fails_no_database", allow_failure: true, before_deploy: before_deploy).run_ci do |test_run|
12
- assert_equal :errored, test_run.status
13
- assert_equal Dir.pwd, @before_deploy_dir_pwd
14
-
15
- assert @before_deploy_called
16
- end
17
-
18
- refute_equal Dir.pwd, @before_deploy_dir_pwd
19
- end
20
- end
@@ -1,19 +0,0 @@
1
- require 'test_helper'
2
-
3
- # Split out to be faster
4
- class CITestToo < Minitest::Test
5
- def test_ci_create_app_with_stack
6
- app = Hatchet::GitApp.new("rails5_ruby_schema_format")
7
- app.run_ci do |test_run|
8
- assert_match "Ruby buildpack tests completed successfully", test_run.output
9
- assert_equal :succeeded, test_run.status
10
- refute_nil app.pipeline_id
11
-
12
- api_rate_limit = app.api_rate_limit.call
13
- couplings = api_rate_limit.pipeline_coupling.list_by_pipeline(app.pipeline_id)
14
- coupled_app = api_rate_limit.app.info(couplings.first["app"]["id"])
15
- assert_equal app.name, coupled_app["name"]
16
- end
17
- assert_nil app.pipeline_id
18
- end
19
- end
@@ -1,51 +0,0 @@
1
- require 'test_helper'
2
-
3
- class ConfigTest < Minitest::Test
4
-
5
- def setup
6
- @config = Hatchet::Config.new
7
- end
8
-
9
- def test_config_path_for_name
10
- assert_equal 'test/fixtures/repos/rails3/rails3_mri_193', @config.path_for_name('rails3_mri_193')
11
- end
12
-
13
- def test_config_dirs
14
- {
15
- "test/fixtures/repos/bundler/no_lockfile" => "https://github.com/sharpstone/no_lockfile.git",
16
- "test/fixtures/repos/default/default_ruby" => "https://github.com/sharpstone/default_ruby.git",
17
- "test/fixtures/repos/rails2/rails2blog" => "https://github.com/sharpstone/rails2blog.git",
18
- "test/fixtures/repos/rails3/rails3_mri_193" => "https://github.com/sharpstone/rails3_mri_193.git"
19
- }.each do |key, value|
20
- assert_include(key, value, @config.dirs)
21
- end
22
- end
23
-
24
- def test_config_repos
25
- {
26
- "default_ruby" => "test/fixtures/repos/default/default_ruby",
27
- "no_lockfile" => "test/fixtures/repos/bundler/no_lockfile",
28
- "rails2blog" => "test/fixtures/repos/rails2/rails2blog",
29
- "rails3_mri_193" => "test/fixtures/repos/rails3/rails3_mri_193"
30
- }.each do |key, value|
31
- assert_include(key, value, @config.repos)
32
- end
33
- end
34
-
35
- def test_no_internal_config_raises_no_errors
36
- # assert no_raise
37
- @config.send :set_internal_config!, {}
38
- assert_equal './repos', @config.repo_directory_path
39
- end
40
-
41
- def test_github_shortcuts
42
- @config.send :init_config!, {"foo" => ["schneems/sextant"]}
43
- assert_equal("https://github.com/schneems/sextant.git", @config.dirs["./repos/foo/sextant"])
44
- end
45
- private
46
-
47
- def assert_include(key, value, actual)
48
- assert_equal value, actual[key], "Expected #{actual.inspect} to include #{ {key => value } } but it did not"
49
- end
50
- end
51
-
@@ -1,20 +0,0 @@
1
- require 'test_helper'
2
-
3
- class EditRepoTest < Minitest::Test
4
- def test_can_deploy_git_app
5
- Hatchet::GitApp.new("default_ruby").in_directory do |app|
6
- msg = `touch foo`
7
- assert $?.success?, msg
8
-
9
- msg = `git add .; git commit -m foo`
10
- assert $?.success?, msg
11
-
12
- assert_match "foo", `ls`
13
- end
14
-
15
- Hatchet::GitApp.new("default_ruby").in_directory do |app|
16
- refute_match(/foo/, `ls`)
17
- end
18
- end
19
- end
20
-
@@ -1,16 +0,0 @@
1
- require 'test_helper'
2
-
3
- class GitAppTest < Minitest::Test
4
- def test_can_deploy_git_app
5
- Hatchet::GitApp.new("rails5_ruby_schema_format").deploy do |app|
6
- assert true
7
- assert_match '2.4.1', app.run("ruby -v")
8
-
9
- app.run("bash") do |cmd|
10
- # cmd.run("cd public/assets")
11
- cmd.run("ls public/") {|r| assert_match("assets", r) }
12
- end
13
- end
14
- end
15
- end
16
-
@@ -1,30 +0,0 @@
1
- require 'test_helper'
2
-
3
- class HerokuApiTest < Minitest::Test
4
-
5
- def test_config_vars
6
- runner = Hatchet::Runner.new("no_lockfile").setup!
7
- expected = {}
8
- actual = runner.get_config
9
- actual.delete("BUILDPACK_URL")
10
- assert_equal expected, actual
11
-
12
- runner.set_config("foo" => "bar")
13
- expected = {"foo" => "bar"}
14
- actual = runner.get_config
15
- actual.delete("BUILDPACK_URL")
16
- assert_equal expected, actual
17
- ensure
18
- runner.teardown! if runner
19
- end
20
-
21
-
22
- def test_config_vars_in_init
23
- runner = Hatchet::Runner.new("no_lockfile", config: { foo: "bar"}).setup!
24
- actual = runner.get_config
25
- expected = {"foo" => "bar"}
26
- assert_equal expected, actual
27
- ensure
28
- runner.teardown! if runner
29
- end
30
- end
@@ -1,20 +0,0 @@
1
- require 'test_helper'
2
-
3
- class LabsTest < Minitest::Test
4
- def setup
5
- @buildpack_path = File.expand_path 'test/fixtures/buildpacks/heroku-buildpack-ruby'
6
- end
7
-
8
- def test_can_deploy_git_app
9
- # You can't enable preboot on a free app.
10
- # BUT you can't make an app hobby until you've deploy once
11
- # Catch-22
12
- # lab_name = "preboot"
13
- # app = Hatchet::App.new("rails3_mri_193", labs: lab_name, buildpack: @buildpack_path)
14
- # app.setup!
15
- # assert(app.lab_is_installed?(lab_name), "Expected #{app.get_labs.inspect} to include {'name' => '#{lab_name}' } but it did not")
16
- assert(true)
17
- # ensure
18
- # app.teardown! if app
19
- end
20
- end
@@ -1,26 +0,0 @@
1
- require 'test_helper'
2
-
3
- class LocalRepoTest < Minitest::Test
4
- def test_in_directory_fork
5
- env_name = SecureRandom.hex
6
- ENV[env_name] = env_name
7
-
8
- Hatchet::App.new("default_ruby").in_directory_fork do
9
- ENV.delete(env_name)
10
- assert_nil ENV[env_name]
11
- end
12
-
13
- assert_equal env_name, ENV[env_name]
14
- end
15
-
16
- def test_repos_checked_into_git
17
- app = Hatchet::App.new("test/different-folder-for-checked-in-repos/default_ruby")
18
- app.in_directory do
19
- assert_equal false, Dir.exist?(".git")
20
- app.setup!
21
- assert_equal true, Dir.exist?(".git")
22
- end
23
- ensure
24
- app.teardown! if app
25
- end
26
- end
@@ -1,18 +0,0 @@
1
- require 'test_helper'
2
-
3
- class LockTest < Minitest::Test
4
- def test_app_with_failure_can_be_locked_to_prior_commit
5
- Hatchet::GitApp.new("lock_fail").deploy do |app|
6
- assert app.deployed?
7
- end
8
- end
9
-
10
- def test_app_with_failure_can_be_locked_to_master
11
- puts `bundle exec hatchet lock`
12
-
13
- lock = YAML.load_file("hatchet.lock")
14
- name, branch = lock.select {|k,v| k.end_with?("lock_fail_master") }.first
15
- assert_equal "test/fixtures/repos/lock/lock_fail_master", name
16
- assert_equal "master", branch
17
- end
18
- end
@@ -1,30 +0,0 @@
1
- require 'test_helper'
2
-
3
- class MultiCmdRunnerTest < Minitest::Test
4
- # slow but needed, there are ghosts in the machine
5
- # by running common command multiple times we can find them
6
- def test_multi_repl_commands
7
- require 'repl_runner'
8
- Hatchet::GitApp.new("default_ruby").deploy do |app|
9
- assert_raise(ReplRunner::UnregisteredCommand) do
10
- app.run("ls", 2) do |ls| # will return right away, should raise error
11
- ls.run("cat")
12
- end
13
- end
14
-
15
- rand(3..7).times do
16
- app.run("irb") do |console|
17
- console.run("`ls`")
18
- console.run("'foo' * 5") {|r| assert_match "foofoofoofoofoo", r }
19
- console.run("'hello ' + 'world'") {|r| assert_match "hello world", r }
20
- end
21
- end
22
-
23
- rand(3..7).times do
24
- app.run("bash") do |bash|
25
- bash.run("ls") { |r| assert_match "Gemfile", r }
26
- end
27
- end
28
- end
29
- end
30
- end
@@ -1,28 +0,0 @@
1
- $LOAD_PATH.unshift File.expand_path('../../lib', __FILE__)
2
- require 'hatchet'
3
-
4
- require 'bundler'
5
- Bundler.require
6
-
7
- # require 'test/unit'
8
-
9
- require 'minitest/autorun'
10
- require "mocha/minitest"
11
-
12
- require 'minitest/retry'
13
- Minitest::Retry.use!
14
-
15
- def assert_raise(*args, &block)
16
- assert_raises(*args, &block)
17
- end
18
-
19
-
20
- ENV['HATCHET_BUILDPACK_BRANCH'] = "master"
21
-
22
- require 'parallel_tests/test/runtime_logger' if ENV['RECORD_RUNTIME']
23
-
24
- def run!(cmd)
25
- out = `#{cmd}`
26
- raise "Error running #{cmd}, output: #{out}" unless $?.success?
27
- out
28
- end