capistrano_multiconfig_parallel 0.4.0 → 0.5.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 807e40ee77401d31f5ca168c79daa993f0742d2e
4
- data.tar.gz: f0fcf399fd6dde6a96fdc40ae10fa6c6e593bd5d
3
+ metadata.gz: 576d2d4c017df766b649b56f90a3410f58beaf9a
4
+ data.tar.gz: e4952851b1bab357329ece299ee8de1346256956
5
5
  SHA512:
6
- metadata.gz: 5e4d5b0d0e9869d781067480e025b25ac187c67a196247fd8f07c2691adb8f968425c297f4b3d5d788068b01b226a7668a32af096cab4b0cdadedf0dfbf2cb94
7
- data.tar.gz: 1ce688cb8219b2bb26ade54ca01af7a198497ed9932ba03242a9c385f951bdc681417b42da32fbb298d613ffd6955020ff4cf29dbf448e1f2cc8906e5df399d0
6
+ metadata.gz: fe9d160ac7cf3658b94f70627b6a0a498097074185ebe1465de2baa638c278a80ba5d5cae140876d6ae02dc3b4e5e588b0070467ee680ef8e74d5cd7a561bc11
7
+ data.tar.gz: baa62229473d2fda8046a4aed016834327b9c659d088f98c876a5bdd91c7553b737a50b488b09893f844fe5d5823dbcd61620392035afd215a24035093ee54b5
data/README.md CHANGED
@@ -99,7 +99,9 @@ development_stages:
99
99
  - development
100
100
  - webdev
101
101
 
102
- syncronize_confirmation: true
102
+ syncronize_confirmation: true
103
+ apply_stage_confirmation:
104
+ - production
103
105
  task_confirmation_active: false
104
106
  task_confirmations:
105
107
  - deploy:symlink:release
@@ -132,6 +134,10 @@ application_dependencies: []
132
134
  * --syncronize_confirmation
133
135
  * if option is present and has value TRUE, all workers will be synchronized to wait for same task from the ***task_confirmations** Array before they execute it
134
136
 
137
+ * --apply_stage_confirmation
138
+ * If option is present and has value an ARRAY of STRING, each string should be the name of a stage.
139
+ The confirmations will only be applied if the workers are executing tasks to one of that stage.
140
+
135
141
  * --task_confirmation_active
136
142
  * if option is present and has value TRUE, will enable user confirmation dialogs before executing each task from option **--task_confirmations**
137
143
 
@@ -176,22 +182,19 @@ bundle exec multi_cap <development_stage> <task_name> BOX=<box_name>,<box_nam
176
182
  ```
177
183
 
178
184
  If a branch is specified using "BRANCH=name" it will deploy same branch to all sandboxes
179
- If a branch is not specified, will ask for each of the sandboxes the name of the branch to deploy
180
185
  The branch environment variable is then passed to the capistrano task
181
186
 
182
187
  Also the script will ask if there are any other environment variables that user might want to pass to each of the sandboxes separately.
183
188
 
184
- ### 1.2) Deploying the application to multiple stages ( Using the customized command "deploy_stages")
189
+ ### 1.2) Deploying the application to multiple stages ( Using the customized command "deploy_multi_stages")
185
190
 
186
191
 
187
192
  ```shell
188
193
 
