capistrano_multiconfig_parallel 0.14.0 → 0.15.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 +1 -1
- data/lib/capistrano_multiconfig_parallel/application.rb +1 -6
- data/lib/capistrano_multiconfig_parallel/celluloid/celluloid_manager.rb +4 -4
- data/lib/capistrano_multiconfig_parallel/celluloid/celluloid_worker.rb +1 -1
- data/lib/capistrano_multiconfig_parallel/configuration.rb +5 -11
- data/lib/capistrano_multiconfig_parallel/managers/base_manager.rb +50 -40
- data/lib/capistrano_multiconfig_parallel/multi_app_helpers/dependency_tracker.rb +1 -1
- data/lib/capistrano_multiconfig_parallel/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: bd23b511de842a842e488d77a14f485c25ea0038
|
4
|
+
data.tar.gz: 4ebc2e9f2a2f11d0546ba60930e70f2b641a8a85
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 408a10f55c1fc2bb2232109abe5fb8ef345f58de0bcd3fda293e3c7c8979a9579a908aaff6bd946798badb61fd6762fece5e69e85dcc4df9fef18830718ebca0
|
7
|
+
data.tar.gz: 854662dee0a090edd903638ae6dd8ab69273cd6fd3b724a61daf0431d3202adde3cfca49843e8a72640126ca352dd00c678fca275f010329de843ca9ec2ca014
|
data/README.md
CHANGED
@@ -112,7 +112,7 @@ Available command line options when executing a command
|
|
112
112
|
|
113
113
|
- --application_dependencies
|
114
114
|
|
115
|
-
- This should be used only for Caphub-like applications , in order to deploy dependencies of an application in parallel and is described at section **[2.) Multiple applications](#
|
115
|
+
- This should be used only for Caphub-like applications , in order to deploy dependencies of an application in parallel and is described at section **[2.) Multiple applications](#2-multiple-apps--like-caphub-)**
|
116
116
|
|
117
117
|
Usage Instructions
|
118
118
|
==================
|
@@ -10,17 +10,12 @@ module CapistranoMulticonfigParallel
|
|
10
10
|
end
|
11
11
|
|
12
12
|
def top_level
|
13
|
-
job_manager = CapistranoMulticonfigParallel::BaseManager.new
|
13
|
+
job_manager = CapistranoMulticonfigParallel::BaseManager.new
|
14
14
|
if job_manager.can_start? && !options.show_prereqs && !options.show_tasks
|
15
15
|
job_manager.start
|
16
16
|
else
|
17
17
|
super
|
18
18
|
end
|
19
19
|
end
|
20
|
-
|
21
|
-
def multi_apps?
|
22
|
-
stages.find { |stage| stage.include?(':') }.present?
|
23
|
-
end
|
24
|
-
|
25
20
|
end
|
26
21
|
end
|
@@ -121,7 +121,7 @@ module CapistranoMulticonfigParallel
|
|
121
121
|
end
|
122
122
|
|
123
123
|
def syncronized_confirmation?
|
124
|
-
|
124
|
+
!@job_manager.can_tag_staging?
|
125
125
|
end
|
126
126
|
|
127
127
|
def apply_confirmation_for_worker(worker)
|
@@ -129,7 +129,7 @@ module CapistranoMulticonfigParallel
|
|
129
129
|
end
|
130
130
|
|
131
131
|
def setup_worker_conditions(worker)
|
132
|
-
return
|
132
|
+
return unless apply_confirmation_for_worker(worker)
|
133
133
|
hash_conditions = {}
|
134
134
|
CapistranoMulticonfigParallel.configuration.task_confirmations.each do |task|
|
135
135
|
hash_conditions[task] = { condition: Celluloid::Condition.new, status: 'unconfirmed' }
|
@@ -138,7 +138,7 @@ module CapistranoMulticonfigParallel
|
|
138
138
|
end
|
139
139
|
|
140
140
|
def mark_completed_remaining_tasks(worker)
|
141
|
-
return
|
141
|
+
return unless apply_confirmation_for_worker(worker)
|
142
142
|
CapistranoMulticonfigParallel.configuration.task_confirmations.each_with_index do |task, _index|
|
143
143
|
fake_result = proc { |sum| sum }
|
144
144
|
task_confirmation = @job_to_condition[worker.job_id][task]
|
@@ -150,7 +150,7 @@ module CapistranoMulticonfigParallel
|
|
150
150
|
end
|
151
151
|
|
152
152
|
def wait_task_confirmations_worker(worker)
|
153
|
-
return if
|
153
|
+
return if !apply_confirmation_for_worker(worker) || !syncronized_confirmation?
|
154
154
|
CapistranoMulticonfigParallel.configuration.task_confirmations.each_with_index do |task, _index|
|
155
155
|
result = wait_condition_for_task(worker.job_id, task)
|
156
156
|
confirm_task_approval(result, task, worker) if result.present?
|
@@ -149,7 +149,7 @@ module CapistranoMulticonfigParallel
|
|
149
149
|
end
|
150
150
|
|
151
151
|
def task_approval(message)
|
152
|
-
|
152
|
+
job_conditions = @manager.job_to_condition[@job_id]
|
153
153
|
if job_conditions.present? && CapistranoMulticonfigParallel.configuration.task_confirmations.include?(message['task']) && message['action'] == 'invoke'
|
154
154
|
task_confirmation = job_conditions[message['task']]
|
155
155
|
task_confirmation[:status] = 'confirmed'
|
@@ -59,9 +59,8 @@ module CapistranoMulticonfigParallel
|
|
59
59
|
end
|
60
60
|
end
|
61
61
|
|
62
|
-
def verify_array_of_strings(
|
63
|
-
|
64
|
-
return unless value.present?
|
62
|
+
def verify_array_of_strings(value)
|
63
|
+
return true if value.blank?
|
65
64
|
value.reject(&:blank?)
|
66
65
|
raise ArgumentError, 'the array must contain only task names' if value.find { |row| !row.is_a?(String) }
|
67
66
|
end
|
@@ -87,8 +86,7 @@ module CapistranoMulticonfigParallel
|
|
87
86
|
end
|
88
87
|
|
89
88
|
def check_boolean(c, prop)
|
90
|
-
|
91
|
-
raise ArgumentError, "the property `#{prop}` must be boolean" unless [true, false, 'true', 'false'].include?(c[prop].to_s.downcase)
|
89
|
+
raise ArgumentError, "the property `#{prop}` must be boolean" unless %w(true false).include?(c[prop].to_s.downcase)
|
92
90
|
end
|
93
91
|
|
94
92
|
def configuration_valid?(stages)
|
@@ -101,13 +99,9 @@ module CapistranoMulticonfigParallel
|
|
101
99
|
c.send("#{prop}=", c[prop.to_sym]) if check_boolean(c, prop.to_sym)
|
102
100
|
end
|
103
101
|
%w(task_confirmations development_stages apply_stage_confirmation).each do |prop|
|
104
|
-
c.send("#{prop}=", c[prop.to_sym]) if verify_array_of_strings(c
|
102
|
+
c.send("#{prop}=", c[prop.to_sym]) if c[prop.to_sym].is_a?(Array) && verify_array_of_strings(c[prop.to_sym])
|
105
103
|
end
|
106
|
-
c.application_dependencies = c[:application_dependencies] if verify_application_dependencies(c[:application_dependencies])
|
107
|
-
check_additional_config(c)
|
108
|
-
end
|
109
|
-
|
110
|
-
def check_additional_config(c)
|
104
|
+
c.application_dependencies = c[:application_dependencies] if c[:application_dependencies].is_a?(Array) && verify_application_dependencies(c[:application_dependencies])
|
111
105
|
CapistranoMulticonfigParallel::CelluloidManager.debug_enabled = true if c[:multi_debug].to_s.downcase == 'true'
|
112
106
|
end
|
113
107
|
end
|
@@ -8,15 +8,25 @@ module CapistranoMulticonfigParallel
|
|
8
8
|
include Celluloid
|
9
9
|
include Celluloid::Logger
|
10
10
|
|
11
|
-
attr_accessor :
|
11
|
+
attr_accessor :stages, :top_level_tasks, :jobs, :branch_backup, :condition, :manager, :dependency_tracker, :application, :stage, :name, :args, :argv, :default_stage
|
12
12
|
|
13
|
-
def initialize
|
14
|
-
@
|
15
|
-
|
16
|
-
@stages = stages
|
13
|
+
def initialize
|
14
|
+
@stages = fetch_stages
|
15
|
+
collect_command_line_tasks(CapistranoMulticonfigParallel.original_args)
|
17
16
|
@jobs = []
|
18
17
|
end
|
19
18
|
|
19
|
+
def fetch_stages
|
20
|
+
stages_root = 'config/deploy'
|
21
|
+
Dir["#{stages_root}/**/*.rb"].map do |file|
|
22
|
+
file.slice(stages_root.size + 1..-4).tr('/', ':')
|
23
|
+
end.tap do |paths|
|
24
|
+
paths.reject! do |path|
|
25
|
+
paths.any? { |another| another != path && another.start_with?(path + ':') }
|
26
|
+
end
|
27
|
+
end.sort
|
28
|
+
end
|
29
|
+
|
20
30
|
def run
|
21
31
|
options = {}
|
22
32
|
if custom_command?
|
@@ -28,13 +38,12 @@ module CapistranoMulticonfigParallel
|
|
28
38
|
process_jobs
|
29
39
|
end
|
30
40
|
|
31
|
-
|
32
41
|
def run_custom_command(options)
|
33
|
-
|
34
|
-
return if
|
35
|
-
|
36
|
-
|
37
|
-
collect_jobs(options.merge('stage' =>
|
42
|
+
custom_stages = fetch_multi_stages
|
43
|
+
return if custom_stages.blank?
|
44
|
+
custom_stages = check_multi_stages(custom_stages)
|
45
|
+
custom_stages.each do |_stage|
|
46
|
+
collect_jobs(options.merge('stage' => custom_stages))
|
38
47
|
end
|
39
48
|
end
|
40
49
|
|
@@ -46,18 +55,18 @@ module CapistranoMulticonfigParallel
|
|
46
55
|
end
|
47
56
|
end
|
48
57
|
|
49
|
-
|
50
58
|
def backup_the_branch
|
51
59
|
return if custom_command? || @argv['BRANCH'].blank?
|
52
60
|
@branch_backup = @argv['BRANCH'].to_s
|
53
61
|
@argv['BRANCH'] = nil
|
54
62
|
end
|
63
|
+
|
55
64
|
def can_start?
|
56
|
-
@top_level_tasks.size > 1 && (stages.include?(@top_level_tasks.first) || custom_command?) && ENV[CapistranoMulticonfigParallel::ENV_KEY_JOB_ID].blank?
|
65
|
+
@top_level_tasks.size > 1 && (@stages.include?(@top_level_tasks.first) || custom_command?) && ENV[CapistranoMulticonfigParallel::ENV_KEY_JOB_ID].blank?
|
57
66
|
end
|
58
67
|
|
59
68
|
def custom_command?
|
60
|
-
@top_level_tasks.first == 'ensure_stage' &&
|
69
|
+
@top_level_tasks.first == 'ensure_stage' && !@stages.include?(@top_level_tasks.second) && !@stages.include?(@top_level_tasks.first) && custom_commands.values.include?(@top_level_tasks.second)
|
61
70
|
end
|
62
71
|
|
63
72
|
def custom_commands
|
@@ -65,12 +74,8 @@ module CapistranoMulticonfigParallel
|
|
65
74
|
CapistranoMulticonfigParallel::CUSTOM_COMMANDS[key]
|
66
75
|
end
|
67
76
|
|
68
|
-
def executes_deploy_stages?
|
69
|
-
@name == custom_commands[:stages]
|
70
|
-
end
|
71
|
-
|
72
77
|
def multi_apps?
|
73
|
-
@
|
78
|
+
@stages.find { |stage| stage.include?(':') }.present?
|
74
79
|
end
|
75
80
|
|
76
81
|
def configuration
|
@@ -89,9 +94,19 @@ module CapistranoMulticonfigParallel
|
|
89
94
|
@stage = custom_command? ? nil : @top_level_tasks.first.split(':').reverse[0]
|
90
95
|
@stage = @stage.present? ? @stage : @default_stage
|
91
96
|
@name, @args = parse_task_string(@top_level_tasks.second)
|
92
|
-
|
93
|
-
|
94
|
-
|
97
|
+
end
|
98
|
+
|
99
|
+
def collect_command_line_tasks(args) # :nodoc:
|
100
|
+
@argv = {}
|
101
|
+
@top_level_tasks = []
|
102
|
+
args.each do |arg|
|
103
|
+
if arg =~ /^(\w+)=(.*)$/m
|
104
|
+
@argv[Regexp.last_match(1)] = Regexp.last_match(2)
|
105
|
+
else
|
106
|
+
@top_level_tasks << arg unless arg =~ /^-/
|
107
|
+
end
|
108
|
+
end
|
109
|
+
@top_level_tasks.push(Rake.application.default_task_name) if @top_level_tasks.blank?
|
95
110
|
end
|
96
111
|
|
97
112
|
def parse_task_string(string) # :nodoc:
|
@@ -130,7 +145,7 @@ module CapistranoMulticonfigParallel
|
|
130
145
|
@manager = CapistranoMulticonfigParallel::CelluloidManager.new(Actor.current)
|
131
146
|
end
|
132
147
|
|
133
|
-
def collect_jobs(options = {}, &
|
148
|
+
def collect_jobs(options = {}, &_block)
|
134
149
|
options = prepare_options(options)
|
135
150
|
options = options.stringify_keys
|
136
151
|
apps = @dependency_tracker.fetch_apps_needed_for_deployment(options['app'], options['action'])
|
@@ -138,7 +153,7 @@ module CapistranoMulticonfigParallel
|
|
138
153
|
deploy_multiple_apps(apps, options)
|
139
154
|
deploy_app(options)
|
140
155
|
rescue => e
|
141
|
-
|
156
|
+
CapistranoMulticonfigParallel::Base.log_message(e)
|
142
157
|
end
|
143
158
|
|
144
159
|
def process_jobs
|
@@ -152,9 +167,9 @@ module CapistranoMulticonfigParallel
|
|
152
167
|
|
153
168
|
def tag_staging_exists? # check exists task from capistrano-gitflow
|
154
169
|
check_giflow_tasks(
|
155
|
-
|
156
|
-
|
157
|
-
|
170
|
+
CapistranoMulticonfigParallel::GITFLOW_TAG_STAGING_TASK,
|
171
|
+
CapistranoMulticonfigParallel::GITFLOW_CALCULATE_TAG_TASK,
|
172
|
+
CapistranoMulticonfigParallel::GITFLOW_VERIFY_UPTODATE_TASK
|
158
173
|
)
|
159
174
|
rescue
|
160
175
|
return false
|
@@ -165,10 +180,10 @@ module CapistranoMulticonfigParallel
|
|
165
180
|
end
|
166
181
|
|
167
182
|
def fetch_multi_stages
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
183
|
+
custom_stages = @argv['STAGES'].blank? ? '' : @argv['STAGES']
|
184
|
+
custom_stages = parse_inputted_value('value' => custom_stages).split(',').compact if custom_stages.present?
|
185
|
+
custom_stages = custom_stages.present? ? custom_stages : [@default_stage]
|
186
|
+
custom_stages
|
172
187
|
end
|
173
188
|
|
174
189
|
def wants_deploy_production?
|
@@ -176,11 +191,11 @@ module CapistranoMulticonfigParallel
|
|
176
191
|
end
|
177
192
|
|
178
193
|
def can_tag_staging?
|
179
|
-
|
194
|
+
wants_deploy_production? && tag_staging_exists? && fetch_multi_stages.include?('staging')
|
180
195
|
end
|
181
196
|
|
182
|
-
def check_multi_stages(
|
183
|
-
can_tag_staging? ?
|
197
|
+
def check_multi_stages(custom_stages)
|
198
|
+
can_tag_staging? ? custom_stages.reject { |u| u == 'production' } : custom_stages
|
184
199
|
end
|
185
200
|
|
186
201
|
def deploy_app(options = {})
|
@@ -206,8 +221,7 @@ module CapistranoMulticonfigParallel
|
|
206
221
|
@jobs.map { |job| job['env'] }
|
207
222
|
end
|
208
223
|
|
209
|
-
|
210
|
-
private
|
224
|
+
private
|
211
225
|
|
212
226
|
def call_task_deploy_app(options = {})
|
213
227
|
options = options.stringify_keys
|
@@ -290,10 +304,6 @@ module CapistranoMulticonfigParallel
|
|
290
304
|
end
|
291
305
|
end
|
292
306
|
|
293
|
-
def using_git?
|
294
|
-
fetch(:scm, :git).to_sym == :git
|
295
|
-
end
|
296
|
-
|
297
307
|
def fetch_app_additional_env_options
|
298
308
|
options = {}
|
299
309
|
return options if fetch(:app_additional_env_options).blank?
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: capistrano_multiconfig_parallel
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.15.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- bogdanRada
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-11-
|
11
|
+
date: 2015-11-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: celluloid-pmap
|