shipit-engine 0.32.0 → 0.33.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (176) hide show
  1. checksums.yaml +4 -4
  2. data/app/assets/images/magic-solid.svg +1 -0
  3. data/app/assets/javascripts/shipit/repositories_search.js.coffee +60 -0
  4. data/app/assets/javascripts/shipit/{search.js.coffee → stack_search.js.coffee} +0 -0
  5. data/app/assets/stylesheets/_pages/_repositories.scss +148 -0
  6. data/app/assets/stylesheets/_pages/_stacks.scss +19 -0
  7. data/app/assets/stylesheets/shipit.scss +1 -0
  8. data/app/controllers/shipit/api/{pull_requests_controller.rb → merge_requests_controller.rb} +8 -8
  9. data/app/controllers/shipit/api/stacks_controller.rb +14 -1
  10. data/app/controllers/shipit/deploys_controller.rb +2 -2
  11. data/app/controllers/shipit/merge_requests_controller.rb +31 -0
  12. data/app/controllers/shipit/merge_status_controller.rb +15 -15
  13. data/app/controllers/shipit/repositories_controller.rb +74 -0
  14. data/app/controllers/shipit/tasks_controller.rb +4 -4
  15. data/app/helpers/shipit/chunks_helper.rb +2 -2
  16. data/app/helpers/shipit/github_url_helper.rb +8 -0
  17. data/app/helpers/shipit/stacks_helper.rb +4 -0
  18. data/app/jobs/shipit/create_on_github_job.rb +1 -0
  19. data/app/jobs/shipit/destroy_repository_job.rb +24 -0
  20. data/app/jobs/shipit/destroy_stack_job.rb +2 -2
  21. data/app/jobs/shipit/perform_task_job.rb +4 -98
  22. data/app/jobs/shipit/process_merge_requests_job.rb +32 -0
  23. data/app/jobs/shipit/refresh_merge_request_job.rb +11 -0
  24. data/app/models/shipit/anonymous_user.rb +4 -0
  25. data/app/models/shipit/check_run.rb +2 -2
  26. data/app/models/shipit/command_line_user.rb +4 -0
  27. data/app/models/shipit/commit.rb +11 -11
  28. data/app/models/shipit/commit_checks.rb +1 -0
  29. data/app/models/shipit/deploy.rb +1 -0
  30. data/app/models/shipit/deploy_spec.rb +16 -4
  31. data/app/models/shipit/deploy_spec/file_system.rb +11 -5
  32. data/app/models/shipit/hook.rb +2 -0
  33. data/app/models/shipit/merge_request.rb +302 -0
  34. data/app/models/shipit/provisioning_handler.rb +32 -0
  35. data/app/models/shipit/provisioning_handler/base.rb +30 -0
  36. data/app/models/shipit/provisioning_handler/unregistered_provisioning_handler.rb +35 -0
  37. data/app/models/shipit/pull_request.rb +25 -264
  38. data/app/models/shipit/pull_request_assignment.rb +10 -0
  39. data/app/models/shipit/repository.rb +54 -0
  40. data/app/models/shipit/review_stack.rb +116 -0
  41. data/app/models/shipit/review_stack_provisioning_queue.rb +39 -0
  42. data/app/models/shipit/stack.rb +22 -8
  43. data/app/models/shipit/task.rb +56 -7
  44. data/app/models/shipit/task_execution_strategy/base.rb +20 -0
  45. data/app/models/shipit/task_execution_strategy/default.rb +110 -0
  46. data/app/models/shipit/user.rb +6 -1
  47. data/app/models/shipit/webhooks.rb +10 -0
  48. data/app/models/shipit/webhooks/handlers/pull_request/assigned_handler.rb +74 -0
  49. data/app/models/shipit/webhooks/handlers/pull_request/closed_handler.rb +68 -0
  50. data/app/models/shipit/webhooks/handlers/pull_request/edited_handler.rb +74 -0
  51. data/app/models/shipit/webhooks/handlers/pull_request/label_capturing_handler.rb +127 -0
  52. data/app/models/shipit/webhooks/handlers/pull_request/labeled_handler.rb +106 -0
  53. data/app/models/shipit/webhooks/handlers/pull_request/opened_handler.rb +83 -0
  54. data/app/models/shipit/webhooks/handlers/pull_request/reopened_handler.rb +88 -0
  55. data/app/models/shipit/webhooks/handlers/pull_request/review_stack_adapter.rb +103 -0
  56. data/app/models/shipit/webhooks/handlers/pull_request/unlabeled_handler.rb +107 -0
  57. data/app/serializers/shipit/deploy_serializer.rb +6 -0
  58. data/app/serializers/shipit/merge_request_serializer.rb +21 -0
  59. data/app/serializers/shipit/pull_request_serializer.rb +5 -8
  60. data/app/serializers/shipit/review_stack_serializer.rb +7 -0
  61. data/app/serializers/shipit/stack_serializer.rb +7 -6
  62. data/app/serializers/shipit/tail_task_serializer.rb +10 -2
  63. data/app/serializers/shipit/task_serializer.rb +1 -1
  64. data/app/views/shipit/merge_requests/_merge_request.html.erb +29 -0
  65. data/app/views/shipit/{pull_requests → merge_requests}/index.html.erb +2 -2
  66. data/app/views/shipit/merge_requests/merge_requests/_pull_request.html.erb +29 -0
  67. data/app/views/shipit/merge_requests/merge_requests/index.html.erb +20 -0
  68. data/app/views/shipit/merge_status/_merge_queue_button.html.erb +3 -3
  69. data/app/views/shipit/merge_status/backlogged.html.erb +1 -1
  70. data/app/views/shipit/merge_status/failure.html.erb +1 -1
  71. data/app/views/shipit/merge_status/locked.html.erb +1 -1
  72. data/app/views/shipit/merge_status/success.html.erb +2 -2
  73. data/app/views/shipit/repositories/_header.html.erb +19 -0
  74. data/app/views/shipit/repositories/index.html.erb +31 -0
  75. data/app/views/shipit/repositories/new.html.erb +23 -0
  76. data/app/views/shipit/repositories/settings.html.erb +53 -0
  77. data/app/views/shipit/repositories/show.html.erb +30 -0
  78. data/app/views/shipit/stacks/_banners.html.erb +13 -0
  79. data/app/views/shipit/stacks/_header.html.erb +5 -2
  80. data/app/views/shipit/stacks/_stack.html.erb +8 -0
  81. data/app/views/shipit/stacks/index.html.erb +2 -1
  82. data/app/views/shipit/stacks/settings.html.erb +5 -5
  83. data/app/views/shipit/stacks/show.html.erb +1 -1
  84. data/app/views/shipit/tasks/_task_output.html.erb +1 -1
  85. data/config/routes.rb +15 -5
  86. data/db/migrate/20200706145406_add_review_stacks.rb +12 -0
  87. data/db/migrate/20200804144639_rename_pull_request_to_merge_request.rb +7 -0
  88. data/db/migrate/20200804161512_rename_commits_pull_request_id_to_merge_request_id.rb +5 -0
  89. data/db/migrate/20200813134712_recreate_shipit_pull_requests.rb +22 -0
  90. data/db/migrate/20200813194056_create_pull_request_assignments.rb +8 -0
  91. data/db/migrate/20201001125502_add_provision_pr_stacks_flag_to_repositories.rb +7 -0
  92. data/db/migrate/20201008145809_add_retry_attempt_to_tasks.rb +5 -0
  93. data/db/migrate/20201008152744_add_max_retries_to_tasks.rb +5 -0
  94. data/lib/shipit.rb +11 -1
  95. data/lib/shipit/github_app.rb +1 -1
  96. data/lib/shipit/review_stack_commands.rb +8 -0
  97. data/lib/shipit/stack_commands.rb +6 -1
  98. data/lib/shipit/task_commands.rb +1 -0
  99. data/lib/shipit/version.rb +1 -1
  100. data/lib/tasks/cron.rake +11 -2
  101. data/test/controllers/api/{pull_requests_controller_test.rb → merge_requests_controller_test.rb} +12 -12
  102. data/test/controllers/api/outputs_controller_test.rb +1 -0
  103. data/test/controllers/api/rollback_controller_test.rb +1 -1
  104. data/test/controllers/api/stacks_controller_test.rb +21 -1
  105. data/test/controllers/{pull_requests_controller_test.rb → merge_requests_controller_test.rb} +6 -6
  106. data/test/controllers/repositories_controller_test.rb +71 -0
  107. data/test/controllers/stacks_controller_test.rb +9 -1
  108. data/test/controllers/tasks_controller_test.rb +14 -2
  109. data/test/controllers/webhooks_controller_test.rb +1 -1
  110. data/test/dummy/config/application.rb +6 -1
  111. data/test/dummy/config/environments/development.rb +0 -3
  112. data/test/dummy/config/environments/test.rb +0 -5
  113. data/test/dummy/db/schema.rb +52 -14
  114. data/test/dummy/db/seeds.rb +1 -1
  115. data/test/fixtures/payloads/check_suite_master.json +2 -2
  116. data/test/fixtures/payloads/invalid_pull_request.json +117 -0
  117. data/test/fixtures/payloads/provision_disabled_pull_request.json +454 -0
  118. data/test/fixtures/payloads/pull_request_assigned.json +480 -0
  119. data/test/fixtures/payloads/pull_request_closed.json +454 -0
  120. data/test/fixtures/payloads/pull_request_labeled.json +461 -0
  121. data/test/fixtures/payloads/pull_request_opened.json +454 -0
  122. data/test/fixtures/payloads/pull_request_reopened.json +454 -0
  123. data/test/fixtures/payloads/pull_request_unlabeled.json +454 -0
  124. data/test/fixtures/payloads/pull_request_with_no_repo.json +454 -0
  125. data/test/fixtures/shipit/commits.yml +15 -2
  126. data/test/fixtures/shipit/merge_requests.yml +141 -0
  127. data/test/fixtures/shipit/pull_request_assignments.yml +3 -0
  128. data/test/fixtures/shipit/pull_requests.yml +10 -131
  129. data/test/fixtures/shipit/repositories.yml +1 -0
  130. data/test/fixtures/shipit/stacks.yml +145 -0
  131. data/test/fixtures/shipit/statuses.yml +9 -0
  132. data/test/fixtures/shipit/tasks.yml +3 -0
  133. data/test/fixtures/shipit/users.yml +7 -0
  134. data/test/helpers/payloads_helper.rb +4 -0
  135. data/test/jobs/chunk_rollup_job_test.rb +15 -1
  136. data/test/jobs/destroy_repository_job_test.rb +27 -0
  137. data/test/jobs/perform_task_job_test.rb +8 -8
  138. data/test/jobs/{merge_pull_requests_job_test.rb → process_merge_requests_job_test.rb} +18 -18
  139. data/test/lib/shipit/deploy_commands_test.rb +16 -0
  140. data/test/lib/shipit/task_commands_test.rb +17 -0
  141. data/test/models/commits_test.rb +22 -13
  142. data/test/models/deploy_spec_test.rb +57 -24
  143. data/test/models/deploys_test.rb +148 -14
  144. data/test/models/{pull_request_test.rb → merge_request_test.rb} +30 -30
  145. data/test/models/pull_request_assignment_test.rb +16 -0
  146. data/test/models/shipit/provisioning_handler/base_test.rb +33 -0
  147. data/test/models/shipit/provisioning_handler/unregistered_provisioning_handler_test.rb +49 -0
  148. data/test/models/shipit/provisioning_handler_test.rb +64 -0
  149. data/test/models/shipit/pull_request_test.rb +52 -0
  150. data/test/models/shipit/repository_test.rb +5 -1
  151. data/test/models/shipit/review_stack_provision_status_test.rb +77 -0
  152. data/test/models/shipit/review_stack_provisioning_queue_test.rb +63 -0
  153. data/test/models/shipit/review_stack_test.rb +59 -0
  154. data/test/models/{stacks_test.rb → shipit/stacks_test.rb} +10 -4
  155. data/test/models/shipit/webhooks/handlers/pull_request/assigned_handler_test.rb +45 -0
  156. data/test/models/shipit/webhooks/handlers/pull_request/closed_handler_test.rb +192 -0
  157. data/test/models/shipit/webhooks/handlers/pull_request/edited_handler_test.rb +47 -0
  158. data/test/models/shipit/webhooks/handlers/pull_request/label_capturing_handler_test.rb +209 -0
  159. data/test/models/shipit/webhooks/handlers/pull_request/labeled_handler_test.rb +332 -0
  160. data/test/models/shipit/webhooks/handlers/pull_request/opened_handler_test.rb +238 -0
  161. data/test/models/shipit/webhooks/handlers/pull_request/reopened_handler_test.rb +282 -0
  162. data/test/models/shipit/webhooks/handlers/pull_request/review_stack_adapter_test.rb +83 -0
  163. data/test/models/shipit/webhooks/handlers/pull_request/unlabeled_handler_test.rb +324 -0
  164. data/test/models/shipit/{wehbooks → webhooks}/handlers_test.rb +0 -0
  165. data/test/models/tasks_test.rb +44 -3
  166. data/test/serializers/shipit/pull_request_serializer_test.rb +29 -0
  167. data/test/unit/command_test.rb +3 -3
  168. data/test/unit/github_url_helper_test.rb +5 -0
  169. data/test/unit/shipit_task_execution_strategy_test.rb +47 -0
  170. metadata +260 -154
  171. data/app/controllers/shipit/pull_requests_controller.rb +0 -31
  172. data/app/jobs/shipit/merge_pull_requests_job.rb +0 -32
  173. data/app/jobs/shipit/refresh_pull_request_job.rb +0 -11
  174. data/app/views/shipit/pull_requests/_pull_request.html.erb +0 -29
  175. data/test/fixtures/shipit/output_chunks.yml +0 -47
  176. data/test/models/output_chunk_test.rb +0 -21