189
- bundle exec multi_cap deploy_stages STAGES=development, staging, production
194
+ bundle exec multi_cap deploy_multi_stages STAGES=development, staging, production
190
195
  ```
191
196
 
192
- If a branch is specified using "BRANCH=name" it will deploy same branch to all stages
193
- If a branch is not specified, will ask for each of the stage the name of the branch to deploy
194
- The branch environment variable is then passed to the capistrano process
197
+ If a branch is specified using "BRANCH=name" it will deploy same branch to all stages.The branch environment variable is then passed to the capistrano task
195
198
 
196
199
  Also the script will ask if there are any other environment variables that user might want to pass to each of the stages separately.
197
200
 
@@ -239,6 +242,17 @@ bundle exec multi_cap foo2:development deploy
239
242
  Will ask user if he wants to deploy the apps "foo" and "bar" , since they appear in the dependencies list for the application "foo2"
240
243
 
241
244
 
245
+ ### 1.2) Deploying multiple application to multiple stages ( Using the customized command "deploy_multi_stages")
246
+
247
+
248
+ ```shell
249
+
250
+ bundle exec multi_cap deploy_multi_stages STAGES=development, staging, production
251
+ ```
252
+
253
+ If a branch is specified using **BRANCH=<name>** it will deploy same branch to all stages.The branch environment variable is then passed to the capistrano task
254
+ If you want different branches , capistrano will ask for additional ENV options for each stage, and can be specified then for each stage
255
+
242
256
  Testing
243
257
  --------
244
258
 
@@ -14,7 +14,6 @@ module CapistranoMulticonfigParallel
14
14
 
15
15
  CUSTOM_COMMANDS = {
16
16
  CapistranoMulticonfigParallel::MULTI_KEY => {
17
- menu: 'show_menu',
18
17
  stages: 'deploy_multi_stages'
19
18
  },
20
19
  CapistranoMulticonfigParallel::SINGLE_KEY => {
@@ -23,7 +22,7 @@ module CapistranoMulticonfigParallel
23
22
  }
24
23
 
25
24
  class << self
26
- attr_accessor :show_task_progress, :execute_in_sequence, :logger, :original_args
25
+ attr_accessor :show_task_progress, :execute_in_sequence, :logger, :original_args, :interactive_menu
27
26
 
28
27
  def root
29
28
  File.expand_path(File.dirname(__dir__))
@@ -105,27 +105,28 @@ module CapistranoMulticonfigParallel
105
105
  debug("all jobs have completed #{condition}") if self.class.debug_enabled?
106
106
  @job_manager.condition.signal('completed') if condition
107
107
  end
108
-
108
+
109
+ def apply_confirmations?
110
+ CapistranoMulticonfigParallel.configuration.task_confirmation_active.to_s.downcase == 'true' &&
111
+ CapistranoMulticonfigParallel.configuration.apply_stage_confirmation.include?(@job_manager.stage)
112
+ end
113
+
109
114
  def syncronized_confirmation?
110
- CapistranoMulticonfigParallel.configuration.syncronize_confirmation.to_s.downcase == 'true' && !@job_manager.executes_deploy_stages?
115
+ CapistranoMulticonfigParallel.configuration.syncronize_confirmation.to_s.downcase == 'true' &&
116
+ !@job_manager.executes_deploy_stages?
111
117
  end
112
118
 
113
119
  def setup_worker_conditions(worker)
120
+ return unless apply_confirmations?
114
121
  hash_conditions = {}
115
- if need_confirmations?
116
- CapistranoMulticonfigParallel.configuration.task_confirmations.each do |task|
117
- hash_conditions[task] = { condition: Celluloid::Condition.new, status: 'unconfirmed' }
118
- end
122
+ CapistranoMulticonfigParallel.configuration.task_confirmations.each do |task|
123
+ hash_conditions[task] = { condition: Celluloid::Condition.new, status: 'unconfirmed' }
119
124
  end
120
125
  @job_to_condition[worker.job_id] = hash_conditions
121
126
  end
122
127
 
123
- def need_confirmations?
124
- CapistranoMulticonfigParallel.configuration.task_confirmation_active.to_s.downcase == 'true'
125
- end
126
-
127
128
  def mark_completed_remaining_tasks(worker)
128
- return unless need_confirmations?
129
+ return unless apply_confirmations?
129
130
  CapistranoMulticonfigParallel.configuration.task_confirmations.each_with_index do |task, _index|
130
131
  fake_result = proc { |sum| sum }
131
132
  task_confirmation = @job_to_condition[worker.job_id][task]
@@ -137,7 +138,7 @@ module CapistranoMulticonfigParallel
137
138
  end
138
139
 
139
140
  def wait_task_confirmations_worker(worker)
140
- return if !need_confirmations? || syncronized_confirmation?
141
+ return if !apply_confirmations? || syncronized_confirmation?
141
142
  CapistranoMulticonfigParallel.configuration.task_confirmations.each_with_index do |task, _index|
142
143
  result = wait_condition_for_task(worker.job_id, task)
143
144
  confirm_task_approval(result, task, worker) if result.present?
@@ -149,7 +150,7 @@ module CapistranoMulticonfigParallel
149
150
  end
150
151
 
151
152
  def wait_task_confirmations
152
- return unless need_confirmations?
153
+ return if !apply_confirmations? || !syncronized_confirmation?
153
154
  CapistranoMulticonfigParallel.configuration.task_confirmations.each_with_index do |task, _index|
154
155
  results = []
155
156
  @jobs.pmap do |job_id, _job|
@@ -38,7 +38,7 @@ module CapistranoMulticonfigParallel
38
38
  @machine = CapistranoMulticonfigParallel::StateMachine.new(job, Actor.current)
39
39
  manager.register_worker_for_job(job, Actor.current)
40
40
  end
41
-
41
+
42
42
  def debug_enabled?
43
43
  @manager.class.debug_enabled?
44
44
  end
@@ -102,7 +102,7 @@ module CapistranoMulticonfigParallel
102
102
  setup_task_arguments
103
103
  debug("worker #{@job_id} executes: #{generate_command}") if debug_enabled?
104
104
  @child_process.async.work(generate_command, actor: Actor.current, silent: true)
105
- @manager.wait_task_confirmations_worker(Actor.current) unless @manager.syncronized_confirmation?
105
+ @manager.wait_task_confirmations_worker(Actor.current)
106
106
  end
107
107
 
108
108
  def check_child_proces
@@ -135,7 +135,7 @@ module CapistranoMulticonfigParallel
135
135
  end
136
136
 
137
137
  def task_approval(message)
138
- if CapistranoMulticonfigParallel.configuration.task_confirmations.include?(message['task']) && message['action'] == 'invoke'
138
+ if @manager.apply_confirmations? && CapistranoMulticonfigParallel.configuration.task_confirmations.include?(message['task']) && message['action'] == 'invoke'
139
139
  task_confirmation = @manager.job_to_condition[@job_id][message['task']]
140
140
  task_confirmation[:status] = 'confirmed'
141
141
  task_confirmation[:condition].signal(message['task'])
@@ -98,6 +98,13 @@ module CapistranoMulticonfigParallel
98
98
  \t from the ***task_confirmations** Array before they execute it ",
99
99
  default: default_config[:syncronize_confirmation]
100
100
  },
101
+ {
102
+ name: 'apply_stage_confirmation',
103
+ type: Array,
104
+ description: "if option is present and has value TRUE, all workers will be synchronized to wait for same task
105
+ \t from the ***task_confirmations** Array before they execute it ",
106
+ default: default_config[:apply_stage_confirmation]
107
+ },
101
108
  {
102
109
  name: 'track_dependencies',
103
110
  type: :boolean,
@@ -159,10 +166,10 @@ module CapistranoMulticonfigParallel
159
166
  end
160
167
 
161
168
  def check_configuration(c)
162
- %w(multi_debug multi_progress multi_secvential task_confirmation_active track_dependencies websocket_server.enable_debug).each do |prop|
169
+ %w(multi_debug multi_progress multi_secvential task_confirmation_active track_dependencies websocket_server.enable_debug syncronize_confirmation).each do |prop|
163
170
  c.send("#{prop}=", c[prop.to_sym]) if check_boolean(c, prop.to_sym)
164
171
  end
165
- %w(task_confirmations development_stages).each do |prop|
172
+ %w(task_confirmations development_stages apply_stage_confirmation).each do |prop|
166
173
  c.send("#{prop}=", c[prop.to_sym]) if verify_array_of_strings(c, prop.to_sym)
167
174
  end
168
175
  c.application_dependencies = c[:application_dependencies] if c[:track_dependencies].to_s.downcase == 'true' && verify_application_dependencies(c[:application_dependencies])
@@ -42,17 +42,19 @@ module CapistranoMulticonfigParallel
42
42
  end
43
43
 
44
44
  def start(&block)
45
- CapistranoMulticonfigParallel.configuration_valid?
45
+ CapistranoMulticonfigParallel.configuration_valid?
46
+ @default_stage = CapistranoMulticonfigParallel.configuration.development_stages.present? ? CapistranoMulticonfigParallel.configuration.development_stages.first : 'development'
46
47
  check_before_starting
47
48
  @application = custom_command? ? nil : @top_level_tasks.first.split(':').reverse[1]
48
49
  @stage = custom_command? ? nil : @top_level_tasks.first.split(':').reverse[0]
50
+ @stage = @stage.present? ? @stage : @default_stage
49
51
  @name, @args = @cap_app.parse_task_string(@top_level_tasks.second)
50
52
  @argv = @cap_app.handle_options.delete_if { |arg| arg == @stage || arg == @name || arg == @top_level_tasks.first }
51
53
  @argv = multi_fetch_argv(@argv)
52
54
  block.call if block_given?
53
55
  run
54
56
  end
55
-
57
+
56
58
  def check_before_starting
57
59
  @condition = Celluloid::Condition.new
58
60
  @manager = CapistranoMulticonfigParallel::CelluloidManager.new(Actor.current)
@@ -89,13 +91,13 @@ module CapistranoMulticonfigParallel
89
91
  app = options['app'].is_a?(Hash) ? options['app'] : { 'app' => options['app'] }
90
92
  branch = @branch_backup.present? ? @branch_backup : @argv['BRANCH'].to_s
91
93
  call_task_deploy_app({
92
- branch: branch,
93
- app: app,
94
- action: options['action']
95
- }.reverse_merge(options))
94
+ branch: branch,
95
+ app: app,
96
+ action: options['action']
97
+ }.reverse_merge(options))
96
98
  end
97
99
 
98
- private
100
+ private
99
101
 
100
102
  def call_task_deploy_app(options = {})
101
103
  options = options.stringify_keys
@@ -154,8 +156,6 @@ module CapistranoMulticonfigParallel
154
156
  end
155
157
 
156
158
  def prepare_options(options)
157
- @default_stage = CapistranoMulticonfigParallel.configuration.development_stages.present? ? CapistranoMulticonfigParallel.configuration.development_stages.first : 'development'
158
- @stage = @stage.present? ? @stage : @default_stage
159
159
  options = options.stringify_keys
160
160
  options['app'] = options.fetch('app', @application.to_s.clone)
161
161
  options['action'] = options.fetch('action', @name.to_s.clone)
@@ -39,9 +39,7 @@ module CapistranoMulticonfigParallel
39
39
  CapistranoMulticonfigParallel.interactive_menu = true
40
40
  options[:action] = @argv['ACTION'].present? ? @argv['ACTION'].present? : 'deploy'
41
41
  action_name = @name
42
- if action_name == custom_commands[:menu]
43
- menu_deploy_interactive(options)
44
- elsif action_name == custom_commands[:stages]
42
+ if action_name == custom_commands[:stages]
45
43
  multi_stage_deploy(options)
46
44
  else
47
45
  raise "Custom command #{@name} not available for multi apps"
@@ -9,6 +9,8 @@ development_stages:
9
9
  - webdev
10
10
 
11
11
  syncronize_confirmation: true
12
+ apply_stage_confirmation:
13
+ - production
12
14
  task_confirmation_active: false
13
15
  task_confirmations:
14
16
  - deploy:symlink:release
@@ -7,7 +7,7 @@ module CapistranoMulticonfigParallel
7
7
  # module used for generating the version
8
8
  module VERSION
9
9
  MAJOR = 0
10
- MINOR = 4
10
+ MINOR = 5
11
11
  TINY = 0
12
12
  PRE = nil
13
13
 
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.0
4
+ version: 0.5.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-07-01 00:00:00.000000000 Z
11
+ date: 2015-07-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: celluloid-pmap