capistrano 3.3.5 → 3.16.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (138) hide show
  1. checksums.yaml +5 -5
  2. data/.github/issue_template.md +19 -0
  3. data/.github/pull_request_template.md +22 -0
  4. data/.github/release-drafter.yml +17 -0
  5. data/.github/workflows/push.yml +12 -0
  6. data/.gitignore +8 -5
  7. data/.rubocop.yml +62 -0
  8. data/.travis.yml +25 -7
  9. data/CHANGELOG.md +1 -273
  10. data/CONTRIBUTING.md +63 -93
  11. data/DEVELOPMENT.md +127 -0
  12. data/Dangerfile +1 -0
  13. data/Gemfile +36 -3
  14. data/LICENSE.txt +1 -1
  15. data/README.md +118 -292
  16. data/RELEASING.md +17 -0
  17. data/Rakefile +9 -1
  18. data/UPGRADING-3.7.md +86 -0
  19. data/bin/cap +1 -1
  20. data/capistrano.gemspec +24 -24
  21. data/features/deploy.feature +35 -1
  22. data/features/doctor.feature +11 -0
  23. data/features/installation.feature +8 -3
  24. data/features/sshconnect.feature +11 -0
  25. data/features/stage_failure.feature +9 -0
  26. data/features/step_definitions/assertions.rb +57 -20
  27. data/features/step_definitions/cap_commands.rb +9 -0
  28. data/features/step_definitions/setup.rb +56 -8
  29. data/features/subdirectory.feature +9 -0
  30. data/features/support/env.rb +5 -5
  31. data/features/support/remote_command_helpers.rb +12 -6
  32. data/features/support/vagrant_helpers.rb +17 -11
  33. data/lib/Capfile +1 -1
  34. data/lib/capistrano/all.rb +10 -10
  35. data/lib/capistrano/application.rb +47 -34
  36. data/lib/capistrano/configuration.rb +95 -44
  37. data/lib/capistrano/configuration/empty_filter.rb +9 -0
  38. data/lib/capistrano/configuration/filter.rb +16 -46
  39. data/lib/capistrano/configuration/host_filter.rb +29 -0
  40. data/lib/capistrano/configuration/null_filter.rb +9 -0
  41. data/lib/capistrano/configuration/plugin_installer.rb +51 -0
  42. data/lib/capistrano/configuration/question.rb +31 -9
  43. data/lib/capistrano/configuration/role_filter.rb +29 -0
  44. data/lib/capistrano/configuration/scm_resolver.rb +149 -0
  45. data/lib/capistrano/configuration/server.rb +30 -62
  46. data/lib/capistrano/configuration/servers.rb +38 -12
  47. data/lib/capistrano/configuration/validated_variables.rb +110 -0
  48. data/lib/capistrano/configuration/variables.rb +112 -0
  49. data/lib/capistrano/defaults.rb +26 -4
  50. data/lib/capistrano/deploy.rb +1 -2
  51. data/lib/capistrano/doctor.rb +6 -0
  52. data/lib/capistrano/doctor/environment_doctor.rb +19 -0
  53. data/lib/capistrano/doctor/gems_doctor.rb +45 -0
  54. data/lib/capistrano/doctor/output_helpers.rb +79 -0
  55. data/lib/capistrano/doctor/servers_doctor.rb +105 -0
  56. data/lib/capistrano/doctor/variables_doctor.rb +72 -0
  57. data/lib/capistrano/dotfile.rb +1 -2
  58. data/lib/capistrano/dsl.rb +49 -18
  59. data/lib/capistrano/dsl/env.rb +16 -46
  60. data/lib/capistrano/dsl/paths.rb +11 -25
  61. data/lib/capistrano/dsl/stages.rb +14 -2
  62. data/lib/capistrano/dsl/task_enhancements.rb +7 -12
  63. data/lib/capistrano/framework.rb +1 -1
  64. data/lib/capistrano/i18n.rb +32 -24
  65. data/lib/capistrano/immutable_task.rb +30 -0
  66. data/lib/capistrano/install.rb +1 -1
  67. data/lib/capistrano/plugin.rb +95 -0
  68. data/lib/capistrano/proc_helpers.rb +13 -0
  69. data/lib/capistrano/scm.rb +7 -20
  70. data/lib/capistrano/scm/git.rb +100 -0
  71. data/lib/capistrano/scm/hg.rb +55 -0
  72. data/lib/capistrano/scm/plugin.rb +13 -0
  73. data/lib/capistrano/scm/svn.rb +56 -0
  74. data/lib/capistrano/scm/tasks/git.rake +73 -0
  75. data/lib/capistrano/scm/tasks/hg.rake +53 -0
  76. data/lib/capistrano/scm/tasks/svn.rake +53 -0
  77. data/lib/capistrano/setup.rb +20 -6
  78. data/lib/capistrano/tasks/console.rake +4 -8
  79. data/lib/capistrano/tasks/deploy.rake +105 -74
  80. data/lib/capistrano/tasks/doctor.rake +24 -0
  81. data/lib/capistrano/tasks/framework.rake +13 -14
  82. data/lib/capistrano/tasks/install.rake +14 -15
  83. data/lib/capistrano/templates/Capfile +22 -11
  84. data/lib/capistrano/templates/deploy.rb.erb +18 -27
  85. data/lib/capistrano/templates/stage.rb.erb +36 -20
  86. data/lib/capistrano/upload_task.rb +1 -1
  87. data/lib/capistrano/version.rb +1 -1
  88. data/lib/capistrano/version_validator.rb +5 -10
  89. data/spec/integration/dsl_spec.rb +311 -289
  90. data/spec/integration_spec_helper.rb +3 -5
  91. data/spec/lib/capistrano/application_spec.rb +23 -39
  92. data/spec/lib/capistrano/configuration/empty_filter_spec.rb +17 -0
  93. data/spec/lib/capistrano/configuration/filter_spec.rb +83 -79
  94. data/spec/lib/capistrano/configuration/host_filter_spec.rb +71 -0
  95. data/spec/lib/capistrano/configuration/null_filter_spec.rb +17 -0
  96. data/spec/lib/capistrano/configuration/plugin_installer_spec.rb +98 -0
  97. data/spec/lib/capistrano/configuration/question_spec.rb +58 -26
  98. data/spec/lib/capistrano/configuration/role_filter_spec.rb +80 -0
  99. data/spec/lib/capistrano/configuration/scm_resolver_spec.rb +55 -0
  100. data/spec/lib/capistrano/configuration/server_spec.rb +124 -100
  101. data/spec/lib/capistrano/configuration/servers_spec.rb +143 -123
  102. data/spec/lib/capistrano/configuration_spec.rb +231 -59
  103. data/spec/lib/capistrano/doctor/environment_doctor_spec.rb +44 -0
  104. data/spec/lib/capistrano/doctor/gems_doctor_spec.rb +67 -0
  105. data/spec/lib/capistrano/doctor/output_helpers_spec.rb +47 -0
  106. data/spec/lib/capistrano/doctor/servers_doctor_spec.rb +86 -0
  107. data/spec/lib/capistrano/doctor/variables_doctor_spec.rb +89 -0
  108. data/spec/lib/capistrano/dsl/paths_spec.rb +201 -42
  109. data/spec/lib/capistrano/dsl/task_enhancements_spec.rb +57 -37
  110. data/spec/lib/capistrano/dsl_spec.rb +84 -11
  111. data/spec/lib/capistrano/immutable_task_spec.rb +31 -0
  112. data/spec/lib/capistrano/plugin_spec.rb +84 -0
  113. data/spec/lib/capistrano/scm/git_spec.rb +184 -0
  114. data/spec/lib/capistrano/scm/hg_spec.rb +109 -0
  115. data/spec/lib/capistrano/scm/svn_spec.rb +137 -0
  116. data/spec/lib/capistrano/scm_spec.rb +7 -8
  117. data/spec/lib/capistrano/upload_task_spec.rb +7 -7
  118. data/spec/lib/capistrano/version_validator_spec.rb +61 -46
  119. data/spec/lib/capistrano_spec.rb +2 -3
  120. data/spec/spec_helper.rb +21 -8
  121. data/spec/support/Vagrantfile +18 -8
  122. data/spec/support/tasks/database.rake +3 -3
  123. data/spec/support/tasks/fail.rake +4 -3
  124. data/spec/support/tasks/failed.rake +2 -2
  125. data/spec/support/tasks/plugin.rake +6 -0
  126. data/spec/support/tasks/root.rake +11 -0
  127. data/spec/support/test_app.rb +63 -39
  128. metadata +121 -44
  129. data/features/remote_file_task.feature +0 -14
  130. data/lib/capistrano/git.rb +0 -46
  131. data/lib/capistrano/hg.rb +0 -43
  132. data/lib/capistrano/svn.rb +0 -38
  133. data/lib/capistrano/tasks/git.rake +0 -81
  134. data/lib/capistrano/tasks/hg.rake +0 -52
  135. data/lib/capistrano/tasks/svn.rake +0 -52
  136. data/spec/lib/capistrano/git_spec.rb +0 -81
  137. data/spec/lib/capistrano/hg_spec.rb +0 -81
  138. data/spec/lib/capistrano/svn_spec.rb +0 -79
