tomo 0.13.0 → 0.14.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 79cfaa19c379a5d143b07102f521a707495a89446b4c08a9048b11ee212585b6
4
- data.tar.gz: 180a8b7e1a7812e7a71b8c9b0dd1c8c9607ac81a5e025de7e685de86dca534d8
3
+ metadata.gz: fccccb439486dd6a01d1ae1c4fd89a00449847275c4510dae1e8de286c21d875
4
+ data.tar.gz: 249c53ba5dcbc1592fcf8ba1c45212dd97c2dbb018ca88b5d6d5a12dcd401895
5
5
  SHA512:
6
- metadata.gz: 737d43b6ab7ca31529ec9c1c3cc7ea98c87af44cc7c7324c36287e536afc0b95313a77ec989295f7f3998ad4eb7acc9b41e2e128d2dceb78c93e4f3c6d529a71
7
- data.tar.gz: e704de839bac059e668f0aa43433cddadd46e2bf2978e6f49d135da3c9d9deb5a63e3f5660bdbf286f3b49f7263201d73a8e24c16986f526179bed4574deaef9
6
+ metadata.gz: a0638893655f98866b04052ca6d512a42d5f56e6cde2a3798b6e5009ac8cff4fe65561159f22aa8791399bd89dc07a12b904a761c921eeba5eb7d5a054545645
7
+ data.tar.gz: e15be0b3b72f5f50733bda37bf5012e7a16b0c4abfff7a2b3f248c87008437df54f4c920846bf07b03368c3745bfe052e7f85819fd408ab758bd24bb3fb0d21d
@@ -40,7 +40,7 @@ module Tomo
40
40
  begin
41
41
  require "concurrent"
42
42
  Tomo.logger.debug("concurrent-ruby #{Concurrent::VERSION}")
43
- rescue LoadError # rubocop:disable Lint/HandleExceptions
43
+ rescue LoadError # rubocop:disable Lint/SuppressedException
44
44
  end
45
45
  end
46
46
  end
@@ -15,7 +15,9 @@ module Tomo
15
15
 
16
16
  Sequentially run the "deploy" list of tasks specified in #{DEFAULT_CONFIG_PATH} to
17
17
  deploy the project to a remote host. Use the #{blue('--dry-run')} option to quickly
18
- simulate the entire deploy without actually connecting to the host.
18
+ simulate the entire deploy without actually connecting to the host. Add the
19
+ #{blue('--debug')} option to see an in-depth explanation of the settings and execution
20
+ plan that will be used for the deployment
19
21
 
20
22
  For a #{DEFAULT_CONFIG_PATH} that specifies distinct environments (e.g. staging,
21
23
  production), you must specify the target environment using the #{blue('-e')} option. If
@@ -11,9 +11,8 @@ module Tomo
11
11
 
12
12
  def initialize(tasks:, hosts:, task_filter:, task_runner:)
13
13
  @hosts = hosts
14
- @tasks = tasks
15
14
  @task_runner = task_runner
16
- @plan = build_plan(task_filter)
15
+ @plan = build_plan(tasks, task_filter)
17
16
  @applicable_hosts = gather_applicable_hosts
18
17
  @thread_pool = build_thread_pool
19
18
  freeze
@@ -33,6 +32,7 @@ module Tomo
33
32
  end
34
33
 
35
34
  def execute
35
+ Tomo.logger.debug("Execution plan:\n#{explain}")
36
36
  open_connections do |remotes|
37
37
  plan.each do |steps|
38
38
  steps.each do |step|
@@ -44,9 +44,13 @@ module Tomo
44
44
  self
45
45
  end
46
46
 
47
+ def explain
48
+ Explanation.new(applicable_hosts, plan, concurrency).to_s
49
+ end
50
+
47
51
  private
48
52
 
49
- attr_reader :tasks, :hosts, :plan, :task_runner, :thread_pool
53
+ attr_reader :hosts, :plan, :task_runner, :thread_pool
50
54
 
51
55
  def validate_tasks!
52
56
  plan.each do |steps|
@@ -70,7 +74,7 @@ module Tomo
70
74
  (remotes || {}).values.each(&:close)
71
75
  end
72
76
 
73
- def build_plan(task_filter)
77
+ def build_plan(tasks, task_filter)
74
78
  tasks.each_with_object([]) do |task, result|
75
79
  steps = hosts.map do |host|