@@ -2,30 +2,30 @@
2
2
  require 'test_helper'
3
3
 
4
4
  module Shipit
5
- class PullRequestsControllerTest < ActionController::TestCase
5
+ class MergeRequestsControllerTest < ActionController::TestCase
6
6
  setup do
7
7
  @stack = shipit_stacks(:shipit)
8
- @pr = shipit_pull_requests(:shipit_pending)
8
+ @pr = shipit_merge_requests(:shipit_pending)
9
9
  session[:user_id] = shipit_users(:walrus).id
10
10
  end
11
11
 
12
12
  test "#index shows pending pull requests" do
13
13
  get :index, params: { stack_id: @stack.to_param }
14
14
  assert_response :success
15
- assert_select '.pr-list .pr', @stack.pull_requests.pending.count
15
+ assert_select '.pr-list .pr', @stack.merge_requests.pending.count
16
16
  end
17
17
 
18
18
  test "#add can enqueue a pull request" do
19
- assert_difference -> { PullRequest.count }, +1 do
19
+ assert_difference -> { MergeRequest.count }, +1 do
20
20
  post :create, params: { stack_id: @stack.to_param, number_or_url: '#5' }
21
21
  end
22
- assert_redirected_to stack_pull_requests_path(@stack)
22
+ assert_redirected_to stack_merge_requests_path(@stack)
23
23
  end