@@ -1,14 +0,0 @@
1
- Feature: Remote file task
2
-
3
- Background:
4
- Given a test app with the default configuration
5
- And a custom task to generate a file
6
- And servers with the roles app and web
7
-
8
- Scenario: Where the file does not exist
9
- When I run cap "deploy:check:linked_files"
10
- Then it creates the file with the remote_task prerequisite
11
-
12
- Scenario: Where the file already exists
13
- When I run cap "deploy:check:linked_files"
14
- Then it will not recreate the file
@@ -1,46 +0,0 @@
1
- load File.expand_path("../tasks/git.rake", __FILE__)
2
-
3
- require 'capistrano/scm'
4
-
5
- class Capistrano::Git < Capistrano::SCM
6
-
7
- # execute git with argument in the context
8
- #
9
- def git(*args)
10
- args.unshift :git
11
- context.execute *args
12
- end
13
-
14
- # The Capistrano default strategy for git. You should want to use this.
15
- module DefaultStrategy
16
- def test
17
- test! " [ -f #{repo_path}/HEAD ] "
18
- end
19
-
20
- def check
21
- git :'ls-remote --heads', repo_url
22
- end
23
-
24
- def clone
25
- git :clone, '--mirror', repo_url, repo_path
26
- end
27
-
28
- def update
29
- git :remote, :update
30
- end
31
-
32
- def release
33
- if tree = fetch(:repo_tree)
34
- tree = tree.slice %r#^/?(.*?)/?$#, 1
35
- components = tree.split('/').size
36
- git :archive, fetch(:branch), tree, "| tar -x --strip-components #{components} -f - -C", release_path
37
- else
38
- git :archive, fetch(:branch), '| tar -x -f - -C', release_path
39
- end
40
- end
41
-
42
- def fetch_revision
43
- context.capture(:git, "rev-parse --short #{fetch(:branch)}")
44
- end
45
- end
46
- end
data/lib/capistrano/hg.rb DELETED
@@ -1,43 +0,0 @@
1
- load File.expand_path("../tasks/hg.rake", __FILE__)
2
-
3
- require 'capistrano/scm'
4
-
5
- class Capistrano::Hg < Capistrano::SCM
6
- # execute hg in context with arguments
7
- def hg(*args)
8
- args.unshift(:hg)
9
- context.execute *args
10
- end
11
-
12
- module DefaultStrategy
13
- def test
14
- test! " [ -d #{repo_path}/.hg ] "
15
- end
16
-
17
- def check
18
- hg "id", repo_url
19
- end
20
-
21
- def clone
22
- hg "clone", "--noupdate", repo_url, repo_path
23
- end
24
-
25
- def update
26
- hg "pull"
27
- end
28
-
29
- def release
30
- if tree = fetch(:repo_tree)
31
- tree = tree.slice %r#^/?(.*?)/?$#, 1
32
- components = tree.split('/').size
33
- hg "archive --type tgz -p . -I", tree, "--rev", fetch(:branch), "| tar -x --strip-components #{components} -f - -C", release_path
34
- else
35
- hg "archive", release_path, "--rev", fetch(:branch)
36
- end
37
- end
38
-
39
- def fetch_revision
40
- context.capture(:hg, "log --rev #{fetch(:branch)} --template \"{node}\n\"")
41
- end
42
- end
43
- end
@@ -1,38 +0,0 @@
1
- load File.expand_path("../tasks/svn.rake", __FILE__)
2
-
3
- require 'capistrano/scm'
4
-
5
- class Capistrano::Svn < Capistrano::SCM
6
-
7
- # execute svn in context with arguments
8
- def svn(*args)
9
- args.unshift(:svn)
10
- context.execute *args
11
- end
12
-
13
- module DefaultStrategy
14
- def test
15
- test! " [ -d #{repo_path}/.svn ] "
16
- end
17
-
18
- def check
19
- test! :svn, :info, repo_url
20
- end
21
-
22
- def clone
23
- svn :checkout, repo_url, repo_path
24
- end
25
-
26
- def update
27
- svn :update
28
- end
29
-
30
- def release
31
- svn :export, '--force', '.', release_path
32
- end
33
-
34
- def fetch_revision
35
- context.capture(:svnversion, repo_path)
36
- end
37
- end
38
- end
@@ -1,81 +0,0 @@
1
- namespace :git do
2
-
3
- def strategy
4
- @strategy ||= Capistrano::Git.new(self, fetch(:git_strategy, Capistrano::Git::DefaultStrategy))
5
- end
6
-
7
- set :git_environmental_variables, ->() {
8
- {
9
- git_askpass: "/bin/echo",
10
- git_ssh: "#{fetch(:tmp_dir)}/#{fetch(:application)}/git-ssh.sh"
11
- }
12
- }
13
-
14
- desc 'Upload the git wrapper script, this script guarantees that we can script git without getting an interactive prompt'
15
- task :wrapper do
16
- on release_roles :all do
17
- execute :mkdir, "-p", "#{fetch(:tmp_dir)}/#{fetch(:application)}/"
18
- upload! StringIO.new("#!/bin/sh -e\nexec /usr/bin/ssh -o PasswordAuthentication=no -o StrictHostKeyChecking=no \"$@\"\n"), "#{fetch(:tmp_dir)}/#{fetch(:application)}/git-ssh.sh"
19
- execute :chmod, "+x", "#{fetch(:tmp_dir)}/#{fetch(:application)}/git-ssh.sh"
20
- end
21
- end
22
-
23
- desc 'Check that the repository is reachable'
24
- task check: :'git:wrapper' do
25
- fetch(:branch)
26
- on release_roles :all do
27
- with fetch(:git_environmental_variables) do
28
- strategy.check
29
- end
30
- end
31
- end
32
-
33
- desc 'Clone the repo to the cache'
34
- task clone: :'git:wrapper' do
35
- on release_roles :all do
36
- if strategy.test
37
- info t(:mirror_exists, at: repo_path)
38
- else
39
- within deploy_path do
40
- with fetch(:git_environmental_variables) do
41
- strategy.clone
42
- end
43
- end
44
- end
45
- end
46
- end
47
-
48
- desc 'Update the repo mirror to reflect the origin state'
49
- task update: :'git:clone' do
50
- on release_roles :all do
51
- within repo_path do
52
- with fetch(:git_environmental_variables) do
53
- strategy.update
54
- end
55
- end
56
- end
57
- end
58
-
59
- desc 'Copy repo to releases'
60
- task create_release: :'git:update' do
61
- on release_roles :all do
62
- with fetch(:git_environmental_variables) do
63
- within repo_path do
64
- execute :mkdir, '-p', release_path
65
- strategy.release
66
- end
67
- end
68
- end
69
- end
70
-
71
- desc 'Determine the revision that will be deployed'
72
- task :set_current_revision do
73
- on release_roles :all do
74
- within repo_path do
75
- with fetch(:git_environmental_variables) do
76
- set :current_revision, strategy.fetch_revision
77
- end
78
- end
79
- end
80
- end
81
- end
@@ -1,52 +0,0 @@
1
- namespace :hg do
2
- def strategy
3
- @strategy ||= Capistrano::Hg.new(self, fetch(:hg_strategy, Capistrano::Hg::DefaultStrategy))
4
- end
5
-
6
- desc 'Check that the repo is reachable'
7
- task :check do
8
- on release_roles :all do
9
- strategy.check
10
- end
11
- end
12
-
13
- desc 'Clone the repo to the cache'
14
- task :clone do
15
- on release_roles :all do
16
- if strategy.test
17
- info t(:mirror_exists, at: repo_path)
18
- else
19
- within deploy_path do
20
- strategy.clone
21
- end
22
- end
23
- end
24
- end
25
-
26
- desc 'Pull changes from the remote repo'
27
- task :update => :'hg:clone' do
28
- on release_roles :all do
29
- within repo_path do
30
- strategy.update
31
- end
32
- end
33
- end
34
-
35
- desc 'Copy repo to releases'
36
- task :create_release => :'hg:update' do
37
- on release_roles :all do
38
- within repo_path do
39
- strategy.release
40
- end
41
- end
42
- end
43
-
44
- desc 'Determine the revision that will be deployed'
45
- task :set_current_revision do
46
- on release_roles :all do
47
- within repo_path do
48
- set :current_revision, strategy.fetch_revision
49
- end
50
- end
51
- end
52
- end
@@ -1,52 +0,0 @@
1
- namespace :svn do
2
- def strategy
3
- @strategy ||= Capistrano::Svn.new(self, fetch(:svn_strategy, Capistrano::Svn::DefaultStrategy))
4
- end
5
-
6
- desc 'Check that the repo is reachable'
7
- task :check do
8
- on release_roles :all do
9
- strategy.check
10
- end
11
- end
12
-
13
- desc 'Clone the repo to the cache'
14
- task :clone do
15
- on release_roles :all do
16
- if strategy.test
17
- info t(:mirror_exists, at: repo_path)
18
- else
19
- within deploy_path do
20
- strategy.clone
21
- end
22
- end
23
- end
24
- end
25
-
26
- desc 'Pull changes from the remote repo'
27
- task :update => :'svn:clone' do
28
- on release_roles :all do
29
- within repo_path do
30
- strategy.update
31
- end
32
- end
33
- end
34
-
35
- desc 'Copy repo to releases'
36
- task :create_release => :'svn:update' do
37
- on release_roles :all do
38
- within repo_path do
39
- strategy.release
40
- end
41
- end
42
- end
43
-
44
- desc 'Determine the revision that will be deployed'
45
- task :set_current_revision do
46
- on release_roles :all do
47
- within repo_path do
48
- set :current_revision, strategy.fetch_revision
49
- end
50
- end
51
- end
52
- end
@@ -1,81 +0,0 @@
1
- require 'spec_helper'
2
-
3
- require 'capistrano/git'
4
-
5
- module Capistrano
6
- describe Git do
7
- let(:context) { Class.new.new }
8
- subject { Capistrano::Git.new(context, Capistrano::Git::DefaultStrategy) }
9
-
10
- describe "#git" do
11
- it "should call execute git in the context, with arguments" do
12
- context.expects(:execute).with(:git, :init)
13
- subject.git(:init)
14
- end
15
- end
16
- end
17
-
18
- describe Git::DefaultStrategy do
19
- let(:context) { Class.new.new }
20
- subject { Capistrano::Git.new(context, Capistrano::Git::DefaultStrategy) }
21
-
22
- describe "#test" do
23
- it "should call test for repo HEAD" do
24
- context.expects(:repo_path).returns("/path/to/repo")
25
- context.expects(:test).with " [ -f /path/to/repo/HEAD ] "
26
-
27
- subject.test
28
- end
29
- end
30
-
31
- describe "#check" do
32
- it "should test the repo url" do
33
- context.expects(:repo_url).returns(:url)
34
- context.expects(:execute).with(:git, :'ls-remote --heads', :url).returns(true)
35
-
36
- subject.check
37
- end
38
- end
39
-
40
- describe "#clone" do
41
- it "should run git clone" do
42
- context.expects(:repo_url).returns(:url)
43
- context.expects(:repo_path).returns(:path)
44
-
45
- context.expects(:execute).with(:git, :clone, '--mirror', :url, :path)
46
-
47
- subject.clone
48
- end
49
- end
50
-
51
- describe "#update" do
52
- it "should run git update" do
53
- context.expects(:execute).with(:git, :remote, :update)
54
-
55
- subject.update
56
- end
57
- end
58
-
59
- describe "#release" do
60
- it "should run git archive without a subtree" do
61
- context.expects(:fetch).with(:repo_tree).returns(nil)
62
- context.expects(:fetch).with(:branch).returns(:branch)
63
- context.expects(:release_path).returns(:path)
64
-
65
- context.expects(:execute).with(:git, :archive, :branch, '| tar -x -f - -C', :path)
66
-
67
- subject.release
68
- end
69
-
70
- it "should run git archive with a subtree" do
71
- context.expects(:fetch).with(:repo_tree).returns('tree')
72
- context.expects(:fetch).with(:branch).returns(:branch)
73
- context.expects(:release_path).returns(:path)
74
-
75
- context.expects(:execute).with(:git, :archive, :branch, 'tree', '| tar -x --strip-components 1 -f - -C', :path)
76
-
77
- subject.release
78
- end
79
- end
80
- end
81
- end
@@ -1,81 +0,0 @@
1
- require 'spec_helper'
2
-
3
- require 'capistrano/hg'
4
-
5
- module Capistrano
6
- describe Hg do
7
- let(:context) { Class.new.new }
8
- subject { Capistrano::Hg.new(context, Capistrano::Hg::DefaultStrategy) }
9
-
10
- describe "#hg" do
11
- it "should call execute hg in the context, with arguments" do
12
- context.expects(:execute).with(:hg, :init)
13
- subject.hg(:init)
14
- end
15
- end
16
- end
17
-
18
- describe Hg::DefaultStrategy do
19
- let(:context) { Class.new.new }
20
- subject { Capistrano::Hg.new(context, Capistrano::Hg::DefaultStrategy) }
21
-
22
- describe "#test" do
23
- it "should call test for repo HEAD" do
24
- context.expects(:repo_path).returns("/path/to/repo")
25
- context.expects(:test).with " [ -d /path/to/repo/.hg ] "
26
-
27
- subject.test
28
- end
29
- end
30
-
31
- describe "#check" do
32
- it "should test the repo url" do
33
- context.expects(:repo_url).returns(:url)
34
- context.expects(:execute).with(:hg, "id", :url)
35
-
36
- subject.check
37
- end
38
- end
39
-
40
- describe "#clone" do
41
- it "should run hg clone" do
42
- context.expects(:repo_url).returns(:url)
43
- context.expects(:repo_path).returns(:path)
44
-
45
- context.expects(:execute).with(:hg, "clone", '--noupdate', :url, :path)
46
-
47
- subject.clone
48
- end
49
- end
50
-
51
- describe "#update" do
52
- it "should run hg update" do
53
- context.expects(:execute).with(:hg, "pull")
54
-
55
- subject.update
56
- end
57
- end
58
-
59
- describe "#release" do
60
- it "should run hg archive without a subtree" do
61
- context.expects(:fetch).with(:repo_tree).returns(nil)
62
- context.expects(:fetch).with(:branch).returns(:branch)
63
- context.expects(:release_path).returns(:path)
64
-
65
- context.expects(:execute).with(:hg, "archive", :path, "--rev", :branch)
66
-
67
- subject.release
68
- end
69
-
70
- it "should run hg archive with a subtree" do
71
- context.expects(:fetch).with(:repo_tree).returns('tree')
72
- context.expects(:fetch).with(:branch).returns(:branch)
73
- context.expects(:release_path).returns(:path)
74
-
75
- context.expects(:execute).with(:hg, "archive --type tgz -p . -I", 'tree', "--rev", :branch, '| tar -x --strip-components 1 -f - -C', :path)
76
-
77
- subject.release
78
- end
79
- end
80
- end
81
- end