shipit-engine 0.38.0 → 0.40.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +48 -4
- data/Rakefile +2 -1
- data/app/assets/javascripts/shipit/continuous_delivery_schedule.js.coffee +15 -0
- data/app/controllers/concerns/shipit/active_model_serializers_patch.rb +1 -0
- data/app/controllers/concerns/shipit/api/cacheable.rb +1 -0
- data/app/controllers/concerns/shipit/api/paginable.rb +3 -2
- data/app/controllers/concerns/shipit/api/rendering.rb +1 -0
- data/app/controllers/concerns/shipit/authentication.rb +1 -0
- data/app/controllers/concerns/shipit/pagination.rb +3 -2
- data/app/controllers/shipit/api/base_controller.rb +12 -10
- data/app/controllers/shipit/api/ccmenu_controller.rb +2 -1
- data/app/controllers/shipit/api/commits_controller.rb +2 -3
- data/app/controllers/shipit/api/deploys_controller.rb +6 -1
- data/app/controllers/shipit/api/hooks_controller.rb +4 -3
- data/app/controllers/shipit/api/locks_controller.rb +1 -0
- data/app/controllers/shipit/api/merge_requests_controller.rb +6 -5
- data/app/controllers/shipit/api/outputs_controller.rb +1 -0
- data/app/controllers/shipit/api/release_statuses_controller.rb +2 -1
- data/app/controllers/shipit/api/rollbacks_controller.rb +1 -0
- data/app/controllers/shipit/api/stacks_controller.rb +15 -14
- data/app/controllers/shipit/api/tasks_controller.rb +6 -5
- data/app/controllers/shipit/api_clients_controller.rb +6 -7
- data/app/controllers/shipit/ccmenu_url_controller.rb +3 -2
- data/app/controllers/shipit/commit_checks_controller.rb +2 -1
- data/app/controllers/shipit/commits_controller.rb +1 -0
- data/app/controllers/shipit/continuous_delivery_schedules_controller.rb +42 -0
- data/app/controllers/shipit/deploys_controller.rb +6 -5
- data/app/controllers/shipit/github_authentication_controller.rb +6 -0
- data/app/controllers/shipit/merge_requests_controller.rb +1 -0
- data/app/controllers/shipit/merge_status_controller.rb +30 -26
- data/app/controllers/shipit/release_statuses_controller.rb +1 -0
- data/app/controllers/shipit/repositories_controller.rb +4 -7
- data/app/controllers/shipit/rollbacks_controller.rb +2 -1
- data/app/controllers/shipit/shipit_controller.rb +1 -0
- data/app/controllers/shipit/stacks_controller.rb +27 -31
- data/app/controllers/shipit/status_controller.rb +1 -0
- data/app/controllers/shipit/tasks_controller.rb +3 -1
- data/app/controllers/shipit/webhooks_controller.rb +2 -1
- data/app/helpers/shipit/api_clients_helper.rb +1 -0
- data/app/helpers/shipit/chunks_helper.rb +3 -1
- data/app/helpers/shipit/deploys_helper.rb +7 -3
- data/app/helpers/shipit/github_url_helper.rb +5 -4
- data/app/helpers/shipit/merge_status_helper.rb +1 -0
- data/app/helpers/shipit/shipit_helper.rb +11 -10
- data/app/helpers/shipit/stacks_helper.rb +10 -11
- data/app/helpers/shipit/tasks_helper.rb +2 -1
- data/app/jobs/shipit/background_job/unique.rb +3 -2
- data/app/jobs/shipit/background_job.rb +9 -1
- data/app/jobs/shipit/cache_deploy_spec_job.rb +2 -1
- data/app/jobs/shipit/chunk_rollup_job.rb +1 -0
- data/app/jobs/shipit/clear_git_cache_job.rb +1 -0
- data/app/jobs/shipit/continuous_delivery_job.rb +5 -0
- data/app/jobs/shipit/create_on_github_job.rb +1 -0
- data/app/jobs/shipit/create_release_statuses_job.rb +2 -0
- data/app/jobs/shipit/deferred_touch_job.rb +1 -0
- data/app/jobs/shipit/deliver_hook_job.rb +1 -0
- data/app/jobs/shipit/destroy_job.rb +1 -0
- data/app/jobs/shipit/destroy_repository_job.rb +1 -0
- data/app/jobs/shipit/destroy_stack_job.rb +36 -15
- data/app/jobs/shipit/emit_event_job.rb +1 -0
- data/app/jobs/shipit/fetch_commit_stats_job.rb +1 -0
- data/app/jobs/shipit/fetch_deployed_revision_job.rb +1 -0
- data/app/jobs/shipit/github_sync_job.rb +4 -2
- data/app/jobs/shipit/mark_deploy_healthy_job.rb +1 -0
- data/app/jobs/shipit/perform_commit_checks_job.rb +1 -0
- data/app/jobs/shipit/perform_task_job.rb +1 -0
- data/app/jobs/shipit/process_merge_requests_job.rb +2 -0
- data/app/jobs/shipit/purge_old_deliveries_job.rb +1 -0
- data/app/jobs/shipit/reap_dead_tasks_job.rb +1 -0
- data/app/jobs/shipit/refresh_check_runs_job.rb +1 -0
- data/app/jobs/shipit/refresh_github_user_job.rb +1 -0
- data/app/jobs/shipit/refresh_merge_request_job.rb +1 -0
- data/app/jobs/shipit/refresh_statuses_job.rb +1 -0
- data/app/jobs/shipit/setup_github_hook_job.rb +1 -0
- data/app/jobs/shipit/update_estimated_deploy_duration_job.rb +1 -0
- data/app/jobs/shipit/update_github_last_deployed_ref_job.rb +6 -7
- data/app/models/concerns/shipit/deferred_touch.rb +5 -2
- data/app/models/shipit/anonymous_user.rb +4 -5
- data/app/models/shipit/api_client.rb +5 -3
- data/app/models/shipit/application_record.rb +1 -0
- data/app/models/shipit/check_run.rb +7 -6
- data/app/models/shipit/command_line_user.rb +4 -5
- data/app/models/shipit/commit.rb +46 -32
- data/app/models/shipit/commit_checks.rb +4 -2
- data/app/models/shipit/commit_deployment.rb +7 -5
- data/app/models/shipit/commit_deployment_status.rb +5 -3
- data/app/models/shipit/commit_message.rb +2 -0
- data/app/models/shipit/continuous_delivery_schedule.rb +84 -0
- data/app/models/shipit/delivery.rb +5 -4
- data/app/models/shipit/deploy.rb +46 -26
- data/app/models/shipit/deploy_spec/bundler_discovery.rb +3 -1
- data/app/models/shipit/deploy_spec/capistrano_discovery.rb +1 -0
- data/app/models/shipit/deploy_spec/file_system.rb +48 -17
- data/app/models/shipit/deploy_spec/kubernetes_discovery.rb +4 -3
- data/app/models/shipit/deploy_spec/lerna_discovery.rb +32 -31
- data/app/models/shipit/deploy_spec/npm_discovery.rb +18 -13
- data/app/models/shipit/deploy_spec/pypi_discovery.rb +5 -4
- data/app/models/shipit/deploy_spec/rubygems_discovery.rb +1 -0
- data/app/models/shipit/deploy_spec.rb +25 -30
- data/app/models/shipit/deploy_stats.rb +6 -1
- data/app/models/shipit/duration.rb +5 -3
- data/app/models/shipit/ephemeral_commit_checks.rb +8 -7
- data/app/models/shipit/github_hook.rb +1 -0
- data/app/models/shipit/github_status.rb +1 -0
- data/app/models/shipit/hook.rb +9 -7
- data/app/models/shipit/membership.rb +1 -0
- data/app/models/shipit/merge_request.rb +26 -16
- data/app/models/shipit/output_chunk.rb +1 -0
- data/app/models/shipit/provisioning_handler.rb +1 -0
- data/app/models/shipit/pull_request.rb +2 -2
- data/app/models/shipit/record.rb +1 -0
- data/app/models/shipit/release_status.rb +4 -3
- data/app/models/shipit/repository.rb +12 -11
- data/app/models/shipit/review_stack.rb +3 -1
- data/app/models/shipit/review_stack_provisioning_queue.rb +2 -2
- data/app/models/shipit/rollback.rb +2 -0
- data/app/models/shipit/stack.rb +71 -60
- data/app/models/shipit/status/common.rb +1 -0
- data/app/models/shipit/status/group.rb +5 -3
- data/app/models/shipit/status/missing.rb +2 -1
- data/app/models/shipit/status/unknown.rb +1 -0
- data/app/models/shipit/status.rb +5 -4
- data/app/models/shipit/task.rb +40 -31
- data/app/models/shipit/task_definition.rb +10 -7
- data/app/models/shipit/task_execution_strategy/default.rb +13 -13
- data/app/models/shipit/team.rb +13 -12
- data/app/models/shipit/undeployed_commit.rb +8 -3
- data/app/models/shipit/unlimited_api_client.rb +2 -2
- data/app/models/shipit/user.rb +23 -16
- data/app/models/shipit/variable_definition.rb +2 -1
- data/app/models/shipit/webhooks/handlers/check_suite_handler.rb +1 -0
- data/app/models/shipit/webhooks/handlers/handler.rb +1 -0
- data/app/models/shipit/webhooks/handlers/membership_handler.rb +1 -0
- data/app/models/shipit/webhooks/handlers/pull_request/assigned_handler.rb +10 -10
- data/app/models/shipit/webhooks/handlers/pull_request/closed_handler.rb +1 -1
- data/app/models/shipit/webhooks/handlers/pull_request/edited_handler.rb +10 -10
- data/app/models/shipit/webhooks/handlers/pull_request/label_capturing_handler.rb +2 -2
- data/app/models/shipit/webhooks/handlers/pull_request/labeled_handler.rb +2 -2
- data/app/models/shipit/webhooks/handlers/pull_request/reopened_handler.rb +1 -1
- data/app/models/shipit/webhooks/handlers/pull_request/review_stack_adapter.rb +3 -3
- data/app/models/shipit/webhooks/handlers/pull_request/unlabeled_handler.rb +1 -1
- data/app/models/shipit/webhooks/handlers/push_handler.rb +2 -1
- data/app/models/shipit/webhooks/handlers/status_handler.rb +1 -0
- data/app/models/shipit/webhooks.rb +3 -2
- data/app/serializers/concerns/shipit/conditional_attributes.rb +1 -0
- data/app/serializers/shipit/anonymous_user_serializer.rb +1 -0
- data/app/serializers/shipit/command_line_user_serializer.rb +1 -0
- data/app/serializers/shipit/commit_serializer.rb +2 -1
- data/app/serializers/shipit/deploy_serializer.rb +1 -0
- data/app/serializers/shipit/hook_serializer.rb +1 -0
- data/app/serializers/shipit/merge_request_serializer.rb +2 -1
- data/app/serializers/shipit/rollback_serializer.rb +1 -0
- data/app/serializers/shipit/short_commit_serializer.rb +1 -0
- data/app/serializers/shipit/stack_serializer.rb +4 -3
- data/app/serializers/shipit/tail_task_serializer.rb +4 -1
- data/app/serializers/shipit/task_serializer.rb +1 -0
- data/app/serializers/shipit/user_serializer.rb +1 -0
- data/app/validators/ascii_only_validator.rb +4 -3
- data/app/validators/subset_validator.rb +1 -0
- data/app/views/shipit/_variables.html.erb +1 -1
- data/app/views/shipit/ccmenu/project.xml.builder +2 -1
- data/app/views/shipit/continuous_delivery_schedules/show.html.erb +59 -0
- data/app/views/shipit/merge_status/failure.html.erb +1 -1
- data/app/views/shipit/missing_settings.html.erb +1 -1
- data/app/views/shipit/stacks/_settings_form.erb +1 -0
- data/config/initializers/inflections.rb +1 -0
- data/config/locales/en.yml +1 -0
- data/config/routes.rb +21 -18
- data/config/secrets.development.example.yml +1 -1
- data/config/secrets.development.shopify.yml +1 -1
- data/db/migrate/20240821003007_add_continuous_delivery_schedules.rb +13 -0
- data/db/migrate/20250207203053_embiggen_github_ids.rb +8 -0
- data/lib/shipit/cast_value.rb +1 -0
- data/lib/shipit/command.rb +29 -9
- data/lib/shipit/commands.rb +4 -2
- data/lib/shipit/csv_serializer.rb +3 -0
- data/lib/shipit/deploy_commands.rb +2 -1
- data/lib/shipit/engine.rb +6 -5
- data/lib/shipit/environment_variables.rb +2 -0
- data/lib/shipit/first_parent_commits_iterator.rb +2 -3
- data/lib/shipit/flock.rb +11 -9
- data/lib/shipit/github_app.rb +14 -16
- data/lib/shipit/github_http_cache_middleware.rb +1 -0
- data/lib/shipit/null_serializer.rb +1 -0
- data/lib/shipit/octokit_check_runs.rb +2 -3
- data/lib/shipit/octokit_iterator.rb +2 -0
- data/lib/shipit/paginator.rb +1 -0
- data/lib/shipit/rollback_commands.rb +2 -1
- data/lib/shipit/same_site_cookie_middleware.rb +1 -0
- data/lib/shipit/simple_message_verifier.rb +1 -0
- data/lib/shipit/stack_commands.rb +35 -27
- data/lib/shipit/stat.rb +1 -0
- data/lib/shipit/task_commands.rb +7 -6
- data/lib/shipit/version.rb +2 -1
- data/lib/shipit.rb +30 -17
- data/lib/tasks/cron.rake +2 -1
- data/lib/tasks/dev.rake +3 -2
- data/lib/tasks/shipit.rake +3 -2
- data/lib/tasks/teams.rake +3 -2
- data/test/controllers/api/base_controller_test.rb +1 -0
- data/test/controllers/api/ccmenu_controller_test.rb +4 -3
- data/test/controllers/api/commits_controller_test.rb +1 -0
- data/test/controllers/api/deploys_controller_test.rb +26 -1
- data/test/controllers/api/hooks_controller_test.rb +6 -5
- data/test/controllers/api/locks_controller_test.rb +1 -0
- data/test/controllers/api/merge_requests_controller_test.rb +1 -0
- data/test/controllers/api/outputs_controller_test.rb +1 -0
- data/test/controllers/api/release_statuses_controller_test.rb +4 -3
- data/test/controllers/api/rollback_controller_test.rb +3 -2
- data/test/controllers/api/stacks_controller_test.rb +13 -12
- data/test/controllers/api/tasks_controller_test.rb +7 -6
- data/test/controllers/api_clients_controller_test.rb +10 -10
- data/test/controllers/ccmenu_controller_test.rb +1 -0
- data/test/controllers/commit_checks_controller_test.rb +1 -0
- data/test/controllers/commits_controller_test.rb +9 -8
- data/test/controllers/continuous_delivery_schedules_controller_test.rb +66 -0
- data/test/controllers/deploys_controller_test.rb +4 -2
- data/test/controllers/github_authentication_controller_test.rb +6 -4
- data/test/controllers/merge_requests_controller_test.rb +1 -0
- data/test/controllers/merge_status_controller_test.rb +5 -4
- data/test/controllers/release_statuses_controller_test.rb +1 -0
- data/test/controllers/repositories_controller_test.rb +6 -5
- data/test/controllers/rollbacks_controller_test.rb +3 -2
- data/test/controllers/stacks_controller_test.rb +8 -6
- data/test/controllers/status_controller_test.rb +1 -0
- data/test/controllers/tasks_controller_test.rb +13 -5
- data/test/controllers/webhooks_controller_test.rb +10 -9
- data/test/dummy/config/application.rb +2 -1
- data/test/dummy/config/initializers/0_load_development_secrets.rb +2 -2
- data/test/dummy/config/secrets.development.json +3 -0
- data/test/dummy/config/secrets.test.json +21 -0
- data/test/dummy/db/schema.rb +33 -6
- data/test/fixtures/shipit/commits.yml +7 -7
- data/test/fixtures/shipit/stacks.yml +4 -10
- data/test/fixtures/shipit/tasks.yml +3 -3
- data/test/helpers/api_helper.rb +2 -3
- data/test/helpers/fixture_aliases_helper.rb +1 -0
- data/test/helpers/hooks_helper.rb +1 -0
- data/test/helpers/json_helper.rb +4 -3
- data/test/helpers/links_helper.rb +2 -1
- data/test/helpers/payloads_helper.rb +1 -0
- data/test/helpers/queries_helper.rb +4 -3
- data/test/jobs/cache_deploy_spec_job_test.rb +3 -2
- data/test/jobs/chunk_rollup_job_test.rb +3 -2
- data/test/jobs/deliver_hook_job_test.rb +1 -0
- data/test/jobs/destroy_repository_job_test.rb +1 -0
- data/test/jobs/destroy_stack_job_test.rb +12 -0
- data/test/jobs/emit_event_job_test.rb +1 -0
- data/test/jobs/fetch_commit_stats_job_test.rb +1 -0
- data/test/jobs/fetch_deployed_revision_job_test.rb +1 -0
- data/test/jobs/github_sync_job_test.rb +22 -21
- data/test/jobs/mark_deploy_healthy_job_test.rb +1 -0
- data/test/jobs/perform_task_job_test.rb +3 -3
- data/test/jobs/process_merge_requests_job_test.rb +7 -6
- data/test/jobs/purge_old_deliveries_job_test.rb +1 -0
- data/test/jobs/reap_dead_tasks_job_test.rb +1 -0
- data/test/jobs/refresh_github_user_job_test.rb +1 -0
- data/test/jobs/refresh_status_job_test.rb +1 -0
- data/test/jobs/shipit/background_job_test.rb +35 -0
- data/test/jobs/shipit/continuous_delivery_job_test.rb +31 -0
- data/test/jobs/unique_job_test.rb +3 -1
- data/test/jobs/update_github_last_deployed_ref_job_test.rb +1 -0
- data/test/middleware/same_site_cookie_middleware_test.rb +2 -2
- data/test/models/api_client_test.rb +1 -0
- data/test/models/commit_checks_test.rb +2 -1
- data/test/models/commit_deployment_status_test.rb +2 -2
- data/test/models/commit_deployment_test.rb +4 -3
- data/test/models/commits_test.rb +72 -70
- data/test/models/delivery_test.rb +3 -2
- data/test/models/deploy_spec_test.rb +113 -109
- data/test/models/deploy_stats_test.rb +1 -0
- data/test/models/deploys_test.rb +65 -56
- data/test/models/duration_test.rb +1 -1
- data/test/models/github_hook_test.rb +1 -0
- data/test/models/hook_test.rb +7 -4
- data/test/models/membership_test.rb +1 -0
- data/test/models/merge_request_test.rb +26 -20
- data/test/models/release_statuses_test.rb +2 -1
- data/test/models/rollbacks_test.rb +4 -3
- data/test/models/shipit/check_run_test.rb +16 -15
- data/test/models/shipit/continuous_delivery_schedule_test.rb +109 -0
- data/test/models/shipit/deploy_spec/file_system_test.rb +54 -10
- data/test/models/shipit/pull_request_test.rb +9 -9
- data/test/models/shipit/repository_test.rb +3 -2
- data/test/models/shipit/review_stack_provisioning_queue_test.rb +2 -2
- data/test/models/shipit/{stacks_test.rb → stack_test.rb} +48 -34
- data/test/models/shipit/webhooks/handlers/pull_request/closed_handler_test.rb +36 -34
- data/test/models/shipit/webhooks/handlers/pull_request/label_capturing_handler_test.rb +28 -28
- data/test/models/shipit/webhooks/handlers/pull_request/labeled_handler_test.rb +42 -42
- data/test/models/shipit/webhooks/handlers/pull_request/opened_handler_test.rb +33 -33
- data/test/models/shipit/webhooks/handlers/pull_request/reopened_handler_test.rb +37 -37
- data/test/models/shipit/webhooks/handlers/pull_request/review_stack_adapter_test.rb +1 -1
- data/test/models/shipit/webhooks/handlers/pull_request/unlabeled_handler_test.rb +44 -42
- data/test/models/shipit/webhooks/handlers_test.rb +1 -0
- data/test/models/status/group_test.rb +3 -2
- data/test/models/status/missing_test.rb +1 -0
- data/test/models/status_test.rb +2 -1
- data/test/models/task_definitions_test.rb +7 -6
- data/test/models/tasks_test.rb +5 -4
- data/test/models/team_test.rb +5 -4
- data/test/models/undeployed_commits_test.rb +10 -9
- data/test/models/users_test.rb +29 -20
- data/test/test_command_integration.rb +1 -1
- data/test/test_helper.rb +12 -10
- data/test/unit/anonymous_user_serializer_test.rb +1 -0
- data/test/unit/command_test.rb +10 -1
- data/test/unit/commands_test.rb +1 -0
- data/test/unit/commit_serializer_test.rb +1 -0
- data/test/unit/csv_serializer_test.rb +3 -2
- data/test/unit/deploy_commands_test.rb +33 -23
- data/test/unit/deploy_serializer_test.rb +1 -0
- data/test/unit/environment_variables_test.rb +2 -1
- data/test/unit/github_app_test.rb +11 -10
- data/test/unit/github_apps_test.rb +19 -18
- data/test/unit/github_url_helper_test.rb +1 -0
- data/test/unit/line_buffer_test.rb +1 -1
- data/test/unit/rollback_commands_test.rb +2 -1
- data/test/unit/shipit_helper_test.rb +1 -0
- data/test/unit/shipit_test.rb +47 -1
- data/test/unit/user_serializer_test.rb +1 -0
- data/test/unit/variable_definition_test.rb +4 -3
- metadata +61 -47
@@ -18,13 +18,15 @@ module Shipit
|
|
18
18
|
end
|
19
19
|
|
20
20
|
test "ignores Github PullRequest webhooks by default" do
|
21
|
-
|
21
|
+
assert_no_difference -> { Shipit::PullRequest.count } do
|
22
|
+
UnlabeledHandler.new(payload_parsed(:pull_request_with_no_repo).merge(action: "closed")).process
|
23
|
+
end
|
22
24
|
end
|
23
25
|
|
24
26
|
test "ignores Github PullRequest webhooks when the Repository has disabled the Review Stacks feature" do
|
25
27
|
repository = shipit_repositories(:shipit)
|
26
28
|
configure_provisioning_behavior(
|
27
|
-
repository
|
29
|
+
repository:,
|
28
30
|
provisioning_enabled: false,
|
29
31
|
behavior: :allow_with_label,
|
30
32
|
label: "pull-requests-label"
|
@@ -45,7 +47,7 @@ module Shipit
|
|
45
47
|
stack = create_stack
|
46
48
|
repository = shipit_repositories(:shipit)
|
47
49
|
configure_provisioning_behavior(
|
48
|
-
repository
|
50
|
+
repository:,
|
49
51
|
behavior: :allow_with_label,
|
50
52
|
label: "pull-requests-label"
|
51
53
|
)
|
@@ -59,7 +61,7 @@ module Shipit
|
|
59
61
|
stack = create_stack
|
60
62
|
repository = shipit_repositories(:shipit)
|
61
63
|
configure_provisioning_behavior(
|
62
|
-
repository
|
64
|
+
repository:,
|
63
65
|
behavior: :allow_with_label,
|
64
66
|
label: "pull-requests-label"
|
65
67
|
)
|
@@ -72,7 +74,7 @@ module Shipit
|
|
72
74
|
test "ignores Github PullRequest webhooks when the repository allow_with_label to create ReviewStacks and the label is absent" do
|
73
75
|
repository = shipit_repositories(:shipit)
|
74
76
|
configure_provisioning_behavior(
|
75
|
-
repository
|
77
|
+
repository:,
|
76
78
|
behavior: :allow_with_label,
|
77
79
|
label: "pull-requests-label"
|
78
80
|
)
|
@@ -86,7 +88,7 @@ module Shipit
|
|
86
88
|
stack = create_archived_stack
|
87
89
|
repository = shipit_repositories(:shipit)
|
88
90
|
configure_provisioning_behavior(
|
89
|
-
repository
|
91
|
+
repository:,
|
90
92
|
behavior: :allow_with_label,
|
91
93
|
label: "pull-requests-label"
|
92
94
|
)
|
@@ -102,7 +104,7 @@ module Shipit
|
|
102
104
|
test "creates and provisions a new review stack when the repository creates ReviewStacks with allow_with_label and the label is present" do
|
103
105
|
repository = shipit_repositories(:shipit)
|
104
106
|
configure_provisioning_behavior(
|
105
|
-
repository
|
107
|
+
repository:,
|
106
108
|
behavior: :allow_with_label,
|
107
109
|
label: "pull-requests-label"
|
108
110
|
)
|
@@ -124,7 +126,7 @@ module Shipit
|
|
124
126
|
stack = create_stack
|
125
127
|
repository = shipit_repositories(:shipit)
|
126
128
|
configure_provisioning_behavior(
|
127
|
-
repository
|
129
|
+
repository:,
|
128
130
|
behavior: :prevent_with_label,
|
129
131
|
label: "pull-requests-label"
|
130
132
|
)
|
@@ -140,7 +142,7 @@ module Shipit
|
|
140
142
|
stack = create_stack
|
141
143
|
repository = shipit_repositories(:shipit)
|
142
144
|
configure_provisioning_behavior(
|
143
|
-
repository
|
145
|
+
repository:,
|
144
146
|
behavior: :prevent_with_label,
|
145
147
|
label: "pull-requests-label"
|
146
148
|
)
|
@@ -155,7 +157,7 @@ module Shipit
|
|
155
157
|
test "ignores Github PullRequest webhooks when the repository prevent_with_label to create ReviewStacks and the label is present" do
|
156
158
|
repository = shipit_repositories(:shipit)
|
157
159
|
configure_provisioning_behavior(
|
158
|
-
repository
|
160
|
+
repository:,
|
159
161
|
behavior: :prevent_with_label,
|
160
162
|
label: "pull-requests-label"
|
161
163
|
)
|
@@ -171,7 +173,7 @@ module Shipit
|
|
171
173
|
stack = create_archived_stack
|
172
174
|
repository = shipit_repositories(:shipit)
|
173
175
|
configure_provisioning_behavior(
|
174
|
-
repository
|
176
|
+
repository:,
|
175
177
|
behavior: :prevent_with_label,
|
176
178
|
label: "pull-requests-label"
|
177
179
|
)
|
@@ -187,7 +189,7 @@ module Shipit
|
|
187
189
|
test "creates and provisions a new review stack when the repository creates ReviewStacks with prevent_with_label and the label is absent" do
|
188
190
|
repository = shipit_repositories(:shipit)
|
189
191
|
configure_provisioning_behavior(
|
190
|
-
repository
|
192
|
+
repository:,
|
191
193
|
behavior: :prevent_with_label,
|
192
194
|
label: "pull-requests-label"
|
193
195
|
)
|
@@ -208,7 +210,7 @@ module Shipit
|
|
208
210
|
test "assigns the PullRequest to newly created stacks" do
|
209
211
|
repository = shipit_repositories(:shipit)
|
210
212
|
configure_provisioning_behavior(
|
211
|
-
repository
|
213
|
+
repository:,
|
212
214
|
behavior: :prevent_with_label,
|
213
215
|
label: "pull-requests-label"
|
214
216
|
)
|
@@ -224,7 +226,7 @@ module Shipit
|
|
224
226
|
create_archived_stack
|
225
227
|
repository = shipit_repositories(:shipit)
|
226
228
|
configure_provisioning_behavior(
|
227
|
-
repository
|
229
|
+
repository:,
|
228
230
|
behavior: :allow_with_label,
|
229
231
|
label: "pull-requests-label"
|
230
232
|
)
|
@@ -273,8 +275,8 @@ module Shipit
|
|
273
275
|
|
274
276
|
def complete_active_tasks(stack)
|
275
277
|
active_tasks = stack
|
276
|
-
|
277
|
-
|
278
|
+
.tasks
|
279
|
+
.active
|
278
280
|
|
279
281
|
active_tasks.map(&:run)
|
280
282
|
active_tasks.reload
|
@@ -290,32 +292,32 @@ module Shipit
|
|
290
292
|
|
291
293
|
setup do
|
292
294
|
Shipit.github.api.stubs(:commit)
|
293
|
-
|
294
|
-
|
295
|
-
|
296
|
-
|
297
|
-
|
298
|
-
|
299
|
-
|
300
|
-
|
301
|
-
|
302
|
-
|
303
|
-
|
304
|
-
|
305
|
-
|
306
|
-
|
307
|
-
|
308
|
-
|
309
|
-
|
310
|
-
|
311
|
-
|
312
|
-
|
313
|
-
|
314
|
-
|
315
|
-
|
316
|
-
|
317
|
-
|
318
|
-
|
295
|
+
.with("shopify/shipit-engine", "ec26c3e57ca3a959ca5aad62de7213c562f8c821")
|
296
|
+
.returns(
|
297
|
+
resource(
|
298
|
+
{
|
299
|
+
sha: "ec26c3e57ca3a959ca5aad62de7213c562f8c821",
|
300
|
+
commit: {
|
301
|
+
author: {
|
302
|
+
name: "Codertocat",
|
303
|
+
email: "21031067+Codertocat@users.noreply.github.com",
|
304
|
+
date: "2019-05-15 15:20:30"
|
305
|
+
},
|
306
|
+
committer: {
|
307
|
+
name: "Codertocat",
|
308
|
+
email: "21031067+Codertocat@users.noreply.github.com",
|
309
|
+
date: "2019-05-15 15:20:30"
|
310
|
+
},
|
311
|
+
message: "Update README.md"
|
312
|
+
},
|
313
|
+
stats: {
|
314
|
+
total: 2,
|
315
|
+
additions: 1,
|
316
|
+
deletions: 1
|
317
|
+
}
|
318
|
+
}
|
319
|
+
)
|
320
|
+
)
|
319
321
|
end
|
320
322
|
end
|
321
323
|
end
|
@@ -1,4 +1,5 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
|
+
|
2
3
|
require 'test_helper'
|
3
4
|
|
4
5
|
module Shipit
|
@@ -21,7 +22,7 @@ module Shipit
|
|
21
22
|
end
|
22
23
|
|
23
24
|
test "#state is significant's status state" do
|
24
|
-
assert_equal %w
|
25
|
+
assert_equal %w[success success failure], @group.statuses.map(&:state)
|
25
26
|
assert_equal 'failure', @group.state
|
26
27
|
end
|
27
28
|
|
@@ -42,7 +43,7 @@ module Shipit
|
|
42
43
|
end
|
43
44
|
|
44
45
|
test "missing required status will have MissingRequiredStatus as placeholder" do
|
45
|
-
@commit.stubs(:required_statuses).returns(%w
|
46
|
+
@commit.stubs(:required_statuses).returns(%w[ci/very-important])
|
46
47
|
status = Status::Group.compact(@commit, [])
|
47
48
|
assert_instance_of Status::Missing, status
|
48
49
|
assert_predicate status, :pending?
|
data/test/models/status_test.rb
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
|
+
|
2
3
|
require 'test_helper'
|
3
4
|
|
4
5
|
module Shipit
|
@@ -50,7 +51,7 @@ module Shipit
|
|
50
51
|
description: 'This is a description',
|
51
52
|
context: 'default',
|
52
53
|
target_url: 'http://example.com',
|
53
|
-
created_at: 1.day.ago.to_time
|
54
|
+
created_at: 1.day.ago.to_time
|
54
55
|
)
|
55
56
|
end
|
56
57
|
|
@@ -1,4 +1,5 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
|
+
|
2
3
|
require 'test_helper'
|
3
4
|
|
4
5
|
module Shipit
|
@@ -7,7 +8,7 @@ module Shipit
|
|
7
8
|
@definition = TaskDefinition.new(
|
8
9
|
'restart',
|
9
10
|
'action' => 'Restart application',
|
10
|
-
'title' => 'Restart application
|
11
|
+
'title' => 'Restart application %<FOO>s',
|
11
12
|
'description' => 'Restart app and job servers',
|
12
13
|
'steps' => ['touch tmp/restart'],
|
13
14
|
'allow_concurrency' => true,
|
@@ -15,8 +16,8 @@ module Shipit
|
|
15
16
|
{ 'name' => 'FOO', 'title' => 'Set to 0 to foo', 'default' => '1' },
|
16
17
|
{ 'name' => 'BAR', 'title' => 'Set to 1 to bar', 'default' => '0' },
|
17
18
|
{ 'name' => 'WALRUS', 'title' => 'Use with caution', 'default' => ' ' },
|
18
|
-
{ 'name' => 'NODEFAULT', 'title' => 'Variable without default' }
|
19
|
-
]
|
19
|
+
{ 'name' => 'NODEFAULT', 'title' => 'Variable without default' }
|
20
|
+
]
|
20
21
|
)
|
21
22
|
end
|
22
23
|
|
@@ -38,7 +39,7 @@ module Shipit
|
|
38
39
|
as_json = {
|
39
40
|
id: 'restart',
|
40
41
|
action: 'Restart application',
|
41
|
-
title: "Restart application
|
42
|
+
title: "Restart application %<FOO>s",
|
42
43
|
description: 'Restart app and job servers',
|
43
44
|
steps: ['touch tmp/restart'],
|
44
45
|
checklist: [],
|
@@ -47,8 +48,8 @@ module Shipit
|
|
47
48
|
{ 'name' => 'FOO', 'title' => 'Set to 0 to foo', 'default' => '1', 'select' => nil },
|
48
49
|
{ 'name' => 'BAR', 'title' => 'Set to 1 to bar', 'default' => '0', 'select' => nil },
|
49
50
|
{ 'name' => 'WALRUS', 'title' => 'Use with caution', 'default' => ' ', 'select' => nil },
|
50
|
-
{ 'name' => 'NODEFAULT', 'title' => 'Variable without default', 'default' => '', 'select' => nil }
|
51
|
-
]
|
51
|
+
{ 'name' => 'NODEFAULT', 'title' => 'Variable without default', 'default' => '', 'select' => nil }
|
52
|
+
]
|
52
53
|
}
|
53
54
|
assert_equal as_json, TaskDefinition.load(TaskDefinition.dump(@definition)).as_json
|
54
55
|
end
|
data/test/models/tasks_test.rb
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
|
+
|
2
3
|
require 'test_helper'
|
3
4
|
|
4
5
|
module Shipit
|
@@ -16,7 +17,7 @@ module Shipit
|
|
16
17
|
|
17
18
|
test '#title returns an error message when the title raises an error' do
|
18
19
|
task = shipit_tasks(:shipit_with_title_parsing_issue)
|
19
|
-
assert_equal 'This task (title: Using the
|
20
|
+
assert_equal 'This task (title: Using the %<WRONG_VARIABLE_NAME>) cannot be shown due to an incorrect variable name. Check your shipit.yml file', task.title
|
20
21
|
end
|
21
22
|
|
22
23
|
test "#write sends line-buffered output to task logger" do
|
@@ -44,7 +45,7 @@ module Shipit
|
|
44
45
|
# We don't use assert_includes because it will print the whole message
|
45
46
|
assert(
|
46
47
|
output.include?(Task::OUTPUT_TRUNCATED_MESSAGE),
|
47
|
-
"'#{Task::OUTPUT_TRUNCATED_MESSAGE.chomp}' was not present in the output"
|
48
|
+
"'#{Task::OUTPUT_TRUNCATED_MESSAGE.chomp}' was not present in the output"
|
48
49
|
)
|
49
50
|
end
|
50
51
|
|
@@ -94,7 +95,7 @@ module Shipit
|
|
94
95
|
task.update(
|
95
96
|
rolled_up: false,
|
96
97
|
created_at: (60 + 1).minutes.ago.to_formatted_s(:db),
|
97
|
-
status: "success"
|
98
|
+
status: "success"
|
98
99
|
)
|
99
100
|
|
100
101
|
assert_includes Shipit::Task.due_for_rollup, task
|
@@ -105,7 +106,7 @@ module Shipit
|
|
105
106
|
task.update(
|
106
107
|
rolled_up: false,
|
107
108
|
created_at: (60 + 1).minutes.ago.to_formatted_s(:db),
|
108
|
-
status: "error"
|
109
|
+
status: "error"
|
109
110
|
)
|
110
111
|
|
111
112
|
assert_includes Shipit::Task.due_for_rollup, task
|
data/test/models/team_test.rb
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
|
+
|
2
3
|
require 'test_helper'
|
3
4
|
|
4
5
|
module Shipit
|
@@ -34,7 +35,7 @@ module Shipit
|
|
34
35
|
skip unless limit
|
35
36
|
|
36
37
|
slug = 'a' * 255
|
37
|
-
team = new_team(slug:
|
38
|
+
team = new_team(slug:)
|
38
39
|
|
39
40
|
response = stub(rels: {}, data: [team])
|
40
41
|
Shipit.github.api.expects(:org_teams).with('shopify', per_page: 100).returns(response.data)
|
@@ -61,7 +62,7 @@ module Shipit
|
|
61
62
|
login: 'george',
|
62
63
|
email: 'george@cyclim.se',
|
63
64
|
avatar_url: 'https://avatars.githubusercontent.com/u/42?v=3',
|
64
|
-
url: 'https://api.github.com/user/george'
|
65
|
+
url: 'https://api.github.com/user/george'
|
65
66
|
)
|
66
67
|
end
|
67
68
|
|
@@ -69,10 +70,10 @@ module Shipit
|
|
69
70
|
stub(
|
70
71
|
id: 24,
|
71
72
|
name: 'New Team',
|
72
|
-
slug
|
73
|
+
slug:,
|
73
74
|
url: 'https://example.com',
|
74
75
|
description: 'The Best one',
|
75
|
-
organization: 'shopify'
|
76
|
+
organization: 'shopify'
|
76
77
|
)
|
77
78
|
end
|
78
79
|
end
|
@@ -1,4 +1,5 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
|
+
|
2
3
|
require 'test_helper'
|
3
4
|
|
4
5
|
module Shipit
|
@@ -41,9 +42,9 @@ module Shipit
|
|
41
42
|
end
|
42
43
|
|
43
44
|
test "#expected_to_be_deployed? returns true if the stack has continuous deployment enabled, next expected commit to deploy id is greater or equals to the commit id and commit is not active" do
|
44
|
-
commit = shipit_commits(:
|
45
|
+
commit = shipit_commits(:undeployed4)
|
45
46
|
next_expected_commit_to_deploy = commit.stack.next_expected_commit_to_deploy
|
46
|
-
undeployed_commit = UndeployedCommit.new(commit, index: 1, next_expected_commit_to_deploy:
|
47
|
+
undeployed_commit = UndeployedCommit.new(commit, index: 1, next_expected_commit_to_deploy:)
|
47
48
|
|
48
49
|
refute_predicate next_expected_commit_to_deploy, :nil?
|
49
50
|
assert_predicate undeployed_commit.stack, :continuous_deployment
|
@@ -56,7 +57,7 @@ module Shipit
|
|
56
57
|
test "#expected_to_be_deployed? returns true if the active task has no commit range" do
|
57
58
|
commit = shipit_commits(:task_no_commits)
|
58
59
|
next_expected_commit_to_deploy = commit.stack.next_expected_commit_to_deploy
|
59
|
-
undeployed_commit = UndeployedCommit.new(commit, index: 1, next_expected_commit_to_deploy:
|
60
|
+
undeployed_commit = UndeployedCommit.new(commit, index: 1, next_expected_commit_to_deploy:)
|
60
61
|
|
61
62
|
refute_predicate next_expected_commit_to_deploy, :nil?
|
62
63
|
assert_predicate undeployed_commit.stack, :continuous_deployment
|
@@ -69,7 +70,7 @@ module Shipit
|
|
69
70
|
test "#expected_to_be_deployed? returns false if the stack has continuous deployment disabled" do
|
70
71
|
commit = shipit_commits(:cyclimse_first)
|
71
72
|
next_expected_commit_to_deploy = commit.stack.next_expected_commit_to_deploy
|
72
|
-
undeployed_commit = UndeployedCommit.new(commit, index: 1, next_expected_commit_to_deploy:
|
73
|
+
undeployed_commit = UndeployedCommit.new(commit, index: 1, next_expected_commit_to_deploy:)
|
73
74
|
|
74
75
|
refute_predicate next_expected_commit_to_deploy, :nil?
|
75
76
|
refute_predicate undeployed_commit.stack, :continuous_deployment
|
@@ -80,9 +81,9 @@ module Shipit
|
|
80
81
|
end
|
81
82
|
|
82
83
|
test "#expected_to_be_deployed? returns false if the commit is part of the active task" do
|
83
|
-
commit = shipit_commits(:
|
84
|
+
commit = shipit_commits(:undeployed3)
|
84
85
|
next_expected_commit_to_deploy = commit.stack.next_expected_commit_to_deploy
|
85
|
-
undeployed_commit = UndeployedCommit.new(commit, index: 1, next_expected_commit_to_deploy:
|
86
|
+
undeployed_commit = UndeployedCommit.new(commit, index: 1, next_expected_commit_to_deploy:)
|
86
87
|
|
87
88
|
refute_predicate next_expected_commit_to_deploy, :nil?
|
88
89
|
assert_predicate undeployed_commit.stack, :continuous_deployment
|
@@ -93,16 +94,16 @@ module Shipit
|
|
93
94
|
end
|
94
95
|
|
95
96
|
test "#expected_to_be_deployed? returns false if there is no commit to deploy" do
|
96
|
-
commit = shipit_commits(:
|
97
|
+
commit = shipit_commits(:undeployed3)
|
97
98
|
undeployed_commit = UndeployedCommit.new(commit, index: 1, next_expected_commit_to_deploy: nil)
|
98
99
|
|
99
100
|
refute_predicate undeployed_commit, :expected_to_be_deployed?
|
100
101
|
end
|
101
102
|
|
102
103
|
test "#expected_to_be_deployed? returns false if the commit has an id greater than next commit to deploy" do
|
103
|
-
commit = shipit_commits(:
|
104
|
+
commit = shipit_commits(:undeployed7)
|
104
105
|
next_expected_commit_to_deploy = commit.stack.next_expected_commit_to_deploy
|
105
|
-
undeployed_commit = UndeployedCommit.new(commit, index: 1, next_expected_commit_to_deploy:
|
106
|
+
undeployed_commit = UndeployedCommit.new(commit, index: 1, next_expected_commit_to_deploy:)
|
106
107
|
|
107
108
|
refute_predicate next_expected_commit_to_deploy, :nil?
|
108
109
|
assert_predicate undeployed_commit.stack, :continuous_deployment
|
data/test/models/users_test.rb
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
|
+
|
2
3
|
require 'test_helper'
|
3
4
|
|
4
5
|
module Shipit
|
@@ -12,7 +13,7 @@ module Shipit
|
|
12
13
|
login: 'george',
|
13
14
|
email: 'george@cyclim.se',
|
14
15
|
avatar_url: 'https://avatars.githubusercontent.com/u/42?v=3',
|
15
|
-
url: 'https://api.github.com/user/george'
|
16
|
+
url: 'https://api.github.com/user/george'
|
16
17
|
)
|
17
18
|
@org_domain = "shopify.com"
|
18
19
|
@emails_url = "https://api.github.com/user/emails"
|
@@ -23,7 +24,7 @@ module Shipit
|
|
23
24
|
email: nil,
|
24
25
|
avatar_url: 'https://avatars.githubusercontent.com/u/43?v=3',
|
25
26
|
url: 'https://api.github.com/user/peter',
|
26
|
-
rels: nil
|
27
|
+
rels: nil
|
27
28
|
)
|
28
29
|
end
|
29
30
|
|
@@ -78,7 +79,7 @@ module Shipit
|
|
78
79
|
login: 'jim',
|
79
80
|
email: "jim@#{@org_domain}",
|
80
81
|
avatar_url: 'https://avatars.githubusercontent.com/u/42?v=3',
|
81
|
-
url: 'https://api.github.com/user/jim'
|
82
|
+
url: 'https://api.github.com/user/jim'
|
82
83
|
)
|
83
84
|
|
84
85
|
Shipit.preferred_org_emails = [].freeze
|
@@ -91,9 +92,9 @@ module Shipit
|
|
91
92
|
expected_email = "myuser@#{@org_domain}"
|
92
93
|
|
93
94
|
stub_request(:get, @emails_url).to_return(
|
94
|
-
status: %w
|
95
|
+
status: %w[200 OK],
|
95
96
|
body: [{ email: expected_email }].to_json,
|
96
|
-
headers: { "Content-Type" => "application/json" }
|
97
|
+
headers: { "Content-Type" => "application/json" }
|
97
98
|
)
|
98
99
|
|
99
100
|
user = User.find_or_create_from_github(@github_user)
|
@@ -106,21 +107,21 @@ module Shipit
|
|
106
107
|
result_email_records = [
|
107
108
|
{
|
108
109
|
email: "notmyuser1@#{@org_domain}",
|
109
|
-
primary: false
|
110
|
+
primary: false
|
110
111
|
},
|
111
112
|
{
|
112
|
-
email: "notmyuser2@#{@org_domain}"
|
113
|
+
email: "notmyuser2@#{@org_domain}"
|
113
114
|
},
|
114
115
|
{
|
115
116
|
email: expected_email,
|
116
|
-
primary: true
|
117
|
-
}
|
117
|
+
primary: true
|
118
|
+
}
|
118
119
|
]
|
119
120
|
|
120
121
|
stub_request(:get, @emails_url).to_return(
|
121
|
-
status: %w
|
122
|
+
status: %w[200 OK],
|
122
123
|
body: result_email_records.to_json,
|
123
|
-
headers: { "Content-Type" => "application/json" }
|
124
|
+
headers: { "Content-Type" => "application/json" }
|
124
125
|
)
|
125
126
|
|
126
127
|
user = User.find_or_create_from_github(@github_user)
|
@@ -132,17 +133,17 @@ module Shipit
|
|
132
133
|
result_email_records = [
|
133
134
|
{
|
134
135
|
email: "notmyuser1@not#{@org_domain}",
|
135
|
-
primary: false
|
136
|
+
primary: false
|
136
137
|
},
|
137
138
|
{
|
138
|
-
email: "notmyuser2@not#{@org_domain}"
|
139
|
-
}
|
139
|
+
email: "notmyuser2@not#{@org_domain}"
|
140
|
+
}
|
140
141
|
]
|
141
142
|
|
142
143
|
stub_request(:get, @emails_url).to_return(
|
143
|
-
status: %w
|
144
|
+
status: %w[200 OK],
|
144
145
|
body: result_email_records.to_json,
|
145
|
-
headers: { "Content-Type" => "application/json" }
|
146
|
+
headers: { "Content-Type" => "application/json" }
|
146
147
|
)
|
147
148
|
|
148
149
|
user = User.find_or_create_from_github(@github_user)
|
@@ -203,6 +204,14 @@ module Shipit
|
|
203
204
|
assert_equal 'george@cyclim.se', user.email
|
204
205
|
end
|
205
206
|
|
207
|
+
test "#refresh_from_github! logs deleted users" do
|
208
|
+
Shipit.github.api.expects(:user).with(@user.github_id).raises(Octokit::Forbidden)
|
209
|
+
|
210
|
+
Rails.logger.expects(:info).with("User #{@user.name}, github_id #{@user.github_id} has forbidden access to their GitHub, likely deleted.")
|
211
|
+
|
212
|
+
@user.refresh_from_github!
|
213
|
+
end
|
214
|
+
|
206
215
|
test "#github_api uses the user's access token" do
|
207
216
|
assert_equal @user.github_access_token, @user.github_api.access_token
|
208
217
|
end
|
@@ -265,15 +274,15 @@ module Shipit
|
|
265
274
|
id: user.github_id,
|
266
275
|
name: user.name,
|
267
276
|
email: user.email,
|
268
|
-
date: Time.now.utc
|
277
|
+
date: Time.now.utc
|
269
278
|
},
|
270
279
|
committer: {
|
271
280
|
name: user.name,
|
272
281
|
email: user.email,
|
273
|
-
date: Time.now.utc
|
282
|
+
date: Time.now.utc
|
274
283
|
},
|
275
|
-
message: "commit to trigger staging build\n\nMerge-Requested-By: missinguser\n"
|
276
|
-
}
|
284
|
+
message: "commit to trigger staging build\n\nMerge-Requested-By: missinguser\n"
|
285
|
+
}
|
277
286
|
)
|
278
287
|
found_user = Shipit::User.find_or_create_author_from_github_commit(github_commit)
|
279
288
|
assert_equal user, found_user
|
@@ -16,7 +16,7 @@ expected_output = [
|
|
16
16
|
"Sleeping for 10 seconds\r\n",
|
17
17
|
"\e[1;31mNo output received in the last 2 seconds.\e[0m\n",
|
18
18
|
"\e[1;31mSending SIGINT to PID #{command.pid}\n\e[0m",
|
19
|
-
"Recieved SIGINT, aborting.\r\n"
|
19
|
+
"Recieved SIGINT, aborting.\r\n"
|
20
20
|
]
|
21
21
|
|
22
22
|
unless buffer.join == expected_output.join
|
data/test/test_helper.rb
CHANGED
@@ -1,9 +1,8 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
|
+
|
2
3
|
ENV["RAILS_ENV"] ||= "test"
|
3
4
|
|
4
|
-
if Warning.respond_to?(:[]=)
|
5
|
-
Warning[:deprecated] = true
|
6
|
-
end
|
5
|
+
Warning[:deprecated] = true if Warning.respond_to?(:[]=)
|
7
6
|
|
8
7
|
require 'simplecov'
|
9
8
|
SimpleCov.start('rails') do
|
@@ -12,10 +11,10 @@ end
|
|
12
11
|
|
13
12
|
require 'webmock/minitest'
|
14
13
|
|
15
|
-
require File.expand_path('
|
14
|
+
require File.expand_path('../test/dummy/config/environment.rb', __dir__)
|
16
15
|
ActiveRecord::Migrator.migrations_paths = [
|
17
|
-
File.expand_path('
|
18
|
-
File.expand_path('
|
16
|
+
File.expand_path('../test/dummy/db/migrate', __dir__),
|
17
|
+
File.expand_path('../db/migrate', __dir__)
|
19
18
|
]
|
20
19
|
require 'rails/test_help'
|
21
20
|
require 'mocha/minitest'
|
@@ -23,11 +22,11 @@ require 'spy/integration'
|
|
23
22
|
|
24
23
|
# Load fixtures from the engine
|
25
24
|
if ActiveSupport::TestCase.respond_to?(:fixture_path=)
|
26
|
-
ActiveSupport::TestCase.
|
25
|
+
ActiveSupport::TestCase.fixture_paths << File.expand_path('fixtures', __dir__)
|
27
26
|
ActiveSupport::TestCase.fixtures(:all)
|
28
27
|
end
|
29
28
|
|
30
|
-
Dir[File.expand_path('
|
29
|
+
Dir[File.expand_path('helpers/**/*.rb', __dir__)].each do |helper|
|
31
30
|
require helper
|
32
31
|
end
|
33
32
|
|
@@ -66,12 +65,15 @@ module ActiveSupport
|
|
66
65
|
teardown do
|
67
66
|
Shipit.redis.flushdb
|
68
67
|
Shipit.instance_variable_names.each do |name|
|
69
|
-
next if %w
|
68
|
+
next if %w[@mocha @redis].include?(name)
|
69
|
+
|
70
70
|
Shipit.remove_instance_variable(name)
|
71
71
|
end
|
72
72
|
end
|
73
73
|
|
74
|
-
ActiveRecord::Migration.
|
74
|
+
ActiveRecord::Migration.check_all_pending!
|
75
|
+
|
76
|
+
fixture_paths << File.expand_path('fixtures', __dir__)
|
75
77
|
|
76
78
|
# Setup all fixtures in test/fixtures/*.yml for all tests in alphabetical order.
|
77
79
|
#
|
data/test/unit/command_test.rb
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
|
+
|
2
3
|
require 'test_helper'
|
3
4
|
|
4
5
|
module Shipit
|
@@ -54,12 +55,20 @@ module Shipit
|
|
54
55
|
assert_equal 10, command.timeout
|
55
56
|
end
|
56
57
|
|
58
|
+
test "#timeout in duration string form" do
|
59
|
+
command = Command.new({ 'cap $LANG deploy' => { 'timeout' => '10m' } }, default_timeout: 5, env: {}, chdir: '.')
|
60
|
+
assert_equal 600, command.timeout
|
61
|
+
|
62
|
+
command = Command.new({ 'cap $LANG deploy' => { 'timeout' => '10B' } }, default_timeout: 5, env: {}, chdir: '.')
|
63
|
+
assert_equal 5, command.timeout # default
|
64
|
+
end
|
65
|
+
|
57
66
|
test "the process is properly terminated if it times out" do
|
58
67
|
# Minitest being run in an at_exit callback, signal handling etc is unreliable
|
59
68
|
assert system(
|
60
69
|
Engine.root.join('test/dummy/bin/rails').to_s,
|
61
70
|
'runner',
|
62
|
-
Engine.root.join('test/test_command_integration.rb').to_s
|
71
|
+
Engine.root.join('test/test_command_integration.rb').to_s
|
63
72
|
)
|
64
73
|
end
|
65
74
|
|