capistrano-data_plane_api 0.1.4 → 0.2.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.
Files changed (90) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +5 -2
  3. data/.ruby-version +1 -1
  4. data/CHANGELOG.md +6 -0
  5. data/Gemfile +7 -4
  6. data/Gemfile.lock +108 -69
  7. data/README.md +5 -0
  8. data/capistrano-data_plane_api.gemspec +5 -2
  9. data/exe/cap_data_plane_api +3 -2
  10. data/lib/capistrano/data_plane_api/configuration/backend.rb +2 -0
  11. data/lib/capistrano/data_plane_api/configuration/server.rb +4 -2
  12. data/lib/capistrano/data_plane_api/configuration/symbol.rb +2 -0
  13. data/lib/capistrano/data_plane_api/configuration.rb +3 -3
  14. data/lib/capistrano/data_plane_api/deploy/args.rb +71 -40
  15. data/lib/capistrano/data_plane_api/deploy/deployment_stats.rb +29 -25
  16. data/lib/capistrano/data_plane_api/deploy/group.rb +33 -24
  17. data/lib/capistrano/data_plane_api/deploy/helper.rb +3 -5
  18. data/lib/capistrano/data_plane_api/deploy/server_stats.rb +60 -43
  19. data/lib/capistrano/data_plane_api/deploy.rb +3 -2
  20. data/lib/capistrano/data_plane_api/diggable.rb +5 -2
  21. data/lib/capistrano/data_plane_api/equatable.rb +4 -2
  22. data/lib/capistrano/data_plane_api/helper.rb +31 -27
  23. data/lib/capistrano/data_plane_api/hooks.rb +1 -0
  24. data/lib/capistrano/data_plane_api/show_state.rb +15 -12
  25. data/lib/capistrano/data_plane_api/tasks.rb +26 -2
  26. data/lib/capistrano/data_plane_api/terminal_print_loop.rb +7 -4
  27. data/lib/capistrano/data_plane_api/type.rb +9 -5
  28. data/lib/capistrano/data_plane_api/version.rb +2 -2
  29. data/lib/capistrano/data_plane_api.rb +96 -74
  30. data/lib/capistrano-data_plane_api.rb +4 -0
  31. data/rbi/capistrano-data_plane_api.rbi +283 -0
  32. data/sorbet/config +6 -0
  33. data/sorbet/rbi/annotations/.gitattributes +1 -0
  34. data/sorbet/rbi/annotations/faraday.rbi +17 -0
  35. data/sorbet/rbi/annotations/minitest.rbi +119 -0
  36. data/sorbet/rbi/annotations/rainbow.rbi +269 -0
  37. data/sorbet/rbi/annotations/webmock.rbi +9 -0
  38. data/sorbet/rbi/dsl/.gitattributes +1 -0
  39. data/sorbet/rbi/dsl/capistrano/data_plane_api/configuration/backend.rbi +50 -0
  40. data/sorbet/rbi/dsl/capistrano/data_plane_api/configuration/server.rbi +24 -0
  41. data/sorbet/rbi/dsl/capistrano/data_plane_api/configuration.rbi +52 -0
  42. data/sorbet/rbi/dsl/capistrano/data_plane_api/type.rbi +12 -0
  43. data/sorbet/rbi/gems/.gitattributes +1 -0
  44. data/sorbet/rbi/gems/addressable@2.8.7.rbi +1994 -0
  45. data/sorbet/rbi/gems/ast@2.4.3.rbi +585 -0
  46. data/sorbet/rbi/gems/base64@0.2.0.rbi +509 -0
  47. data/sorbet/rbi/gems/bigdecimal@3.1.9.rbi +8 -0
  48. data/sorbet/rbi/gems/booleans@0.1.3.rbi +28 -0
  49. data/sorbet/rbi/gems/byebug@12.0.0.rbi +37 -0
  50. data/sorbet/rbi/gems/crack@1.0.0.rbi +145 -0
  51. data/sorbet/rbi/gems/data_plane_api@0.2.0.rbi +238 -0
  52. data/sorbet/rbi/gems/faraday-net_http@3.4.0.rbi +147 -0
  53. data/sorbet/rbi/gems/faraday@2.13.0.rbi +2974 -0
  54. data/sorbet/rbi/gems/hashdiff@1.1.2.rbi +353 -0
  55. data/sorbet/rbi/gems/json@2.10.2.rbi +2113 -0
  56. data/sorbet/rbi/gems/lint_roller@1.1.0.rbi +240 -0
  57. data/sorbet/rbi/gems/logger@1.7.0.rbi +963 -0
  58. data/sorbet/rbi/gems/minitest@5.25.5.rbi +1547 -0
  59. data/sorbet/rbi/gems/net-http@0.6.0.rbi +4247 -0
  60. data/sorbet/rbi/gems/parallel@1.26.3.rbi +291 -0
  61. data/sorbet/rbi/gems/pastel@0.8.0.rbi +733 -0
  62. data/sorbet/rbi/gems/public_suffix@6.0.1.rbi +936 -0
  63. data/sorbet/rbi/gems/racc@1.8.1.rbi +160 -0
  64. data/sorbet/rbi/gems/rainbow@3.1.1.rbi +404 -0
  65. data/sorbet/rbi/gems/rake@13.0.6.rbi +3030 -0
  66. data/sorbet/rbi/gems/rexml@3.4.1.rbi +5346 -0
  67. data/sorbet/rbi/gems/rubocop-espago@1.1.8.rbi +9 -0
  68. data/sorbet/rbi/gems/ruby-progressbar@1.13.0.rbi +1318 -0
  69. data/sorbet/rbi/gems/shale-builder@0.2.4.rbi +9 -0
  70. data/sorbet/rbi/gems/shale@1.2.2.rbi +2323 -0
  71. data/sorbet/rbi/gems/shoulda-context@2.0.0.rbi +563 -0
  72. data/sorbet/rbi/gems/strings-ansi@0.2.0.rbi +178 -0
  73. data/sorbet/rbi/gems/strings@0.2.1.rbi +830 -0
  74. data/sorbet/rbi/gems/thor@1.2.1.rbi +3957 -0
  75. data/sorbet/rbi/gems/tty-box@0.7.0.rbi +593 -0
  76. data/sorbet/rbi/gems/tty-color@0.6.0.rbi +241 -0
  77. data/sorbet/rbi/gems/tty-cursor@0.7.1.rbi +443 -0
  78. data/sorbet/rbi/gems/unicode-display_width@2.6.0.rbi +66 -0
  79. data/sorbet/rbi/gems/unicode_utils@1.4.0.rbi +184 -0
  80. data/sorbet/rbi/gems/uri@1.0.3.rbi +2349 -0
  81. data/sorbet/rbi/gems/vcr@6.3.1.rbi +3040 -0
  82. data/sorbet/rbi/gems/webmock@3.25.1.rbi +1792 -0
  83. data/sorbet/rbi/shims/gems/faraday.rbi +21 -0
  84. data/sorbet/rbi/shims/gems/shoulda-context@2.0.0.rbi +15 -0
  85. data/sorbet/rbi/todo.rbi +7 -0
  86. data/sorbet/tapioca/config.yml +28 -0
  87. data/sorbet/tapioca/extensions/load_gem.rb +1 -0
  88. data/sorbet/tapioca/require.rb +4 -0
  89. data/templates/bin/deploy.rb +1 -0
  90. metadata +106 -8
