bard 1.9.6 → 2.0.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/.github/workflows/ci.yml +2 -2
- data/CLAUDE.md +1 -1
- data/PLUGINS.md +31 -46
- data/bard.gemspec +2 -1
- data/features/ci.feature +1 -0
- data/features/data.feature +1 -0
- data/features/deploy.feature +1 -0
- data/features/deploy_git_workflow.feature +1 -0
- data/features/run.feature +1 -0
- data/features/step_definitions/bard_steps.rb +1 -0
- data/features/support/test_server.rb +3 -3
- data/lib/bard/cli.rb +9 -28
- data/lib/bard/command.rb +9 -88
- data/lib/bard/config.rb +38 -177
- data/lib/bard/copy.rb +28 -82
- data/lib/bard/plugins/data.rb +56 -0
- data/lib/bard/{ci → plugins/deploy/ci}/github_actions.rb +2 -2
- data/lib/bard/{ci → plugins/deploy/ci}/jenkins.rb +1 -1
- data/lib/bard/{ci → plugins/deploy/ci}/local.rb +1 -1
- data/lib/bard/{ci → plugins/deploy/ci}/runner.rb +3 -3
- data/lib/bard/{ci.rb → plugins/deploy/ci.rb} +1 -1
- data/lib/bard/plugins/deploy/ssh_strategy.rb +27 -0
- data/lib/bard/{deploy_strategy.rb → plugins/deploy/strategy.rb} +1 -4
- data/lib/bard/plugins/deploy.rb +240 -0
- data/lib/bard/{git.rb → plugins/git.rb} +6 -3
- data/lib/bard/{github.rb → plugins/github.rb} +2 -2
- data/lib/bard/{deploy_strategy/github_pages.rb → plugins/github_pages/strategy.rb} +3 -4
- data/lib/bard/plugins/github_pages.rb +11 -15
- data/lib/bard/plugins/hurt.rb +12 -4
- data/{install_files → lib/bard/plugins/install}/.github/dependabot.yml +2 -1
- data/{install_files → lib/bard/plugins/install}/.github/workflows/cache-ci.yml +1 -1
- data/{install_files → lib/bard/plugins/install}/.github/workflows/ci.yml +2 -2
- data/lib/bard/plugins/install.rb +7 -3
- data/lib/bard/plugins/open.rb +20 -0
- data/lib/bard/{ping.rb → plugins/ping/check.rb} +4 -4
- data/lib/bard/plugins/ping/target_methods.rb +23 -0
- data/lib/bard/plugins/ping.rb +8 -4
- data/lib/bard/plugins/run.rb +19 -0
- data/lib/bard/plugins/setup.rb +54 -0
- data/lib/bard/plugins/ssh/connection.rb +75 -0
- data/lib/bard/plugins/ssh/copy.rb +95 -0
- data/lib/bard/{ssh_server.rb → plugins/ssh/server.rb} +10 -42
- data/lib/bard/plugins/ssh/target_methods.rb +20 -0
- data/lib/bard/plugins/ssh.rb +10 -0
- data/lib/bard/plugins/url/target_methods.rb +23 -0
- data/lib/bard/plugins/url.rb +1 -0
- data/lib/bard/plugins/vim.rb +5 -4
- data/lib/bard/retryable.rb +25 -0
- data/lib/bard/target.rb +21 -230
- data/lib/bard/version.rb +1 -1
- data/lib/bard.rb +1 -3
- data/spec/acceptance/docker/Dockerfile +1 -1
- data/spec/bard/capability_spec.rb +8 -50
- data/spec/bard/ci/github_actions_spec.rb +1 -1
- data/spec/bard/ci/jenkins_spec.rb +1 -1
- data/spec/bard/ci/runner_spec.rb +3 -3
- data/spec/bard/ci_spec.rb +1 -1
- data/spec/bard/cli/ci_spec.rb +4 -23
- data/spec/bard/cli/data_spec.rb +7 -26
- data/spec/bard/cli/deploy_spec.rb +43 -40
- data/spec/bard/cli/hurt_spec.rb +2 -8
- data/spec/bard/cli/install_spec.rb +4 -10
- data/spec/bard/cli/master_key_spec.rb +5 -19
- data/spec/bard/cli/open_spec.rb +17 -35
- data/spec/bard/cli/ping_spec.rb +10 -25
- data/spec/bard/cli/run_spec.rb +10 -23
- data/spec/bard/cli/setup_spec.rb +10 -27
- data/spec/bard/cli/ssh_spec.rb +10 -25
- data/spec/bard/cli/stage_spec.rb +17 -32
- data/spec/bard/cli/vim_spec.rb +5 -11
- data/spec/bard/command_spec.rb +1 -10
- data/spec/bard/config_spec.rb +68 -116
- data/spec/bard/copy_spec.rb +54 -18
- data/spec/bard/deploy_strategy/ssh_spec.rb +65 -7
- data/spec/bard/deploy_strategy_spec.rb +1 -1
- data/spec/bard/dynamic_dsl_spec.rb +18 -98
- data/spec/bard/git_spec.rb +9 -5
- data/spec/bard/github_spec.rb +1 -1
- data/spec/bard/ping_spec.rb +5 -5
- data/spec/bard/ssh_copy_spec.rb +44 -0
- data/spec/bard/ssh_server_spec.rb +1 -98
- data/spec/bard/target_spec.rb +61 -108
- metadata +50 -124
- data/lib/bard/ci/retryable.rb +0 -27
- data/lib/bard/cli/ci.rb +0 -73
- data/lib/bard/cli/command.rb +0 -26
- data/lib/bard/cli/data.rb +0 -45
- data/lib/bard/cli/deploy.rb +0 -116
- data/lib/bard/cli/hurt.rb +0 -15
- data/lib/bard/cli/install.rb +0 -11
- data/lib/bard/cli/master_key.rb +0 -17
- data/lib/bard/cli/new.rb +0 -101
- data/lib/bard/cli/new_rails_template.rb +0 -197
- data/lib/bard/cli/open.rb +0 -18
- data/lib/bard/cli/ping.rb +0 -12
- data/lib/bard/cli/provision.rb +0 -34
- data/lib/bard/cli/run.rb +0 -26
- data/lib/bard/cli/setup.rb +0 -56
- data/lib/bard/cli/ssh.rb +0 -14
- data/lib/bard/cli/stage.rb +0 -35
- data/lib/bard/cli/vim.rb +0 -8
- data/lib/bard/default_config.rb +0 -35
- data/lib/bard/deploy_strategy/ssh.rb +0 -19
- data/lib/bard/deprecation.rb +0 -19
- data/lib/bard/github_pages.rb +0 -134
- data/lib/bard/plugin.rb +0 -100
- data/lib/bard/plugins/backup.rb +0 -19
- data/lib/bard/plugins/jenkins.rb +0 -6
- data/lib/bard/plugins/new.rb +0 -5
- data/lib/bard/plugins/provision.rb +0 -5
- data/lib/bard/provision/app.rb +0 -10
- data/lib/bard/provision/apt.rb +0 -16
- data/lib/bard/provision/authorizedkeys.rb +0 -25
- data/lib/bard/provision/data.rb +0 -27
- data/lib/bard/provision/deploy.rb +0 -10
- data/lib/bard/provision/http.rb +0 -16
- data/lib/bard/provision/logrotation.rb +0 -30
- data/lib/bard/provision/masterkey.rb +0 -18
- data/lib/bard/provision/mysql.rb +0 -22
- data/lib/bard/provision/passenger.rb +0 -37
- data/lib/bard/provision/repo.rb +0 -72
- data/lib/bard/provision/rvm.rb +0 -22
- data/lib/bard/provision/ssh.rb +0 -79
- data/lib/bard/provision/swapfile.rb +0 -23
- data/lib/bard/provision/user.rb +0 -42
- data/lib/bard/provision.rb +0 -16
- data/lib/bard/server.rb +0 -160
- data/spec/bard/cli/command_spec.rb +0 -50
- data/spec/bard/cli/new_spec.rb +0 -73
- data/spec/bard/cli/provision_spec.rb +0 -42
- data/spec/bard/deprecation_spec.rb +0 -281
- data/spec/bard/github_pages_spec.rb +0 -143
- data/spec/bard/plugin_spec.rb +0 -79
- data/spec/bard/provision/app_spec.rb +0 -33
- data/spec/bard/provision/apt_spec.rb +0 -39
- data/spec/bard/provision/authorizedkeys_spec.rb +0 -40
- data/spec/bard/provision/data_spec.rb +0 -54
- data/spec/bard/provision/deploy_spec.rb +0 -33
- data/spec/bard/provision/http_spec.rb +0 -57
- data/spec/bard/provision/logrotation_spec.rb +0 -34
- data/spec/bard/provision/masterkey_spec.rb +0 -63
- data/spec/bard/provision/mysql_spec.rb +0 -55
- data/spec/bard/provision/passenger_spec.rb +0 -81
- data/spec/bard/provision/repo_spec.rb +0 -208
- data/spec/bard/provision/rvm_spec.rb +0 -49
- data/spec/bard/provision/ssh_spec.rb +0 -242
- data/spec/bard/provision/swapfile_spec.rb +0 -33
- data/spec/bard/provision/user_spec.rb +0 -103
- data/spec/bard/provision_spec.rb +0 -28
- data/spec/bard/server_spec.rb +0 -127
- /data/lib/bard/{ci → plugins/deploy/ci}/state.rb +0 -0
- /data/{install_files → lib/bard/plugins/install}/apt_dependencies.rb +0 -0
- /data/{install_files → lib/bard/plugins/install}/ci +0 -0
- /data/{install_files → lib/bard/plugins/install}/setup +0 -0
- /data/{install_files → lib/bard/plugins/install}/specified_bundler.rb +0 -0
- /data/{install_files → lib/bard/plugins/install}/specified_ruby.rb +0 -0
data/lib/bard/target.rb
CHANGED
|
@@ -1,23 +1,14 @@
|
|
|
1
|
-
require "uri"
|
|
2
1
|
require "bard/command"
|
|
3
|
-
require "bard/copy"
|
|
4
|
-
require "bard/deploy_strategy"
|
|
5
|
-
require "bard/deprecation"
|
|
6
2
|
|
|
7
3
|
module Bard
|
|
8
4
|
class Target
|
|
9
5
|
attr_reader :key, :config
|
|
10
|
-
attr_accessor :server
|
|
11
6
|
|
|
12
7
|
def initialize(key, config)
|
|
13
8
|
@key = key
|
|
14
9
|
@config = config
|
|
15
10
|
@capabilities = []
|
|
16
|
-
@ping_urls = []
|
|
17
|
-
@strategy_options_hash = {}
|
|
18
|
-
@deploy_strategy = nil
|
|
19
11
|
@path = nil
|
|
20
|
-
@server = nil
|
|
21
12
|
end
|
|
22
13
|
|
|
23
14
|
# Capability tracking
|
|
@@ -31,234 +22,25 @@ module Bard
|
|
|
31
22
|
|
|
32
23
|
def require_capability!(capability)
|
|
33
24
|
unless has_capability?(capability)
|
|
34
|
-
|
|
35
|
-
when :ssh
|
|
36
|
-
"SSH not configured for this target"
|
|
37
|
-
when :ping
|
|
38
|
-
"Ping URL not configured for this target"
|
|
39
|
-
else
|
|
40
|
-
"#{capability} capability not configured for this target"
|
|
41
|
-
end
|
|
42
|
-
raise error_message
|
|
25
|
+
raise "#{capability} capability not configured for this target"
|
|
43
26
|
end
|
|
44
27
|
end
|
|
45
28
|
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
if uri_or_false.nil?
|
|
49
|
-
# Getter - return false if explicitly disabled, otherwise return server
|
|
50
|
-
return @ssh_disabled ? false : @server
|
|
51
|
-
elsif uri_or_false == false
|
|
52
|
-
# Disable SSH
|
|
53
|
-
@server = nil
|
|
54
|
-
@ssh_disabled = true
|
|
55
|
-
@capabilities.delete(:ssh)
|
|
56
|
-
else
|
|
57
|
-
# Enable SSH
|
|
58
|
-
require "bard/ssh_server"
|
|
59
|
-
@server = SSHServer.new(uri_or_false, **options)
|
|
60
|
-
@path = options[:path] if options[:path]
|
|
61
|
-
@gateway = options[:gateway] if options[:gateway]
|
|
62
|
-
@ssh_key = options[:ssh_key] if options[:ssh_key]
|
|
63
|
-
@env = options[:env] if options[:env]
|
|
64
|
-
enable_capability(:ssh)
|
|
65
|
-
|
|
66
|
-
# Set SSH as default deployment strategy if none set
|
|
67
|
-
@deploy_strategy ||= :ssh
|
|
68
|
-
|
|
69
|
-
# Auto-configure ping from hostname
|
|
70
|
-
hostname = @server.hostname
|
|
71
|
-
ping("https://#{hostname}") if hostname
|
|
72
|
-
end
|
|
73
|
-
end
|
|
74
|
-
|
|
75
|
-
def ssh_uri
|
|
76
|
-
server&.ssh_uri
|
|
77
|
-
end
|
|
78
|
-
|
|
79
|
-
# Path configuration
|
|
80
|
-
def path(new_path = nil)
|
|
81
|
-
if new_path
|
|
82
|
-
Deprecation.warn "Separate `path` call is deprecated; pass as keyword argument to `ssh` instead, e.g., `ssh \"user@host\", path: \"#{new_path}\"` (will be removed in v2.0)"
|
|
83
|
-
@path = new_path
|
|
84
|
-
else
|
|
85
|
-
@path || config.project_name
|
|
86
|
-
end
|
|
29
|
+
def path
|
|
30
|
+
@path || config.project_name
|
|
87
31
|
end
|
|
88
32
|
|
|
89
|
-
# Deprecated separate setter methods - use ssh(..., option: value) instead
|
|
90
|
-
def gateway(value = nil)
|
|
91
|
-
if value
|
|
92
|
-
Deprecation.warn "Separate `gateway` call is deprecated; pass as keyword argument to `ssh` instead, e.g., `ssh \"user@host\", gateway: \"#{value}\"` (will be removed in v2.0)"
|
|
93
|
-
@gateway = value
|
|
94
|
-
else
|
|
95
|
-
@gateway
|
|
96
|
-
end
|
|
97
|
-
end
|
|
98
|
-
|
|
99
|
-
def ssh_key(value = nil)
|
|
100
|
-
if value
|
|
101
|
-
Deprecation.warn "Separate `ssh_key` call is deprecated; pass as keyword argument to `ssh` instead, e.g., `ssh \"user@host\", ssh_key: \"#{value}\"` (will be removed in v2.0)"
|
|
102
|
-
@ssh_key = value
|
|
103
|
-
else
|
|
104
|
-
@ssh_key
|
|
105
|
-
end
|
|
106
|
-
end
|
|
107
|
-
|
|
108
|
-
def env(value = nil)
|
|
109
|
-
if value
|
|
110
|
-
Deprecation.warn "Separate `env` call is deprecated; pass as keyword argument to `ssh` instead, e.g., `ssh \"user@host\", env: \"#{value}\"` (will be removed in v2.0)"
|
|
111
|
-
@env = value
|
|
112
|
-
else
|
|
113
|
-
@env
|
|
114
|
-
end
|
|
115
|
-
end
|
|
116
|
-
|
|
117
|
-
# Ping configuration
|
|
118
|
-
def ping(*urls)
|
|
119
|
-
if urls.empty?
|
|
120
|
-
# Getter - normalize URLs like Server does
|
|
121
|
-
@ping_urls.map { |url| normalize_ping(url) }
|
|
122
|
-
elsif urls.first == false
|
|
123
|
-
# Disable ping
|
|
124
|
-
@ping_urls = []
|
|
125
|
-
@capabilities.delete(:ping)
|
|
126
|
-
else
|
|
127
|
-
# Enable ping
|
|
128
|
-
@ping_urls = urls.flatten
|
|
129
|
-
enable_capability(:ping)
|
|
130
|
-
end
|
|
131
|
-
end
|
|
132
|
-
|
|
133
|
-
def ping_urls
|
|
134
|
-
@ping_urls
|
|
135
|
-
end
|
|
136
|
-
|
|
137
|
-
def ping!
|
|
138
|
-
require_capability!(:ping)
|
|
139
|
-
require "bard/ping"
|
|
140
|
-
failed_urls = Bard::Ping.call(self)
|
|
141
|
-
if failed_urls.any?
|
|
142
|
-
raise "Ping failed for: #{failed_urls.join(', ')}"
|
|
143
|
-
end
|
|
144
|
-
end
|
|
145
|
-
|
|
146
|
-
def open
|
|
147
|
-
require_capability!(:ping)
|
|
148
|
-
system "open #{ping_urls.first}"
|
|
149
|
-
end
|
|
150
|
-
|
|
151
|
-
# Deploy strategy
|
|
152
|
-
attr_reader :deploy_strategy
|
|
153
|
-
|
|
154
|
-
# GitHub Pages deployment configuration
|
|
155
|
-
def github_pages(url = nil)
|
|
156
|
-
if url.nil?
|
|
157
|
-
# Getter
|
|
158
|
-
@github_pages_url
|
|
159
|
-
else
|
|
160
|
-
# Setter
|
|
161
|
-
@deploy_strategy = :github_pages
|
|
162
|
-
@github_pages_url = url
|
|
163
|
-
enable_capability(:github_pages)
|
|
164
|
-
end
|
|
165
|
-
end
|
|
166
|
-
|
|
167
|
-
# Deprecated strategy configuration methods
|
|
168
|
-
def strategy(name)
|
|
169
|
-
Deprecation.warn "`strategy` is deprecated; use the strategy method directly, e.g., `#{name} \"url\"` instead of `strategy :#{name}` (will be removed in v2.0)"
|
|
170
|
-
@deploy_strategy = name
|
|
171
|
-
end
|
|
172
|
-
|
|
173
|
-
def option(key, value)
|
|
174
|
-
Deprecation.warn "`option` is deprecated; pass options as keyword arguments to the strategy method, e.g., `jets \"url\", #{key}: #{value.inspect}` (will be removed in v2.0)"
|
|
175
|
-
@strategy_options_hash[@deploy_strategy] ||= {}
|
|
176
|
-
@strategy_options_hash[@deploy_strategy][key] = value
|
|
177
|
-
end
|
|
178
|
-
|
|
179
|
-
def strategy_options(strategy_name)
|
|
180
|
-
@strategy_options_hash[strategy_name] || {}
|
|
181
|
-
end
|
|
182
|
-
|
|
183
|
-
def deploy_strategy_instance
|
|
184
|
-
raise "No deployment strategy configured for target #{key}" unless @deploy_strategy
|
|
185
|
-
|
|
186
|
-
strategy_class = DeployStrategy[@deploy_strategy]
|
|
187
|
-
raise "Unknown deployment strategy: #{@deploy_strategy}" unless strategy_class
|
|
188
|
-
|
|
189
|
-
strategy_class.new(self)
|
|
190
|
-
end
|
|
191
|
-
|
|
192
|
-
# Dynamic strategy DSL via method_missing
|
|
193
|
-
def method_missing(method, *args, **kwargs, &block)
|
|
194
|
-
strategy_class = DeployStrategy[method]
|
|
195
|
-
|
|
196
|
-
if strategy_class
|
|
197
|
-
# This is a deployment strategy
|
|
198
|
-
@deploy_strategy = method
|
|
199
|
-
|
|
200
|
-
# Store options
|
|
201
|
-
@strategy_options_hash[method] = kwargs
|
|
202
|
-
|
|
203
|
-
# Auto-configure ping if first arg is a URL
|
|
204
|
-
if args.first && args.first.to_s =~ /^https?:\/\//
|
|
205
|
-
ping(args.first)
|
|
206
|
-
end
|
|
207
|
-
|
|
208
|
-
# Call the strategy's initializer if it wants to configure the target
|
|
209
|
-
# (This will be handled by the strategy class)
|
|
210
|
-
else
|
|
211
|
-
super
|
|
212
|
-
end
|
|
213
|
-
end
|
|
214
|
-
|
|
215
|
-
def respond_to_missing?(method, include_private = false)
|
|
216
|
-
DeployStrategy[method] || super
|
|
217
|
-
end
|
|
218
|
-
|
|
219
|
-
# Remote command execution
|
|
220
33
|
def run!(command, home: false, verbose: false, quiet: false, capture: false)
|
|
221
|
-
|
|
222
|
-
result = Command.run!(command, on: self, home: home, verbose: verbose, quiet: quiet)
|
|
34
|
+
result = Command.run!(command, verbose:, quiet:)
|
|
223
35
|
result if capture
|
|
224
36
|
end
|
|
225
37
|
|
|
226
38
|
def run(command, home: false, verbose: false, quiet: false)
|
|
227
|
-
|
|
228
|
-
Command.run(command, on: self, home: home, verbose: verbose, quiet: quiet)
|
|
39
|
+
Command.run(command, verbose:, quiet:)
|
|
229
40
|
end
|
|
230
41
|
|
|
231
42
|
def exec!(command, home: false)
|
|
232
|
-
|
|
233
|
-
Command.exec!(command, on: self, home: home)
|
|
234
|
-
end
|
|
235
|
-
|
|
236
|
-
# File transfer
|
|
237
|
-
def copy_file(path, to:, verbose: false)
|
|
238
|
-
require_capability!(:ssh)
|
|
239
|
-
to.require_capability!(:ssh) if to.respond_to?(:require_capability!)
|
|
240
|
-
Copy.file(path, from: self, to: to, verbose: verbose)
|
|
241
|
-
end
|
|
242
|
-
|
|
243
|
-
def copy_dir(path, to:, verbose: false)
|
|
244
|
-
require_capability!(:ssh)
|
|
245
|
-
to.require_capability!(:ssh) if to.respond_to?(:require_capability!)
|
|
246
|
-
Copy.dir(path, from: self, to: to, verbose: verbose)
|
|
247
|
-
end
|
|
248
|
-
|
|
249
|
-
# URI methods for compatibility
|
|
250
|
-
def scp_uri(file_path = nil)
|
|
251
|
-
full_path = "/#{path}"
|
|
252
|
-
full_path += "/#{file_path}" if file_path
|
|
253
|
-
URI::Generic.build(scheme: "scp", userinfo: server.user, host: server.host, port: server.port.to_i, path: full_path)
|
|
254
|
-
end
|
|
255
|
-
|
|
256
|
-
def rsync_uri(file_path = nil)
|
|
257
|
-
uri = ssh_uri
|
|
258
|
-
str = "#{uri.user}@#{uri.host}"
|
|
259
|
-
str += ":#{path}"
|
|
260
|
-
str += "/#{file_path}" if file_path
|
|
261
|
-
str
|
|
43
|
+
Command.exec!(command)
|
|
262
44
|
end
|
|
263
45
|
|
|
264
46
|
# Utility methods
|
|
@@ -278,13 +60,22 @@ module Bard
|
|
|
278
60
|
end
|
|
279
61
|
end
|
|
280
62
|
|
|
281
|
-
|
|
63
|
+
def ==(other)
|
|
64
|
+
return false unless other.is_a?(Bard::Target)
|
|
65
|
+
comparable_state == other.comparable_state
|
|
66
|
+
end
|
|
67
|
+
alias_method :eql?, :==
|
|
68
|
+
|
|
69
|
+
def hash
|
|
70
|
+
comparable_state.hash
|
|
71
|
+
end
|
|
72
|
+
|
|
73
|
+
protected
|
|
282
74
|
|
|
283
|
-
def
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
normalized
|
|
75
|
+
def comparable_state
|
|
76
|
+
(instance_variables - [:@key, :@config]).sort.map do |ivar|
|
|
77
|
+
[ivar, instance_variable_get(ivar)]
|
|
78
|
+
end
|
|
288
79
|
end
|
|
289
80
|
end
|
|
290
81
|
end
|
data/lib/bard/version.rb
CHANGED
data/lib/bard.rb
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
require "spec_helper"
|
|
2
2
|
require "bard/target"
|
|
3
|
+
require "bard/plugins/ssh/target_methods"
|
|
4
|
+
require "bard/plugins/ping/target_methods"
|
|
3
5
|
|
|
4
6
|
describe "Capability System" do
|
|
5
7
|
let(:config) { double("config", project_name: "testapp") }
|
|
@@ -13,9 +15,9 @@ describe "Capability System" do
|
|
|
13
15
|
|
|
14
16
|
it "can enable multiple capabilities" do
|
|
15
17
|
target.enable_capability(:ssh)
|
|
16
|
-
target.enable_capability(:
|
|
18
|
+
target.enable_capability(:url)
|
|
17
19
|
expect(target.has_capability?(:ssh)).to be true
|
|
18
|
-
expect(target.has_capability?(:
|
|
20
|
+
expect(target.has_capability?(:url)).to be true
|
|
19
21
|
end
|
|
20
22
|
end
|
|
21
23
|
|
|
@@ -38,59 +40,15 @@ describe "Capability System" do
|
|
|
38
40
|
|
|
39
41
|
it "raises an error if capability is not enabled" do
|
|
40
42
|
expect { target.require_capability!(:ssh) }
|
|
41
|
-
.to raise_error(/
|
|
42
|
-
end
|
|
43
|
-
|
|
44
|
-
it "provides custom error message for ping capability" do
|
|
45
|
-
expect { target.require_capability!(:ping) }
|
|
46
|
-
.to raise_error(/Ping URL not configured for this target/)
|
|
47
|
-
end
|
|
48
|
-
|
|
49
|
-
it "provides generic error message for unknown capabilities" do
|
|
50
|
-
expect { target.require_capability!(:unknown) }
|
|
51
|
-
.to raise_error(/unknown capability not configured for this target/)
|
|
43
|
+
.to raise_error(/ssh capability not configured for this target/)
|
|
52
44
|
end
|
|
53
45
|
end
|
|
54
46
|
|
|
55
47
|
describe "capability dependency checking" do
|
|
56
|
-
context "
|
|
57
|
-
it "
|
|
58
|
-
expect { target.run!("ls") }
|
|
59
|
-
.to raise_error(/SSH not configured/)
|
|
60
|
-
end
|
|
61
|
-
|
|
62
|
-
it "run requires SSH capability" do
|
|
63
|
-
expect { target.run("ls") }
|
|
64
|
-
.to raise_error(/SSH not configured/)
|
|
65
|
-
end
|
|
66
|
-
|
|
67
|
-
it "exec! requires SSH capability" do
|
|
68
|
-
expect { target.exec!("ls") }
|
|
69
|
-
.to raise_error(/SSH not configured/)
|
|
70
|
-
end
|
|
71
|
-
|
|
72
|
-
it "copy_file requires SSH capability" do
|
|
73
|
-
other_target = Bard::Target.new(:staging, config)
|
|
74
|
-
expect { target.copy_file("test.txt", to: other_target) }
|
|
75
|
-
.to raise_error(/SSH not configured/)
|
|
76
|
-
end
|
|
77
|
-
|
|
78
|
-
it "copy_dir requires SSH capability" do
|
|
79
|
-
other_target = Bard::Target.new(:staging, config)
|
|
80
|
-
expect { target.copy_dir("test/", to: other_target) }
|
|
81
|
-
.to raise_error(/SSH not configured/)
|
|
82
|
-
end
|
|
83
|
-
end
|
|
84
|
-
|
|
85
|
-
context "Ping-dependent methods" do
|
|
86
|
-
it "ping! requires ping capability" do
|
|
48
|
+
context "URL-dependent methods" do
|
|
49
|
+
it "ping! requires url capability" do
|
|
87
50
|
expect { target.ping! }
|
|
88
|
-
.to raise_error(/
|
|
89
|
-
end
|
|
90
|
-
|
|
91
|
-
it "open requires ping capability" do
|
|
92
|
-
expect { target.open }
|
|
93
|
-
.to raise_error(/Ping URL not configured/)
|
|
51
|
+
.to raise_error(/url capability not configured/)
|
|
94
52
|
end
|
|
95
53
|
end
|
|
96
54
|
end
|
data/spec/bard/ci/runner_spec.rb
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
require "bard/ci/runner"
|
|
1
|
+
require "bard/plugins/deploy/ci/runner"
|
|
2
2
|
|
|
3
3
|
RSpec.describe Bard::CI::Runner do
|
|
4
4
|
describe ".runners" do
|
|
@@ -9,8 +9,8 @@ RSpec.describe Bard::CI::Runner do
|
|
|
9
9
|
|
|
10
10
|
describe ".[]" do
|
|
11
11
|
before do
|
|
12
|
-
require "bard/ci/local"
|
|
13
|
-
require "bard/ci/github_actions"
|
|
12
|
+
require "bard/plugins/deploy/ci/local"
|
|
13
|
+
require "bard/plugins/deploy/ci/github_actions"
|
|
14
14
|
end
|
|
15
15
|
|
|
16
16
|
it "looks up runners by name" do
|
data/spec/bard/ci_spec.rb
CHANGED
data/spec/bard/cli/ci_spec.rb
CHANGED
|
@@ -1,33 +1,14 @@
|
|
|
1
1
|
require "spec_helper"
|
|
2
2
|
require "bard/cli"
|
|
3
|
-
require "bard/cli/ci"
|
|
4
|
-
require "thor"
|
|
5
3
|
require "ostruct"
|
|
6
4
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
attr_reader :options
|
|
11
|
-
|
|
12
|
-
def initialize
|
|
13
|
-
super
|
|
14
|
-
@options = {}
|
|
15
|
-
end
|
|
16
|
-
|
|
17
|
-
def project_name
|
|
18
|
-
"test_project"
|
|
19
|
-
end
|
|
20
|
-
|
|
21
|
-
def config
|
|
22
|
-
@config ||= OpenStruct.new(ci: nil)
|
|
23
|
-
end
|
|
24
|
-
end
|
|
25
|
-
|
|
26
|
-
describe Bard::CLI::CI do
|
|
27
|
-
let(:cli) { TestCICLI.new }
|
|
5
|
+
describe "bard ci" do
|
|
6
|
+
let(:cli) { Bard::CLI.new }
|
|
28
7
|
let(:ci_runner) { double("ci_runner") }
|
|
29
8
|
|
|
30
9
|
before do
|
|
10
|
+
allow(cli).to receive(:config).and_return(OpenStruct.new(ci: nil))
|
|
11
|
+
allow(cli).to receive(:project_name).and_return("test_project")
|
|
31
12
|
allow(cli).to receive(:puts)
|
|
32
13
|
allow(cli).to receive(:print)
|
|
33
14
|
allow(cli).to receive(:exit)
|
data/spec/bard/cli/data_spec.rb
CHANGED
|
@@ -1,35 +1,15 @@
|
|
|
1
1
|
require "spec_helper"
|
|
2
2
|
require "bard/cli"
|
|
3
|
-
require "bard/cli/data"
|
|
4
3
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
require "term/ansicolor"
|
|
8
|
-
|
|
9
|
-
class TestCLI < Thor
|
|
10
|
-
include Bard::CLI::Data
|
|
11
|
-
include Term::ANSIColor
|
|
12
|
-
|
|
13
|
-
attr_reader :config
|
|
14
|
-
|
|
15
|
-
def initialize
|
|
16
|
-
@config = {}
|
|
17
|
-
end
|
|
18
|
-
|
|
19
|
-
def options
|
|
20
|
-
{}
|
|
21
|
-
end
|
|
22
|
-
end
|
|
23
|
-
|
|
24
|
-
describe Bard::CLI::Data do
|
|
25
|
-
let(:cli) { TestCLI.new }
|
|
4
|
+
describe "bard data" do
|
|
5
|
+
let(:cli) { Bard::CLI.new }
|
|
26
6
|
|
|
27
7
|
it "should have a data command" do
|
|
28
8
|
expect(cli).to respond_to(:data)
|
|
29
9
|
end
|
|
30
10
|
|
|
31
11
|
context "data" do
|
|
32
|
-
let(:from) { double("from", key: :production, run!: nil,
|
|
12
|
+
let(:from) { double("from", key: :production, run!: nil, require_capability!: nil) }
|
|
33
13
|
let(:to) { double("to", key: :local, run!: nil) }
|
|
34
14
|
|
|
35
15
|
let(:config) do
|
|
@@ -42,17 +22,18 @@ describe Bard::CLI::Data do
|
|
|
42
22
|
before do
|
|
43
23
|
allow(cli).to receive(:config).and_return(config)
|
|
44
24
|
allow(cli).to receive(:options).and_return({from: "production", to: "local"})
|
|
25
|
+
allow(cli).to receive(:puts)
|
|
45
26
|
end
|
|
46
27
|
|
|
47
28
|
it "should run the data command" do
|
|
48
29
|
expect(from).to receive(:run!).with("bin/rake db:dump")
|
|
49
|
-
expect(
|
|
30
|
+
expect(Bard::Copy).to receive(:file).with("db/data.sql.gz", from: from, to: to, verbose: true)
|
|
50
31
|
expect(to).to receive(:run!).with("bin/rake db:load")
|
|
51
32
|
cli.data
|
|
52
33
|
end
|
|
53
34
|
|
|
54
35
|
context "pushing to production" do
|
|
55
|
-
let(:to) { double("to", key: :production,
|
|
36
|
+
let(:to) { double("to", key: :production, url: "https://example.com", run!: nil, require_capability!: nil) }
|
|
56
37
|
|
|
57
38
|
before do
|
|
58
39
|
allow(cli).to receive(:options).and_return({from: "local", to: "production"})
|
|
@@ -68,7 +49,7 @@ describe Bard::CLI::Data do
|
|
|
68
49
|
it "should allow pushing to production if the user confirms" do
|
|
69
50
|
expect(cli).to receive(:ask).and_return("https://example.com")
|
|
70
51
|
expect(from).to receive(:run!).with("bin/rake db:dump")
|
|
71
|
-
expect(
|
|
52
|
+
expect(Bard::Copy).to receive(:file).with("db/data.sql.gz", from: from, to: to, verbose: true)
|
|
72
53
|
expect(to).to receive(:run!).with("bin/rake db:load")
|
|
73
54
|
cli.data
|
|
74
55
|
end
|