24
24
 
25
25
  test "#destroy can cancel a pending pull request" do
26
26
  assert_predicate @pr, :pending?
27
27
  delete :destroy, params: { stack_id: @stack.to_param, id: @pr.id }
28
- assert_redirected_to stack_pull_requests_path(@stack)
28
+ assert_redirected_to stack_merge_requests_path(@stack)
29
29
  assert_predicate @pr.reload, :canceled?
30
30
  end
31
31
  end
@@ -0,0 +1,71 @@
1
+ # frozen_string_literal: true
2
+ require 'test_helper'
3
+
4
+ module Shipit
5
+ class RepositoriesControllerTest < ActionController::TestCase
6
+ setup do
7
+ @routes = Shipit::Engine.routes
8
+ @repository = shipit_repositories(:shipit)
9
+ session[:user_id] = shipit_users(:walrus).id
10
+ end
11
+
12
+ test "GitHub authentication is mandatory" do
13
+ session[:user_id] = nil
14
+ get :index
15
+ assert_redirected_to '/github/auth/github?origin=http%3A%2F%2Ftest.host%2Frepositories'
16
+ end
17
+
18
+ test "current_user must be a member of at least a Shipit.github_teams" do
19
+ session[:user_id] = shipit_users(:bob).id
20
+ Shipit.stubs(:github_teams).returns([shipit_teams(:cyclimse_cooks), shipit_teams(:shopify_developers)])
21
+ get :index
22
+ assert_response :forbidden
23
+ assert_equal(
24
+ 'You must be a member of cyclimse/cooks or shopify/developers to access this application.',
25
+ response.body,
26
+ )
27
+ end
28
+
29
+ test "#show is success" do
30
+ get :show, params: { id: @repository.to_param }
31
+ assert_response :ok
32
+ end
33
+
34
+ test "#create creates a repository and redirects to it" do
35
+ assert_difference "Repository.count" do
36
+ post :create, params: {
37
+ repository: {
38
+ name: 'valid',
39
+ owner: 'repository',
40
+ },
41
+ }
42
+ end
43
+ assert_redirected_to repository_path(Repository.last)
44
+ end
45
+
46
+ test "#create when not valid renders new" do
47
+ assert_no_difference "Repository.count" do
48
+ post :create, params: {
49
+ repository: {
50
+ owner: 'some',
51
+ name: 'owner/path',
52
+ },
53
+ }
54
+ end
55
+ assert_response :success
56
+ end
57
+
58
+ test "#destroy enqueues a DestroyRepositoryJob" do
59
+ assert_enqueued_with(job: DestroyRepositoryJob, args: [@repository]) do
60
+ delete :destroy, params: { id: @repository.to_param }
61
+ end
62
+
63
+ assert_redirected_to repositories_path
64
+ end
65
+
66
+ test "#settings is success" do
67
+ get :settings, params: { id: @repository.to_param }
68
+ assert_response :success
69
+ end
70
+ end
71
+ end
@@ -48,11 +48,17 @@ module Shipit
48
48
  end