@@ -1,5 +1,7 @@
1
+ # typed: true
1
2
  # frozen_string_literal: true
2
3
 
4
+ require 'booleans/kernel_extension'
3
5
  require 'optparse'
4
6
 
5
7
  module Capistrano
@@ -9,11 +11,9 @@ module Capistrano
9
11
  # passed to the deployment script and saves them in
10
12
  # an object.
11
13
  class Args
12
- # @return [Array<String>]
13
14
  PRINTABLE_ENV_VARS = %w[BRANCH NO_MIGRATIONS].freeze
14
15
 
15
- # @param options [Array, nil]
16
- # @return [self]
16
+ #: (Array[untyped]?) -> instance
17
17
  def self.parse(options = nil) # rubocop:disable Metrics/MethodLength, Style/ClassMethodsDefinitions
18
18
  args = new
19
19
 
@@ -28,7 +28,7 @@ module Capistrano
28
28
  parser.on(
29
29
  '-c',
30
30
  '--current',
31
- 'Deploy from the currently checked out branch'
31
+ 'Deploy from the currently checked out branch',
32
32
  ) do |_val|
33
33
  args.branch = `git branch --show-current`.strip
34
34
  ::ENV['BRANCH'] = args.branch
@@ -37,22 +37,33 @@ module Capistrano
37
37
  parser.on(
38
38
  '-t',
39
39
  '--test',
40
- 'Show the commands that would be executed but do not carry out the deployment'
40
+ 'Show the commands that would be executed but do not carry out the deployment',
41
41
  ) do |val|
