bard 2.2.0 → 3.1.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 (98) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/ci.yml +0 -21
  3. data/README.md +7 -487
  4. data/Rakefile +1 -4
  5. data/bard.gemspec +2 -11
  6. data/lib/bard/config.rb +23 -20
  7. data/lib/bard/plugins/deploy_url/target_methods.rb +16 -0
  8. data/lib/bard/plugins/ping/target_methods.rb +0 -9
  9. data/lib/bard/plugins/ssh/connection.rb +2 -35
  10. data/lib/bard/target.rb +0 -15
  11. data/lib/bard/version.rb +1 -1
  12. data/lib/bard.rb +2 -1
  13. data/spec/bard/capability_spec.rb +0 -8
  14. data/spec/bard/config_spec.rb +30 -67
  15. data/spec/bard/target_spec.rb +35 -36
  16. metadata +5 -225
  17. data/ARCHITECTURE.md +0 -957
  18. data/CUSTOM_STRATEGIES.md +0 -701
  19. data/MIGRATION_GUIDE.md +0 -513
  20. data/PLUGINS.md +0 -99
  21. data/bin/bard +0 -4
  22. data/features/ci.feature +0 -63
  23. data/features/data.feature +0 -13
  24. data/features/deploy.feature +0 -14
  25. data/features/deploy_git_workflow.feature +0 -89
  26. data/features/run.feature +0 -14
  27. data/features/step_definitions/bard_steps.rb +0 -136
  28. data/features/support/bard-coverage +0 -16
  29. data/features/support/env.rb +0 -22
  30. data/features/support/test_server.rb +0 -216
  31. data/lib/bard/cli.rb +0 -44
  32. data/lib/bard/command.rb +0 -31
  33. data/lib/bard/copy.rb +0 -45
  34. data/lib/bard/plugins/data.rb +0 -56
  35. data/lib/bard/plugins/deploy/ci/github_actions.rb +0 -202
  36. data/lib/bard/plugins/deploy/ci/jenkins.rb +0 -176
  37. data/lib/bard/plugins/deploy/ci/local.rb +0 -57
  38. data/lib/bard/plugins/deploy/ci/runner.rb +0 -112
  39. data/lib/bard/plugins/deploy/ci/state.rb +0 -40
  40. data/lib/bard/plugins/deploy/ci.rb +0 -38
  41. data/lib/bard/plugins/deploy/ssh_strategy.rb +0 -26
  42. data/lib/bard/plugins/deploy/strategy.rb +0 -60
  43. data/lib/bard/plugins/deploy.rb +0 -260
  44. data/lib/bard/plugins/git.rb +0 -45
  45. data/lib/bard/plugins/github.rb +0 -152
  46. data/lib/bard/plugins/github_pages/strategy.rb +0 -170
  47. data/lib/bard/plugins/github_pages.rb +0 -35
  48. data/lib/bard/plugins/hurt.rb +0 -13
  49. data/lib/bard/plugins/install/.github/dependabot.yml +0 -18
  50. data/lib/bard/plugins/install/.github/workflows/cache-ci.yml +0 -15
  51. data/lib/bard/plugins/install/.github/workflows/ci.yml +0 -74
  52. data/lib/bard/plugins/install/apt_dependencies.rb +0 -33
  53. data/lib/bard/plugins/install/ci +0 -5
  54. data/lib/bard/plugins/install/setup +0 -13
  55. data/lib/bard/plugins/install/specified_bundler.rb +0 -15
  56. data/lib/bard/plugins/install/specified_ruby.rb +0 -59
  57. data/lib/bard/plugins/install.rb +0 -9
  58. data/lib/bard/plugins/open.rb +0 -20
  59. data/lib/bard/plugins/ping/check.rb +0 -66
  60. data/lib/bard/plugins/ping.rb +0 -10
  61. data/lib/bard/plugins/run.rb +0 -19
  62. data/lib/bard/plugins/setup.rb +0 -75
  63. data/lib/bard/plugins/ssh/copy.rb +0 -95
  64. data/lib/bard/plugins/ssh.rb +0 -10
  65. data/lib/bard/plugins/vim.rb +0 -6
  66. data/lib/bard/retryable.rb +0 -25
  67. data/lib/bard/secrets.rb +0 -10
  68. data/spec/acceptance/.gitignore +0 -4
  69. data/spec/acceptance/docker/Dockerfile +0 -36
  70. data/spec/acceptance/docker/test_key +0 -27
  71. data/spec/acceptance/docker/test_key.pub +0 -1
  72. data/spec/bard/ci/github_actions_spec.rb +0 -138
  73. data/spec/bard/ci/jenkins_spec.rb +0 -139
  74. data/spec/bard/ci/runner_spec.rb +0 -61
  75. data/spec/bard/ci_spec.rb +0 -10
  76. data/spec/bard/cli/ci_spec.rb +0 -170
  77. data/spec/bard/cli/data_spec.rb +0 -58
  78. data/spec/bard/cli/deploy_spec.rb +0 -243
  79. data/spec/bard/cli/hurt_spec.rb +0 -17
  80. data/spec/bard/cli/install_spec.rb +0 -19
  81. data/spec/bard/cli/master_key_spec.rb +0 -38
  82. data/spec/bard/cli/open_spec.rb +0 -51
  83. data/spec/bard/cli/ping_spec.rb +0 -32
  84. data/spec/bard/cli/run_spec.rb +0 -57
  85. data/spec/bard/cli/setup_spec.rb +0 -99
  86. data/spec/bard/cli/ssh_spec.rb +0 -40
  87. data/spec/bard/cli/stage_spec.rb +0 -127
  88. data/spec/bard/cli/vim_spec.rb +0 -28
  89. data/spec/bard/command_spec.rb +0 -30
  90. data/spec/bard/copy_spec.rb +0 -69
  91. data/spec/bard/deploy_strategy/github_pages_spec.rb +0 -58
  92. data/spec/bard/deploy_strategy/ssh_spec.rb +0 -135
  93. data/spec/bard/deploy_strategy_spec.rb +0 -107
  94. data/spec/bard/dynamic_dsl_spec.rb +0 -46
  95. data/spec/bard/git_spec.rb +0 -101
  96. data/spec/bard/github_spec.rb +0 -45
  97. data/spec/bard/ping_spec.rb +0 -60
  98. data/spec/bard/ssh_copy_spec.rb +0 -44
