shipit-engine 0.5.2 → 0.6.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/controllers/concerns/shipit/api/cacheable.rb +13 -0
- data/app/controllers/concerns/shipit/api/paginable.rb +37 -0
- data/app/controllers/concerns/shipit/api/rendering.rb +25 -0
- data/app/controllers/concerns/{api/paginable.rb → shipit/pagination.rb} +5 -13
- data/app/controllers/shipit/api/base_controller.rb +68 -0
- data/app/controllers/shipit/api/deploys_controller.rb +17 -0
- data/app/controllers/shipit/api/hooks_controller.rb +53 -0
- data/app/controllers/shipit/api/locks_controller.rb +32 -0
- data/app/controllers/shipit/api/outputs_controller.rb +17 -0
- data/app/controllers/shipit/api/stacks_controller.rb +21 -0
- data/app/controllers/shipit/api/tasks_controller.rb +20 -0
- data/app/controllers/shipit/commit_checks_controller.rb +26 -0
- data/app/controllers/shipit/deploys_controller.rb +47 -0
- data/app/controllers/shipit/github_authentication_controller.rb +27 -0
- data/app/controllers/shipit/rollbacks_controller.rb +26 -0
- data/app/controllers/shipit/shipit_controller.rb +62 -0
- data/app/controllers/shipit/stacks_controller.rb +81 -0
- data/app/controllers/shipit/status_controller.rb +7 -0
- data/app/controllers/shipit/tasks_controller.rb +48 -0
- data/app/controllers/shipit/webhooks_controller.rb +101 -0
- data/app/helpers/shipit/chunks_helper.rb +8 -0
- data/app/helpers/shipit/deploys_helper.rb +28 -0
- data/app/helpers/shipit/github_url_helper.rb +48 -0
- data/app/helpers/shipit/shipit_helper.rb +64 -0
- data/app/helpers/shipit/stacks_helper.rb +78 -0
- data/app/helpers/shipit/tasks_helper.rb +11 -0
- data/app/jobs/shipit/background_job.rb +24 -0
- data/app/jobs/shipit/background_job/unique.rb +28 -0
- data/app/jobs/shipit/cache_deploy_spec_job.rb +12 -0
- data/app/jobs/shipit/chunk_rollup_job.rb +21 -0
- data/app/jobs/shipit/clear_git_cache_job.rb +9 -0
- data/app/jobs/shipit/deliver_hook_job.rb +9 -0
- data/app/jobs/shipit/destroy_stack_job.rb +9 -0
- data/app/jobs/shipit/emit_event_job.rb +10 -0
- data/app/jobs/shipit/fetch_commit_stats_job.rb +9 -0
- data/app/jobs/shipit/fetch_deployed_revision_job.rb +23 -0
- data/app/jobs/shipit/git_mirror_update_job.rb +12 -0
- data/app/jobs/shipit/github_sync_job.rb +55 -0
- data/app/jobs/shipit/perform_commit_checks_job.rb +7 -0
- data/app/jobs/shipit/perform_task_job.rb +57 -0
- data/app/jobs/shipit/refresh_github_user_job.rb +9 -0
- data/app/jobs/shipit/refresh_statuses_job.rb +14 -0
- data/app/jobs/shipit/setup_github_hook_job.rb +11 -0
- data/app/models/shipit/anonymous_user.rb +43 -0
- data/app/models/shipit/api_client.rb +44 -0
- data/app/models/shipit/commit.rb +209 -0
- data/app/models/shipit/commit_checks.rb +90 -0
- data/app/models/shipit/delivery.rb +47 -0
- data/app/models/shipit/deploy.rb +153 -0
- data/app/models/shipit/deploy_spec.rb +150 -0
- data/app/models/shipit/deploy_spec/bundler_discovery.rb +61 -0
- data/app/models/shipit/deploy_spec/capistrano_discovery.rb +29 -0
- data/app/models/shipit/deploy_spec/file_system.rb +64 -0
- data/app/models/shipit/deploy_spec/pypi_discovery.rb +34 -0
- data/app/models/shipit/deploy_spec/rubygems_discovery.rb +34 -0
- data/app/models/shipit/github_hook.rb +148 -0
- data/app/models/shipit/hook.rb +86 -0
- data/app/models/shipit/membership.rb +8 -0
- data/app/models/shipit/missing_status.rb +21 -0
- data/app/models/shipit/output_chunk.rb +11 -0
- data/app/models/shipit/rollback.rb +31 -0
- data/app/models/shipit/stack.rb +308 -0
- data/app/models/shipit/status.rb +44 -0
- data/app/models/shipit/status_group.rb +35 -0
- data/app/models/shipit/task.rb +201 -0
- data/app/models/shipit/task_definition.rb +38 -0
- data/app/models/shipit/team.rb +69 -0
- data/app/models/shipit/unknown_status.rb +43 -0
- data/app/models/shipit/user.rb +83 -0
- data/app/models/shipit/variable_definition.rb +21 -0
- data/app/serializers/concerns/shipit/conditional_attributes.rb +22 -0
- data/app/serializers/shipit/anonymous_user_serializer.rb +4 -0
- data/app/serializers/shipit/commit_serializer.rb +8 -0
- data/app/serializers/shipit/deploy_serializer.rb +15 -0
- data/app/serializers/shipit/hook_serializer.rb +12 -0
- data/app/serializers/shipit/rollback_serializer.rb +7 -0
- data/app/serializers/shipit/short_commit_serializer.rb +9 -0
- data/app/serializers/shipit/stack_serializer.rb +33 -0
- data/app/serializers/shipit/tail_task_serializer.rb +39 -0
- data/app/serializers/shipit/task_serializer.rb +30 -0
- data/app/serializers/shipit/user_serializer.rb +5 -0
- data/app/views/{commits → shipit/commits}/_commit.html.erb +1 -1
- data/app/views/{commits → shipit/commits}/_commit_author.html.erb +0 -0
- data/app/views/{deploys → shipit/deploys}/_checklist.html.erb +0 -0
- data/app/views/{deploys → shipit/deploys}/_checks.html.erb +0 -0
- data/app/views/{deploys → shipit/deploys}/_concurrent_deploy_warning.html.erb +0 -0
- data/app/views/{deploys → shipit/deploys}/_deploy.html.erb +1 -1
- data/app/views/{deploys → shipit/deploys}/_monitoring.html.erb +0 -0
- data/app/views/{deploys → shipit/deploys}/_summary.html.erb +0 -0
- data/app/views/{deploys → shipit/deploys}/new.html.erb +3 -3
- data/app/views/{deploys → shipit/deploys}/rollback.html.erb +2 -2
- data/app/views/{deploys → shipit/deploys}/show.html.erb +1 -1
- data/app/views/{github_authentication → shipit/github_authentication}/failed.html.erb +0 -0
- data/app/views/{stacks → shipit/stacks}/_header.html.erb +0 -0
- data/app/views/{stacks → shipit/stacks}/index.html.erb +0 -0
- data/app/views/{stacks → shipit/stacks}/new.html.erb +0 -0
- data/app/views/{stacks → shipit/stacks}/settings.html.erb +1 -1
- data/app/views/{stacks → shipit/stacks}/show.html.erb +2 -2
- data/app/views/{statuses → shipit/statuses}/_group.html.erb +1 -1
- data/app/views/{statuses → shipit/statuses}/_status.html.erb +0 -0
- data/app/views/{tasks → shipit/tasks}/_task.html.erb +1 -1
- data/app/views/{tasks → shipit/tasks}/_task_output.html.erb +1 -1
- data/app/views/{tasks → shipit/tasks}/index.html.erb +1 -1
- data/app/views/{tasks → shipit/tasks}/new.html.erb +1 -1
- data/app/views/{tasks → shipit/tasks}/show.html.erb +1 -1
- data/db/migrate/20160104151742_increase_tasks_type_size_back.rb +5 -0
- data/db/migrate/20160104151833_convert_sti_columns.rb +10 -0
- data/lib/shipit.rb +11 -10
- data/lib/shipit/command.rb +171 -0
- data/lib/shipit/commands.rb +25 -0
- data/lib/shipit/deploy_commands.rb +21 -0
- data/lib/shipit/engine.rb +3 -0
- data/lib/shipit/rollback_commands.rb +7 -0
- data/lib/shipit/stack_commands.rb +60 -0
- data/lib/shipit/task_commands.rb +68 -0
- data/lib/shipit/version.rb +1 -1
- data/lib/tasks/cron.rake +3 -3
- data/test/controllers/api/base_controller_test.rb +18 -14
- data/test/controllers/api/deploys_controller_test.rb +56 -52
- data/test/controllers/api/hooks_controller_test.rb +62 -58
- data/test/controllers/api/locks_controller_test.rb +38 -34
- data/test/controllers/api/outputs_controller_test.rb +15 -11
- data/test/controllers/api/stacks_controller_test.rb +56 -52
- data/test/controllers/api/tasks_controller_test.rb +30 -26
- data/test/controllers/commit_checks_controller_test.rb +29 -27
- data/test/controllers/deploys_controller_test.rb +68 -66
- data/test/controllers/github_authentication_controller_test.rb +9 -7
- data/test/controllers/rollbacks_controller_test.rb +43 -41
- data/test/controllers/stacks_controller_test.rb +131 -128
- data/test/controllers/status_controller_test.rb +8 -6
- data/test/controllers/tasks_controller_test.rb +70 -68
- data/test/controllers/webhooks_controller_test.rb +127 -125
- data/test/dummy/db/development.sqlite3 +0 -0
- data/test/dummy/db/schema.rb +2 -2
- data/test/dummy/db/seeds.rb +133 -131
- data/test/dummy/db/test.sqlite3 +0 -0
- data/test/fixtures/{api_clients.yml → shipit/api_clients.yml} +0 -0
- data/test/fixtures/{commits.yml → shipit/commits.yml} +0 -0
- data/test/fixtures/{deliveries.yml → shipit/deliveries.yml} +0 -0
- data/test/fixtures/{github_hooks.yml → shipit/github_hooks.yml} +4 -4
- data/test/fixtures/{hooks.yml → shipit/hooks.yml} +0 -0
- data/test/fixtures/{memberships.yml → shipit/memberships.yml} +0 -0
- data/test/fixtures/{output_chunks.yml → shipit/output_chunks.yml} +0 -0
- data/test/fixtures/{stacks.yml → shipit/stacks.yml} +0 -0
- data/test/fixtures/{statuses.yml → shipit/statuses.yml} +0 -0
- data/test/fixtures/{tasks.yml → shipit/tasks.yml} +8 -8
- data/test/fixtures/{teams.yml → shipit/teams.yml} +0 -0
- data/test/fixtures/{users.yml → shipit/users.yml} +0 -0
- data/test/helpers/api_helper.rb +1 -1
- data/test/helpers/fixture_aliases_helper.rb +4 -4
- data/test/jobs/cache_deploy_spec_job_test.rb +15 -13
- data/test/jobs/chunk_rollup_job_test.rb +30 -28
- data/test/jobs/deliver_hook_job_test.rb +11 -9
- data/test/jobs/destroy_stack_job_test.rb +11 -9
- data/test/jobs/emit_event_job_test.rb +10 -8
- data/test/jobs/fetch_commit_stats_job_test.rb +10 -8
- data/test/jobs/fetch_deployed_revision_job_test.rb +24 -22
- data/test/jobs/github_sync_job_test.rb +51 -49
- data/test/jobs/perform_task_job_test.rb +78 -76
- data/test/jobs/refresh_github_user_job_test.rb +10 -8
- data/test/jobs/refresh_status_job_test.rb +14 -12
- data/test/jobs/unique_job_test.rb +18 -15
- data/test/models/api_client_test.rb +20 -18
- data/test/models/commit_checks_test.rb +63 -61
- data/test/models/commits_test.rb +317 -314
- data/test/models/delivery_test.rb +29 -27
- data/test/models/deploys_test.rb +289 -287
- data/test/models/github_hook_test.rb +45 -43
- data/test/models/hook_test.rb +44 -42
- data/test/models/membership_test.rb +9 -7
- data/test/models/missing_status_test.rb +16 -14
- data/test/models/output_chunk_test.rb +14 -12
- data/test/models/rollbacks_test.rb +14 -12
- data/test/models/stacks_test.rb +272 -270
- data/test/models/status_group_test.rb +18 -16
- data/test/models/status_test.rb +42 -40
- data/test/models/task_definitions_test.rb +27 -25
- data/test/models/team_test.rb +39 -37
- data/test/models/users_test.rb +61 -59
- data/test/unit/command_test.rb +43 -41
- data/test/unit/commands_test.rb +8 -6
- data/test/unit/csv_serializer_test.rb +28 -26
- data/test/unit/deploy_commands_test.rb +179 -176
- data/test/unit/deploy_spec_test.rb +237 -235
- data/test/unit/github_url_helper_test.rb +19 -17
- data/test/unit/shipit_test.rb +44 -42
- metadata +139 -137
- data/app/controllers/api/base_controller.rb +0 -66
- data/app/controllers/api/deploys_controller.rb +0 -15
- data/app/controllers/api/hooks_controller.rb +0 -51
- data/app/controllers/api/locks_controller.rb +0 -30
- data/app/controllers/api/outputs_controller.rb +0 -15
- data/app/controllers/api/stacks_controller.rb +0 -19
- data/app/controllers/api/tasks_controller.rb +0 -18
- data/app/controllers/commit_checks_controller.rb +0 -24
- data/app/controllers/concerns/api/cacheable.rb +0 -11
- data/app/controllers/concerns/api/rendering.rb +0 -23
- data/app/controllers/concerns/pagination.rb +0 -25
- data/app/controllers/deploys_controller.rb +0 -45
- data/app/controllers/github_authentication_controller.rb +0 -25
- data/app/controllers/rollbacks_controller.rb +0 -24
- data/app/controllers/shipit_controller.rb +0 -54
- data/app/controllers/stacks_controller.rb +0 -79
- data/app/controllers/status_controller.rb +0 -5
- data/app/controllers/tasks_controller.rb +0 -46
- data/app/controllers/webhooks_controller.rb +0 -99
- data/app/helpers/chunks_helper.rb +0 -6
- data/app/helpers/deploys_helper.rb +0 -26
- data/app/helpers/github_url_helper.rb +0 -46
- data/app/helpers/shipit_helper.rb +0 -62
- data/app/helpers/stacks_helper.rb +0 -76
- data/app/helpers/tasks_helper.rb +0 -9
- data/app/jobs/background_job.rb +0 -22
- data/app/jobs/background_job/unique.rb +0 -26
- data/app/jobs/cache_deploy_spec_job.rb +0 -10
- data/app/jobs/chunk_rollup_job.rb +0 -19
- data/app/jobs/clear_git_cache_job.rb +0 -7
- data/app/jobs/deliver_hook_job.rb +0 -7
- data/app/jobs/destroy_stack_job.rb +0 -7
- data/app/jobs/emit_event_job.rb +0 -8
- data/app/jobs/fetch_commit_stats_job.rb +0 -7
- data/app/jobs/fetch_deployed_revision_job.rb +0 -21
- data/app/jobs/git_mirror_update_job.rb +0 -10
- data/app/jobs/github_sync_job.rb +0 -53
- data/app/jobs/perform_commit_checks_job.rb +0 -5
- data/app/jobs/perform_task_job.rb +0 -55
- data/app/jobs/refresh_github_user_job.rb +0 -7
- data/app/jobs/refresh_statuses_job.rb +0 -12
- data/app/jobs/setup_github_hook_job.rb +0 -9
- data/app/models/anonymous_user.rb +0 -41
- data/app/models/api_client.rb +0 -42
- data/app/models/commit.rb +0 -207
- data/app/models/commit_checks.rb +0 -88
- data/app/models/delivery.rb +0 -45
- data/app/models/deploy.rb +0 -151
- data/app/models/deploy_spec.rb +0 -148
- data/app/models/deploy_spec/bundler_discovery.rb +0 -59
- data/app/models/deploy_spec/capistrano_discovery.rb +0 -27
- data/app/models/deploy_spec/file_system.rb +0 -62
- data/app/models/deploy_spec/pypi_discovery.rb +0 -32
- data/app/models/deploy_spec/rubygems_discovery.rb +0 -32
- data/app/models/github_hook.rb +0 -144
- data/app/models/hook.rb +0 -84
- data/app/models/membership.rb +0 -6
- data/app/models/missing_status.rb +0 -18
- data/app/models/output_chunk.rb +0 -9
- data/app/models/rollback.rb +0 -29
- data/app/models/stack.rb +0 -306
- data/app/models/status.rb +0 -42
- data/app/models/status_group.rb +0 -33
- data/app/models/task.rb +0 -197
- data/app/models/task_definition.rb +0 -36
- data/app/models/team.rb +0 -67
- data/app/models/unknown_status.rb +0 -41
- data/app/models/user.rb +0 -81
- data/app/models/variable_definition.rb +0 -19
- data/app/serializers/anonymous_user_serializer.rb +0 -2
- data/app/serializers/commit_serializer.rb +0 -6
- data/app/serializers/concerns/conditional_attributes.rb +0 -20
- data/app/serializers/deploy_serializer.rb +0 -13
- data/app/serializers/hook_serializer.rb +0 -10
- data/app/serializers/rollback_serializer.rb +0 -5
- data/app/serializers/short_commit_serializer.rb +0 -7
- data/app/serializers/stack_serializer.rb +0 -31
- data/app/serializers/tail_task_serializer.rb +0 -37
- data/app/serializers/task_serializer.rb +0 -28
- data/app/serializers/user_serializer.rb +0 -3
- data/lib/command.rb +0 -169
- data/lib/commands.rb +0 -23
- data/lib/deploy_commands.rb +0 -19
- data/lib/rollback_commands.rb +0 -5
- data/lib/stack_commands.rb +0 -58
- data/lib/task_commands.rb +0 -66
data/test/unit/commands_test.rb
CHANGED
@@ -1,11 +1,13 @@
|
|
1
1
|
require 'test_helper'
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
3
|
+
module Shipit
|
4
|
+
class CommandsTest < ActiveSupport::TestCase
|
5
|
+
def setup
|
6
|
+
@commands = Commands.new
|
7
|
+
end
|
7
8
|
|
8
|
-
|
9
|
-
|
9
|
+
test 'SHIPIT gets added to the environment variables' do
|
10
|
+
assert_equal '1', @commands.env['SHIPIT']
|
11
|
+
end
|
10
12
|
end
|
11
13
|
end
|
@@ -1,36 +1,38 @@
|
|
1
1
|
require 'test_helper'
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
3
|
+
module Shipit
|
4
|
+
class CSVSerializerTest < ActiveSupport::TestCase
|
5
|
+
test "blank values are dumped as nil" do
|
6
|
+
assert_dumped nil, ''
|
7
|
+
assert_dumped nil, ' '
|
8
|
+
assert_dumped nil, nil
|
9
|
+
assert_dumped nil, []
|
10
|
+
end
|
10
11
|
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
12
|
+
test "blank values are loaded as an empty array" do
|
13
|
+
assert_loaded [], ''
|
14
|
+
assert_loaded [], ' '
|
15
|
+
assert_loaded [], nil
|
16
|
+
end
|
16
17
|
|
17
|
-
|
18
|
-
|
19
|
-
|
18
|
+
test "load split the words by comma" do
|
19
|
+
assert_loaded %w(foo bar), 'foo,bar'
|
20
|
+
end
|
20
21
|
|
21
|
-
|
22
|
-
|
23
|
-
|
22
|
+
test "dump join the words with a comma" do
|
23
|
+
assert_dumped 'foo,bar', %w(foo bar)
|
24
|
+
end
|
24
25
|
|
25
|
-
|
26
|
+
private
|
26
27
|
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
28
|
+
def assert_dumped(expected, object)
|
29
|
+
message = "Expected CSVSerializer.dump(#{object.inspect}) to eq #{expected.inspect}"
|
30
|
+
assert_equal(expected, Shipit::CSVSerializer.dump(object), message)
|
31
|
+
end
|
31
32
|
|
32
|
-
|
33
|
-
|
34
|
-
|
33
|
+
def assert_loaded(expected, payload)
|
34
|
+
message = "Expected CSVSerializer.load(#{payload.inspect}) to eq #{expected.inspect}"
|
35
|
+
assert_equal(expected, Shipit::CSVSerializer.load(payload), message)
|
36
|
+
end
|
35
37
|
end
|
36
38
|
end
|
@@ -1,180 +1,183 @@
|
|
1
1
|
require 'test_helper'
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
Shipit.
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
3
|
+
module Shipit
|
4
|
+
class DeployCommandsTest < ActiveSupport::TestCase
|
5
|
+
def setup
|
6
|
+
@stack = shipit_stacks(:shipit)
|
7
|
+
@deploy = shipit_deploys(:shipit_pending)
|
8
|
+
@commands = DeployCommands.new(@deploy)
|
9
|
+
@deploy_spec = stub(
|
10
|
+
dependencies_steps!: ['bundle install --some-args'],
|
11
|
+
deploy_steps!: ['bundle exec cap $ENVIRONMENT deploy'],
|
12
|
+
rollback_steps!: ['bundle exec cap $ENVIRONMENT deploy:rollback'],
|
13
|
+
machine_env: {'GLOBAL' => '1'},
|
14
|
+
directory: nil,
|
15
|
+
)
|
16
|
+
@commands.stubs(:deploy_spec).returns(@deploy_spec)
|
17
|
+
|
18
|
+
StackCommands.stubs(git_version: Gem::Version.new('1.8.4.3'))
|
19
|
+
end
|
20
|
+
|
21
|
+
test "#fetch calls git fetch if repository cache already exist" do
|
22
|
+
Dir.expects(:exist?).with(@stack.git_path).returns(true)
|
23
|
+
command = @commands.fetch
|
24
|
+
assert_equal %w(git fetch origin --tags master), command.args
|
25
|
+
end
|
26
|
+
|
27
|
+
test "#fetch calls git fetch in git_path directory if repository cache already exist" do
|
28
|
+
Dir.expects(:exist?).with(@stack.git_path).returns(true)
|
29
|
+
command = @commands.fetch
|
30
|
+
assert_equal @stack.git_path, command.chdir
|
31
|
+
end
|
32
|
+
|
33
|
+
test "#fetch calls git clone if repository cache do not exist" do
|
34
|
+
Dir.expects(:exist?).with(@stack.git_path).returns(false)
|
35
|
+
command = @commands.fetch
|
36
|
+
expected = %W(git clone --single-branch --recursive --branch master #{@stack.repo_git_url} #{@stack.git_path})
|
37
|
+
assert_equal expected, command.args
|
38
|
+
end
|
39
|
+
|
40
|
+
test "#fetch does not use --single-branch if git is outdated" do
|
41
|
+
Dir.expects(:exist?).with(@stack.git_path).returns(false)
|
42
|
+
StackCommands.stubs(git_version: Gem::Version.new('1.7.2.30'))
|
43
|
+
command = @commands.fetch
|
44
|
+
expected = %W(git clone --recursive --branch master #{@stack.repo_git_url} #{@stack.git_path})
|
45
|
+
assert_equal expected, command.args
|
46
|
+
end
|
47
|
+
|
48
|
+
test "#fetch calls git fetch in base_path directory if repository cache do not exist" do
|
49
|
+
Dir.expects(:exist?).with(@stack.git_path).returns(false)
|
50
|
+
command = @commands.fetch
|
51
|
+
assert_equal @stack.deploys_path, command.chdir
|
52
|
+
end
|
53
|
+
|
54
|
+
test "#fetch merges Shipit.env in ENVIRONMENT" do
|
55
|
+
Shipit.stubs(:env).returns("SPECIFIC_CONFIG" => 5)
|
56
|
+
command = @commands.fetch
|
57
|
+
assert_equal 5, command.env["SPECIFIC_CONFIG"]
|
58
|
+
end
|
59
|
+
|
60
|
+
test "#clone clones the repository cache into the working directory" do
|
61
|
+
command = @commands.clone
|
62
|
+
assert_equal ['git', 'clone', '--local', @stack.git_path, @deploy.working_directory], command.args
|
63
|
+
end
|
64
|
+
|
65
|
+
test "#clone clones the repository cache from the deploys_path" do
|
66
|
+
command = @commands.clone
|
67
|
+
assert_equal @stack.deploys_path, command.chdir
|
68
|
+
end
|
69
|
+
|
70
|
+
test "#checkout checks out the deployed commit" do
|
71
|
+
command = @commands.checkout(@deploy.until_commit)
|
72
|
+
assert_equal ['git', 'checkout', @deploy.until_commit.sha], command.args
|
73
|
+
end
|
74
|
+
|
75
|
+
test "#checkout checks out the deployed commit from the working directory" do
|
76
|
+
command = @commands.checkout(@deploy.until_commit)
|
77
|
+
assert_equal @deploy.working_directory, command.chdir
|
78
|
+
end
|
79
|
+
|
80
|
+
test "#perform calls cap $environment deploy" do
|
81
|
+
commands = @commands.perform
|
82
|
+
assert_equal 1, commands.length
|
83
|
+
command = commands.first
|
84
|
+
assert_equal ['bundle exec cap $ENVIRONMENT deploy'], command.args
|
85
|
+
end
|
86
|
+
|
87
|
+
test "#perform calls cap $environment deploy:rollback for a rollback of a capistrano stack" do
|
88
|
+
@rollback = @deploy.build_rollback
|
89
|
+
@rollback.save!
|
90
|
+
@commands = Commands.for(@rollback)
|
91
|
+
@commands.stubs(:deploy_spec).returns(@deploy_spec)
|
92
|
+
|
93
|
+
steps = @commands.perform
|
94
|
+
assert_equal 1, steps.length
|
95
|
+
step = steps.first
|
96
|
+
assert_equal ['bundle exec cap $ENVIRONMENT deploy:rollback'], step.args
|
97
|
+
end
|
98
|
+
|
99
|
+
test "#perform calls cap $environment deploy from the working_directory" do
|
100
|
+
commands = @commands.perform
|
101
|
+
assert_equal 1, commands.length
|
102
|
+
command = commands.first
|
103
|
+
assert_equal @deploy.working_directory, command.chdir
|
104
|
+
end
|
105
|
+
|
106
|
+
test "the working_directory can be overriten in the spec" do
|
107
|
+
@deploy_spec.stubs(:directory).returns('my_directory')
|
108
|
+
commands = @commands.perform
|
109
|
+
assert_equal 1, commands.length
|
110
|
+
command = commands.first
|
111
|
+
assert_equal File.join(@deploy.working_directory, 'my_directory'), command.chdir
|
112
|
+
end
|
113
|
+
|
114
|
+
test "#perform calls cap $environment deploy with the SHA in the environment" do
|
115
|
+
commands = @commands.perform
|
116
|
+
assert_equal 1, commands.length
|
117
|
+
command = commands.first
|
118
|
+
assert_equal @deploy.until_commit.sha, command.env['SHA']
|
119
|
+
end
|
120
|
+
|
121
|
+
test "#perform calls cap $environment deploy with the SHIPIT_LINK in the environment" do
|
122
|
+
commands = @commands.perform
|
123
|
+
assert_equal 1, commands.length
|
124
|
+
command = commands.first
|
125
|
+
url = "http://shipit.com/shopify/shipit-engine/production/deploys/#{@deploy.id}"
|
126
|
+
assert_equal url, command.env['SHIPIT_LINK']
|
127
|
+
end
|
128
|
+
|
129
|
+
test "#perform calls cap $environment deploy with the LAST_DEPLOYED_SHA in the environment" do
|
130
|
+
commands = @commands.perform
|
131
|
+
assert_equal 1, commands.length
|
132
|
+
command = commands.first
|
133
|
+
assert_equal @deploy.stack.last_deployed_commit.sha, command.env['LAST_DEPLOYED_SHA']
|
134
|
+
end
|
135
|
+
|
136
|
+
test "#perform transliterates the user name" do
|
137
|
+
@deploy.user = User.new(login: 'Sirupsen', name: "Simon Hørup Eskildsen")
|
138
|
+
commands = @commands.perform
|
139
|
+
assert_equal 1, commands.length
|
140
|
+
command = commands.first
|
141
|
+
assert_equal "Sirupsen (Simon Horup Eskildsen) via Shipit", command.env['USER']
|
142
|
+
end
|
143
|
+
|
144
|
+
test "#perform calls cap $environment deploy with the ENVIRONMENT in the environment" do
|
145
|
+
commands = @commands.perform
|
146
|
+
assert_equal 1, commands.length
|
147
|
+
command = commands.first
|
148
|
+
assert_equal @stack.environment, command.env['ENVIRONMENT']
|
149
|
+
end
|
150
|
+
|
151
|
+
test "#perform merges Shipit.env in ENVIRONMENT" do
|
152
|
+
Shipit.stubs(:env).returns("SPECIFIC_CONFIG" => 5)
|
153
|
+
assert_equal 5, @commands.env["SPECIFIC_CONFIG"]
|
154
|
+
end
|
155
|
+
|
156
|
+
test "#perform merges shipit.yml machine_env in ENVIRONMENT" do
|
157
|
+
assert_equal '1', @commands.env['GLOBAL']
|
158
|
+
end
|
159
|
+
|
160
|
+
test "#install_dependencies calls bundle install" do
|
161
|
+
commands = @commands.install_dependencies
|
162
|
+
assert_equal 1, commands.length
|
163
|
+
assert_equal ['bundle install --some-args'], commands.first.args
|
164
|
+
end
|
165
|
+
|
166
|
+
test "#install_dependencies merges Shipit.env in ENVIRONMENT" do
|
167
|
+
Shipit.stubs(:env).returns("SPECIFIC_CONFIG" => 5)
|
168
|
+
command = @commands.install_dependencies.first
|
169
|
+
assert_equal 5, command.env["SPECIFIC_CONFIG"]
|
170
|
+
end
|
171
|
+
|
172
|
+
test "#install_dependencies merges machine_env in ENVIRONMENT" do
|
173
|
+
command = @commands.install_dependencies.first
|
174
|
+
assert_equal '1', command.env['GLOBAL']
|
175
|
+
end
|
176
|
+
|
177
|
+
test "the deploy's `env` is merged in ENVIRONMENT" do
|
178
|
+
@deploy.env = {'FOO' => 'BAR'}
|
179
|
+
command = @commands.install_dependencies.first
|
180
|
+
assert_equal 'BAR', command.env['FOO']
|
181
|
+
end
|
179
182
|
end
|
180
183
|
end
|
@@ -1,288 +1,290 @@
|
|
1
1
|
require 'test_helper'
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
3
|
+
module Shipit
|
4
|
+
class DeploySpecTest < ActiveSupport::TestCase
|
5
|
+
setup do
|
6
|
+
@spec = DeploySpec::FileSystem.new('/tmp/', 'env')
|
7
|
+
@spec.stubs(:load_config).returns({})
|
8
|
+
end
|
8
9
|
|
9
|
-
|
10
|
-
|
11
|
-
|
10
|
+
test '#supports_fetch_deployed_revision? returns false by default' do
|
11
|
+
refute @spec.supports_fetch_deployed_revision?
|
12
|
+
end
|
12
13
|
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
14
|
+
test '#supports_fetch_deployed_revision? returns true if steps are defined' do
|
15
|
+
@spec.stubs(:load_config).returns('fetch' => ['curl --silent https://example.com/status/version'])
|
16
|
+
assert @spec.supports_fetch_deployed_revision?
|
17
|
+
end
|
17
18
|
|
18
|
-
|
19
|
-
|
20
|
-
|
19
|
+
test '#supports_rollback? returns false by default' do
|
20
|
+
refute @spec.supports_rollback?
|
21
|
+
end
|
21
22
|
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
23
|
+
test '#supports_rollback? returns true if steps are defined' do
|
24
|
+
@spec.stubs(:load_config).returns('rollback' => {'override' => ['rm -rf /usr /lib/nvidia-current/xorg/xorg']})
|
25
|
+
assert @spec.supports_rollback?
|
26
|
+
end
|
26
27
|
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
28
|
+
test '#supports_rollback? returns true if stack is detected as capistrano' do
|
29
|
+
@spec.expects(:capistrano?).returns(true)
|
30
|
+
assert @spec.supports_rollback?
|
31
|
+
end
|
31
32
|
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
33
|
+
test '#dependencies_steps returns `dependencies.override` if present' do
|
34
|
+
@spec.stubs(:load_config).returns('dependencies' => {'override' => %w(foo bar baz)})
|
35
|
+
assert_equal %w(foo bar baz), @spec.dependencies_steps
|
36
|
+
end
|
36
37
|
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
38
|
+
test '#dependencies_steps returns `bundle install` if a `Gemfile` is present' do
|
39
|
+
@spec.expects(:bundler?).returns(true)
|
40
|
+
@spec.expects(:bundle_install).returns(:bundle_install)
|
41
|
+
assert_equal :bundle_install, @spec.dependencies_steps
|
42
|
+
end
|
42
43
|
|
43
|
-
|
44
|
-
|
45
|
-
|
44
|
+
test '#fetch_deployed_revision_steps! is unknown by default' do
|
45
|
+
assert_raises DeploySpec::Error do
|
46
|
+
@spec.fetch_deployed_revision_steps!
|
47
|
+
end
|
46
48
|
end
|
47
|
-
end
|
48
49
|
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
50
|
+
test '#fetch_deployed_revision_steps use `fetch` is present' do
|
51
|
+
@spec.stubs(:load_config).returns('fetch' => ['echo l33t'])
|
52
|
+
assert_equal ['echo l33t'], @spec.fetch_deployed_revision_steps
|
53
|
+
end
|
53
54
|
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
55
|
+
test '#bundle_install return a sane default bundle install command' do
|
56
|
+
@spec.stubs(:gemfile_lock_exists?).returns(true)
|
57
|
+
command = %(
|
58
|
+
bundle check --path=#{DeploySpec.bundle_path} ||
|
59
|
+
bundle install
|
60
|
+
--frozen
|
61
|
+
--path=#{DeploySpec.bundle_path}
|
62
|
+
--retry=2
|
63
|
+
--without=default:production:development:test:staging:benchmark:debug
|
64
|
+
).gsub(/\s+/, ' ').strip
|
65
|
+
assert_equal command, @spec.bundle_install.last
|
66
|
+
end
|
66
67
|
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
68
|
+
test '#bundle_install use `dependencies.bundler.without` if present to build the --without argument' do
|
69
|
+
@spec.stubs(:gemfile_lock_exists?).returns(true)
|
70
|
+
@spec.stubs(:load_config).returns('dependencies' => {'bundler' => {'without' => %w(some custom groups)}})
|
71
|
+
command = %(
|
72
|
+
bundle check --path=#{DeploySpec.bundle_path} ||
|
73
|
+
bundle install
|
74
|
+
--frozen
|
75
|
+
--path=#{DeploySpec.bundle_path}
|
76
|
+
--retry=2
|
77
|
+
--without=some:custom:groups
|
78
|
+
).gsub(/\s+/, ' ').strip
|
79
|
+
assert_equal command, @spec.bundle_install.last
|
80
|
+
end
|
80
81
|
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
82
|
+
test '#bundle_install has --frozen option if Gemfile.lock is present' do
|
83
|
+
@spec.stubs(:load_config).returns('dependencies' => {'bundler' => {'without' => %w(some custom groups)}})
|
84
|
+
@spec.stubs(:gemfile_lock_exists?).returns(true)
|
85
|
+
assert @spec.bundle_install.last.include?('--frozen')
|
86
|
+
end
|
86
87
|
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
88
|
+
test '#bundle_install does not have --frozen option if Gemfile.lock is not present' do
|
89
|
+
@spec.stubs(:load_config).returns('dependencies' => {'bundler' => {'without' => %w(some custom groups)}})
|
90
|
+
@spec.stubs(:gemfile_lock_exists?).returns(false)
|
91
|
+
refute @spec.bundle_install.last.include?('--frozen')
|
92
|
+
end
|
92
93
|
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
94
|
+
test '#bundle_install does not have --frozen if overridden in shipit.yml' do
|
95
|
+
@spec.stubs(:load_config).returns('dependencies' => {'bundler' => {'frozen' => false}})
|
96
|
+
@spec.stubs(:gemfile_lock_exists?).returns(true)
|
97
|
+
refute @spec.bundle_install.last.include?('--frozen')
|
98
|
+
end
|
98
99
|
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
100
|
+
test '#deploy_steps returns `deploy.override` if present' do
|
101
|
+
@spec.stubs(:load_config).returns('deploy' => {'override' => %w(foo bar baz)})
|
102
|
+
assert_equal %w(foo bar baz), @spec.deploy_steps
|
103
|
+
end
|
103
104
|
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
105
|
+
test '#deploy_steps returns `cap $ENVIRONMENT deploy` if a `Capfile` is present' do
|
106
|
+
@spec.expects(:bundler?).returns(true)
|
107
|
+
@spec.expects(:capistrano?).returns(true)
|
108
|
+
assert_equal ['bundle exec cap $ENVIRONMENT deploy'], @spec.deploy_steps
|
109
|
+
end
|
109
110
|
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
111
|
+
test '#deploy_steps raise a DeploySpec::Error! if it dont know how to deploy the app' do
|
112
|
+
@spec.expects(:capistrano?).returns(false)
|
113
|
+
assert_raise DeploySpec::Error do
|
114
|
+
@spec.deploy_steps!
|
115
|
+
end
|
114
116
|
end
|
115
|
-
end
|
116
117
|
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
118
|
+
test '#rollback_steps returns `rollback.override` if present' do
|
119
|
+
@spec.stubs(:load_config).returns('rollback' => {'override' => %w(foo bar baz)})
|
120
|
+
assert_equal %w(foo bar baz), @spec.rollback_steps
|
121
|
+
end
|
121
122
|
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
123
|
+
test '#rollback_steps returns `cap $ENVIRONMENT deploy:rollback` if a `Capfile` is present' do
|
124
|
+
@spec.expects(:bundler?).returns(true)
|
125
|
+
@spec.expects(:capistrano?).returns(true)
|
126
|
+
assert_equal ['bundle exec cap $ENVIRONMENT deploy:rollback'], @spec.rollback_steps
|
127
|
+
end
|
127
128
|
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
129
|
+
test '#machine_env return an environment hash' do
|
130
|
+
@spec.stubs(:load_config).returns('machine' => {'environment' => {'GLOBAL' => '1'}})
|
131
|
+
assert_equal({'GLOBAL' => '1'}, @spec.machine_env)
|
132
|
+
end
|
132
133
|
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
134
|
+
test '#load_config can grab the env-specific shipit.yml file' do
|
135
|
+
config = {}
|
136
|
+
config.expects(:exist?).returns(true)
|
137
|
+
config.expects(:read).returns({'dependencies' => {'override' => %w(foo bar baz)}}.to_yaml)
|
138
|
+
spec = DeploySpec::FileSystem.new('.', 'staging')
|
139
|
+
spec.expects(:file).with('shipit.staging.yml').returns(config)
|
140
|
+
assert_equal %w(foo bar baz), spec.dependencies_steps
|
141
|
+
end
|
141
142
|
|
142
|
-
|
143
|
-
|
144
|
-
|
143
|
+
test '#load_config grabs the global shipit.yml file if there is no env-specific file' do
|
144
|
+
not_config = {}
|
145
|
+
not_config.expects(:exist?).returns(false)
|
145
146
|
|
146
|
-
|
147
|
-
|
148
|
-
|
147
|
+
config = {}
|
148
|
+
config.expects(:exist?).returns(true)
|
149
|
+
config.expects(:read).returns({'dependencies' => {'override' => %w(foo bar baz)}}.to_yaml)
|
149
150
|
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
151
|
+
spec = DeploySpec::FileSystem.new('.', 'staging')
|
152
|
+
spec.expects(:file).with('shipit.staging.yml').returns(not_config)
|
153
|
+
spec.expects(:file).with('shipit.yml').returns(config)
|
154
|
+
assert_equal %w(foo bar baz), spec.dependencies_steps
|
155
|
+
end
|
155
156
|
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
157
|
+
test '#gemspec gives the path of the repo gemspec if present' do
|
158
|
+
spec = DeploySpec::FileSystem.new('foobar/', 'production')
|
159
|
+
Dir.expects(:[]).with('foobar/*.gemspec').returns(['foobar/foobar.gemspec'])
|
160
|
+
assert_equal 'foobar/foobar.gemspec', spec.gemspec
|
161
|
+
end
|
161
162
|
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
163
|
+
test '#gem? is true if a gemspec is present' do
|
164
|
+
@spec.expects(:gemspec).returns('something')
|
165
|
+
assert @spec.gem?
|
166
|
+
end
|
166
167
|
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
168
|
+
test '#gem? is false if there is no gemspec' do
|
169
|
+
@spec.expects(:gemspec).returns(nil)
|
170
|
+
refute @spec.gem?
|
171
|
+
end
|
171
172
|
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
173
|
+
test '#publish_gem first check if version tag have been created, and then invoke bundler release task' do
|
174
|
+
@spec.stubs(:gemspec).returns('/tmp/shipit.gemspec')
|
175
|
+
refute @spec.capistrano?
|
176
|
+
assert_equal ['assert-gem-version-tag /tmp/shipit.gemspec', 'bundle exec rake release'], @spec.deploy_steps
|
177
|
+
end
|
177
178
|
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
179
|
+
test '#setup_dot_py gives the path of the repo setup.py if present' do
|
180
|
+
spec = DeploySpec::FileSystem.new('foobar/', 'production')
|
181
|
+
assert_equal Pathname.new('foobar/setup.py'), spec.setup_dot_py
|
182
|
+
end
|
182
183
|
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
184
|
+
test '#egg? is true if a setup.py is present' do
|
185
|
+
@spec.expects(:setup_dot_py).returns(Shipit::Engine.root.join('Gemfile'))
|
186
|
+
assert @spec.egg?
|
187
|
+
end
|
187
188
|
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
189
|
+
test '#egg? is false if there is no setup.py' do
|
190
|
+
@spec.expects(:setup_dot_py).returns(Shipit::Engine.root.join("tmp-#{SecureRandom.hex}"))
|
191
|
+
refute @spec.egg?
|
192
|
+
end
|
192
193
|
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
194
|
+
test '#publish_egg first check if version tag have been created and then invoke setup.py upload' do
|
195
|
+
file = Pathname.new('/tmp/fake_setup.py')
|
196
|
+
file.write('foo')
|
197
|
+
@spec.stubs(:setup_dot_py).returns(file)
|
198
|
+
steps = ['assert-egg-version-tag /tmp/fake_setup.py', 'python setup.py register sdist upload']
|
199
|
+
assert_equal steps, @spec.deploy_steps
|
200
|
+
end
|
200
201
|
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
|
212
|
-
|
213
|
-
|
214
|
-
|
215
|
-
|
216
|
-
|
202
|
+
test '#cacheable returns a DeploySpec instance that can be serialized' do
|
203
|
+
assert_instance_of DeploySpec::FileSystem, @spec
|
204
|
+
assert_instance_of DeploySpec, @spec.cacheable
|
205
|
+
config = {
|
206
|
+
'ci' => {'hide' => [], 'allow_failures' => [], 'require' => []},
|
207
|
+
'machine' => {'environment' => {}, 'directory' => nil},
|
208
|
+
'review' => {'checklist' => [], 'monitoring' => [], 'checks' => []},
|
209
|
+
'dependencies' => {'override' => []},
|
210
|
+
'plugins' => {},
|
211
|
+
'deploy' => {'override' => nil, 'variables' => []},
|
212
|
+
'rollback' => {'override' => nil},
|
213
|
+
'fetch' => nil,
|
214
|
+
'tasks' => {},
|
215
|
+
}
|
216
|
+
assert_equal config, @spec.cacheable.config
|
217
|
+
end
|
217
218
|
|
218
|
-
|
219
|
-
|
220
|
-
|
219
|
+
test "#deploy_variables returns an empty array by default" do
|
220
|
+
assert_equal [], @spec.deploy_variables
|
221
|
+
end
|
221
222
|
|
222
|
-
|
223
|
-
|
224
|
-
|
225
|
-
|
226
|
-
|
227
|
-
|
223
|
+
test "#deploy_variables returns an array of VariableDefinition instances" do
|
224
|
+
@spec.stubs(:load_config).returns('deploy' => {'variables' => [{
|
225
|
+
'name' => 'SAFETY_DISABLED',
|
226
|
+
'title' => 'Set to 1 to do dangerous things',
|
227
|
+
'default' => 0,
|
228
|
+
}]})
|
228
229
|
|
229
|
-
|
230
|
-
|
231
|
-
|
232
|
-
|
230
|
+
assert_equal 1, @spec.deploy_variables.size
|
231
|
+
variable_definition = @spec.deploy_variables.first
|
232
|
+
assert_equal 'SAFETY_DISABLED', variable_definition.name
|
233
|
+
end
|
233
234
|
|
234
|
-
|
235
|
-
|
236
|
-
|
237
|
-
|
235
|
+
test "task definitions prepend bundle exec if necessary" do
|
236
|
+
@spec.expects(:load_config).returns('tasks' => {'restart' => {'steps' => %w(foo)}})
|
237
|
+
@spec.expects(:bundler?).returns(true).at_least_once
|
238
|
+
definition = @spec.find_task_definition('restart')
|
238
239
|
|
239
|
-
|
240
|
-
|
240
|
+
assert_equal ['bundle exec foo'], definition.steps
|
241
|
+
end
|
241
242
|
|
242
|
-
|
243
|
-
|
244
|
-
|
243
|
+
test "task definitions prepend bundle exec before serialization" do
|
244
|
+
@spec.expects(:load_config).returns('tasks' => {'restart' => {'steps' => %w(foo)}})
|
245
|
+
@spec.expects(:bundler?).returns(true).at_least_once
|
245
246
|
|
246
|
-
|
247
|
-
|
248
|
-
|
249
|
-
|
247
|
+
cached_spec = DeploySpec.load(DeploySpec.dump(@spec))
|
248
|
+
definition = cached_spec.find_task_definition('restart')
|
249
|
+
assert_equal ['bundle exec foo'], definition.steps
|
250
|
+
end
|
250
251
|
|
251
|
-
|
252
|
-
|
253
|
-
|
254
|
-
|
252
|
+
test "#review_checklist returns an array" do
|
253
|
+
@spec.expects(:load_config).returns('review' => {'checklist' => %w(foo bar)})
|
254
|
+
assert_equal %w(foo bar), @spec.review_checklist
|
255
|
+
end
|
255
256
|
|
256
|
-
|
257
|
-
|
258
|
-
|
257
|
+
test "#review_checklist returns an empty array if the section is missing" do
|
258
|
+
assert_equal [], @spec.review_checklist
|
259
|
+
end
|
259
260
|
|
260
|
-
|
261
|
-
|
262
|
-
|
263
|
-
|
264
|
-
|
265
|
-
|
266
|
-
|
267
|
-
|
268
|
-
|
269
|
-
|
261
|
+
test "#review_monitoring returns an array of hashes" do
|
262
|
+
@spec.expects(:load_config).returns('review' => {'monitoring' => [
|
263
|
+
{'image' => 'http://example.com/foo.png', 'width' => 200, 'height' => 400},
|
264
|
+
{'iframe' => 'http://example.com/', 'width' => 200, 'height' => 400},
|
265
|
+
]})
|
266
|
+
assert_equal [
|
267
|
+
{'image' => 'http://example.com/foo.png', 'width' => 200, 'height' => 400},
|
268
|
+
{'iframe' => 'http://example.com/', 'width' => 200, 'height' => 400},
|
269
|
+
], @spec.review_monitoring
|
270
|
+
end
|
270
271
|
|
271
|
-
|
272
|
-
|
273
|
-
|
272
|
+
test "#review_monitoring returns an empty array if the section is missing" do
|
273
|
+
assert_equal [], @spec.review_monitoring
|
274
|
+
end
|
274
275
|
|
275
|
-
|
276
|
-
|
277
|
-
|
276
|
+
test "#hidden_statuses is empty by default" do
|
277
|
+
assert_equal [], @spec.hidden_statuses
|
278
|
+
end
|
278
279
|
|
279
|
-
|
280
|
-
|
281
|
-
|
282
|
-
|
280
|
+
test "#hidden_statuses is an array even if the value is a string" do
|
281
|
+
@spec.expects(:load_config).returns('ci' => {'hide' => 'ci/circleci'})
|
282
|
+
assert_equal %w(ci/circleci), @spec.hidden_statuses
|
283
|
+
end
|
283
284
|
|
284
|
-
|
285
|
-
|
286
|
-
|
285
|
+
test "#hidden_statuses is an array even if the value is present" do
|
286
|
+
@spec.expects(:load_config).returns('ci' => {'hide' => %w(ci/circleci ci/jenkins)})
|
287
|
+
assert_equal %w(ci/circleci ci/jenkins), @spec.hidden_statuses
|
288
|
+
end
|
287
289
|
end
|
288
290
|
end
|