42
42
  args.test = val
43
43
  end
44
44
 
45
+ parser.on(
46
+ '-C',
47
+ '--check',
48
+ 'Test deployment dependencies. ' \
49
+ 'Checks things like directory permissions, necessary utilities, ' \
50
+ 'HaProxy backends and servers',
51
+ ) do |val|
52
+ args.check = val
53
+ args.rake = 'deploy:check' if val
54
+ end
55
+
45
56
  parser.on(
46
57
  '-g GROUP',
47
58
  '--group=GROUP',
48
- 'Deploy the code to every server in the passed HAProxy backend/group'
59
+ 'Deploy the code to every server in the passed HAProxy backend/group',
49
60
  ) do |val|
50
61
  args.group = val
51
62
  end
52
63
 
53
64
  parser.on(
54
65
  '--no-haproxy',
55
- 'Do not modify the state of any server in HAProxy'
66
+ 'Do not modify the state of any server in HAProxy',
56
67
  ) do |val|
57
68
  args.no_haproxy = val
58
69
  ::ENV['NO_HAPROXY'] = 'true'
@@ -60,7 +71,7 @@ module Capistrano
60
71
 
61
72
  parser.on(
62
73
  '--force-haproxy',
63
- 'Ignore the current state of servers in HAProxy'
74
+ 'Ignore the current state of servers in HAProxy',
64
75
  ) do |val|
65
76
  args.force_haproxy = val
66
77
  ::ENV['FORCE_HAPROXY'] = 'true'
@@ -69,7 +80,7 @@ module Capistrano
69
80
  parser.on(
70
81
  '-o ONLY',
71
82
  '--only=ONLY',
72
- 'Deploy the code only to the passed servers in the same order'
83
+ 'Deploy the code only to the passed servers in the same order',
73
84
  ) do |val|
74
85
  next unless val
75
86
 
@@ -79,7 +90,7 @@ module Capistrano
79
90
  parser.on(
80
91
  '-H',
81
92
  '--haproxy-config',
82
- 'Show the current HAProxy configuration'
93
+ 'Show the current HAProxy configuration',
83
94
  ) do |val|
84
95
  next unless val
85
96
 
@@ -91,7 +102,7 @@ module Capistrano
91
102
  parser.on(
92
103
  '-S',
93
104
  '--haproxy-state',
94
- 'Show the current HAProxy state'
105
+ 'Show the current HAProxy state',
95
106
  ) do |val|
96
107
  next unless val
97
108
 
@@ -103,7 +114,7 @@ module Capistrano
103
114
  parser.on(
104
115
  '-T',
105
116
  '--tasks',
106
- 'Print a list of all available deployment Rake tasks'
117
+ 'Print a list of all available deployment Rake tasks',
107
118
  ) do |val|
