bard 1.9.0 → 1.9.1
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/lib/bard/cli/stage.rb +10 -1
- data/lib/bard/cli.rb +7 -0
- data/lib/bard/command.rb +3 -3
- data/lib/bard/config.rb +3 -1
- data/lib/bard/provision/ssh.rb +9 -2
- data/lib/bard/server.rb +3 -2
- data/lib/bard/target.rb +3 -2
- data/lib/bard/version.rb +1 -1
- data/spec/bard/cli/stage_spec.rb +20 -0
- data/spec/bard/config_spec.rb +12 -0
- data/spec/bard/provision/ssh_spec.rb +17 -4
- metadata +2 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 9d66092e3bc2b19b6010e668ead98981db7d41ce14434be33b02caa7c7c23e97
|
|
4
|
+
data.tar.gz: bbe41031b2b9c5974069bae36a5606063d3d4a75f43bf86ac61787b60e12eb9b
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: d13c12fc322c9cdcfa2ae0c8a6a5fd9c4e033e026ef423823494d02f63eec55a5bd1a7268689017b56bf7e4243ece08f2b041d41958b751f2808d5403529d745
|
|
7
|
+
data.tar.gz: 26a9703810bc8c2063803a8efc8720ca2bb9e9f6cb82667e18b00297b76256a745434a453cabd1bb6f1966337a6b1b27e6bcd62674671922d300ccdad53e25e3
|
data/lib/bard/cli/stage.rb
CHANGED
|
@@ -12,7 +12,16 @@ module Bard::CLI::Stage
|
|
|
12
12
|
end
|
|
13
13
|
|
|
14
14
|
run! "git push -u origin #{branch}", verbose: true
|
|
15
|
-
|
|
15
|
+
|
|
16
|
+
target = config[:staging]
|
|
17
|
+
if target.respond_to?(:deploy_strategy) && target.deploy_strategy
|
|
18
|
+
require "bard/deploy_strategy/#{target.deploy_strategy}"
|
|
19
|
+
strategy = target.deploy_strategy_instance
|
|
20
|
+
strategy.deploy
|
|
21
|
+
else
|
|
22
|
+
target.run! "git fetch && git checkout -f origin/#{branch} && bin/setup"
|
|
23
|
+
end
|
|
24
|
+
|
|
16
25
|
puts green("Stage Succeeded")
|
|
17
26
|
|
|
18
27
|
ping :staging
|
data/lib/bard/cli.rb
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
# this file gets loaded in the CLI context, not the Rails boot context
|
|
2
2
|
|
|
3
3
|
require "thor"
|
|
4
|
+
require "bard/version"
|
|
4
5
|
require "bard/config"
|
|
5
6
|
require "bard/command"
|
|
6
7
|
require "bard/plugin"
|
|
@@ -33,6 +34,12 @@ module Bard
|
|
|
33
34
|
require "bard/ci/local"
|
|
34
35
|
require "bard/ci/github_actions"
|
|
35
36
|
|
|
37
|
+
map "--version" => :version
|
|
38
|
+
desc "version", "Display version"
|
|
39
|
+
def version
|
|
40
|
+
puts Bard::VERSION
|
|
41
|
+
end
|
|
42
|
+
|
|
36
43
|
def self.exit_on_failure? = true
|
|
37
44
|
|
|
38
45
|
no_commands do
|
data/lib/bard/command.rb
CHANGED
|
@@ -17,9 +17,9 @@ module Bard
|
|
|
17
17
|
end
|
|
18
18
|
|
|
19
19
|
def run! verbose: false, quiet: false
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
20
|
+
result = run(verbose:, quiet:)
|
|
21
|
+
raise Error.new(full_command) unless result
|
|
22
|
+
result
|
|
23
23
|
end
|
|
24
24
|
|
|
25
25
|
def run verbose: false, quiet: false
|
data/lib/bard/config.rb
CHANGED
|
@@ -52,7 +52,9 @@ module Bard
|
|
|
52
52
|
# New v2.0 API - creates Target instances
|
|
53
53
|
def target(key, &block)
|
|
54
54
|
key = key.to_sym
|
|
55
|
-
@servers[key]
|
|
55
|
+
unless @servers[key].is_a?(Target)
|
|
56
|
+
@servers[key] = Target.new(key, self)
|
|
57
|
+
end
|
|
56
58
|
@servers[key].instance_eval(&block) if block
|
|
57
59
|
@servers[key]
|
|
58
60
|
end
|
data/lib/bard/provision/ssh.rb
CHANGED
|
@@ -19,7 +19,14 @@ class Bard::Provision::SSH < Bard::Provision
|
|
|
19
19
|
add_ssh_known_host!(provision_server.ssh_uri)
|
|
20
20
|
end
|
|
21
21
|
print " Reconfiguring port to #{target_port},"
|
|
22
|
-
provision_server.run! %(echo "Port #{target_port}" | sudo tee /etc/ssh/sshd_config.d/port_#{target_port}.conf
|
|
22
|
+
provision_server.run! %(echo "Port #{target_port}" | sudo tee /etc/ssh/sshd_config.d/port_#{target_port}.conf && sudo service ssh restart), home: true
|
|
23
|
+
5.times do
|
|
24
|
+
sleep 1
|
|
25
|
+
break if ssh_available?(provision_server.ssh_uri, port: target_port)
|
|
26
|
+
end
|
|
27
|
+
if !ssh_available?(provision_server.ssh_uri, port: target_port)
|
|
28
|
+
raise "reconfigured SSH to port #{target_port} but it's not responding — check firewall and sshd_config Include directive"
|
|
29
|
+
end
|
|
23
30
|
end
|
|
24
31
|
|
|
25
32
|
if !ssh_known_host?(provision_server.ssh_uri)
|
|
@@ -65,7 +72,7 @@ class Bard::Provision::SSH < Bard::Provision
|
|
|
65
72
|
|
|
66
73
|
def disable_password_auth!
|
|
67
74
|
provision_server.run!(
|
|
68
|
-
%q{echo "PasswordAuthentication no" | sudo tee /etc/ssh/sshd_config.d/disable_password_auth.conf
|
|
75
|
+
%q{echo "PasswordAuthentication no" | sudo tee /etc/ssh/sshd_config.d/disable_password_auth.conf && sudo service ssh restart},
|
|
69
76
|
home: true
|
|
70
77
|
)
|
|
71
78
|
end
|
data/lib/bard/server.rb
CHANGED
|
@@ -135,8 +135,9 @@ module Bard
|
|
|
135
135
|
key
|
|
136
136
|
end
|
|
137
137
|
|
|
138
|
-
def run! command, home: false, verbose: false, quiet: false
|
|
139
|
-
Bard::Command.run!
|
|
138
|
+
def run! command, home: false, verbose: false, quiet: false, capture: false
|
|
139
|
+
result = Bard::Command.run!(command, on: self, home:, verbose:, quiet:)
|
|
140
|
+
result if capture
|
|
140
141
|
end
|
|
141
142
|
|
|
142
143
|
def run command, home: false, verbose: false, quiet: false
|
data/lib/bard/target.rb
CHANGED
|
@@ -217,9 +217,10 @@ module Bard
|
|
|
217
217
|
end
|
|
218
218
|
|
|
219
219
|
# Remote command execution
|
|
220
|
-
def run!(command, home: false, verbose: false, quiet: false)
|
|
220
|
+
def run!(command, home: false, verbose: false, quiet: false, capture: false)
|
|
221
221
|
require_capability!(:ssh)
|
|
222
|
-
Command.run!(command, on: self, home: home, verbose: verbose, quiet: quiet)
|
|
222
|
+
result = Command.run!(command, on: self, home: home, verbose: verbose, quiet: quiet)
|
|
223
|
+
result if capture
|
|
223
224
|
end
|
|
224
225
|
|
|
225
226
|
def run(command, home: false, verbose: false, quiet: false)
|
data/lib/bard/version.rb
CHANGED
data/spec/bard/cli/stage_spec.rb
CHANGED
|
@@ -55,6 +55,26 @@ describe Bard::CLI::Stage do
|
|
|
55
55
|
end
|
|
56
56
|
end
|
|
57
57
|
|
|
58
|
+
context "when staging target has a deploy strategy" do
|
|
59
|
+
let(:strategy_instance) { double("strategy") }
|
|
60
|
+
let(:staging_server) { double("staging", deploy_strategy: :fake) }
|
|
61
|
+
|
|
62
|
+
before do
|
|
63
|
+
allow(staging_server).to receive(:respond_to?).with(:deploy_strategy).and_return(true)
|
|
64
|
+
allow(staging_server).to receive(:deploy_strategy_instance).and_return(strategy_instance)
|
|
65
|
+
allow(cli).to receive(:require).with("bard/deploy_strategy/fake").and_return(true)
|
|
66
|
+
end
|
|
67
|
+
|
|
68
|
+
it "uses the deploy strategy instead of SSH" do
|
|
69
|
+
expect(cli).to receive(:run!).with("git push -u origin main", verbose: true)
|
|
70
|
+
expect(strategy_instance).to receive(:deploy)
|
|
71
|
+
expect(staging_server).not_to receive(:run!)
|
|
72
|
+
expect(cli).to receive(:ping).with(:staging)
|
|
73
|
+
|
|
74
|
+
cli.stage
|
|
75
|
+
end
|
|
76
|
+
end
|
|
77
|
+
|
|
58
78
|
context "when production server is not defined" do
|
|
59
79
|
let(:servers) { { staging: staging_server } }
|
|
60
80
|
|
data/spec/bard/config_spec.rb
CHANGED
|
@@ -148,6 +148,18 @@ describe Bard::Config do
|
|
|
148
148
|
end
|
|
149
149
|
end
|
|
150
150
|
|
|
151
|
+
context "with target overriding default server" do
|
|
152
|
+
subject { described_class.new("tracker", source: <<~SOURCE) }
|
|
153
|
+
target :staging do
|
|
154
|
+
ssh false
|
|
155
|
+
end
|
|
156
|
+
SOURCE
|
|
157
|
+
|
|
158
|
+
it "replaces the default Server with a Target" do
|
|
159
|
+
expect(subject[:staging]).to be_a(Bard::Target)
|
|
160
|
+
end
|
|
161
|
+
end
|
|
162
|
+
|
|
151
163
|
context "with github_pages directive" do
|
|
152
164
|
subject { described_class.new("test", source: "github_pages 'example.com'") }
|
|
153
165
|
|
|
@@ -45,26 +45,39 @@ describe Bard::Provision::SSH do
|
|
|
45
45
|
context "when SSH is not available on target port but available on default port" do
|
|
46
46
|
it "reconfigures SSH port and adds to known hosts" do
|
|
47
47
|
allow(ssh_provisioner).to receive(:password_auth_enabled?).and_return(false)
|
|
48
|
-
allow(ssh_provisioner).to receive(:ssh_available?).with(provision_ssh_uri, port: 2222).and_return(false)
|
|
48
|
+
allow(ssh_provisioner).to receive(:ssh_available?).with(provision_ssh_uri, port: 2222).and_return(false, true)
|
|
49
49
|
allow(ssh_provisioner).to receive(:ssh_available?).with(provision_ssh_uri).and_return(true)
|
|
50
50
|
allow(ssh_provisioner).to receive(:ssh_known_host?).with(provision_ssh_uri).and_return(false)
|
|
51
|
+
allow(ssh_provisioner).to receive(:sleep)
|
|
51
52
|
|
|
52
53
|
expect(ssh_provisioner).to receive(:add_ssh_known_host!).with(provision_ssh_uri).twice
|
|
53
54
|
expect(provision_server).to receive(:run!).with(
|
|
54
|
-
'echo "Port 2222" | sudo tee /etc/ssh/sshd_config.d/port_2222.conf
|
|
55
|
+
'echo "Port 2222" | sudo tee /etc/ssh/sshd_config.d/port_2222.conf && sudo service ssh restart',
|
|
55
56
|
home: true
|
|
56
57
|
)
|
|
57
58
|
|
|
58
59
|
ssh_provisioner.call
|
|
59
60
|
end
|
|
60
61
|
|
|
61
|
-
it "
|
|
62
|
+
it "raises if new port is not responding after reconfiguration" do
|
|
62
63
|
allow(ssh_provisioner).to receive(:password_auth_enabled?).and_return(false)
|
|
63
64
|
allow(ssh_provisioner).to receive(:ssh_available?).with(provision_ssh_uri, port: 2222).and_return(false)
|
|
64
65
|
allow(ssh_provisioner).to receive(:ssh_available?).with(provision_ssh_uri).and_return(true)
|
|
66
|
+
allow(ssh_provisioner).to receive(:ssh_known_host?).with(provision_ssh_uri).and_return(true)
|
|
67
|
+
allow(provision_server).to receive(:run!)
|
|
68
|
+
allow(ssh_provisioner).to receive(:sleep)
|
|
69
|
+
|
|
70
|
+
expect { ssh_provisioner.call }.to raise_error(/reconfigured SSH to port 2222 but it's not responding/)
|
|
71
|
+
end
|
|
72
|
+
|
|
73
|
+
it "prints status messages during reconfiguration" do
|
|
74
|
+
allow(ssh_provisioner).to receive(:password_auth_enabled?).and_return(false)
|
|
75
|
+
allow(ssh_provisioner).to receive(:ssh_available?).with(provision_ssh_uri, port: 2222).and_return(false, true)
|
|
76
|
+
allow(ssh_provisioner).to receive(:ssh_available?).with(provision_ssh_uri).and_return(true)
|
|
65
77
|
allow(ssh_provisioner).to receive(:ssh_known_host?).and_return(false)
|
|
66
78
|
allow(ssh_provisioner).to receive(:add_ssh_known_host!)
|
|
67
79
|
allow(provision_server).to receive(:run!)
|
|
80
|
+
allow(ssh_provisioner).to receive(:sleep)
|
|
68
81
|
|
|
69
82
|
expect(ssh_provisioner).to receive(:print).with("SSH:")
|
|
70
83
|
expect(ssh_provisioner).to receive(:print).with(" Adding known host,")
|
|
@@ -218,7 +231,7 @@ describe Bard::Provision::SSH do
|
|
|
218
231
|
describe "#disable_password_auth!" do
|
|
219
232
|
it "creates sshd config file to disable password authentication and restarts ssh" do
|
|
220
233
|
expect(provision_server).to receive(:run!).with(
|
|
221
|
-
%q{echo "PasswordAuthentication no" | sudo tee /etc/ssh/sshd_config.d/disable_password_auth.conf
|
|
234
|
+
%q{echo "PasswordAuthentication no" | sudo tee /etc/ssh/sshd_config.d/disable_password_auth.conf && sudo service ssh restart},
|
|
222
235
|
home: true
|
|
223
236
|
)
|
|
224
237
|
|
metadata
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: bard
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 1.9.
|
|
4
|
+
version: 1.9.1
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Micah Geisel
|
|
8
8
|
bindir: bin
|
|
9
9
|
cert_chain: []
|
|
10
|
-
date: 2026-02-
|
|
10
|
+
date: 2026-02-11 00:00:00.000000000 Z
|
|
11
11
|
dependencies:
|
|
12
12
|
- !ruby/object:Gem::Dependency
|
|
13
13
|
name: thor
|