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.
- checksums.yaml +4 -4
- data/app/assets/images/magic-solid.svg +1 -0
- data/app/assets/javascripts/shipit/repositories_search.js.coffee +60 -0
- data/app/assets/javascripts/shipit/{search.js.coffee → stack_search.js.coffee} +0 -0
- data/app/assets/stylesheets/_pages/_repositories.scss +148 -0
- data/app/assets/stylesheets/_pages/_stacks.scss +19 -0
- data/app/assets/stylesheets/shipit.scss +1 -0
- data/app/controllers/shipit/api/{pull_requests_controller.rb → merge_requests_controller.rb} +8 -8
- data/app/controllers/shipit/api/stacks_controller.rb +14 -1
- data/app/controllers/shipit/deploys_controller.rb +2 -2
- data/app/controllers/shipit/merge_requests_controller.rb +31 -0
- data/app/controllers/shipit/merge_status_controller.rb +15 -15
- data/app/controllers/shipit/repositories_controller.rb +74 -0
- data/app/controllers/shipit/tasks_controller.rb +4 -4
- data/app/helpers/shipit/chunks_helper.rb +2 -2
- data/app/helpers/shipit/github_url_helper.rb +8 -0
- data/app/helpers/shipit/stacks_helper.rb +4 -0
- data/app/jobs/shipit/create_on_github_job.rb +1 -0
- data/app/jobs/shipit/destroy_repository_job.rb +24 -0
- data/app/jobs/shipit/destroy_stack_job.rb +2 -2
- data/app/jobs/shipit/perform_task_job.rb +4 -98
- data/app/jobs/shipit/process_merge_requests_job.rb +32 -0
- data/app/jobs/shipit/refresh_merge_request_job.rb +11 -0
- data/app/models/shipit/anonymous_user.rb +4 -0
- data/app/models/shipit/check_run.rb +2 -2
- data/app/models/shipit/command_line_user.rb +4 -0
- data/app/models/shipit/commit.rb +11 -11
- data/app/models/shipit/commit_checks.rb +1 -0
- data/app/models/shipit/deploy.rb +1 -0
- data/app/models/shipit/deploy_spec.rb +16 -4
- data/app/models/shipit/deploy_spec/file_system.rb +11 -5
- data/app/models/shipit/hook.rb +2 -0
- data/app/models/shipit/merge_request.rb +302 -0
- data/app/models/shipit/provisioning_handler.rb +32 -0
- data/app/models/shipit/provisioning_handler/base.rb +30 -0
- data/app/models/shipit/provisioning_handler/unregistered_provisioning_handler.rb +35 -0
- data/app/models/shipit/pull_request.rb +25 -264
- data/app/models/shipit/pull_request_assignment.rb +10 -0
- data/app/models/shipit/repository.rb +54 -0
- data/app/models/shipit/review_stack.rb +116 -0
- data/app/models/shipit/review_stack_provisioning_queue.rb +39 -0
- data/app/models/shipit/stack.rb +22 -8
- data/app/models/shipit/task.rb +56 -7
- data/app/models/shipit/task_execution_strategy/base.rb +20 -0
- data/app/models/shipit/task_execution_strategy/default.rb +110 -0
- data/app/models/shipit/user.rb +6 -1
- data/app/models/shipit/webhooks.rb +10 -0
- data/app/models/shipit/webhooks/handlers/pull_request/assigned_handler.rb +74 -0
- data/app/models/shipit/webhooks/handlers/pull_request/closed_handler.rb +68 -0
- data/app/models/shipit/webhooks/handlers/pull_request/edited_handler.rb +74 -0
- data/app/models/shipit/webhooks/handlers/pull_request/label_capturing_handler.rb +127 -0
- data/app/models/shipit/webhooks/handlers/pull_request/labeled_handler.rb +106 -0
- data/app/models/shipit/webhooks/handlers/pull_request/opened_handler.rb +83 -0
- data/app/models/shipit/webhooks/handlers/pull_request/reopened_handler.rb +88 -0
- data/app/models/shipit/webhooks/handlers/pull_request/review_stack_adapter.rb +103 -0
- data/app/models/shipit/webhooks/handlers/pull_request/unlabeled_handler.rb +107 -0
- data/app/serializers/shipit/deploy_serializer.rb +6 -0
- data/app/serializers/shipit/merge_request_serializer.rb +21 -0
- data/app/serializers/shipit/pull_request_serializer.rb +5 -8
- data/app/serializers/shipit/review_stack_serializer.rb +7 -0
- data/app/serializers/shipit/stack_serializer.rb +7 -6
- data/app/serializers/shipit/tail_task_serializer.rb +10 -2
- data/app/serializers/shipit/task_serializer.rb +1 -1
- data/app/views/shipit/merge_requests/_merge_request.html.erb +29 -0
- data/app/views/shipit/{pull_requests → merge_requests}/index.html.erb +2 -2
- data/app/views/shipit/merge_requests/merge_requests/_pull_request.html.erb +29 -0
- data/app/views/shipit/merge_requests/merge_requests/index.html.erb +20 -0
- data/app/views/shipit/merge_status/_merge_queue_button.html.erb +3 -3
- data/app/views/shipit/merge_status/backlogged.html.erb +1 -1
- data/app/views/shipit/merge_status/failure.html.erb +1 -1
- data/app/views/shipit/merge_status/locked.html.erb +1 -1
- data/app/views/shipit/merge_status/success.html.erb +2 -2
- data/app/views/shipit/repositories/_header.html.erb +19 -0
- data/app/views/shipit/repositories/index.html.erb +31 -0
- data/app/views/shipit/repositories/new.html.erb +23 -0
- data/app/views/shipit/repositories/settings.html.erb +53 -0
- data/app/views/shipit/repositories/show.html.erb +30 -0
- data/app/views/shipit/stacks/_banners.html.erb +13 -0
- data/app/views/shipit/stacks/_header.html.erb +5 -2
- data/app/views/shipit/stacks/_stack.html.erb +8 -0
- data/app/views/shipit/stacks/index.html.erb +2 -1
- data/app/views/shipit/stacks/settings.html.erb +5 -5
- data/app/views/shipit/stacks/show.html.erb +1 -1
- data/app/views/shipit/tasks/_task_output.html.erb +1 -1
- data/config/routes.rb +15 -5
- data/db/migrate/20200706145406_add_review_stacks.rb +12 -0
- data/db/migrate/20200804144639_rename_pull_request_to_merge_request.rb +7 -0
- data/db/migrate/20200804161512_rename_commits_pull_request_id_to_merge_request_id.rb +5 -0
- data/db/migrate/20200813134712_recreate_shipit_pull_requests.rb +22 -0
- data/db/migrate/20200813194056_create_pull_request_assignments.rb +8 -0
- data/db/migrate/20201001125502_add_provision_pr_stacks_flag_to_repositories.rb +7 -0
- data/db/migrate/20201008145809_add_retry_attempt_to_tasks.rb +5 -0
- data/db/migrate/20201008152744_add_max_retries_to_tasks.rb +5 -0
- data/lib/shipit.rb +11 -1
- data/lib/shipit/github_app.rb +1 -1
- data/lib/shipit/review_stack_commands.rb +8 -0
- data/lib/shipit/stack_commands.rb +6 -1
- data/lib/shipit/task_commands.rb +1 -0
- data/lib/shipit/version.rb +1 -1
- data/lib/tasks/cron.rake +11 -2
- data/test/controllers/api/{pull_requests_controller_test.rb → merge_requests_controller_test.rb} +12 -12
- data/test/controllers/api/outputs_controller_test.rb +1 -0
- data/test/controllers/api/rollback_controller_test.rb +1 -1
- data/test/controllers/api/stacks_controller_test.rb +21 -1
- data/test/controllers/{pull_requests_controller_test.rb → merge_requests_controller_test.rb} +6 -6
- data/test/controllers/repositories_controller_test.rb +71 -0
- data/test/controllers/stacks_controller_test.rb +9 -1
- data/test/controllers/tasks_controller_test.rb +14 -2
- data/test/controllers/webhooks_controller_test.rb +1 -1
- data/test/dummy/config/application.rb +6 -1
- data/test/dummy/config/environments/development.rb +0 -3
- data/test/dummy/config/environments/test.rb +0 -5
- data/test/dummy/db/schema.rb +52 -14
- data/test/dummy/db/seeds.rb +1 -1
- data/test/fixtures/payloads/check_suite_master.json +2 -2
- data/test/fixtures/payloads/invalid_pull_request.json +117 -0
- data/test/fixtures/payloads/provision_disabled_pull_request.json +454 -0
- data/test/fixtures/payloads/pull_request_assigned.json +480 -0
- data/test/fixtures/payloads/pull_request_closed.json +454 -0
- data/test/fixtures/payloads/pull_request_labeled.json +461 -0
- data/test/fixtures/payloads/pull_request_opened.json +454 -0
- data/test/fixtures/payloads/pull_request_reopened.json +454 -0
- data/test/fixtures/payloads/pull_request_unlabeled.json +454 -0
- data/test/fixtures/payloads/pull_request_with_no_repo.json +454 -0
- data/test/fixtures/shipit/commits.yml +15 -2
- data/test/fixtures/shipit/merge_requests.yml +141 -0
- data/test/fixtures/shipit/pull_request_assignments.yml +3 -0
- data/test/fixtures/shipit/pull_requests.yml +10 -131
- data/test/fixtures/shipit/repositories.yml +1 -0
- data/test/fixtures/shipit/stacks.yml +145 -0
- data/test/fixtures/shipit/statuses.yml +9 -0
- data/test/fixtures/shipit/tasks.yml +3 -0
- data/test/fixtures/shipit/users.yml +7 -0
- data/test/helpers/payloads_helper.rb +4 -0
- data/test/jobs/chunk_rollup_job_test.rb +15 -1
- data/test/jobs/destroy_repository_job_test.rb +27 -0
- data/test/jobs/perform_task_job_test.rb +8 -8
- data/test/jobs/{merge_pull_requests_job_test.rb → process_merge_requests_job_test.rb} +18 -18
- data/test/lib/shipit/deploy_commands_test.rb +16 -0
- data/test/lib/shipit/task_commands_test.rb +17 -0
- data/test/models/commits_test.rb +22 -13
- data/test/models/deploy_spec_test.rb +57 -24
- data/test/models/deploys_test.rb +148 -14
- data/test/models/{pull_request_test.rb → merge_request_test.rb} +30 -30
- data/test/models/pull_request_assignment_test.rb +16 -0
- data/test/models/shipit/provisioning_handler/base_test.rb +33 -0
- data/test/models/shipit/provisioning_handler/unregistered_provisioning_handler_test.rb +49 -0
- data/test/models/shipit/provisioning_handler_test.rb +64 -0
- data/test/models/shipit/pull_request_test.rb +52 -0
- data/test/models/shipit/repository_test.rb +5 -1
- data/test/models/shipit/review_stack_provision_status_test.rb +77 -0
- data/test/models/shipit/review_stack_provisioning_queue_test.rb +63 -0
- data/test/models/shipit/review_stack_test.rb +59 -0
- data/test/models/{stacks_test.rb → shipit/stacks_test.rb} +10 -4
- data/test/models/shipit/webhooks/handlers/pull_request/assigned_handler_test.rb +45 -0
- data/test/models/shipit/webhooks/handlers/pull_request/closed_handler_test.rb +192 -0
- data/test/models/shipit/webhooks/handlers/pull_request/edited_handler_test.rb +47 -0
- data/test/models/shipit/webhooks/handlers/pull_request/label_capturing_handler_test.rb +209 -0
- data/test/models/shipit/webhooks/handlers/pull_request/labeled_handler_test.rb +332 -0
- data/test/models/shipit/webhooks/handlers/pull_request/opened_handler_test.rb +238 -0
- data/test/models/shipit/webhooks/handlers/pull_request/reopened_handler_test.rb +282 -0
- data/test/models/shipit/webhooks/handlers/pull_request/review_stack_adapter_test.rb +83 -0
- data/test/models/shipit/webhooks/handlers/pull_request/unlabeled_handler_test.rb +324 -0
- data/test/models/shipit/{wehbooks → webhooks}/handlers_test.rb +0 -0
- data/test/models/tasks_test.rb +44 -3
- data/test/serializers/shipit/pull_request_serializer_test.rb +29 -0
- data/test/unit/command_test.rb +3 -3
- data/test/unit/github_url_helper_test.rb +5 -0
- data/test/unit/shipit_task_execution_strategy_test.rb +47 -0
- metadata +260 -154
- data/app/controllers/shipit/pull_requests_controller.rb +0 -31
- data/app/jobs/shipit/merge_pull_requests_job.rb +0 -32
- data/app/jobs/shipit/refresh_pull_request_job.rb +0 -11
- data/app/views/shipit/pull_requests/_pull_request.html.erb +0 -29
- data/test/fixtures/shipit/output_chunks.yml +0 -47
- data/test/models/output_chunk_test.rb +0 -21
@@ -1,31 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
module Shipit
|
3
|
-
class PullRequestsController < ShipitController
|
4
|
-
def index
|
5
|
-
@pull_requests = stack.pull_requests.queued
|
6
|
-
end
|
7
|
-
|
8
|
-
def create
|
9
|
-
if pr_number = PullRequest.extract_number(stack, params[:number_or_url])
|
10
|
-
pull_request = PullRequest.request_merge!(stack, pr_number, current_user)
|
11
|
-
flash[:success] = "Pull request ##{pull_request.number} added to the queue."
|
12
|
-
else
|
13
|
-
flash[:warning] = "Invalid or missing pull request number."
|
14
|
-
end
|
15
|
-
redirect_to(stack_pull_requests_path)
|
16
|
-
end
|
17
|
-
|
18
|
-
def destroy
|
19
|
-
pull_request = stack.pull_requests.find(params[:id])
|
20
|
-
pull_request.cancel!
|
21
|
-
flash[:success] = 'Merge canceled'
|
22
|
-
redirect_to(stack_pull_requests_path)
|
23
|
-
end
|
24
|
-
|
25
|
-
private
|
26
|
-
|
27
|
-
def stack
|
28
|
-
@stack ||= Stack.from_param!(params[:stack_id])
|
29
|
-
end
|
30
|
-
end
|
31
|
-
end
|
@@ -1,32 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
module Shipit
|
3
|
-
class MergePullRequestsJob < BackgroundJob
|
4
|
-
include BackgroundJob::Unique
|
5
|
-
on_duplicate :drop
|
6
|
-
|
7
|
-
queue_as :default
|
8
|
-
|
9
|
-
def perform(stack)
|
10
|
-
pull_requests = stack.pull_requests.to_be_merged.to_a
|
11
|
-
pull_requests.each do |pull_request|
|
12
|
-
pull_request.refresh!
|
13
|
-
pull_request.reject_unless_mergeable!
|
14
|
-
pull_request.cancel! if pull_request.closed?
|
15
|
-
pull_request.revalidate! if pull_request.need_revalidation?
|
16
|
-
end
|
17
|
-
|
18
|
-
return false unless stack.allows_merges?
|
19
|
-
|
20
|
-
pull_requests.select(&:pending?).each do |pull_request|
|
21
|
-
pull_request.refresh!
|
22
|
-
next unless pull_request.all_status_checks_passed?
|
23
|
-
begin
|
24
|
-
pull_request.merge!
|
25
|
-
rescue PullRequest::NotReady
|
26
|
-
MergePullRequestsJob.set(wait: 10.seconds).perform_later(stack)
|
27
|
-
return false
|
28
|
-
end
|
29
|
-
end
|
30
|
-
end
|
31
|
-
end
|
32
|
-
end
|
@@ -1,29 +0,0 @@
|
|
1
|
-
<li class="pr" id="pr-<%= pull_request.id %>">
|
2
|
-
<%= render 'shipit/shared/author', author: pull_request.merge_requested_by %>
|
3
|
-
<div class="pr-details">
|
4
|
-
<span class="pr-number">
|
5
|
-
<%= pull_request_link(pull_request) %>
|
6
|
-
</span>
|
7
|
-
<span class="pr-title">
|
8
|
-
<%= render_pull_request_title_with_link pull_request %>
|
9
|
-
</span>
|
10
|
-
<p class="pr-meta">
|
11
|
-
<span class="code-additions">+<%= pull_request.additions %></span>
|
12
|
-
<span class="code-deletions">-<%= pull_request.deletions %></span>
|
13
|
-
</p>
|
14
|
-
<p class="pr-meta">
|
15
|
-
Enqueued <%= timeago_tag(pull_request.merge_requested_at, force: true) %>
|
16
|
-
<% if pull_request.revalidating? %>
|
17
|
-
<em class="warning">Need revalidation.</em>
|
18
|
-
<% end %>
|
19
|
-
</p>
|
20
|
-
</div>
|
21
|
-
<% if pull_request.revalidating? %>
|
22
|
-
<div class="commit-actions">
|
23
|
-
<%= button_to 'Confirm', stack_pull_requests_path(pull_request.stack, number_or_url: pull_request.number), class: 'btn btn--warning', method: 'post' %>
|
24
|
-
</div>
|
25
|
-
<% end %>
|
26
|
-
<div class="commit-actions">
|
27
|
-
<%= button_to 'Cancel', stack_pull_request_path(pull_request.stack, pull_request), class: 'btn btn--warning', method: 'delete' %>
|
28
|
-
</div>
|
29
|
-
</li>
|
@@ -1,47 +0,0 @@
|
|
1
|
-
shipit:
|
2
|
-
task_id: 1 # shipit
|
3
|
-
text: "deploy deploy deploy, faiiil"
|
4
|
-
|
5
|
-
shipit2:
|
6
|
-
task_id: 1 # shipit
|
7
|
-
text: "Migrating some stuff"
|
8
|
-
|
9
|
-
shipit3:
|
10
|
-
task_id: 1 # shipit
|
11
|
-
text: "Compiling all the sass"
|
12
|
-
|
13
|
-
shipit4:
|
14
|
-
task_id: 1 # shipit
|
15
|
-
text: "Making ops cry"
|
16
|
-
|
17
|
-
shipit5:
|
18
|
-
task_id: 1 # shipit
|
19
|
-
text: "sudo rm -rf /"
|
20
|
-
|
21
|
-
shipit6:
|
22
|
-
task_id: 1 # shipit
|
23
|
-
text: "sudo chmod -R 777 /"
|
24
|
-
|
25
|
-
shipit_running:
|
26
|
-
task_id: 5 # shipit_running
|
27
|
-
text: "deploy deploy deploy, faiiil"
|
28
|
-
|
29
|
-
shipit_running:
|
30
|
-
task_id: 5 # shipit_running
|
31
|
-
text: "Migrating some stuff"
|
32
|
-
|
33
|
-
shipit_running3:
|
34
|
-
task_id: 5 # shipit_running
|
35
|
-
text: "Compiling all the sass"
|
36
|
-
|
37
|
-
shipit_running4:
|
38
|
-
task_id: 5 # shipit_running
|
39
|
-
text: "Making ops cry"
|
40
|
-
|
41
|
-
shipit_running5:
|
42
|
-
task_id: 5 # shipit_running
|
43
|
-
text: "sudo rm -rf /"
|
44
|
-
|
45
|
-
shipit_running6:
|
46
|
-
task_id: 5 # shipit_running
|
47
|
-
text: "sudo chmod -R 777 /"
|
@@ -1,21 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
require 'test_helper'
|
3
|
-
|
4
|
-
module Shipit
|
5
|
-
class OutputChunkTest < ActiveSupport::TestCase
|
6
|
-
def setup
|
7
|
-
@deploy = shipit_deploys(:shipit)
|
8
|
-
@chunks = 3.times.map { OutputChunk.create!(text: 'bla', task: @deploy) }
|
9
|
-
end
|
10
|
-
|
11
|
-
test "tail" do
|
12
|
-
start = @chunks.first
|
13
|
-
rest = @chunks - [start]
|
14
|
-
assert_equal rest, @deploy.chunks.tail(start.id)
|
15
|
-
end
|
16
|
-
|
17
|
-
test "tail without start" do
|
18
|
-
assert_equal @deploy.chunks, @deploy.chunks.tail(nil)
|
19
|
-
end
|
20
|
-
end
|
21
|
-
end
|