capistrano_multiconfig_parallel 0.15.3 → 0.15.4

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: e6ef58b7705f7108cbf9c27d87770adc5f34996a
4
- data.tar.gz: 063a8f3085ffb19f7e0b685eca4abc24b5888fa1
3
+ metadata.gz: b6cd09cc8132c08c2d8ae96463ddebaf9262f296
4
+ data.tar.gz: 8b2521b82d898dd019ed65db627b9c4e068b5181
5
5
  SHA512:
6
- metadata.gz: 5962c3b2ef441dc9eec088288af0e60aa7bb967c1a59763d4d0946a0829c167b9d8678e614b022e2ed121eff508d633bf023486048e34c01d7feb1e9bf277ce8
7
- data.tar.gz: 6fc5b41b03e0fbd22745e3f4585daa147f3fe07f9f734aeaabb4c2590c3d570bd5b9aee711dc50c2ead2a3d84a20cf30a3c21844b8c239de7c3285e51cdb79a0
6
+ metadata.gz: 8b99f2a7c3dc0fbf602b816d8d59c37800ee19ed9c153209afc05887c88ac13d3cfb0d61fec4ad9cfbda34898b05bd53911923e1e9fee92a5cb0f5f33b8a2285
7
+ data.tar.gz: bc29a225e6eef5b902d66e030e342b3be7486c5a988dcc62354870f5d69b717c0c74c0e05a8a866b8c56052dded9ae3374498b2fc211dec5edd114fbf4daa0b8
data/Rakefile CHANGED
@@ -45,12 +45,12 @@ task default: [:all]
45
45
  desc 'Test the plugin under all supported Rails versions.'
46
46
  task :all do |_t|
47
47
  if ENV['TRAVIS']
48
- exec(' bundle exec phare && bundle exec rake spec && bundle exec rake coveralls:push')
48
+ exec(' bundle exec rubocop . && bundle exec reek . && bundle exec rake spec && bundle exec rake coveralls:push')
49
49
  else
50
- exec('bundle exec rubocop -a . && bundle exec phare && bundle exec rake spec')
50
+ exec('bundle exec rubocop -a . && bundle exec rubocop . && bundle exec reek . && bundle exec rake spec')
51
51
  end
52
52
  end
53
53
 
54
54
  task :docs do
55
- exec(' bundle exec rubocop -a . && bundle exec phare && bundle exec inch --pedantic && bundle exec yard')
55
+ exec('bundle exec rubocop -a . && bundle exec rubocop . && bundle exec reek . && bundle exec inch --pedantic && bundle exec yard')
56
56
  end
@@ -41,7 +41,7 @@ Gem::Specification.new do |s|
41
41
  s.add_development_dependency 'rvm-tester', '~> 1.1', '>= 1.1'
42
42
 
43
43
  s.add_development_dependency 'rubocop', '~> 0.33', '>= 0.33'
44
- s.add_development_dependency 'phare', '~> 0.7', '>= 0.7'
44
+ s.add_development_dependency 'reek', '~> 3.7', '>= 3.7'
45
45
  s.add_development_dependency 'yard', '~> 0.8', '>= 0.8.7'
46
46
  s.add_development_dependency 'yard-rspec', '~> 0.1', '>= 0.1'
47
47
  s.add_development_dependency 'redcarpet', '~> 3.3', '>= 3.3'
@@ -76,9 +76,9 @@ module CapistranoMulticonfigParallel
76
76
  err_backtrace = message.respond_to?(:backtrace) ? message.backtrace.join("\n\n") : ''
77
77
  if err_backtrace.present?
78
78
  logger.debug(
79
- class_name: message.class,
80
- message: error_message,
81
- backtrace: err_backtrace
79
+ class_name: message.class,
80
+ message: error_message,
81
+ backtrace: err_backtrace
82
82
  )
83
83
  else
84
84
  logger.debug(message)
@@ -22,15 +22,14 @@ module CapistranoMulticonfigParallel
22
22
  include Celluloid::Logger
23
23
  class TaskFailed < StandardError; end
24
24
 
25
- attr_accessor :job, :manager, :job_id, :app_name, :env_name, :action_name, :env_options, :machine, :client, :task_argv, :execute_deploy, :executed_dry_run,
25
+ attr_accessor :job, :manager, :job_id, :app_name, :env_name, :action_name, :env_options, :machine, :client, :task_argv,
26
26
  :rake_tasks, :current_task_number, # tracking tasks
27
27
  :successfull_subscription, :subscription_channel, :publisher_channel, # for subscriptions and publishing events