49
49
 
50
50
  test "#index list all stacks" do
51
- get :index
51
+ get :index, params: { show_archived: true }
52
52
  assert_response :ok
53
53
  assert_select ".stack", count: Stack.count
54
54
  end
55
55
 
56
+ test "#index list all not archived stacks" do
57
+ get :index
58
+ assert_response :ok
59
+ assert_select ".stack", count: Stack.not_archived.count
60
+ end
61
+
56
62
  test "#index list a repo stacks if the :repo params is passed" do
57
63
  repo = shipit_repositories(:shipit)
58
64
  get :index, params: { repo: repo.full_name }
@@ -175,6 +181,8 @@ module Shipit
175
181
  @stack.reload
176
182
  refute @stack.archived?
177
183
  refute @stack.locked?
184
+ assert_nil @stack.locked_since
185
+ assert_nil @stack.lock_reason
178
186
  assert_instance_of AnonymousUser, @stack.lock_author
179
187
  end
180
188
 
@@ -101,12 +101,24 @@ module Shipit
101
101
 
102
102
  test ":tail returns the task status, output, and next url" do
103
103
  @task = shipit_deploys(:shipit_running)
104
- last_chunk = @task.chunks.last
104
+ @task.write("dummy output")
105
+ last_chunk = @task.chunk_output.bytesize
105
106
 
