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
@@ -0,0 +1,74 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Shipit
4
+ class RepositoriesController < ShipitController
5
+ before_action :load_repository, only: %i(destroy settings update new_stack)
6
+
7
+ def index
8
+ @user_repositories = current_user.repositories_contributed_to
9
+
10
+ @repositories = Repository.order(:owner, :name).to_a
11
+ end
12
+
13
+ def show
14
+ @repository = Repository.from_param!(params[:id])
15
+
16
+ @stacks = @repository.stacks
17
+
18
+ @show_archived = params[:show_archived]
19
+ @stacks = @stacks.not_archived unless @show_archived
20
+ end
21
+
22
+ def create
23
+ @repository = Repository.new(create_params)
24
+ unless @repository.save
25
+ flash[:warning] = @repository.errors.full_messages.to_sentence
26
+ end
27
+ respond_with(@repository)
28
+ end
29
+
30
+ def new
31
+ @repository = Repository.new
32
+ end
33
+
34
+ def destroy
35
+ @repository.schedule_for_destroy!
36
+ redirect_to(repositories_url)
37
+ end
38
+
39
+ def update
40
+ options = {}
41
+ unless @repository.update(update_params)
42
+ options = { flash: { warning: @repository.errors.full_messages.to_sentence } }
43
+ end
44
+
45
+ redirect_to(params[:return_to].presence || repository_settings_path(@repository), options)
46
+ end
47
+
48
+ def settings
49
+ end
50
+
51
+ def new_stack
52
+ @stack = @repository.stacks.new
53
+ render("shipit/stacks/new")
54
+ end
55
+
56
+ private
57
+
58
+ def create_params
59
+ params.require(:repository).permit(:owner, :name)
60
+ end
61
+
62
+ def update_params
63
+ params.require(:repository).permit(
64
+ :review_stacks_enabled,
65
+ :provisioning_behavior,
66
+ :provisioning_label_name,
67
+ )
68
+ end
69
+
70
+ def load_repository
71
+ @repository = Repository.from_param!(params[:id])
72
+ end
73
+ end
74
+ end
@@ -22,7 +22,7 @@ module Shipit
22
22
  task
23
23
  respond_to do |format|
24
24
  format.html
25
- format.text { render plain: @task.chunk_output }
25
+ format.text { render(plain: @task.chunk_output) }
26
26
  end
27
27
  end
28
28
 
@@ -48,7 +48,7 @@ module Shipit
48
48
  end
49
49
 
50
50
  def tail
51
- render(json: TailTaskSerializer.new(task, context: params))
51
+ render(json: TailTaskSerializer.new(task, context: { last_byte: params[:last_byte].to_i }))
52
52
  end
53
53
 
54
54
  def lookup
@@ -62,7 +62,7 @@ module Shipit
62
62
  def url_for_task
63
63
  base_task = @task.is_a?(Deploy) ? @task.becomes(Deploy) : @task
64
64
 
65
- url_for([base_task.stack, base_task])
65
+ url_for([base_task.stack.becomes(Stack), base_task])
66
66
  end
67
67
 
68
68
  def task
@@ -70,7 +70,7 @@ module Shipit
70
70
  end
71
71
 
72
72
  def stack
73
- @stack ||= Stack.from_param!(params[:stack_id])
73
+ @stack ||= Stack.from_param!(params[:stack_id]).becomes(Stack)
74
74
  end
75
75
 
76
76
  def task_params
@@ -1,9 +1,9 @@
1
1
  # frozen_string_literal: true
2
2
  module Shipit
3
3
  module ChunksHelper
4
- def next_chunks_url(task)
4
+ def next_chunks_url(task, last_byte: 0)
5
5
  return if task.finished?
6
- tail_stack_task_path(task.stack, task, last_id: task.chunks.last)
6
+ tail_stack_task_path(task.stack, task, last_byte: last_byte)
7
7
  end
8
8
  end
9
9
  end