108
119
  next unless val
109
120
 
@@ -117,7 +128,7 @@ module Capistrano
117
128
  parser.on(
118
129
  '-r RAKE',
119
130
  '--rake=RAKE',
120
- 'Carry out a particular Rake task on the server'
131
+ 'Carry out a particular Rake task on the server',
121
132
  ) do |val|
122
133
  next unless val
123
134
 
@@ -132,7 +143,7 @@ module Capistrano
132
143
  parser.on(
133
144
  '-b BRANCH',
134
145
  '--branch=BRANCH',
135
- 'Deploy the code from the passed Git branch'
146
+ 'Deploy the code from the passed Git branch',
136
147
  ) do |val|
137
148
  args.branch = val
138
149
  ::ENV['BRANCH'] = val
@@ -140,7 +151,7 @@ module Capistrano
140
151
 
141
152
  parser.on(
142
153
  '--no-migrations',
143
- 'Do not carry out migrations'
154
+ 'Do not carry out migrations',
144
155
  ) do |val|
145
156
  args.no_migrations = val
146
157
  ::ENV['NO_MIGRATIONS'] = 'true'
@@ -153,56 +164,79 @@ module Capistrano
153
164
  args
154
165
  end
155
166
 
156
- # @return [String, nil] Git branch that the code will be deployed to
167
+ # Git branch that the code will be deployed to
168
+ #
169
+ #: String?
157
170
  attr_accessor :branch
158
- # @return [Boolean] Runs in test mode if true, only prints commands without executing them
171
+
172
+ # Runs in test mode if true, only prints commands without executing them
173
+ #
174
+ #: bool
159
175
  attr_accessor :test
160
- # @return [String, nil] Name of the HAProxy server group/backend
176
+
177
+ # Name of the HAProxy server group/backend
178
+ #
179
+ #: String?
161
180
  attr_accessor :group
162
- # @return [Boolean]
181
+
182
+ #: bool
163
183
  attr_accessor :no_haproxy
164
- # @return [Boolean]
184
+
185
+ #: bool
165
186
  attr_accessor :no_migrations
166
- # @return [Boolean]
187
+
188
+ #: bool
167
189
  attr_accessor :force_haproxy
168
- # @return [Array<String>, nil] Ordered list of servers to which the app will be deployed
190
+
191
+ # Ordered list of servers to which the app will be deployed
192
+ #
193
+ #: Array[String]?
169
194
  attr_accessor :only
170
- # @return [String, nil] Rake command that will be called remotely (`deploy` by default)
195
+
196
+ # Rake command that will be called remotely (`deploy` by default)
197
+ #
198
+ #: String?
171
199
  attr_accessor :rake
172
- # @return [String, nil] Name of the deployment stage/server
200
+
201
+ # Name of the deployment stage/server
202
+ #
203
+ #: String?
173
204
  attr_accessor :stage
174
205
 
206
+ # Checks deployment dependencies
207
+ #: bool
208
+ attr_accessor :check
209
+
175
210
  alias test? test
176
211
 
212
+ #: -> void
177
213
  def initialize
178
214
  @rake = 'deploy'
179
215
  end
180
216
 
181
- # @return [Boolean]
217
+ #: -> bool
182
218
  def only?
183
219
  return false if @only.nil?
184
220
 
185
221
  @only.any?
186
222
  end
187
223
 
188
- # @return [void]
224
+ #: -> void
189
225
  def prepare_if_one_server
190
226
  return unless one_server?
191
227
 
192
- server, backend = ::Capistrano::DataPlaneApi.find_server_and_backend(@stage)
193
- @only = [server['name']]
194
- @group = backend['name']
228
+ server, backend = ::Capistrano::DataPlaneApi.find_server_and_backend(T.must(@stage))
229
+ @only = [T.must(server.name)]
230
+ @group = backend.name
195
231
  end
196
232
 