106
- get :tail, params: { stack_id: @stack.to_param, id: @task.id, last_id: last_chunk.id }, format: :json
107
+ get :tail, params: { stack_id: @stack.to_param, id: @task.id }, format: :json
107
108
  assert_response :success
108
109
  assert_json_keys %w(url status output)
109
110
  assert_json 'status', @task.status
111
+ assert_json 'output', @task.chunk_output
112
+ assert_json 'url', "/shopify/shipit-engine/production/tasks/#{@task.id}/tail?last_byte=#{last_chunk}"
113
+ end
114
+
115
+ test ":tail can handle last_byte as string" do
116
+ @task = shipit_deploys(:shipit_running)
117
+ @task.write("dummy output")
118
+
119
+ get :tail, params: { stack_id: @stack.to_param, id: @task.id, last_byte: "50" }, format: :json
120
+ assert_response :success
121
+ assert_json_keys %w(url status output)
110
122
  end
111
123
 
112
124
  test ":tail doesn't returns the next url if the task is finished" do
@@ -158,7 +158,7 @@ module Shipit
158
158
  event = 'pull_request'
159
159
  mock_handler = mock
160
160
  mock_handler.expects(:call).with(pull_request_params.stringify_keys).once
161
- Shipit::Webhooks.register_handler(event, mock_handler)
161
+ Shipit::Webhooks.handlers["pull_request"] = [mock_handler]
162
162
 
163
163
  @request.headers['X-Github-Event'] = event
164
164
  post :create, body: pull_request_params.to_json, as: :json
@@ -1,6 +1,11 @@
1
1
  require File.expand_path('../boot', __FILE__)
2
2
 
3
- require 'rails/all'
3
+ require 'active_record/railtie'
4
+ require 'action_controller/railtie'
5
+ require 'action_view/railtie'
6
+ require 'active_job/railtie'
7
+ require 'rails/test_unit/railtie'
8
+ require 'sprockets/railtie'
4
9
 
5
10
  Bundler.require(*Rails.groups)
6
11
  require "shipit"
@@ -28,9 +28,6 @@ Rails.application.configure do
28
28
  config.cache_store = :null_store
29
29
  end
30
30
 
31
- # Don't care if the mailer can't send.
32
- config.action_mailer.raise_delivery_errors = false
33
-
34
31
  # Print deprecation notices to the Rails logger.
35
32
  config.active_support.deprecation = :log
36
33
 
@@ -26,11 +26,6 @@ Rails.application.configure do
26
26
  # Disable request forgery protection in test environment.
27
27
  config.action_controller.allow_forgery_protection = false
28
28
 
29
- # Tell Action Mailer not to deliver emails to the real world.
30
- # The :test delivery method accumulates sent emails in the
31
- # ActionMailer::Base.deliveries array.
32
- config.action_mailer.delivery_method = :test
33
-
34
29
  # Randomize the order test cases are executed.
35
30
  config.active_support.test_order = :random
36
31
 
@@ -10,7 +10,7 @@
10
10
  #
11
11
  # It's strongly recommended that you check this file into your version control system.
12
12
 
13
- ActiveRecord::Schema.define(version: 2020_06_15_181558) do
13
+ ActiveRecord::Schema.define(version: 2020_10_08_152744) do
14
14
 
15
15
  create_table "api_clients", force: :cascade do |t|
16
16
  t.text "permissions", limit: 65535
@@ -75,7 +75,7 @@ ActiveRecord::Schema.define(version: 2020_06_15_181558) do
75
75
  t.integer "deletions", limit: 4
76
76
  t.integer "pull_request_number"
77
77
  t.string "pull_request_title", limit: 1024
78
- t.integer "pull_request_id"
78
+ t.integer "merge_request_id"
79
79
  t.boolean "locked", default: false, null: false
80
80
  t.integer "lock_author_id", limit: 4
81
81
  t.string "pull_request_head_sha", limit: 40
@@ -138,15 +138,7 @@ ActiveRecord::Schema.define(version: 2020_06_15_181558) do
138
138
  t.index ["user_id"], name: "index_memberships_on_user_id"
139
139
  end
140
140
 
141
- create_table "output_chunks", force: :cascade do |t|
142
- t.integer "task_id", limit: 4
143
- t.text "text", limit: 16777215
144
- t.datetime "created_at"
145
- t.datetime "updated_at"
146
- t.index ["task_id"], name: "index_output_chunks_on_task_id"
147
- end
148
-
149
- create_table "pull_requests", force: :cascade do |t|
141
+ create_table "merge_requests", force: :cascade do |t|
150
142
  t.integer "stack_id", null: false