@@ -51,6 +51,14 @@ module Shipit
51
51
  github_repo_url(stack.repo_owner, stack.repo_name, 'pull', number)
52
52
  end
53
53
 
54
+ def stack_github_url(stack)
55
+ if stack.respond_to?(:pull_request) && stack.pull_request
56
+ github_pull_request_url(stack.pull_request)
57
+ else
58
+ github_repo_url(stack.repo_owner, stack.repo_name)
59
+ end
60
+ end
61
+
54
62
  def link_to_github_deploy(deploy)
55
63
  url = github_commit_range_url(deploy.stack, *deploy.commit_range)
56
64
  text = deploy.commit_range.map(&:short_sha).join('...')
@@ -91,5 +91,9 @@ module Shipit
91
91
  def positive_negative_class(value)
92
92
  value.to_f >= 0 ? 'positive' : 'negative'
93
93
  end
94
+
95
+ def contributor_class(stacks_contributed_to, stack_id)
96
+ stacks_contributed_to.include?(stack_id) ? "contributor" : "not-matching"
97
+ end
94
98
  end
95
99
  end
@@ -4,6 +4,7 @@ module Shipit
4
4
  include BackgroundJob::Unique
5
5
 
6
6
  queue_as :default
7
+ on_duplicate :drop
7
8
 
8
9
  # We observe that some objects regularly take longer than the default 10 seconds to create, e.g. deployments
9
10
  self.timeout = 40
@@ -0,0 +1,24 @@
1
+ # frozen_string_literal: true
2
+ module Shipit
3
+ class DestroyRepositoryJob < BackgroundJob
4
+ queue_as :default
5
+
6
+ # repository
7
+ # +-- stacks
8
+ # +-- api_clients
9
+ # +-- commits
10
+ # | +-- commit_deployments
11
+ # | | +-- statuses
12
+ # | +-- statuses
13
+ # +-- github_hooks
14
+ # +-- hooks
15
+ # +-- pull_requests
16
+ # +-- tasks
17
+ # +-- chunks
18
+
19
+ def perform(repository)
20
+ repository.stacks.each { |stack| DestroyStackJob.perform_now(stack) }
21
+ repository.destroy!
22
+ end
23
+ end
24
+ end
@@ -11,7 +11,7 @@ module Shipit
11
11
  # | +-- statuses
12
12
  # +-- github_hooks
13
13
  # +-- hooks
14
- # +-- pull_requests
14
+ # +-- merge_requests
15
15
  # +-- tasks
16
16
  # +-- chunks
17
17
 
@@ -26,7 +26,7 @@ module Shipit
26
26
  Shipit::Commit.where(id: commits_ids).delete_all
27
27
  Shipit::GithubHook.where(stack_id: stack.id).destroy_all
28
28
  Shipit::Hook.where(stack_id: stack.id).delete_all
29
- Shipit::PullRequest.where(stack_id: stack.id).delete_all
29
+ Shipit::MergeRequest.where(stack_id: stack.id).delete_all
30
30
  tasks_ids.each_slice(100) do |ids|
31
31
  Shipit::OutputChunk.where(task_id: ids).delete_all
32
32
  Shipit::Task.where(id: ids).delete_all
@@ -4,104 +4,10 @@ module Shipit
4
4
  queue_as :deploys
5
5
 
6
6
  def perform(task)