197
- # @param stage [String, Symbol, nil]
198
- # @return [String]
233
+ #: (String | Symbol | nil) -> String
199
234
  def deploy_command(stage = nil)
200
235
  used_stage = stage || self.stage
201
236
  "cap #{used_stage} #{rake}"
202
237
  end
203
238
 
204
- # @param stage [String, Symbol, nil]
205
- # @return [String]
239
+ #: (String | Symbol | nil) -> String
206
240
  def humanized_deploy_command(stage = nil)
207
241
  result = ::String.new
208
242
  PRINTABLE_ENV_VARS.each do |env_var_name|
@@ -215,24 +249,21 @@ module Capistrano
215
249
  result
216
250
  end
217
251
 
218
- # @param key [Symbol, String]
219
- # @return [Object]
252
+ #: (Symbol | String) -> Object
220
253
  def [](key)
221
254
  public_send(key)
222
255
  end
223
256
 
224
- # @param key [Symbol, String]
225
- # @param val [Object]
226
- # @return [Object]
257
+ #: (Symbol | String, Object) -> Object
227
258
  def []=(key, val)
228
259
  public_send("#{key}=", val)
229
260
  end
230
261
 
231
262
  private
232
263
 
233
- # @return [Boolean]
264
+ #: -> bool
234
265
  def one_server?
235
- @stage && @group.nil?
266
+ Boolean(@stage && @group.nil?)
236
267
  end
237
268
  end
238
269
  end
@@ -1,3 +1,4 @@
1
+ # typed: strict
1
2
  # frozen_string_literal: true
2
3
 
3
4
  require_relative 'helper'
@@ -7,58 +8,59 @@ module Capistrano
7
8
  module Deploy
8
9
  # Represents a collection of deployment stats for particular servers.
9
10
  class DeploymentStats
10
- # @return [Capistrano::DataPlaneApi::Configuration::Backend, nil]
11
- # Configuration data of a particular HAProxy backend
11
+ # Configuration data of a particular HAProxy backend
12
+ #
13
+ #: Capistrano::DataPlaneApi::Configuration::Backend?
12
14
  attr_accessor :backend
13
15
 
14
- # @return [Time, nil]
16
+ #: Time?
15
17
  attr_accessor :start_time
16
18
 
17
- # @return [Time, nil]
19
+ #: Time?
18
20
  attr_accessor :end_time
19
21
 
20
- # @return [Hash{String => Deploy::ServerStats}]
22
+ #: Hash[String, Deploy::ServerStats]
21
23
  attr_accessor :server_stats
22
24
 
23
- # @return [Boolean]
24
- attr_accessor :success
25
+ #: Symbol
26
+ attr_accessor :state
25
27
 
28
+ #: -> void
26
29
  def initialize
27
30
  @backend = nil
28
31
  @start_time = nil
29
32
  @end_time = nil
30
- @success = true
31
- @server_stats = {}
33
+ @state = T.let(:pending, Symbol)
34
+ @server_stats = T.let({}, T::Hash[String, Deploy::ServerStats])
35
+ @seconds = T.let(nil, T.nilable(Integer))
36
+ @update_states_in_stats = T.let(false, T::Boolean)
32
37
  end
33
38
 
34
- # @param key [String]
35
- # @return [Deploy::ServerStats]
39
+ #: (String) -> Deploy::ServerStats
36
40
  def [](key)
37
- @server_stats[key]
41
+ @server_stats.fetch(key)
38
42
  end
39
43
 
40
- # @param key [String]
41
- # @param val [Deploy::ServerStats]
44
+ #: (String, Deploy::ServerStats) -> void
42
45
  def []=(key, val)
43
46
  @server_stats[key] = val
44
47
  end
45
48
 
46
- # @param servers [Array<Capistrano::DataPlaneApi::Configuration::Server>, Capistrano::DataPlaneApi::Configuration::Server]
47
- # @return [void]
49
+ #: (Array[Configuration::Server] | Configuration::Server) -> void
48
50
  def create_stats_for(servers)