@@ -1,101 +0,0 @@
1
- require "spec_helper"
2
- require "bard/plugins/git"
3
-
4
- describe Bard::Git do
5
- describe ".current_branch" do
6
- it "should return the current branch" do
7
- allow(Bard::Git).to receive(:`).with("git symbolic-ref HEAD 2>&1").and_return("refs/heads/master\n")
8
- expect(Bard::Git.current_branch).to eq("master")
9
- end
10
-
11
- it "should return false if not on a branch" do
12
- allow(Bard::Git).to receive(:`).with("git symbolic-ref HEAD 2>&1").and_return("fatal: ref HEAD is not a symbolic ref\n")
13
- expect(Bard::Git.current_branch).to be_falsey
14
- end
15
- end
16
-
17
- describe ".fast_forward_merge?" do
18
- it "should return true if the root is an ancestor of the branch" do
19
- allow(Bard::Git).to receive(:sha_of).with("root").and_return("root_sha")
20
- allow(Bard::Git).to receive(:sha_of).with("branch").and_return("branch_sha")
21
- allow(Bard::Git).to receive(:`).with("git merge-base root_sha branch_sha").and_return("root_sha\n")
22
- expect(Bard::Git.fast_forward_merge?("root", "branch")).to be_truthy
23
- end
24
-
25
- it "should return false if the root is not an ancestor of the branch" do
26
- allow(Bard::Git).to receive(:sha_of).with("root").and_return("root_sha")
27
- allow(Bard::Git).to receive(:sha_of).with("branch").and_return("branch_sha")
28
- allow(Bard::Git).to receive(:`).with("git merge-base root_sha branch_sha").and_return("other_sha\n")
29
- expect(Bard::Git.fast_forward_merge?("root", "branch")).to be_falsey
30
- end
31
- end
32
-
33
- describe ".up_to_date_with_remote?" do
34
- it "should return true if the local branch is up to date with the remote" do
35
- allow(Bard::Git).to receive(:sha_of).with("branch").and_return("sha")
36
- allow(Bard::Git).to receive(:sha_of).with("origin/branch").and_return("sha")
37
- expect(Bard::Git.up_to_date_with_remote?("branch")).to be_truthy
38
- end
39
-
40
- it "should return false if the local branch is not up to date with the remote" do
41
- allow(Bard::Git).to receive(:sha_of).with("branch").and_return("sha1")
42
- allow(Bard::Git).to receive(:sha_of).with("origin/branch").and_return("sha2")
43
- expect(Bard::Git.up_to_date_with_remote?("branch")).to be_falsey
44
- end
45
- end
46
-
47
- describe ".sha_of" do
48
- it "should return the sha of a ref" do
49
- allow(Bard::Git).to receive(:`).with("git rev-parse ref 2>/dev/null") {
50
- `true` # sets $? to success
51
- "sha\n"
52
- }
53
- expect(Bard::Git.sha_of("ref")).to eq("sha")
54
- end
55
-
56
- it "should return nil if the ref does not exist" do
57
- allow(Bard::Git).to receive(:`).with("git rev-parse ref 2>/dev/null") {
58
- `false` # sets $? to failure
59
- "ref: fatal: ambiguous argument 'ref': unknown revision or path not in the working tree.\n"
60
- }
61
- expect(Bard::Git.sha_of("ref")).to be_nil
62
- end
63
- end
64
-
65
- describe ".github_pages_url" do
66
- def stub_origin(remote)
67
- allow(Bard::Git).to receive(:`).with("git remote get-url origin").and_return("#{remote}\n")
68
- end
69
-
70
- it "derives a project pages url from an ssh remote" do
71
- stub_origin("git@github.com:botandrose/bard")
72
- expect(Bard::Git.github_pages_url).to eq("https://botandrose.github.io/bard/")
73
- end
74
-
75
- it "derives a project pages url from an https remote with a .git suffix" do
76
- stub_origin("https://github.com/botandrose/bard.git")
77
- expect(Bard::Git.github_pages_url).to eq("https://botandrose.github.io/bard/")
78
- end
79
-
80
- it "lowercases the owner in the pages host" do
81
- stub_origin("git@github.com:BotAndRose/Bard.git")
82
- expect(Bard::Git.github_pages_url).to eq("https://botandrose.github.io/Bard/")
83
- end
84
-
85
- it "uses the root url for a user/org pages repo" do
86
- stub_origin("git@github.com:botandrose/botandrose.github.io")
87
- expect(Bard::Git.github_pages_url).to eq("https://botandrose.github.io/")
88
- end
89
-
90
- it "raises for a non-github remote" do
91
- stub_origin("git@gitlab.com:botandrose/bard.git")
92
- expect { Bard::Git.github_pages_url }.to raise_error(/not a github\.com repository/)
93
- end
94
-
95
- it "raises when there is no origin remote" do
96
- allow(Bard::Git).to receive(:`).with("git remote get-url origin").and_return("\n")
97
- expect { Bard::Git.github_pages_url }.to raise_error(/not a github\.com repository/)
98
- end
99
- end
100
- end
101
-
@@ -1,45 +0,0 @@
1
- require "spec_helper"
2
- require "bard/plugins/github"
3
-
4
- describe Bard::Github do
5
- let(:github) { Bard::Github.new("test-project") }
6
-
7
- before do
8
- allow(Bard::Secrets).to receive(:fetch).with("github-apikey").and_return("12345")
9
- end
10
-
11
- describe "#get" do
12
- it "should make a GET request to the GitHub API" do
13
- stub_request(:get, "https://api.github.com/repos/botandrosedesign/test-project/path").to_return(body: "{}")
14
- github.get("path")
15
- end
16
- end
17
-
18
- describe "#post" do
19
- it "should make a POST request to the GitHub API" do
20
- stub_request(:post, "https://api.github.com/repos/botandrosedesign/test-project/path").with(body: "{\"foo\":\"bar\"}").to_return(body: "{}")
21
- github.post("path", { foo: "bar" })
22
- end
23
- end
24
-
25
- describe "#put" do
26
- it "should make a PUT request to the GitHub API" do
27
- stub_request(:put, "https://api.github.com/repos/botandrosedesign/test-project/path").with(body: "{\"foo\":\"bar\"}").to_return(body: "{}")
28
- github.put("path", { foo: "bar" })
29
- end
30
- end
31
-
32
- describe "#patch" do
33
- it "should make a PATCH request to the GitHub API" do
34
- stub_request(:patch, "https://api.github.com/repos/botandrosedesign/test-project/path").with(body: "{\"foo\":\"bar\"}").to_return(body: "{}")
35
- github.patch("path", { foo: "bar" })
36
- end
37
- end
38
-
39
- describe "#delete" do
40
- it "should make a DELETE request to the GitHub API" do
41
- stub_request(:delete, "https://api.github.com/repos/botandrosedesign/test-project").with(body: "{\"foo\":\"bar\"}").to_return(body: "{}")
42
- github.delete(nil, { foo: "bar" })
43
- end
44
- end
45
- end
@@ -1,60 +0,0 @@
1
- require "spec_helper"
2
- require "bard/plugins/ping/check"
3
-
4
- describe Bard::Ping do
5
- let(:target) { double("target", ping: ["http://example.com"]) }
6
- let(:ping) { described_class.new(target) }
7
-
8
- def success_response
9
- Net::HTTPSuccess.new(1.0, "200", "OK")
10
- end
11
-
12
- def not_found_response
13
- Net::HTTPNotFound.new(1.0, "404", "Not Found")
14
- end
15
-
16
- context "when the target is reachable" do
17
- it "returns an empty array" do
18
- allow(ping).to receive(:http_get).and_return(success_response)
19
- expect(ping.call).to be_empty
20
- end
21
- end
22
-
23
- context "when the target is not reachable" do
24
- it "returns the url" do
25
- allow(ping).to receive(:http_get).and_return(not_found_response)
26
- expect(ping.call).to eq(["http://example.com"])
27
- end
28
- end
29
-
30
- context "when there is a redirect" do
31
- it "follows the redirect and returns an empty array" do
32
- redirect_response = Net::HTTPRedirection.new(1.0, "301", "Moved Permanently")
33
- redirect_response["location"] = "/new"
34
- allow(ping).to receive(:http_get).with(URI("http://example.com")).and_return(redirect_response)
35
- allow(ping).to receive(:http_get).with(URI("http://example.com/new")).and_return(success_response)
36
- expect(ping.call).to be_empty
37
- end
38
- end
39
-
40
- context "when a transient error occurs" do
41
- it "retries once before marking down" do
42
- calls = 0
43
- allow(ping).to receive(:http_get) do
44
- calls += 1
45
- raise Errno::ECONNRESET if calls == 1
46
-
47
- success_response
48
- end
49
-
50
- expect(ping.call).to be_empty
51
- end
52
- end
53
-
54
- context "when errors persist across retries" do
55
- it "returns the url" do
56
- allow(ping).to receive(:http_get).and_raise(Errno::ECONNREFUSED)
57
- expect(ping.call).to eq(["http://example.com"])
58
- end
59
- end
60
- end
@@ -1,44 +0,0 @@
1
- require "spec_helper"
2
- require "bard/plugins/ssh/copy"
3
-
4
- describe Bard::SSH::Copy do
5
- let(:ssh_server) { double("ssh_server", gateway: nil, ssh_key: nil, port: "22", ssh_uri: double(port: 22, user: "user", host: "example.com")) }
6
- let(:production) { double("production", key: :production, server: ssh_server, scp_uri: "user@example.com:/path/to/file", rsync_uri: "user@example.com:/path/to/", path: "/path/to", has_capability?: true) }
7
- let(:local) { double("local", key: :local, has_capability?: false) }
8
-
9
- describe ".can_handle?" do
10
- it "handles pairs where at least one target has ssh capability" do
11
- expect(Bard::SSH::Copy.can_handle?(local, production)).to be true
12
- expect(Bard::SSH::Copy.can_handle?(production, local)).to be true
13
- expect(Bard::SSH::Copy.can_handle?(production, production)).to be true
14
- end
15
-
16
- it "does not handle pairs where neither target has ssh capability" do
17
- expect(Bard::SSH::Copy.can_handle?(local, local)).to be false
18
- end
19
- end
20
-
21
- context ".file via Bard::Copy dispatch" do
22
- it "should copy a file from a remote server to the local machine" do
23
- expect(Bard::Command).to receive(:run!).with("scp -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -o LogLevel=ERROR user@example.com:/path/to/file path/to/file", verbose: false)
24
- Bard::Copy.file "path/to/file", from: production, to: local
25
- end
26
-
27
- it "should copy a file from the local machine to a remote server" do
28
- expect(Bard::Command).to receive(:run!).with("scp -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -o LogLevel=ERROR path/to/file user@example.com:/path/to/file", verbose: false)
29
- Bard::Copy.file "path/to/file", from: local, to: production
30
- end
31
- end
32
-
33
- context ".dir via Bard::Copy dispatch" do
34
- it "should copy a directory from a remote server to the local machine" do
35
- expect(Bard::Command).to receive(:run!).with("rsync -e'ssh -p22' --delete --info=progress2 -az user@example.com:/path/to/ ./path/", verbose: false)
36
- Bard::Copy.dir "path/to", from: production, to: local
37
- end
38
-
39
- it "should copy a directory from the local machine to a remote server" do
40
- expect(Bard::Command).to receive(:run!).with("rsync -e'ssh -p22' --delete --info=progress2 -az ./path/to user@example.com:/path/to/", verbose: false)
41
- Bard::Copy.dir "path/to", from: local, to: production
42
- end
43
- end
44
- end