151
143
  t.integer "number", null: false
152
144
  t.string "title", limit: 256
@@ -168,11 +160,46 @@ ActiveRecord::Schema.define(version: 2020_06_15_181558) do
168
160
  t.datetime "merged_at"
169
161
  t.string "base_ref", limit: 1024
170
162
  t.integer "base_commit_id"
163
+ t.index ["head_id"], name: "index_merge_requests_on_head_id"
164
+ t.index ["merge_requested_by_id"], name: "index_merge_requests_on_merge_requested_by_id"
165
+ t.index ["merge_status"], name: "index_merge_requests_on_merge_status"
166
+ t.index ["stack_id", "github_id"], name: "index_merge_requests_on_stack_id_and_github_id", unique: true
167
+ t.index ["stack_id", "merge_status"], name: "index_merge_requests_on_stack_id_and_merge_status"
168
+ t.index ["stack_id", "number"], name: "index_merge_requests_on_stack_id_and_number", unique: true
169
+ t.index ["stack_id"], name: "index_merge_requests_on_stack_id"
170
+ end
171
+
172
+ create_table "output_chunks", force: :cascade do |t|
173
+ t.integer "task_id", limit: 4
174
+ t.text "text", limit: 16777215
175
+ t.datetime "created_at"
176
+ t.datetime "updated_at"
177
+ t.index ["task_id"], name: "index_output_chunks_on_task_id"
178
+ end
179
+
180
+ create_table "pull_request_assignments", force: :cascade do |t|
181
+ t.integer "pull_request_id"
182
+ t.integer "user_id"
183
+ t.index ["pull_request_id"], name: "index_pull_request_assignments_on_pull_request_id"
184
+ t.index ["user_id"], name: "index_pull_request_assignments_on_user_id"
185
+ end
186
+
187
+ create_table "pull_requests", force: :cascade do |t|
188
+ t.integer "stack_id", null: false
189
+ t.integer "number", null: false
190
+ t.string "title", limit: 256
191
+ t.integer "github_id", limit: 8
192
+ t.string "api_url", limit: 1024
193
+ t.string "state"
194
+ t.integer "additions", default: 0, null: false
195
+ t.integer "deletions", default: 0, null: false
196
+ t.integer "user_id"
197
+ t.text "labels"
198
+ t.integer "head_id"
199
+ t.datetime "created_at", precision: 6, null: false
200
+ t.datetime "updated_at", precision: 6, null: false
171
201
  t.index ["head_id"], name: "index_pull_requests_on_head_id"
172
- t.index ["merge_requested_by_id"], name: "index_pull_requests_on_merge_requested_by_id"
173
- t.index ["merge_status"], name: "index_pull_requests_on_merge_status"
174
202
  t.index ["stack_id", "github_id"], name: "index_pull_requests_on_stack_id_and_github_id", unique: true
175
- t.index ["stack_id", "merge_status"], name: "index_pull_requests_on_stack_id_and_merge_status"
176
203
  t.index ["stack_id", "number"], name: "index_pull_requests_on_stack_id_and_number", unique: true
177
204
  t.index ["stack_id"], name: "index_pull_requests_on_stack_id"
178
205
  end
@@ -197,6 +224,9 @@ ActiveRecord::Schema.define(version: 2020_06_15_181558) do
197
224
  t.string "name", limit: 100, null: false
198
225
  t.datetime "created_at", precision: 6, null: false
199
226
  t.datetime "updated_at", precision: 6, null: false
227
+ t.boolean "review_stacks_enabled", default: false
228
+ t.string "provisioning_behavior", default: "allow_all"
229
+ t.string "provisioning_label_name"
200
230
  t.index ["owner", "name"], name: "repository_unicity", unique: true
201
231
  end
202
232
 
@@ -221,9 +251,15 @@ ActiveRecord::Schema.define(version: 2020_06_15_181558) do
221
251
  t.datetime "last_deployed_at"
222
252
  t.integer "repository_id", null: false
223
253
  t.datetime "archived_since"
254
+ t.string "provision_status", default: "deprovisioned", null: false
255
+ t.string "type", default: "Shipit::Stack"
256
+ t.boolean "awaiting_provision", default: false, null: false
224
257
  t.index ["archived_since"], name: "index_stacks_on_archived_since"
258
+ t.index ["awaiting_provision"], name: "index_stacks_on_awaiting_provision"
259
+ t.index ["provision_status"], name: "index_stacks_on_provision_status"
225
260
  t.index ["repository_id", "environment"], name: "stack_unicity", unique: true
226
261
  t.index ["repository_id"], name: "index_stacks_on_repository_id"
262
+ t.index ["type"], name: "index_stacks_on_type"
227
263
  end
228
264
 
229
265
  create_table "statuses", force: :cascade do |t|
@@ -262,6 +298,8 @@ ActiveRecord::Schema.define(version: 2020_06_15_181558) do
262
298
  t.boolean "ignored_safeties", default: false, null: false