28
- :job_termination_condition, :worker_state, :executing_dry_run, :job_argv, :dry_run_tasks
28
+ :job_termination_condition, :worker_state, :invocation_chain
29
29
 
30
30
  def work(job, manager)
31
31
  @job = job
32
32
  @worker_state = 'started'
33
- @executing_dry_run = nil
34
33
  @manager = manager
35
34
  @job_confirmation_conditions = []
36
35
  process_job(job) if job.present?
@@ -76,8 +75,8 @@ module CapistranoMulticonfigParallel
76
75
  @rake_tasks ||= []
77
76
  end
78
77
 
79
- def dry_run_tasks
80
- @dry_run_tasks ||= []
78
+ def invocation_chain
79
+ @invocation_chain ||= []
81
80
  end
82
81
 
83
82
  def cd_working_directory
@@ -91,7 +90,6 @@ module CapistranoMulticonfigParallel
91
90
  end
92
91
 
93
92
  def execute_deploy
94
- @execute_deploy = true
95
93
  debug("invocation chain #{@job_id} is : #{@rake_tasks.inspect}") if debug_enabled?
96
94
  check_child_proces
97
95
  setup_task_arguments
@@ -115,13 +113,11 @@ module CapistranoMulticonfigParallel
115
113
  end
116
114
 
117
115
  def check_gitflow
118
- return if dry_running? || @env_name != 'staging' || !@manager.can_tag_staging? || !executed_task?(CapistranoMulticonfigParallel::GITFLOW_TAG_STAGING_TASK)
116
+ return if @env_name != 'staging' || !@manager.can_tag_staging? || !executed_task?(CapistranoMulticonfigParallel::GITFLOW_TAG_STAGING_TASK)
119
117
  @manager.dispatch_new_job(@job.merge('env' => 'production'))
120
118
  end
121
119
 
122
120
  def handle_subscription(message)
123
- @executing_dry_run = message['action'] == 'count' ? true : false
124
- @manager.jobs[@job_id]['job_argv'] = @job_argv
125
121
  if message_is_about_a_task?(message)
126
122
  check_gitflow
127
123
  save_tasks_to_be_executed(message)
@@ -162,7 +158,7 @@ module CapistranoMulticonfigParallel
162
158
  def save_tasks_to_be_executed(message)
163
159
  debug("worler #{@job_id} current invocation chain : #{rake_tasks.inspect}") if debug_enabled?
164
160
  rake_tasks << message['task'] if rake_tasks.last != message['task']
165
- dry_run_tasks << message['task'] if dry_running? && dry_run_tasks.last != message['task']
161
+ invocation_chain << message['task'] if invocation_chain.last != message['task']
166
162
  end
167
163
 
168
164
  def update_machine_state(name)
@@ -180,14 +176,6 @@ module CapistranoMulticonfigParallel
180
176
  @task_argv
181
177
  end
182
178
 
183
- def dry_run_command
184
- '--dry-run'
185
- end
186
-
187
- def dry_running?
188
- @task_argv.include?(dry_run_command) == true
189
- end
190
-
191
179
  def worker_stage
192
180
  @app_name.present? ? "#{@app_name}:#{@env_name}" : "#{@env_name}"
193
181
  end
@@ -206,7 +194,7 @@ module CapistranoMulticonfigParallel
206
194
  args.each do |arg|
207
195
  array_options << arg
208
196
  end
209
- @job_argv = array_options.clone
197
+ @manager.jobs[@job_id]['job_argv'] = array_options.clone
210
198
  array_options.unshift("#{worker_action}")
211
199
  array_options.unshift("#{worker_stage}")
212
200
  setup_command_line(*array_options)
@@ -32,7 +32,7 @@ module CapistranoMulticonfigParallel
32
32
  def set_worker_log
33
33
  FileUtils.mkdir_p(CapistranoMulticonfigParallel.log_directory) unless File.directory?(CapistranoMulticonfigParallel.log_directory)
34
34
  @filename = File.join(CapistranoMulticonfigParallel.log_directory, "worker_#{@actor.job_id}.log")
35
- FileUtils.rm_rf(@filename) if File.file?(@filename) && !@actor.crashed? && (@options[:dry_run] || @actor.executed_dry_run != true)
35
+ FileUtils.rm_rf(@filename) if File.file?(@filename) && !@actor.crashed?
36
36
  @worker_log = ::Logger.new(@filename)
37
37
  @worker_log.level = ::Logger::Severity::DEBUG
38
38
  @worker_log.formatter = proc do |severity, datetime, progname, msg|
@@ -47,14 +47,9 @@ module CapistranoMulticonfigParallel
47
47
  end
48
48
 
49
49
  def check_exit_status