49
51
  servers = *servers
50
52
 
51
53
  servers.each do |server|
52
- @server_stats[server.name] = ServerStats.new(server.name, @backend.name)
54
+ @server_stats[server.name] = ServerStats.new(server.name, T.must(@backend&.name))
53
55
  end
54
56
  end
55
57
 
56
- # @return [String]
58
+ #: -> String
57
59
  def to_s
58
60
  update_states_in_stats
59
61
 
60
62
  time_string = COLORS.bold.yellow ::Time.now.to_s
61
- if success
63
+ if state == :success
62
64
  state = COLORS.bold.green 'Successful'
63
65
  time_sentence = 'took'
64
66
  else
@@ -68,8 +70,8 @@ module Capistrano
68
70
 
69
71
  result = ::String.new
70
72
  result << "\n#{time_string}\n\n"
71
- result << "#{state} deployment to #{::Capistrano::DataPlaneApi.humanize_backend_name(@backend)}\n"
72
- result << " #{time_sentence} #{Helper.humanize_time(seconds)}\n"
73
+ result << "#{state} deployment to #{::Capistrano::DataPlaneApi.humanize_backend_name(T.must(@backend))}\n"
74
+ result << " #{time_sentence} #{Helper.humanize_time(T.must(seconds))}\n"
73
75
 
74
76
  @server_stats.each_value do |stats|
75
77
  result << "\n#{stats}"
@@ -78,14 +80,15 @@ module Capistrano
78
80
  result
79
81
  end
80
82
 
81
- # @return [Integer, nil] How much time has the deployment taken
83
+ # How much time has the deployment taken
84
+ #: -> Integer?
82
85
  def seconds
83
- @seconds ||= Helper.seconds_since(@start_time, to: @end_time)
86
+ @seconds ||= Helper.seconds_since(T.must(@start_time), to: T.must(@end_time))
84
87
  end
85
88
 
86
89
  private
87
90
 
88
- # @return [void]
91
+ #: -> void
89
92
  def update_states_in_stats
90
93
  return if @update_states_in_stats
91
94
 
@@ -93,9 +96,10 @@ module Capistrano
93
96
  update_states_in_stats!
94
97
  end
95
98
 
99
+ #: -> void
96
100
  def update_states_in_stats!
97
101
  server_states = begin
98
- ::Capistrano::DataPlaneApi.get_backend_servers_settings(@backend.name).body
102
+ ::Capistrano::DataPlaneApi.get_backend_servers_settings(T.must(@backend&.name)).body
99
103
  rescue Error
100
104
  nil
101
105
  end
@@ -1,3 +1,4 @@
1
+ # typed: strict
1
2
  # frozen_string_literal: true
2
3
 
3
4
  module Capistrano
@@ -7,28 +8,30 @@ module Capistrano
7
8
  # in a particular HAProxy backend/group.
8
9
  class Group
9
10
  class << self
10
- # @param args [DeployArgs]
11
- # @return [void]
11
+ #: (Args) -> Symbol
12
12
  def call(args)
13
13
  new(args).call
14
14
  end
15
15
  end
16
16
 
17
- # @param args [DeployArgs]
17
+ #: (Args) -> void
18
18
  def initialize(args)
19
19
  @args = args
20
- @deployment_stats = DeploymentStats.new
20
+ @deployment_stats = T.let(DeploymentStats.new, DeploymentStats)
21
+ @backend = T.let(nil, T.nilable(Configuration::Backend))
22
+ @servers = T.let(nil, T.nilable(T::Array[Configuration::Server]))
21
23
  end
22
24
 
23
- # @return [Boolean, nil] Whether the deployment has been successful
25
+ # Whether the deployment has been successful
26
+ #: -> Symbol
24
27
  def call
25
- @backend = ::Capistrano::DataPlaneApi.find_backend(@args.group)
28
+ @backend = ::Capistrano::DataPlaneApi.find_backend(T.must(@args.group))
26
29
  @servers = servers(@backend)