76
80
  HostExecutionStep.new(
@@ -0,0 +1,44 @@
1
+ module Tomo
2
+ class Runtime
3
+ class Explanation
4
+ def initialize(applicable_hosts, plan, concurrency)
5
+ @applicable_hosts = applicable_hosts
6
+ @plan = plan
7
+ @concurrency = concurrency
8
+ end
9
+
10
+ # rubocop:disable Metrics/MethodLength
11
+ # rubocop:disable Metrics/AbcSize
12
+ # rubocop:disable Metrics/CyclomaticComplexity
13
+ def to_s
14
+ desc = []
15
+ threads = [applicable_hosts.length, concurrency].min
16
+ desc << "CONCURRENTLY (#{threads} THREADS):" if threads > 1
17
+ applicable_hosts.each do |host|
18
+ indent = threads > 1 ? " = " : ""
19
+ desc << "#{indent}CONNECT #{host}"
20
+ end
21
+ plan.each do |steps|
22
+ threads = [steps.length, concurrency].min
23
+ desc << "CONCURRENTLY (#{threads} THREADS):" if threads > 1
24
+ steps.each do |step|
25
+ indent = threads > 1 ? " = " : ""
26
+ if threads > 1 && step.applicable_tasks.length > 1
27
+ desc << "#{indent}IN SEQUENCE:"
28
+ indent.sub!(/=/, " ")
29
+ end
30
+ desc << step.explain.gsub(/^/, indent)
31
+ end
32
+ end
33
+ desc.join("\n")
34
+ end
35
+ # rubocop:enable Metrics/MethodLength
36
+ # rubocop:enable Metrics/AbcSize
37
+ # rubocop:enable Metrics/CyclomaticComplexity
38
+
39
+ private
40
+
41
+ attr_reader :applicable_hosts, :plan, :concurrency
42
+ end
43
+ end
44
+ end
@@ -30,6 +30,15 @@ module Tomo
30
30
  end
31
31
  end
32
32
 
33
+ def explain
34
+ desc = []
35
+ applicable_tasks.each do |task|
36
+ task_host = task.is_a?(PrivilegedTask) ? host.as_privileged : host
37
+ desc << "RUN #{task} ON #{task_host}"
38
+ end
39
+ desc.join("\n")
40
+ end
41
+
33
42
  private
34
43
 
35
44
  attr_reader :host, :task_runner
data/lib/tomo/runtime.rb CHANGED
@@ -8,6 +8,7 @@ module Tomo
8
8
  autoload :Context, "tomo/runtime/context"
9
9
  autoload :Current, "tomo/runtime/current"
10
10
  autoload :ExecutionPlan, "tomo/runtime/execution_plan"
11
+ autoload :Explanation, "tomo/runtime/explanation"
11
12
  autoload :HostExecutionStep, "tomo/runtime/host_execution_step"
12
13
  autoload :InlineThreadPool, "tomo/runtime/inline_thread_pool"
13
14
  autoload :NoTasksError, "tomo/runtime/no_tasks_error"
@@ -49,7 +49,7 @@ module Tomo
49
49
  on_data&.call(line)
50
50
  buffer << line
51
51
  end
52
- rescue IOError # rubocop:disable Lint/HandleExceptions
52
+ rescue IOError # rubocop:disable Lint/SuppressedException
53
53
  end
54
54
  end
55
55
  end
data/lib/tomo/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Tomo
2
- VERSION = "0.13.0".freeze
2
+ VERSION = "0.14.0".freeze
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tomo
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.13.0
4
+ version: 0.14.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Matt Brictson
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2019-11-21 00:00:00.000000000 Z
11
+ date: 2019-11-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -114,28 +114,28 @@ dependencies:
114
114
  requirements:
115
115
  - - '='
116
116
  - !ruby/object:Gem::Version
117
- version: 0.76.0
117
+ version: 0.77.0
118
118
  type: :development
119
119
  prerelease: false
120
120
  version_requirements: !ruby/object:Gem::Requirement
121
121
  requirements:
122
122
  - - '='
123
123
  - !ruby/object:Gem::Version
124
- version: 0.76.0
124
+ version: 0.77.0
125
125
  - !ruby/object:Gem::Dependency
126
126
  name: rubocop-minitest
127
127
  requirement: !ruby/object:Gem::Requirement
128
128
  requirements:
129
129
  - - '='
130
130
  - !ruby/object:Gem::Version
131
- version: 0.4.1
131
+ version: 0.5.0
132
132
  type: :development
133
133
  prerelease: false
134
134
  version_requirements: !ruby/object:Gem::Requirement
135
135
  requirements:
136
136
  - - '='
137
137
  - !ruby/object:Gem::Version
138
- version: 0.4.1
138
+ version: 0.5.0
139
139
  - !ruby/object:Gem::Dependency
140
140
  name: rubocop-performance
141
141
  requirement: !ruby/object:Gem::Requirement
@@ -257,6 +257,7 @@ files:
257
257
  - lib/tomo/runtime/context.rb
258
258
  - lib/tomo/runtime/current.rb
259
259
  - lib/tomo/runtime/execution_plan.rb
260
+ - lib/tomo/runtime/explanation.rb
260
261
  - lib/tomo/runtime/host_execution_step.rb
261
262
  - lib/tomo/runtime/inline_thread_pool.rb
262
263
  - lib/tomo/runtime/no_tasks_error.rb
@@ -329,7 +330,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
329
330
  - !ruby/object:Gem::Version
330
331
  version: '0'
331
332
  requirements: []
332
- rubygems_version: 3.0.6
333
+ rubygems_version: 3.0.3
333
334
  signing_key:
334
335
  specification_version: 4
335
336
  summary: A friendly CLI for deploying Rails apps ✨