50
- return unless @exit_status.present?
51
- if @exit_status.exitstatus == 0 && @options[:dry_run]
52
- debug("worker #{@actor.job_id} starts execute deploy") if @debug_enabled
53
- @actor.async.execute_deploy
54
- elsif !@actor.worker_finshed?
55
- debug("worker #{@actor.job_id} startsnotify finished") if @debug_enabled
56
- @actor.notify_finished(@exit_status)
57
- end
50
+ return if @exit_status.blank? || !@actor.worker_finshed?
51
+ debug("worker #{@actor.job_id} startsnotify finished") if @debug_enabled
52
+ @actor.notify_finished(@exit_status)
58
53
  end
59
54
 
60
55
  def start_async_deploy(cmd, options)
@@ -73,14 +73,15 @@ module CapistranoMulticonfigParallel
73
73
  end
74
74
 
75
75
  def on_message(message)
76
+ return unless message.present?
76
77
  debug("Rake worker #{@job_id} received after parse #{message}") # if debug_enabled?
77
78
  if @client.succesfull_subscription?(message)
78
79
  debug("Rake worker #{@job_id} received parse #{message}") if debug_enabled?
79
80
  @successfull_subscription = true
80
81
  publish_to_worker(task_data)
81
- elsif message.present? && message['task'].present?
82
+ elsif message['task'].present?
82
83
  task_approval(message)
83
- elsif message.present? && message['action'].present? && message['action'] == 'stdin'
84
+ elsif message['action'].present? && message['action'] == 'stdin'
84
85
  stdin_approval(message)
85
86
  else
86
87
  warn "unknown action: #{message.inspect}" if debug_enabled?
@@ -132,19 +132,18 @@ module CapistranoMulticonfigParallel
132
132
  system('cls') || system('clear') || puts("\e[H\e[2J")
133
133
  end
134
134
 
135
- def worker_dry_running?(worker)
136
- worker.alive? && worker.dry_running?
137
- end
138
-
139
135
  def worker_progress(_details, worker)
140
136
  return worker_state(worker) unless worker.alive?
141
- return if worker.executing_dry_run.nil?
142
- tasks = worker.alive? ? worker.dry_run_tasks : []
137
+ tasks = worker.alive? ? worker.invocation_chain : []
143
138
  current_task = worker.alive? ? worker.machine.state.to_s : ''
144
- total_tasks = worker_dry_running?(worker) ? nil : tasks.size
145
- task_index = worker_dry_running?(worker) ? 0 : tasks.index(current_task.to_s).to_i + 1
139
+ show_worker_percent(worker, tasks, current_task)
140
+ end
141
+
142
+ def show_worker_percent(worker, tasks, current_task)
143
+ total_tasks = worker.alive? ? tasks.size : nil
144
+ task_index = worker.alive? ? tasks.index(current_task.to_s).to_i + 1 : 0
146
145
  percent = percent_of(task_index, total_tasks)
147
- result = worker_dry_running?(worker) ? 'Please wait.. building the progress bars' : "Progress [#{format('%.2f', percent)}%] (executed #{task_index} of #{total_tasks})"
146
+ result = "Progress [#{format('%.2f', percent)}%] (executed #{task_index} of #{total_tasks})"
148
147
  if worker.alive?
149
148
  worker.crashed? ? result.red : result.green
150
149
  else
@@ -65,18 +65,21 @@ module CapistranoMulticonfigParallel
65
65
  raise ArgumentError, 'the array must contain only task names' if value.find { |row| !row.is_a?(String) }
66
66
  end
67
67
 
68
- def verify_application_dependencies(value)
68
+ def verify_application_dependencies(c, prop, props)
69
+ value = c[prop.to_sym]
70
+ return unless value.is_a?(Array)
69
71
  value.reject { |val| val.blank? || !val.is_a?(Hash) }
70
- wrong = value.find do|hash|
71
- !Set[:app, :priority, :dependencies].subset?(hash.keys.to_set) ||
72
- hash[:app].blank? ||
73
- hash[:priority].blank?
74
- !hash[:priority].is_a?(Numeric) ||
75
- !hash[:dependencies].is_a?(Array)
76
- end
72
+ wrong = check_array_of_hash(value, props.map(&:to_sym))
77
73
  raise ArgumentError, "invalid configuration for #{wrong.inspect}" if wrong.present?
78
74
  end
79
75
 
76
+ def check_array_of_hash(value, props)
77
+ value.find do|hash|
78
+ !Set.new(props).subset?(hash.keys.to_set) ||
79
+ hash.values.find(&:blank?).present?
80
+ end
81
+ end
82
+
80
83
  def verify_app_dependencies(stages)