27
30
  start_deployment
28
31
 
29
- success = nil
30
- @servers.each do |server|
31
- server_stats = @deployment_stats[server.name]
32
+ state = :pending
33
+ @servers&.each do |server|
34
+ server_stats = @deployment_stats[T.must(server.name)]
32
35
  puts COLORS.bold.blue("Deploying the app to `#{server.stage}` -- `#{@backend.name}:#{server.name}`")
33
36
 
34
37
  puts @args.humanized_deploy_command(server.stage)
@@ -38,27 +41,34 @@ module Capistrano
38
41
 
39
42
  server_stats.start_time = ::Time.now
40
43
  deploy_command = @args.deploy_command(server.stage)
41
- success = system deploy_command
44
+ case system deploy_command
45
+ when true
46
+ state = :success
47
+ when false
48
+ state = :failed
49
+ when nil
50
+ state = :pending
51
+ end
42
52
 
43
53
  server_stats.end_time = ::Time.now
44
- server_stats.success = success
54
+ server_stats.state = state
45
55
 
46
- next if success
56
+ next if state == :success
47
57
 
48
58
  puts COLORS.bold.red("Command `#{deploy_command}` failed")
49
59
  break
50
60
  end
51
61
 
52
- return if @args.test?
62
+ return :pending if @args.test?
53
63
 
54
- finish_deployment(success: success)
64
+ finish_deployment(state: state)
55
65
  print_summary
56
- success
66
+ state
57
67
  end
58
68
 
59
69
  private
60
70
 
61
- # @return [void]
71
+ #: -> void
62
72
  def start_deployment
63
73
  @deployment_stats.tap do |d|
64
74
  d.start_time = ::Time.now
@@ -67,25 +77,24 @@ module Capistrano
67
77
  end
68
78
  end
69
79
 
70
- # @param success [Boolean]
71
- def finish_deployment(success: true)
80
+ #: (Symbol) -> void
81
+ def finish_deployment(state: :success)
72
82
  @deployment_stats.end_time = ::Time.now
73
- @deployment_stats.success = success
83
+ @deployment_stats.state = state
74
84
  end
75
85
 
76
- # @return [void]
86
+ #: -> void
77
87
  def print_summary
78
88
  puts @deployment_stats
79
89
  end
80
90
 
81
- # @param backend [Capistrano::DataPlaneApi::Configuration::Backend]
82
- # @return [Array<Capistrano::DataPlaneApi::Configuration::Server>]
91
+ #: (Configuration::Backend) -> Array[Configuration::Server]?
83
92
  def servers(backend)
84
93
  return backend.servers unless @args.only?
85
94
 
86
95
  chosen_servers = []
87
- @args.only.each do |current_server_name|
88
- backend.servers.each do |server|
96
+ @args.only&.each do |current_server_name|
97
+ backend.servers&.each do |server|
89
98
  next unless server.name == current_server_name || server.stage == current_server_name
90
99
 
91
100
  chosen_servers << server
@@ -1,3 +1,4 @@
1
+ # typed: true
1
2
  # frozen_string_literal: true
2
3
 
3
4
  module Capistrano
@@ -8,8 +9,7 @@ module Capistrano
8
9
  module Helper
9
10
  extend self
10
11
 
11
- # @param seconds [Integer]
12
- # @return [String]
12
+ #: (Integer) -> String
13
13
  def humanize_time(seconds)
14
14
  hours = seconds / 3600
15
15
  rest_seconds = seconds - (hours * 3600)
@@ -39,9 +39,7 @@ module Capistrano
39
39
  # Calculate how many seconds have passed
40
40
  # since the given point in time.
41
41
  #
42
- # @param time [Time]
43
- # @param to [Time]
44
- # @return [Integer]
42
+ #: (Time, Time) -> Integer
45
43
  def seconds_since(time, to: ::Time.now)
46
44
  (to - time).to_i
47
45
  end