shipit-engine 0.32.0 → 0.35.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +13 -2
- 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/_deploy.scss +2 -3
- 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/ccmenu_controller.rb +1 -1
- data/app/controllers/shipit/api/deploys_controller.rb +2 -0
- data/app/controllers/shipit/api/{pull_requests_controller.rb → merge_requests_controller.rb} +8 -8
- data/app/controllers/shipit/api/rollbacks_controller.rb +2 -1
- data/app/controllers/shipit/api/stacks_controller.rb +15 -1
- data/app/controllers/shipit/deploys_controller.rb +1 -1
- 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/stacks_controller.rb +2 -2
- data/app/controllers/shipit/tasks_controller.rb +2 -2
- data/app/controllers/shipit/webhooks_controller.rb +23 -4
- data/app/helpers/shipit/chunks_helper.rb +2 -2
- data/app/helpers/shipit/github_url_helper.rb +8 -0
- data/app/helpers/shipit/shipit_helper.rb +0 -1
- data/app/helpers/shipit/stacks_helper.rb +4 -0
- data/app/jobs/shipit/create_on_github_job.rb +1 -0
- data/app/jobs/shipit/deliver_hook_job.rb +1 -1
- data/app/jobs/shipit/destroy_repository_job.rb +24 -0
- data/app/jobs/shipit/destroy_stack_job.rb +2 -2
- data/app/jobs/shipit/github_sync_job.rb +13 -9
- 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/jobs/shipit/update_github_last_deployed_ref_job.rb +1 -1
- data/app/models/shipit/anonymous_user.rb +10 -2
- data/app/models/shipit/check_run.rb +38 -2
- data/app/models/shipit/command_line_user.rb +4 -0
- data/app/models/shipit/commit.rb +31 -20
- data/app/models/shipit/commit_checks.rb +14 -13
- data/app/models/shipit/commit_deployment.rb +3 -3
- data/app/models/shipit/commit_deployment_status.rb +3 -3
- data/app/models/shipit/deploy.rb +17 -11
- data/app/models/shipit/deploy_spec/file_system.rb +11 -5
- data/app/models/shipit/deploy_spec/lerna_discovery.rb +12 -4
- data/app/models/shipit/deploy_spec.rb +16 -4
- data/app/models/shipit/duration.rb +2 -0
- data/app/models/shipit/hook.rb +28 -2
- data/app/models/shipit/merge_request.rb +304 -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/provisioning_handler.rb +32 -0
- data/app/models/shipit/pull_request.rb +26 -265
- data/app/models/shipit/pull_request_assignment.rb +10 -0
- data/app/models/shipit/release_status.rb +1 -1
- data/app/models/shipit/repository.rb +63 -3
- data/app/models/shipit/review_stack.rb +130 -0
- data/app/models/shipit/review_stack_provisioning_queue.rb +39 -0
- data/app/models/shipit/rollback.rb +5 -0
- data/app/models/shipit/stack.rb +78 -30
- data/app/models/shipit/status/group.rb +1 -1
- data/app/models/shipit/task.rb +62 -9
- data/app/models/shipit/task_execution_strategy/base.rb +20 -0
- data/app/models/shipit/task_execution_strategy/default.rb +109 -0
- data/app/models/shipit/team.rb +4 -2
- data/app/models/shipit/user.rb +10 -1
- 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/models/shipit/webhooks/handlers/push_handler.rb +4 -1
- data/app/models/shipit/webhooks.rb +10 -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/validators/subset_validator.rb +1 -1
- data/app/views/layouts/merge_status.html.erb +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 +15 -1
- 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/new.html.erb +1 -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/config/secrets.development.example.yml +24 -0
- data/config/secrets.development.shopify.yml +20 -9
- 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/db/migrate/20210325194053_remove_stacks_branch_default.rb +5 -0
- data/db/migrate/20210504200438_add_github_updated_at_to_check_runs.rb +5 -0
- data/db/migrate/20210823075617_change_check_runs_github_updated_at_default.rb +5 -0
- data/lib/shipit/command.rb +7 -6
- data/lib/shipit/commands.rb +18 -5
- data/lib/shipit/engine.rb +2 -0
- data/lib/shipit/flock.rb +8 -1
- data/lib/shipit/github_app.rb +8 -6
- data/lib/shipit/octokit_iterator.rb +3 -3
- data/lib/shipit/review_stack_commands.rb +8 -0
- data/lib/shipit/simple_message_verifier.rb +2 -2
- data/lib/shipit/stack_commands.rb +36 -7
- data/lib/shipit/task_commands.rb +8 -1
- data/lib/shipit/version.rb +1 -1
- data/lib/shipit.rb +50 -16
- data/lib/snippets/publish-lerna-independent-packages +35 -34
- data/lib/snippets/publish-lerna-independent-packages-legacy +39 -0
- data/lib/tasks/cron.rake +11 -2
- data/test/controllers/api/ccmenu_controller_test.rb +1 -1
- data/test/controllers/api/deploys_controller_test.rb +17 -0
- 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 +42 -8
- 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 +27 -12
- data/test/dummy/app/assets/config/manifest.js +3 -0
- data/test/dummy/config/application.rb +7 -2
- data/test/dummy/config/database.yml +9 -0
- data/test/dummy/config/environments/development.rb +1 -4
- data/test/dummy/config/environments/test.rb +0 -5
- data/test/dummy/config/secrets_double_github_app.yml +79 -0
- data/test/dummy/db/schema.rb +56 -17
- data/test/dummy/db/seeds.rb +2 -1
- data/test/fixtures/payloads/check_suite_master.json +4 -32
- 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/payloads/push_master.json +1 -1
- data/test/fixtures/payloads/push_not_master.json +1 -1
- data/test/fixtures/shipit/commits.yml +17 -4
- data/test/fixtures/shipit/hooks.yml +1 -0
- 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 +4 -1
- data/test/fixtures/shipit/users.yml +7 -0
- data/test/helpers/json_helper.rb +5 -1
- 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/github_sync_job_test.rb +2 -1
- 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/commit_deployment_status_test.rb +3 -3
- data/test/models/commits_test.rb +24 -13
- data/test/models/deploy_spec_test.rb +64 -24
- data/test/models/deploys_test.rb +188 -14
- data/test/models/hook_test.rb +30 -1
- data/test/models/{pull_request_test.rb → merge_request_test.rb} +49 -34
- data/test/models/pull_request_assignment_test.rb +16 -0
- data/test/models/shipit/check_run_test.rb +124 -5
- 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 +91 -0
- data/test/models/{stacks_test.rb → shipit/stacks_test.rb} +52 -8
- 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 +107 -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 +66 -3
- data/test/serializers/shipit/pull_request_serializer_test.rb +29 -0
- data/test/test_helper.rb +15 -0
- data/test/unit/anonymous_user_serializer_test.rb +1 -1
- data/test/unit/command_test.rb +8 -3
- data/test/unit/commit_serializer_test.rb +1 -1
- data/test/unit/deploy_commands_test.rb +73 -17
- data/test/unit/deploy_serializer_test.rb +1 -1
- data/test/unit/github_app_test.rb +2 -3
- data/test/unit/github_apps_test.rb +416 -0
- data/test/unit/github_url_helper_test.rb +5 -0
- data/test/unit/shipit_deployment_checks_test.rb +77 -0
- data/test/unit/shipit_task_execution_strategy_test.rb +47 -0
- data/test/unit/shipit_test.rb +14 -0
- data/test/unit/user_serializer_test.rb +1 -1
- metadata +306 -188
- 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
@@ -106,6 +106,12 @@ module Shipit
|
|
106
106
|
refute @spec.bundle_install.last.include?('--frozen')
|
107
107
|
end
|
108
108
|
|
109
|
+
test "#provisioning_handler returns `provision.handler` if present" do
|
110
|
+
@spec.stubs(:load_config).returns('provision' => { 'handler_name' => 'ExpectedProvisioningHandler' })
|
111
|
+
|
112
|
+
assert_equal "ExpectedProvisioningHandler", @spec.provisioning_handler_name
|
113
|
+
end
|
114
|
+
|
109
115
|
test '#deploy_steps returns `deploy.override` if present' do
|
110
116
|
@spec.stubs(:load_config).returns('deploy' => { 'override' => %w(foo bar baz) })
|
111
117
|
assert_equal %w(foo bar baz), @spec.deploy_steps
|
@@ -175,11 +181,31 @@ module Shipit
|
|
175
181
|
end
|
176
182
|
end
|
177
183
|
|
184
|
+
test '#retries_on_deploy returns `deploy.retries` if present' do
|
185
|
+
@spec.stubs(:load_config).returns('deploy' => { 'retries' => 5 })
|
186
|
+
assert_equal 5, @spec.retries_on_deploy
|
187
|
+
end
|
188
|
+
|
189
|
+
test '#retries_on_deploy returns a default value if `deploy.retries` is not present' do
|
190
|
+
@spec.stubs(:load_config).returns('deploy' => {})
|
191
|
+
assert_nil @spec.retries_on_deploy
|
192
|
+
end
|
193
|
+
|
178
194
|
test '#rollback_steps returns `rollback.override` if present' do
|
179
195
|
@spec.stubs(:load_config).returns('rollback' => { 'override' => %w(foo bar baz) })
|
180
196
|
assert_equal %w(foo bar baz), @spec.rollback_steps
|
181
197
|
end
|
182
198
|
|
199
|
+
test '#retries_on_rollback returns `rollback.retries` if present' do
|
200
|
+
@spec.stubs(:load_config).returns('rollback' => { 'retries' => 5 })
|
201
|
+
assert_equal 5, @spec.retries_on_rollback
|
202
|
+
end
|
203
|
+
|
204
|
+
test '#retries_on_rollback returns a default value if `rollback.retries` is not present' do
|
205
|
+
@spec.stubs(:load_config).returns('rollback' => {})
|
206
|
+
assert_nil @spec.retries_on_rollback
|
207
|
+
end
|
208
|
+
|
183
209
|
test '#rollback_steps returns `cap $ENVIRONMENT deploy:rollback` if a `Capfile` is present' do
|
184
210
|
@spec.expects(:bundler?).returns(true).at_least_once
|
185
211
|
@spec.expects(:capistrano?).returns(true)
|
@@ -364,13 +390,20 @@ module Shipit
|
|
364
390
|
},
|
365
391
|
'dependencies' => { 'override' => [] },
|
366
392
|
'plugins' => {},
|
393
|
+
'provision' => {
|
394
|
+
'handler_name' => nil,
|
395
|
+
},
|
367
396
|
'deploy' => {
|
368
397
|
'override' => nil,
|
369
398
|
'variables' => [],
|
370
399
|
'max_commits' => 8,
|
371
400
|
'interval' => 0,
|
401
|
+
'retries' => nil,
|
402
|
+
},
|
403
|
+
'rollback' => {
|
404
|
+
'override' => nil,
|
405
|
+
'retries' => nil,
|
372
406
|
},
|
373
|
-
'rollback' => { 'override' => nil },
|
374
407
|
'fetch' => nil,
|
375
408
|
'tasks' => {},
|
376
409
|
}
|
@@ -559,40 +592,40 @@ module Shipit
|
|
559
592
|
assert_equal %w(ci/circleci soc/compliance), @spec.required_statuses
|
560
593
|
end
|
561
594
|
|
562
|
-
test "
|
595
|
+
test "merge_request_merge_method defaults to `nil`" do
|
563
596
|
@spec.expects(:load_config).returns({})
|
564
|
-
assert_nil @spec.
|
597
|
+
assert_nil @spec.merge_request_merge_method
|
565
598
|
end
|
566
599
|
|
567
|
-
test "
|
600
|
+
test "merge_request_merge_method returns `merge.method`" do
|
568
601
|
@spec.expects(:load_config).returns(
|
569
602
|
'merge' => {
|
570
603
|
'method' => 'squash',
|
571
604
|
},
|
572
605
|
)
|
573
|
-
assert_equal 'squash', @spec.
|
606
|
+
assert_equal 'squash', @spec.merge_request_merge_method
|
574
607
|
end
|
575
608
|
|
576
|
-
test "
|
609
|
+
test "merge_request_merge_method returns `nil` if `merge.method` is invalid" do
|
577
610
|
@spec.expects(:load_config).returns(
|
578
611
|
'merge' => {
|
579
612
|
'method' => 'squashing',
|
580
613
|
},
|
581
614
|
)
|
582
|
-
assert_nil @spec.
|
615
|
+
assert_nil @spec.merge_request_merge_method
|
583
616
|
end
|
584
617
|
|
585
|
-
test "
|
618
|
+
test "merge_request_ignored_statuses defaults to the union of ci.hide and ci.allow_failures" do
|
586
619
|
@spec.expects(:load_config).returns(
|
587
620
|
'ci' => {
|
588
621
|
'hide' => %w(ci/circleci ci/jenkins),
|
589
622
|
'allow_failures' => %w(ci/circleci ci/travis),
|
590
623
|
},
|
591
624
|
)
|
592
|
-
assert_equal %w(ci/circleci ci/jenkins ci/travis).sort, @spec.
|
625
|
+
assert_equal %w(ci/circleci ci/jenkins ci/travis).sort, @spec.merge_request_ignored_statuses.sort
|
593
626
|
end
|
594
627
|
|
595
|
-
test "
|
628
|
+
test "merge_request_ignored_statuses defaults to empty if `merge.require` is present" do
|
596
629
|
@spec.expects(:load_config).returns(
|
597
630
|
'merge' => {
|
598
631
|
'require' => 'bar',
|
@@ -602,10 +635,10 @@ module Shipit
|
|
602
635
|
'allow_failures' => %w(ci/circleci ci/travis),
|
603
636
|
},
|
604
637
|
)
|
605
|
-
assert_equal [], @spec.
|
638
|
+
assert_equal [], @spec.merge_request_ignored_statuses
|
606
639
|
end
|
607
640
|
|
608
|
-
test "
|
641
|
+
test "merge_request_ignored_statuses returns `merge.ignore` if present" do
|
609
642
|
@spec.expects(:load_config).returns(
|
610
643
|
'merge' => {
|
611
644
|
'ignore' => 'bar',
|
@@ -615,19 +648,19 @@ module Shipit
|
|
615
648
|
'allow_failures' => %w(ci/circleci ci/travis),
|
616
649
|
},
|
617
650
|
)
|
618
|
-
assert_equal ['bar'], @spec.
|
651
|
+
assert_equal ['bar'], @spec.merge_request_ignored_statuses
|
619
652
|
end
|
620
653
|
|
621
|
-
test "
|
654
|
+
test "merge_request_required_statuses defaults to ci.require" do
|
622
655
|
@spec.expects(:load_config).returns(
|
623
656
|
'ci' => {
|
624
657
|
'require' => %w(ci/circleci ci/jenkins),
|
625
658
|
},
|
626
659
|
)
|
627
|
-
assert_equal %w(ci/circleci ci/jenkins), @spec.
|
660
|
+
assert_equal %w(ci/circleci ci/jenkins), @spec.merge_request_required_statuses
|
628
661
|
end
|
629
662
|
|
630
|
-
test "
|
663
|
+
test "merge_request_required_statuses defaults to empty if `merge.ignore` is present" do
|
631
664
|
@spec.expects(:load_config).returns(
|
632
665
|
'merge' => {
|
633
666
|
'ignore' => 'bar',
|
@@ -636,10 +669,10 @@ module Shipit
|
|
636
669
|
'require' => %w(ci/circleci ci/jenkins),
|
637
670
|
},
|
638
671
|
)
|
639
|
-
assert_equal [], @spec.
|
672
|
+
assert_equal [], @spec.merge_request_required_statuses
|
640
673
|
end
|
641
674
|
|
642
|
-
test "
|
675
|
+
test "merge_request_required_statuses returns `merge.require` if present" do
|
643
676
|
@spec.expects(:load_config).returns(
|
644
677
|
'merge' => {
|
645
678
|
'require' => 'bar',
|
@@ -649,21 +682,21 @@ module Shipit
|
|
649
682
|
'allow_failures' => %w(ci/circleci ci/travis),
|
650
683
|
},
|
651
684
|
)
|
652
|
-
assert_equal ['bar'], @spec.
|
685
|
+
assert_equal ['bar'], @spec.merge_request_required_statuses
|
653
686
|
end
|
654
687
|
|
655
|
-
test "
|
688
|
+
test "revalidate_merge_requests_after defaults to `nil" do
|
656
689
|
@spec.expects(:load_config).returns({})
|
657
|
-
assert_nil @spec.
|
690
|
+
assert_nil @spec.revalidate_merge_requests_after
|
658
691
|
end
|
659
692
|
|
660
|
-
test "
|
693
|
+
test "revalidate_merge_requests_after defaults to `nil` if `merge.timeout` cannot be parsed" do
|
661
694
|
@spec.expects(:load_config).returns(
|
662
695
|
'merge' => {
|
663
696
|
'revalidate_after' => 'ALSKhfjsdkf',
|
664
697
|
},
|
665
698
|
)
|
666
|
-
assert_nil @spec.
|
699
|
+
assert_nil @spec.revalidate_merge_requests_after
|
667
700
|
end
|
668
701
|
|
669
702
|
test "revalidate_after returns `merge.revalidate_after` if present" do
|
@@ -672,7 +705,7 @@ module Shipit
|
|
672
705
|
'revalidate_after' => '5m30s',
|
673
706
|
},
|
674
707
|
)
|
675
|
-
assert_equal 330, @spec.
|
708
|
+
assert_equal 330, @spec.revalidate_merge_requests_after.to_i
|
676
709
|
end
|
677
710
|
|
678
711
|
test "#file is impacted by `machine.directory`" do
|
@@ -795,6 +828,13 @@ module Shipit
|
|
795
828
|
@spec.stubs(:lerna?).returns(true)
|
796
829
|
@spec.stubs(:lerna_config).returns('lerna' => '2.0.0', 'version' => 'independent')
|
797
830
|
assert_equal 'assert-lerna-independent-version-tags', @spec.deploy_steps[0]
|
831
|
+
assert_equal 'publish-lerna-independent-packages-legacy', @spec.deploy_steps[1]
|
832
|
+
end
|
833
|
+
|
834
|
+
test '#publish_lerna_packages checks if independent version tags exist, checks if a newer version of lerna is used, and then invokes lerna deploy script' do
|
835
|
+
@spec.stubs(:lerna?).returns(true)
|
836
|
+
@spec.stubs(:lerna_config).returns('lerna' => '3.0.0', 'version' => 'independent')
|
837
|
+
assert_equal 'assert-lerna-independent-version-tags', @spec.deploy_steps[0]
|
798
838
|
assert_equal 'publish-lerna-independent-packages', @spec.deploy_steps[1]
|
799
839
|
end
|
800
840
|
|
data/test/models/deploys_test.rb
CHANGED
@@ -5,6 +5,7 @@ module Shipit
|
|
5
5
|
class DeploysTest < ActiveSupport::TestCase
|
6
6
|
def setup
|
7
7
|
@deploy = shipit_deploys(:shipit)
|
8
|
+
@deploy.write("dummy output")
|
8
9
|
@deploy.pid = 42
|
9
10
|
@stack = shipit_stacks(:shipit)
|
10
11
|
@user = shipit_users(:walrus)
|
@@ -60,6 +61,146 @@ module Shipit
|
|
60
61
|
assert_equal [], @deploy.commits
|
61
62
|
end
|
62
63
|
|
64
|
+
test "deploys retry up to limit upon timeout when configured" do
|
65
|
+
runnable_deploy = shipit_deploys(:shipit_pending)
|
66
|
+
deploy_stack = runnable_deploy.stack
|
67
|
+
|
68
|
+
Shipit::Deploy.any_instance.expects(:acquire_git_cache_lock).twice
|
69
|
+
.raises(Shipit::Command::TimedOut, 'Deploy timed out')
|
70
|
+
.then.raises(Shipit::Command::Error, "Second command error failure")
|
71
|
+
|
72
|
+
perform_enqueued_jobs(only: Shipit::PerformTaskJob) do
|
73
|
+
runnable_deploy.enqueue
|
74
|
+
end
|
75
|
+
assert_performed_jobs 2
|
76
|
+
|
77
|
+
runnable_deploy.reload
|
78
|
+
assert_equal 'timedout', runnable_deploy.status
|
79
|
+
|
80
|
+
retried_deploy = deploy_stack.deploys.last
|
81
|
+
assert_not_equal runnable_deploy.id, retried_deploy.id
|
82
|
+
assert_equal runnable_deploy.since_commit, retried_deploy.since_commit
|
83
|
+
assert_equal runnable_deploy.until_commit, retried_deploy.until_commit
|
84
|
+
assert_equal 'failed', retried_deploy.status
|
85
|
+
assert_equal 1, retried_deploy.retry_attempt
|
86
|
+
end
|
87
|
+
|
88
|
+
test "deploys retry up to limit upon failure when configured" do
|
89
|
+
runnable_deploy = shipit_deploys(:shipit_pending)
|
90
|
+
deploy_stack = runnable_deploy.stack
|
91
|
+
|
92
|
+
Shipit::Deploy.any_instance.expects(:acquire_git_cache_lock).twice
|
93
|
+
.raises(Shipit::Command::Error, 'Deploy failed')
|
94
|
+
.then.raises(Shipit::Command::Error, "Second deploy failed")
|
95
|
+
|
96
|
+
perform_enqueued_jobs(only: Shipit::PerformTaskJob) do
|
97
|
+
runnable_deploy.enqueue
|
98
|
+
end
|
99
|
+
assert_performed_jobs 2
|
100
|
+
|
101
|
+
runnable_deploy.reload
|
102
|
+
assert_equal 'failed', runnable_deploy.status
|
103
|
+
|
104
|
+
retried_deploy = deploy_stack.deploys.last
|
105
|
+
assert_not_equal runnable_deploy.id, retried_deploy.id
|
106
|
+
assert_equal runnable_deploy.since_commit, retried_deploy.since_commit
|
107
|
+
assert_equal runnable_deploy.until_commit, retried_deploy.until_commit
|
108
|
+
assert_equal 'failed', retried_deploy.status
|
109
|
+
assert_equal 1, retried_deploy.retry_attempt
|
110
|
+
end
|
111
|
+
|
112
|
+
test "deploys retry up to limit upon error when configured" do
|
113
|
+
runnable_deploy = shipit_deploys(:shipit_pending)
|
114
|
+
deploy_stack = runnable_deploy.stack
|
115
|
+
|
116
|
+
Shipit::Deploy.any_instance.expects(:acquire_git_cache_lock).twice
|
117
|
+
.raises(StandardError, 'Deploy failed')
|
118
|
+
.then.raises(StandardError, "Second deploy failed")
|
119
|
+
|
120
|
+
perform_enqueued_jobs(only: Shipit::PerformTaskJob) do
|
121
|
+
runnable_deploy.enqueue
|
122
|
+
end
|
123
|
+
assert_performed_jobs 2
|
124
|
+
|
125
|
+
runnable_deploy.reload
|
126
|
+
assert_equal 'error', runnable_deploy.status
|
127
|
+
|
128
|
+
retried_deploy = deploy_stack.deploys.last
|
129
|
+
assert_not_equal runnable_deploy.id, retried_deploy.id
|
130
|
+
assert_equal runnable_deploy.since_commit, retried_deploy.since_commit
|
131
|
+
assert_equal runnable_deploy.until_commit, retried_deploy.until_commit
|
132
|
+
assert_equal 'error', retried_deploy.status
|
133
|
+
assert_equal 1, retried_deploy.retry_attempt
|
134
|
+
end
|
135
|
+
|
136
|
+
test "deploys do not retry upon timeout when not configured" do
|
137
|
+
runnable_deploy = shipit_deploys(:shipit_pending)
|
138
|
+
runnable_deploy.update!(retry_attempt: 0, max_retries: 0)
|
139
|
+
|
140
|
+
Shipit::Deploy.any_instance.expects(:acquire_git_cache_lock)
|
141
|
+
.raises(Shipit::Command::TimedOut, 'Deploy timed out')
|
142
|
+
|
143
|
+
perform_enqueued_jobs(only: Shipit::PerformTaskJob) do
|
144
|
+
runnable_deploy.enqueue
|
145
|
+
end
|
146
|
+
assert_performed_jobs 1
|
147
|
+
|
148
|
+
runnable_deploy.reload
|
149
|
+
|
150
|
+
assert_equal 'timedout', runnable_deploy.status
|
151
|
+
end
|
152
|
+
|
153
|
+
test "rollbacks retry on timeouts if configured" do
|
154
|
+
deploy = shipit_deploys(:shipit)
|
155
|
+
deploy_stack = deploy.stack
|
156
|
+
|
157
|
+
DeploySpec.any_instance.expects(:retries_on_rollback).returns(1)
|
158
|
+
|
159
|
+
Shipit::Command.any_instance.expects(:run).twice
|
160
|
+
.raises(Shipit::Command::TimedOut, 'Rollback timed out')
|
161
|
+
.then.raises(Shipit::Command::Error, "Second command error failure")
|
162
|
+
|
163
|
+
first_rollback = nil
|
164
|
+
|
165
|
+
perform_enqueued_jobs(only: Shipit::PerformTaskJob) do
|
166
|
+
first_rollback = deploy.trigger_rollback(@user, force: true)
|
167
|
+
end
|
168
|
+
assert_performed_jobs 2
|
169
|
+
|
170
|
+
first_rollback.reload
|
171
|
+
|
172
|
+
assert_equal 'timedout', first_rollback.status
|
173
|
+
retried_rollback = deploy_stack.deploys_and_rollbacks.last
|
174
|
+
|
175
|
+
assert_not_equal first_rollback.id, retried_rollback.id
|
176
|
+
assert_equal first_rollback.since_commit, retried_rollback.since_commit
|
177
|
+
assert_equal first_rollback.until_commit, retried_rollback.until_commit
|
178
|
+
assert_equal 'failed', retried_rollback.status
|
179
|
+
assert_equal 1, retried_rollback.max_retries
|
180
|
+
end
|
181
|
+
|
182
|
+
test "rollbacks do not retry if not configured" do
|
183
|
+
deploy_stack = @deploy.stack
|
184
|
+
|
185
|
+
DeploySpec.any_instance.expects(:retries_on_rollback).returns(0)
|
186
|
+
|
187
|
+
Shipit::Command.any_instance.expects(:run).once
|
188
|
+
.raises(Shipit::Command::TimedOut, 'Rollback timed out')
|
189
|
+
.then.raises(Shipit::Command::Error, "Second command error failure")
|
190
|
+
|
191
|
+
first_rollback = nil
|
192
|
+
|
193
|
+
perform_enqueued_jobs(only: Shipit::PerformTaskJob) do
|
194
|
+
first_rollback = @deploy.trigger_rollback(@user, force: true)
|
195
|
+
end
|
196
|
+
assert_performed_jobs 1
|
197
|
+
|
198
|
+
first_rollback.reload
|
199
|
+
|
200
|
+
assert_equal 'timedout', first_rollback.status
|
201
|
+
assert_equal first_rollback, deploy_stack.deploys_and_rollbacks.last
|
202
|
+
end
|
203
|
+
|
63
204
|
test "additions and deletions are denormalized on before create" do
|
64
205
|
stack = shipit_stacks(:shipit)
|
65
206
|
first = shipit_commits(:first)
|
@@ -200,7 +341,7 @@ module Shipit
|
|
200
341
|
since_commit: shipit.commits.first,
|
201
342
|
until_commit: shipit.commits.last,
|
202
343
|
)
|
203
|
-
deploy.stubs(:
|
344
|
+
deploy.stubs(:merge_request_head_for_commit).returns(nil)
|
204
345
|
|
205
346
|
expect_event(deploy)
|
206
347
|
deploy.save!
|
@@ -263,9 +404,9 @@ module Shipit
|
|
263
404
|
assert_in_delta @deploy.ended_at, @stack.last_deployed_at, 2
|
264
405
|
end
|
265
406
|
|
266
|
-
test "transitioning to success schedule a
|
407
|
+
test "transitioning to success schedule a MergeMergeRequests job" do
|
267
408
|
@deploy = shipit_deploys(:shipit_running)
|
268
|
-
assert_enqueued_with(job:
|
409
|
+
assert_enqueued_with(job: ProcessMergeRequestsJob, args: [@deploy.stack]) do
|
269
410
|
@deploy.complete!
|
270
411
|
end
|
271
412
|
end
|
@@ -393,7 +534,7 @@ module Shipit
|
|
393
534
|
# Check that the next item in the series is 1 greater than the last.
|
394
535
|
def assert_generated_record_ids_are_sequential(record_id_series)
|
395
536
|
record_id_series[0..-2].each_with_index do |id_element, index|
|
396
|
-
assert_equal
|
537
|
+
assert_equal(id_element + 1, record_id_series[index + 1])
|
397
538
|
end
|
398
539
|
end
|
399
540
|
|
@@ -661,6 +802,12 @@ module Shipit
|
|
661
802
|
assert_equal @user, @stack.lock_author
|
662
803
|
end
|
663
804
|
|
805
|
+
test "#trigger_rollback does not lock the stack if not requested" do
|
806
|
+
refute @stack.locked?
|
807
|
+
@deploy.trigger_rollback(@user, lock: false)
|
808
|
+
refute @stack.reload.locked?
|
809
|
+
end
|
810
|
+
|
664
811
|
test "#trigger_rollback marks the rollback as `ignored_safeties` if the force option was used" do
|
665
812
|
rollback = @deploy.trigger_rollback(@user, force: true)
|
666
813
|
assert_predicate rollback, :ignored_safeties?
|
@@ -699,20 +846,13 @@ module Shipit
|
|
699
846
|
assert_predicate @deploy, :error?
|
700
847
|
end
|
701
848
|
|
702
|
-
test "
|
703
|
-
|
704
|
-
@deploy.destroy
|
705
|
-
end
|
706
|
-
end
|
707
|
-
|
708
|
-
test "#chunk_output joins all chunk test if logs not rolled up" do
|
709
|
-
assert_equal @deploy.chunks.count, @deploy.chunks.count
|
710
|
-
assert_equal @deploy.chunks.pluck(:text).join, @deploy.chunk_output
|
849
|
+
test "#chunk_output fetches from Redis if logs not rolled up" do
|
850
|
+
assert_equal Shipit.redis.get(@deploy.send(:output_key)), @deploy.chunk_output
|
711
851
|
refute @deploy.rolled_up
|
712
852
|
end
|
713
853
|
|
714
854
|
test "#chunk_output returns logs from records if rolled up" do
|
715
|
-
expected_output = @deploy.
|
855
|
+
expected_output = Shipit.redis.get(@deploy.send(:output_key))
|
716
856
|
@deploy.rollup_chunks
|
717
857
|
|
718
858
|
assert_no_queries do
|
@@ -833,6 +973,18 @@ module Shipit
|
|
833
973
|
end
|
834
974
|
end
|
835
975
|
|
976
|
+
test "succeeding a deploy sets the release status as pending and does not schedule job if the status delay is negative (-1)" do
|
977
|
+
@deploy = shipit_deploys(:canaries_running)
|
978
|
+
@deploy.stack.expects(:release_status_delay).at_least_once.returns(Duration.parse(-1))
|
979
|
+
|
980
|
+
assert_difference -> { ReleaseStatus.count }, +1 do
|
981
|
+
assert_not_equal 'success', @deploy.last_release_status.state
|
982
|
+
@deploy.report_complete!
|
983
|
+
assert_equal 'validating', @deploy.status
|
984
|
+
assert_equal 'pending', @deploy.last_release_status.state
|
985
|
+
end
|
986
|
+
end
|
987
|
+
|
836
988
|
test "triggering a rollback via abort! sets the release status as failure" do
|
837
989
|
@deploy = shipit_deploys(:canaries_running)
|
838
990
|
@deploy.ping
|
@@ -878,6 +1030,28 @@ module Shipit
|
|
878
1030
|
end
|
879
1031
|
end
|
880
1032
|
|
1033
|
+
test "manually triggered rollbacks sets rollbacked deploys as faulty and not the rollback task" do
|
1034
|
+
@deploy = shipit_deploys(:canaries_validating)
|
1035
|
+
@middle_deploy = shipit_deploys(:canaries_faulty)
|
1036
|
+
@rollback_to_deploy = shipit_deploys(:canaries_success)
|
1037
|
+
|
1038
|
+
@rollback_task = @rollback_to_deploy.trigger_rollback(force: true)
|
1039
|
+
|
1040
|
+
@rollback_task.run!
|
1041
|
+
@rollback_task.complete!
|
1042
|
+
@rollback_task.reload
|
1043
|
+
@deploy.reload
|
1044
|
+
@middle_deploy.reload
|
1045
|
+
|
1046
|
+
assert_equal 'faulty', @deploy.status
|
1047
|
+
assert_equal 'failure', @deploy.last_release_status.state
|
1048
|
+
|
1049
|
+
assert_equal 'faulty', @middle_deploy.status
|
1050
|
+
assert_equal 'failure', @middle_deploy.last_release_status.state
|
1051
|
+
|
1052
|
+
assert_equal 'success', @rollback_task.status
|
1053
|
+
end
|
1054
|
+
|
881
1055
|
test "succeeding a deploy creates CommitDeploymentStatuses" do
|
882
1056
|
@deploy = shipit_deploys(:shipit_running)
|
883
1057
|
refute_empty @deploy.commit_deployments
|