7
- @task = task
8
- @commands = Commands.for(@task)
9
- unless @task.pending?
10
- logger.error("Task ##{@task.id} already in `#{@task.status}` state. Aborting.")
11
- return
12
- end
13
- run
14
- ensure
15
- @commands.clear_working_directory
16
- end
17
-
18
- def run
19
- @task.ping
20
- @task.run!
21
- checkout_repository
22
- perform_task
23
- @task.write("\nCompleted successfully\n")
24
- @task.report_complete!
25
- rescue Command::TimedOut => error
26
- @task.write("\n#{error.message}\n")
27
- @task.report_timeout!(error)
28
- rescue Command::Error => error
29
- @task.write("\n#{error.message}\n")
30
- @task.report_failure!(error)
31
- rescue StandardError => error
32
- @task.report_error!(error)
33
- rescue Exception => error
34
- @task.report_error!(error)
35
- raise
36
- end
37
-
38
- def abort!(signal: 'TERM')
39
- pid = @task.pid
40
- if pid
41
- @task.write("$ kill #{pid}\n")
42
- Process.kill(signal, pid)
43
- else
44
- @task.write("Can't abort, no recorded pid, WTF?\n")
45
- end
46
- rescue SystemCallError => error
47
- @task.write("kill: (#{pid}) - #{error.message}\n")
48
- end
49
-
50
- def check_for_abort
51
- @task.should_abort? do |times_killed|
52
- if times_killed > 3
53
- abort!(signal: 'KILL')
54
- else
55
- abort!
56
- end
57
- end
58
- end
59
-
60
- def perform_task
61
- capture_all!(@commands.install_dependencies)
62
- capture_all!(@commands.perform)
63
- end
64
-
65
- def checkout_repository
66
- unless @commands.fetched?(@task.until_commit).tap(&:run).success?
67
- # acquire_git_cache_lock can take upto 15 seconds
68
- # to process. Try to make sure that the job isn't
69
- # marked dead while we attempt to acquire the lock.
70
- @task.ping
71
- @task.acquire_git_cache_lock do
72
- @task.ping
73
- unless @commands.fetched?(@task.until_commit).tap(&:run).success?
74
- capture!(@commands.fetch)
75
- end
76
- end
77
- end
78
- capture_all!(@commands.clone)
79
- capture!(@commands.checkout(@task.until_commit))
80
- end
81
-
82
- def capture_all!(commands)
83
- commands.map { |c| capture!(c) }
84
- end
85
-
86
- def capture!(command)
87
- command.start do
88
- @task.ping
89
- check_for_abort
90
- end
91
- @task.write("$ #{command}\npid: #{command.pid}\n")
92
- @task.pid = command.pid
93
- command.stream! do |line|
94
- @task.write(line)
95
- end
96
- @task.write("\n")
97
- command.success?
98
- end
99
-
100
- def capture(command)
101
- capture!(command)
102
- command.success?
103
- rescue Command::Error
104
- false
7
+ Shipit
8
+ .task_execution_strategy
9
+ .new(task)
10
+ .execute
105
11
  end
106
12
  end
107
13
  end
@@ -0,0 +1,32 @@
1
+ # frozen_string_literal: true
2
+ module Shipit
3
+ class ProcessMergeRequestsJob < BackgroundJob
4
+ include BackgroundJob::Unique
5
+ on_duplicate :drop
6
+
7
+ queue_as :default
8
+
9
+ def perform(stack)
10
+ merge_requests = stack.merge_requests.to_be_merged.to_a
11
+ merge_requests.each do |merge_request|
12
+ merge_request.refresh!
13
+ merge_request.reject_unless_mergeable!
14
+ merge_request.cancel! if merge_request.closed?
15
+ merge_request.revalidate! if merge_request.need_revalidation?
16
+ end
17
+
18
+ return false unless stack.allows_merges?
19
+
20
+ merge_requests.select(&:pending?).each do |merge_request|
21
+ merge_request.refresh!
22
+ next unless merge_request.all_status_checks_passed?
23
+ begin
24
+ merge_request.merge!
25
+ rescue MergeRequest::NotReady
26
+ ProcessMergeRequestsJob.set(wait: 10.seconds).perform_later(stack)
27
+ return false
28
+ end
29
+ end
30
+ end
31
+ end
32
+ end
@@ -0,0 +1,11 @@
1
+ # frozen_string_literal: true
2
+ module Shipit
3
+ class RefreshMergeRequestJob < BackgroundJob
4
+ queue_as :default
5
+
6
+ def perform(merge_request)
7
+ merge_request.refresh!
8
+ ProcessMergeRequestsJob.perform_later(merge_request.stack)
9
+ end
10
+ end
11
+ end
@@ -35,6 +35,10 @@ module Shipit
35
35
  Shipit.authentication_disabled?