81
84
  applications = stages.map { |stage| stage.split(':').reverse[1] }
82
85
  wrong = configuration.application_dependencies.find do |hash|
@@ -94,14 +97,22 @@ module CapistranoMulticonfigParallel
94
97
  verify_app_dependencies(stages) if configuration.application_dependencies.present?
95
98
  end
96
99
 
97
- def check_configuration(c)
98
- %w(multi_debug multi_secvential websocket_server.enable_debug).each do |prop|
100
+ def check_boolean_props(c, props)
101
+ props.each do |prop|
99
102
  c.send("#{prop}=", c[prop.to_sym]) if check_boolean(c, prop.to_sym)
100
103
  end
101
- %w(task_confirmations development_stages apply_stage_confirmation).each do |prop|
104
+ end
105
+
106
+ def check_array_props(c, props)
107
+ props.each do |prop|
102
108
  c.send("#{prop}=", c[prop.to_sym]) if c[prop.to_sym].is_a?(Array) && verify_array_of_strings(c[prop.to_sym])
103
109
  end
104
- c.application_dependencies = c[:application_dependencies] if c[:application_dependencies].is_a?(Array) && verify_application_dependencies(c[:application_dependencies])
110
+ end
111
+
112
+ def check_configuration(c)
113
+ check_boolean_props(c, %w(multi_debug multi_secvential websocket_server.enable_debug))
114
+ check_array_props(c, %w(task_confirmations development_stages apply_stage_confirmation))
115
+ verify_application_dependencies(c, 'application_dependencies', %w(app priority dependencies))
105
116
  CapistranoMulticonfigParallel::CelluloidManager.debug_enabled = true if c[:multi_debug].to_s.downcase == 'true'
106
117
  end
107
118
  end
@@ -1,8 +1,8 @@
1
1
  # module used for feching gem information
2
2
  module Helper
3
- # function that makes the methods incapsulated as utility functions
3
+ # function that makes the methods incapsulated as utility functions
4
4
 
5
- module_function
5
+ module_function
6
6
 
7
7
  def find_loaded_gem_property(gem_name, property)
8
8
  gem_spec = Gem.loaded_specs.values.find { |repo| repo.name == gem_name }
@@ -15,7 +15,7 @@ module Helper
15
15
  end
16
16
 
17
17
  def get_parsed_version(version, options)
18
- parsing_options = {optional_fields: [:tiny]}.merge(options.fetch("unparse", {}))
18
+ parsing_options = { optional_fields: [:tiny] }.merge(options.fetch('unparse', {}))
19
19
  Versionomy.parse(version).unparse(parsing_options)
20
20
  rescue Versionomy::Errors::ParseError
21
21
  nil
@@ -27,5 +27,4 @@ module Helper
27
27
  gem_version = fetch_gem_version(gem_name, options)
28
28
  gem_version.blank? ? false : gem_version.send(options.fetch('operator', '<='), version)
29
29
  end
30
-
31
30
  end
@@ -8,7 +8,7 @@ module CapistranoMulticonfigParallel
8
8
  module VERSION
9
9
  MAJOR = 0
10
10
  MINOR = 15
11
- TINY = 3
11
+ TINY = 4
12
12
  PRE = nil
13
13
 
14
14
  STRING = [MAJOR, MINOR, TINY, PRE].compact.join('.')
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: capistrano_multiconfig_parallel
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.15.3
4
+ version: 0.15.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - bogdanRada
@@ -451,25 +451,25 @@ dependencies:
451
451
  - !ruby/object:Gem::Version
452
452
  version: '0.33'
453
453
  - !ruby/object:Gem::Dependency
454
- name: phare
454
+ name: reek
455
455
  requirement: !ruby/object:Gem::Requirement
456
456
  requirements:
457
457
  - - "~>"
458
458
  - !ruby/object:Gem::Version
459
- version: '0.7'
459
+ version: '3.7'
460
460
  - - ">="
461
461
  - !ruby/object:Gem::Version
462
- version: '0.7'
462
+ version: '3.7'
463
463
  type: :development
464
464
  prerelease: false
465
465
  version_requirements: !ruby/object:Gem::Requirement
466
466
  requirements:
467
467
  - - "~>"
468
468
  - !ruby/object:Gem::Version
469
- version: '0.7'
469
+ version: '3.7'
470
470
  - - ">="
471
471
  - !ruby/object:Gem::Version
472
- version: '0.7'
472
+ version: '3.7'
473
473
  - !ruby/object:Gem::Dependency
474
474
  name: yard
475
475
  requirement: !ruby/object:Gem::Requirement