263
299
  t.integer "aborted_by_id"
264
300
  t.integer "rollback_once_aborted_to_id"
301
+ t.integer "retry_attempt", default: 0, null: false
302
+ t.integer "max_retries"
265
303
  t.index ["rolled_up", "created_at", "status"], name: "index_tasks_on_rolled_up_and_created_at_and_status"
266
304
  t.index ["since_commit_id"], name: "index_tasks_on_since_commit_id"
267
305
  t.index ["stack_id", "allow_concurrency", "status"], name: "index_active_tasks"
@@ -147,7 +147,7 @@ module Shipit
147
147
  end
148
148
  end
149
149
 
150
- stack.pull_requests.create!(
150
+ stack.merge_requests.create!(
151
151
  number: Faker::Number.number(digits: 3),
152
152
  title: Faker::Company.catch_phrase,
153
153
  merge_status: 'pending',
@@ -9,7 +9,7 @@
9
9
  "url": "https://api.github.com/repos/Shopify/shipit-engine/check-suites/5",
10
10
  "before": "146e867f55c26428e5f9fade55a9bbf5e95a7912",
11
11
  "after": "d6fde92930d4715a2b49857d24b940956b26d2d3",
12
- "pull_requests": [
12
+ "merge_requests": [
13
13
 
14
14
  ],
15
15
  "app": {
@@ -191,4 +191,4 @@
191
191
  "installation": {
192
192
  "id": 1
193
193
  }
194
- }
194
+ }
@@ -0,0 +1,117 @@
1
+ {
2
+ "action": "opened",
3
+ "repository": {
4
+ "id": 186853002,
5
+ "node_id": "MDEwOlJlcG9zaXRvcnkxODY4NTMwMDI=",
6
+ "name": "Hello-World",
7
+ "full_name": "Codertocat/Hello-World",
8
+ "private": false,
9
+ "owner": {
10
+ "login": "Codertocat",
11
+ "id": 21031067,
12
+ "node_id": "MDQ6VXNlcjIxMDMxMDY3",
13
+ "avatar_url": "https://avatars1.githubusercontent.com/u/21031067?v=4",
14
+ "gravatar_id": "",
15
+ "url": "https://api.github.com/users/Codertocat",
16
+ "html_url": "https://github.com/Codertocat",
17
+ "followers_url": "https://api.github.com/users/Codertocat/followers",
18
+ "following_url": "https://api.github.com/users/Codertocat/following{/other_user}",
19
+ "gists_url": "https://api.github.com/users/Codertocat/gists{/gist_id}",
20
+ "starred_url": "https://api.github.com/users/Codertocat/starred{/owner}{/repo}",
21
+ "subscriptions_url": "https://api.github.com/users/Codertocat/subscriptions",
22
+ "organizations_url": "https://api.github.com/users/Codertocat/orgs",
23
+ "repos_url": "https://api.github.com/users/Codertocat/repos",
24
+ "events_url": "https://api.github.com/users/Codertocat/events{/privacy}",
25
+ "received_events_url": "https://api.github.com/users/Codertocat/received_events",
26
+ "type": "User",
27
+ "site_admin": false
28
+ },
29
+ "html_url": "https://github.com/Codertocat/Hello-World",
30
+ "description": null,
31
+ "fork": false,
32
+ "url": "https://api.github.com/repos/Codertocat/Hello-World",
33
+ "forks_url": "https://api.github.com/repos/Codertocat/Hello-World/forks",
34
+ "keys_url": "https://api.github.com/repos/Codertocat/Hello-World/keys{/key_id}",
35
+ "collaborators_url": "https://api.github.com/repos/Codertocat/Hello-World/collaborators{/collaborator}",
36
+ "teams_url": "https://api.github.com/repos/Codertocat/Hello-World/teams",
37
+ "hooks_url": "https://api.github.com/repos/Codertocat/Hello-World/hooks",
38
+ "issue_events_url": "https://api.github.com/repos/Codertocat/Hello-World/issues/events{/number}",
39
+ "events_url": "https://api.github.com/repos/Codertocat/Hello-World/events",
40
+ "assignees_url": "https://api.github.com/repos/Codertocat/Hello-World/assignees{/user}",
41
+ "branches_url": "https://api.github.com/repos/Codertocat/Hello-World/branches{/branch}",
42
+ "tags_url": "https://api.github.com/repos/Codertocat/Hello-World/tags",
43
+ "blobs_url": "https://api.github.com/repos/Codertocat/Hello-World/git/blobs{/sha}",
44
+ "git_tags_url": "https://api.github.com/repos/Codertocat/Hello-World/git/tags{/sha}",
45
+ "git_refs_url": "https://api.github.com/repos/Codertocat/Hello-World/git/refs{/sha}",
46
+ "trees_url": "https://api.github.com/repos/Codertocat/Hello-World/git/trees{/sha}",
47
+ "statuses_url": "https://api.github.com/repos/Codertocat/Hello-World/statuses/{sha}",
48
+ "languages_url": "https://api.github.com/repos/Codertocat/Hello-World/languages",
49
+ "stargazers_url": "https://api.github.com/repos/Codertocat/Hello-World/stargazers",
50
+ "contributors_url": "https://api.github.com/repos/Codertocat/Hello-World/contributors",
51
+ "subscribers_url": "https://api.github.com/repos/Codertocat/Hello-World/subscribers",
52
+ "subscription_url": "https://api.github.com/repos/Codertocat/Hello-World/subscription",
53
+ "commits_url": "https://api.github.com/repos/Codertocat/Hello-World/commits{/sha}",
54
+ "git_commits_url": "https://api.github.com/repos/Codertocat/Hello-World/git/commits{/sha}",
55
+ "comments_url": "https://api.github.com/repos/Codertocat/Hello-World/comments{/number}",
56
+ "issue_comment_url": "https://api.github.com/repos/Codertocat/Hello-World/issues/comments{/number}",
57
+ "contents_url": "https://api.github.com/repos/Codertocat/Hello-World/contents/{+path}",
58
+ "compare_url": "https://api.github.com/repos/Codertocat/Hello-World/compare/{base}...{head}",
59
+ "merges_url": "https://api.github.com/repos/Codertocat/Hello-World/merges",
60
+ "archive_url": "https://api.github.com/repos/Codertocat/Hello-World/{archive_format}{/ref}",
61
+ "downloads_url": "https://api.github.com/repos/Codertocat/Hello-World/downloads",
62
+ "issues_url": "https://api.github.com/repos/Codertocat/Hello-World/issues{/number}",
63
+ "pulls_url": "https://api.github.com/repos/Codertocat/Hello-World/pulls{/number}",
64
+ "milestones_url": "https://api.github.com/repos/Codertocat/Hello-World/milestones{/number}",
65
+ "notifications_url": "https://api.github.com/repos/Codertocat/Hello-World/notifications{?since,all,participating}",
66
+ "labels_url": "https://api.github.com/repos/Codertocat/Hello-World/labels{/name}",
67
+ "releases_url": "https://api.github.com/repos/Codertocat/Hello-World/releases{/id}",
68
+ "deployments_url": "https://api.github.com/repos/Codertocat/Hello-World/deployments",
69
+ "created_at": "2019-05-15T15:19:25Z",
70
+ "updated_at": "2019-05-15T15:19:27Z",
71
+ "pushed_at": "2019-05-15T15:20:32Z",
72
+ "git_url": "git://github.com/Codertocat/Hello-World.git",
73
+ "ssh_url": "git@github.com:Codertocat/Hello-World.git",
74
+ "clone_url": "https://github.com/Codertocat/Hello-World.git",
75
+ "svn_url": "https://github.com/Codertocat/Hello-World",
76
+ "homepage": null,
77
+ "size": 0,
78
+ "stargazers_count": 0,
79
+ "watchers_count": 0,
80
+ "language": null,
81
+ "has_issues": true,
82
+ "has_projects": true,
83
+ "has_downloads": true,
84
+ "has_wiki": true,
85
+ "has_pages": true,
86
+ "forks_count": 0,
87
+ "mirror_url": null,
88
+ "archived": false,
89
+ "disabled": false,
90
+ "open_issues_count": 2,
91
+ "license": null,
92
+ "forks": 0,
93
+ "open_issues": 2,
94
+ "watchers": 0,
95
+ "default_branch": "master"
96
+ },
97
+ "sender": {
98
+ "login": "Codertocat",
99
+ "id": 21031067,
100
+ "node_id": "MDQ6VXNlcjIxMDMxMDY3",
101
+ "avatar_url": "https://avatars1.githubusercontent.com/u/21031067?v=4",
102
+ "gravatar_id": "",
103
+ "url": "https://api.github.com/users/Codertocat",
104
+ "html_url": "https://github.com/Codertocat",
105
+ "followers_url": "https://api.github.com/users/Codertocat/followers",
106
+ "following_url": "https://api.github.com/users/Codertocat/following{/other_user}",
107
+ "gists_url": "https://api.github.com/users/Codertocat/gists{/gist_id}",
108
+ "starred_url": "https://api.github.com/users/Codertocat/starred{/owner}{/repo}",
109
+ "subscriptions_url": "https://api.github.com/users/Codertocat/subscriptions",
110
+ "organizations_url": "https://api.github.com/users/Codertocat/orgs",
111
+ "repos_url": "https://api.github.com/users/Codertocat/repos",
112
+ "events_url": "https://api.github.com/users/Codertocat/events{/privacy}",
113
+ "received_events_url": "https://api.github.com/users/Codertocat/received_events",
114
+ "type": "User",
115
+ "site_admin": false
116
+ }
117
+ }