36
36
  end
37
37
 
38
+ def repositories_contributed_to
39
+ []
40
+ end
41
+
38
42
  def stacks_contributed_to
39
43
  []
40
44
  end
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
  module Shipit
3
3
  class CheckRun < ApplicationRecord
4
- CONCLUSIONS = %w(success failure neutral cancelled timed_out action_required stale).freeze
4
+ CONCLUSIONS = %w(success failure neutral cancelled timed_out action_required stale skipped).freeze
5
5
  include DeferredTouch
6
6
  include Status::Common
7
7
 
@@ -44,7 +44,7 @@ module Shipit
44
44
  case conclusion
45
45
  when nil, 'action_required'
46
46
  'pending'
47
- when 'success', 'neutral'
47
+ when 'success', 'neutral', 'skipped'
48
48
  'success'
49
49
  when 'failure', 'cancelled', 'stale'
50
50
  'failure'
@@ -35,6 +35,10 @@ module Shipit
35
35
  Shipit.authentication_disabled?
36
36
  end
37
37
 
38
+ def repositories_contributed_to
39
+ []
40
+ end
41
+
38
42
  def stacks_contributed_to
39
43
  []
40
44
  end
@@ -13,11 +13,11 @@ module Shipit
13
13
  has_many :check_runs, -> { order(created_at: :desc) }, dependent: :destroy, inverse_of: :commit
14
14
  has_many :commit_deployments, dependent: :destroy
15
15
  has_many :release_statuses, dependent: :destroy
16
- belongs_to :pull_request, inverse_of: :merge_commit, optional: true
16
+ belongs_to :merge_request, inverse_of: :merge_commit, optional: true
17
17
 
18
18
  deferred_touch stack: :updated_at
19
19
 
20
- before_create :identify_pull_request
20
+ before_create :identify_merge_request
21
21
  after_commit { broadcast_update }
22
22
  after_create { stack.update_undeployed_commits_count }
23
23
 
@@ -113,7 +113,7 @@ module Shipit
113
113
 
114
114
  def message=(message)
115
115
  limit = self.class.columns_hash['message'].limit
116
- if limit && message && message.size > limit
116
+ if limit && message && message.bytesize > limit
117
117
  message = message.truncate_bytes(limit)
118
118
  end
119
119
  super(message)
@@ -287,13 +287,13 @@ module Shipit
287
287
  stack.deploys.unsuccessful.where(until_commit_id: id).any?
288
288
  end
289
289
 
290
- def identify_pull_request
290
+ def identify_merge_request
291
291
  return unless message_parser.pull_request?
292
- if pull_request = stack.pull_requests.find_by(number: message_parser.pull_request_number)
293
- self.pull_request = pull_request
294
- self.pull_request_number = pull_request.number
295
- self.pull_request_title = pull_request.title
296
- self.author = pull_request.merge_requested_by if pull_request.merge_requested_by
292
+ if merge_request = stack.merge_requests.find_by(number: message_parser.pull_request_number)
293
+ self.merge_request = merge_request
294
+ self.pull_request_number = merge_request.number
295
+ self.pull_request_title = merge_request.title
296
+ self.author = merge_request.merge_requested_by if merge_request.merge_requested_by
297
297
  end
298
298
 
299
299
  self.pull_request_number = message_parser.pull_request_number unless self[:pull_request_number]
@@ -301,8 +301,8 @@ module Shipit
301
301
  end
302
302
 
303
303
  def deploy_requested_at
304
- if pull_request&.merged?
305
- pull_request.merge_requested_at
304
+ if merge_request&.merged?
305
+ merge_request.merge_requested_at
306
306
  else
307
307
  created_at
308
308
  end