capistrano 2.1.0 → 3.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.
Files changed (166) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +20 -0
  3. data/.travis.yml +7 -0
  4. data/CHANGELOG.md +89 -0
  5. data/Gemfile +4 -0
  6. data/LICENSE.txt +674 -0
  7. data/README.md +226 -0
  8. data/Rakefile +5 -0
  9. data/bin/cap +2 -3
  10. data/bin/capify +7 -77
  11. data/capistrano-public_cert.pem +22 -0
  12. data/capistrano.gemspec +35 -0
  13. data/features/deploy.feature +52 -0
  14. data/features/installation.feature +16 -0
  15. data/features/remote_file_task.feature +14 -0
  16. data/features/step_definitions/assertions.rb +90 -0
  17. data/features/step_definitions/cap_commands.rb +8 -0
  18. data/features/step_definitions/setup.rb +25 -0
  19. data/features/support/env.rb +12 -0
  20. data/features/support/remote_command_helpers.rb +20 -0
  21. data/lib/Capfile +3 -0
  22. data/lib/capistrano/all.rb +16 -0
  23. data/lib/capistrano/application.rb +60 -0
  24. data/lib/capistrano/configuration/question.rb +42 -0
  25. data/lib/capistrano/configuration/server.rb +133 -0
  26. data/lib/capistrano/configuration/servers/role_filter.rb +86 -0
  27. data/lib/capistrano/configuration/servers.rb +53 -58
  28. data/lib/capistrano/configuration.rb +84 -30
  29. data/lib/capistrano/console.rb +1 -0
  30. data/lib/capistrano/defaults.rb +13 -0
  31. data/lib/capistrano/deploy.rb +3 -0
  32. data/lib/capistrano/dotfile.rb +3 -0
  33. data/lib/capistrano/dsl/env.rb +64 -0
  34. data/lib/capistrano/dsl/paths.rb +94 -0
  35. data/lib/capistrano/dsl/stages.rb +15 -0
  36. data/lib/capistrano/dsl/task_enhancements.rb +53 -0
  37. data/lib/capistrano/dsl.rb +48 -0
  38. data/lib/capistrano/git.rb +1 -0
  39. data/lib/capistrano/hg.rb +1 -0
  40. data/lib/capistrano/i18n.rb +34 -0
  41. data/lib/capistrano/install.rb +1 -0
  42. data/lib/capistrano/setup.rb +21 -0
  43. data/lib/capistrano/tasks/console.rake +21 -0
  44. data/lib/capistrano/tasks/deploy.rake +204 -0
  45. data/lib/capistrano/tasks/framework.rake +67 -0
  46. data/lib/capistrano/tasks/git.rake +62 -0
  47. data/lib/capistrano/tasks/hg.rake +39 -0
  48. data/lib/capistrano/tasks/install.rake +39 -0
  49. data/lib/capistrano/templates/Capfile +26 -0
  50. data/lib/capistrano/templates/deploy.rb.erb +40 -0
  51. data/lib/capistrano/templates/stage.rb.erb +42 -0
  52. data/lib/capistrano/version.rb +1 -20
  53. data/lib/capistrano/version_validator.rb +37 -0
  54. data/lib/capistrano.rb +0 -2
  55. data/spec/integration/dsl_spec.rb +344 -0
  56. data/spec/integration_spec_helper.rb +7 -0
  57. data/spec/lib/capistrano/application_spec.rb +61 -0
  58. data/spec/lib/capistrano/configuration/question_spec.rb +54 -0
  59. data/spec/lib/capistrano/configuration/server_spec.rb +249 -0
  60. data/spec/lib/capistrano/configuration/servers/role_filter_spec.rb +140 -0
  61. data/spec/lib/capistrano/configuration/servers_spec.rb +184 -0
  62. data/spec/lib/capistrano/configuration_spec.rb +101 -0
  63. data/spec/lib/capistrano/dsl/env_spec.rb +10 -0
  64. data/spec/lib/capistrano/dsl/paths_spec.rb +69 -0
  65. data/spec/lib/capistrano/dsl_spec.rb +63 -0
  66. data/spec/lib/capistrano/version_validator_spec.rb +103 -0
  67. data/spec/lib/capistrano_spec.rb +8 -0
  68. data/spec/spec_helper.rb +15 -0
  69. data/spec/support/.gitignore +1 -0
  70. data/spec/support/Vagrantfile +13 -0
  71. data/spec/support/matchers.rb +5 -0
  72. data/spec/support/tasks/database.cap +11 -0
  73. data/spec/support/test_app.rb +138 -0
  74. metadata +251 -179
  75. data/CHANGELOG +0 -512
  76. data/MIT-LICENSE +0 -20
  77. data/README +0 -43
  78. data/examples/sample.rb +0 -14
  79. data/lib/capistrano/callback.rb +0 -45
  80. data/lib/capistrano/cli/execute.rb +0 -82
  81. data/lib/capistrano/cli/help.rb +0 -102
  82. data/lib/capistrano/cli/help.txt +0 -53
  83. data/lib/capistrano/cli/options.rb +0 -183
  84. data/lib/capistrano/cli/ui.rb +0 -28
  85. data/lib/capistrano/cli.rb +0 -47
  86. data/lib/capistrano/command.rb +0 -161
  87. data/lib/capistrano/configuration/actions/file_transfer.rb +0 -35
  88. data/lib/capistrano/configuration/actions/inspect.rb +0 -46
  89. data/lib/capistrano/configuration/actions/invocation.rb +0 -134
  90. data/lib/capistrano/configuration/callbacks.rb +0 -148
  91. data/lib/capistrano/configuration/connections.rb +0 -159
  92. data/lib/capistrano/configuration/execution.rb +0 -126
  93. data/lib/capistrano/configuration/loading.rb +0 -198
  94. data/lib/capistrano/configuration/namespaces.rb +0 -196
  95. data/lib/capistrano/configuration/roles.rb +0 -51
  96. data/lib/capistrano/configuration/variables.rb +0 -127
  97. data/lib/capistrano/errors.rb +0 -15
  98. data/lib/capistrano/extensions.rb +0 -57
  99. data/lib/capistrano/gateway.rb +0 -131
  100. data/lib/capistrano/logger.rb +0 -59
  101. data/lib/capistrano/recipes/compat.rb +0 -32
  102. data/lib/capistrano/recipes/deploy/dependencies.rb +0 -44
  103. data/lib/capistrano/recipes/deploy/local_dependency.rb +0 -46
  104. data/lib/capistrano/recipes/deploy/remote_dependency.rb +0 -96
  105. data/lib/capistrano/recipes/deploy/scm/accurev.rb +0 -169
  106. data/lib/capistrano/recipes/deploy/scm/base.rb +0 -192
  107. data/lib/capistrano/recipes/deploy/scm/bzr.rb +0 -86
  108. data/lib/capistrano/recipes/deploy/scm/cvs.rb +0 -151
  109. data/lib/capistrano/recipes/deploy/scm/darcs.rb +0 -85
  110. data/lib/capistrano/recipes/deploy/scm/git.rb +0 -191
  111. data/lib/capistrano/recipes/deploy/scm/mercurial.rb +0 -129
  112. data/lib/capistrano/recipes/deploy/scm/perforce.rb +0 -126
  113. data/lib/capistrano/recipes/deploy/scm/subversion.rb +0 -114
  114. data/lib/capistrano/recipes/deploy/scm.rb +0 -19
  115. data/lib/capistrano/recipes/deploy/strategy/base.rb +0 -64
  116. data/lib/capistrano/recipes/deploy/strategy/checkout.rb +0 -20
  117. data/lib/capistrano/recipes/deploy/strategy/copy.rb +0 -144
  118. data/lib/capistrano/recipes/deploy/strategy/export.rb +0 -20
  119. data/lib/capistrano/recipes/deploy/strategy/remote.rb +0 -52
  120. data/lib/capistrano/recipes/deploy/strategy/remote_cache.rb +0 -47
  121. data/lib/capistrano/recipes/deploy/strategy.rb +0 -19
  122. data/lib/capistrano/recipes/deploy/templates/maintenance.rhtml +0 -53
  123. data/lib/capistrano/recipes/deploy.rb +0 -494
  124. data/lib/capistrano/recipes/standard.rb +0 -37
  125. data/lib/capistrano/recipes/templates/maintenance.rhtml +0 -53
  126. data/lib/capistrano/recipes/upgrade.rb +0 -33
  127. data/lib/capistrano/server_definition.rb +0 -51
  128. data/lib/capistrano/shell.rb +0 -256
  129. data/lib/capistrano/ssh.rb +0 -109
  130. data/lib/capistrano/task_definition.rb +0 -69
  131. data/lib/capistrano/upload.rb +0 -146
  132. data/test/cli/execute_test.rb +0 -132
  133. data/test/cli/help_test.rb +0 -139
  134. data/test/cli/options_test.rb +0 -226
  135. data/test/cli/ui_test.rb +0 -28
  136. data/test/cli_test.rb +0 -17
  137. data/test/command_test.rb +0 -309
  138. data/test/configuration/actions/file_transfer_test.rb +0 -40
  139. data/test/configuration/actions/inspect_test.rb +0 -62
  140. data/test/configuration/actions/invocation_test.rb +0 -202
  141. data/test/configuration/callbacks_test.rb +0 -206
  142. data/test/configuration/connections_test.rb +0 -288
  143. data/test/configuration/execution_test.rb +0 -159
  144. data/test/configuration/loading_test.rb +0 -127
  145. data/test/configuration/namespace_dsl_test.rb +0 -297
  146. data/test/configuration/roles_test.rb +0 -47
  147. data/test/configuration/servers_test.rb +0 -90
  148. data/test/configuration/variables_test.rb +0 -180
  149. data/test/configuration_test.rb +0 -81
  150. data/test/deploy/scm/accurev_test.rb +0 -23
  151. data/test/deploy/scm/base_test.rb +0 -55
  152. data/test/deploy/scm/git_test.rb +0 -112
  153. data/test/deploy/strategy/copy_test.rb +0 -147
  154. data/test/extensions_test.rb +0 -69
  155. data/test/fixtures/cli_integration.rb +0 -5
  156. data/test/fixtures/config.rb +0 -5
  157. data/test/fixtures/custom.rb +0 -3
  158. data/test/gateway_test.rb +0 -167
  159. data/test/logger_test.rb +0 -123
  160. data/test/server_definition_test.rb +0 -108
  161. data/test/shell_test.rb +0 -64
  162. data/test/ssh_test.rb +0 -97
  163. data/test/task_definition_test.rb +0 -101
  164. data/test/upload_test.rb +0 -131
  165. data/test/utils.rb +0 -42
  166. data/test/version_test.rb +0 -24
@@ -0,0 +1,69 @@
1
+ require 'spec_helper'
2
+
3
+ module Capistrano
4
+ module DSL
5
+
6
+ class DummyPaths
7
+ include Paths
8
+ end
9
+
10
+ describe Paths do
11
+ let(:paths) { DummyPaths.new }
12
+ let(:parent) { Pathname.new('/var/shared') }
13
+
14
+ let(:linked_dirs) { %w{log public/system} }
15
+ let(:linked_files) { %w{config/database.yml log/my.log} }
16
+
17
+
18
+ describe '#linked_dirs' do
19
+ subject { paths.linked_dirs(parent) }
20
+
21
+ before do
22
+ paths.expects(:fetch).with(:linked_dirs).returns(linked_dirs)
23
+ end
24
+
25
+ it 'returns the full pathnames' do
26
+ expect(subject).to eq [Pathname.new('/var/shared/log'), Pathname.new('/var/shared/public/system')]
27
+ end
28
+ end
29
+
30
+
31
+ describe '#linked_files' do
32
+ subject { paths.linked_files(parent) }
33
+
34
+ before do
35
+ paths.expects(:fetch).with(:linked_files).returns(linked_files)
36
+ end
37
+
38
+ it 'returns the full pathnames' do
39
+ expect(subject).to eq [Pathname.new('/var/shared/config/database.yml'), Pathname.new('/var/shared/log/my.log')]
40
+ end
41
+ end
42
+
43
+ describe '#linked_file_dirs' do
44
+ subject { paths.linked_file_dirs(parent) }
45
+
46
+ before do
47
+ paths.expects(:fetch).with(:linked_files).returns(linked_files)
48
+ end
49
+
50
+ it 'returns the full paths names of the parent dirs' do
51
+ expect(subject).to eq [Pathname.new('/var/shared/config'), Pathname.new('/var/shared/log')]
52
+ end
53
+ end
54
+
55
+ describe '#linked_dir_parents' do
56
+ subject { paths.linked_dir_parents(parent) }
57
+
58
+ before do
59
+ paths.expects(:fetch).with(:linked_dirs).returns(linked_dirs)
60
+ end
61
+
62
+ it 'returns the full paths names of the parent dirs' do
63
+ expect(subject).to eq [Pathname.new('/var/shared'), Pathname.new('/var/shared/public')]
64
+ end
65
+ end
66
+
67
+ end
68
+ end
69
+ end
@@ -0,0 +1,63 @@
1
+ require 'spec_helper'
2
+
3
+ module Capistrano
4
+
5
+ class DummyDSL
6
+ include DSL
7
+ end
8
+
9
+ # see also - spec/integration/dsl_spec.rb
10
+ describe DSL do
11
+ let(:dsl) { DummyDSL.new }
12
+
13
+ describe '#t' do
14
+ before do
15
+ I18n.expects(:t).with(:phrase, {count: 2, scope: :capistrano})
16
+ end
17
+
18
+ it 'delegates to I18n' do
19
+ dsl.t(:phrase, count: 2)
20
+ end
21
+ end
22
+
23
+ describe '#stages' do
24
+ before do
25
+ Dir.expects(:[]).with('config/deploy/*.rb').
26
+ returns(['config/deploy/staging.rb', 'config/deploy/production.rb'])
27
+ end
28
+
29
+ it 'returns a list of defined stages' do
30
+ expect(dsl.stages).to eq %w{staging production}
31
+ end
32
+ end
33
+
34
+ describe '#stage_set?' do
35
+ subject { dsl.stage_set? }
36
+
37
+ context 'stage is set' do
38
+ before do
39
+ dsl.set(:stage, :sandbox)
40
+ end
41
+ it { should be_true }
42
+ end
43
+
44
+ context 'stage is not set' do
45
+ before do
46
+ dsl.set(:stage, nil)
47
+ end
48
+ it { should be_false }
49
+ end
50
+ end
51
+
52
+ describe '#sudo' do
53
+
54
+ before do
55
+ dsl.expects(:execute).with(:sudo, :my, :command)
56
+ end
57
+
58
+ it 'prepends sudo, delegates to execute' do
59
+ dsl.sudo(:my, :command)
60
+ end
61
+ end
62
+ end
63
+ end
@@ -0,0 +1,103 @@
1
+ require 'spec_helper'
2
+
3
+ module Capistrano
4
+
5
+ describe VersionValidator do
6
+ let(:validator) { VersionValidator.new(version) }
7
+ let(:version) { stub }
8
+
9
+ describe '#new' do
10
+ it 'takes a version' do
11
+ expect(validator)
12
+ end
13
+ end
14
+
15
+ describe '#verify' do
16
+ let(:current_version) { '3.0.1' }
17
+
18
+ subject { validator.verify }
19
+
20
+ before do
21
+ validator.stubs(:current_version).returns(current_version)
22
+ end
23
+
24
+ context 'with exact version' do
25
+ context 'valid' do
26
+ let(:version) { '3.0.1' }
27
+ it { should be_true }
28
+ end
29
+
30
+ context 'invalid - lower' do
31
+ let(:version) { '3.0.0' }
32
+
33
+ it 'fails' do
34
+ expect { subject }.to raise_error
35
+ end
36
+ end
37
+
38
+ context 'invalid - higher' do
39
+ let(:version) { '3.0.2' }
40
+
41
+ it 'fails' do
42
+ expect { subject }.to raise_error
43
+ end
44
+ end
45
+
46
+ end
47
+
48
+ context 'with optimistic versioning' do
49
+ context 'valid' do
50
+ let(:version) { '>= 3.0.0' }
51
+ it { should be_true }
52
+ end
53
+
54
+ context 'invalid - lower' do
55
+ let(:version) { '<= 2.0.0' }
56
+
57
+ it 'fails' do
58
+ expect { subject }.to raise_error
59
+ end
60
+ end
61
+ end
62
+
63
+
64
+
65
+ context 'with pessimistic versioning' do
66
+ context '2 decimal places' do
67
+ context 'valid' do
68
+ let(:version) { '~> 3.0.0' }
69
+ it { should be_true }
70
+ end
71
+
72
+ context 'invalid' do
73
+ let(:version) { '~> 3.1.0' }
74
+
75
+ it 'fails' do
76
+ expect { subject }.to raise_error
77
+ end
78
+ end
79
+ end
80
+
81
+ context '1 decimal place' do
82
+ let(:current_version) { '3.5.0' }
83
+
84
+ context 'valid' do
85
+ let(:version) { '~> 3.1' }
86
+ it { should be_true }
87
+ end
88
+
89
+ context 'invalid' do
90
+ let(:version) { '~> 3.6' }
91
+ it 'fails' do
92
+ expect { subject }.to raise_error
93
+ end
94
+ end
95
+ end
96
+
97
+ end
98
+
99
+ end
100
+
101
+ end
102
+
103
+ end
@@ -0,0 +1,8 @@
1
+ require 'spec_helper'
2
+
3
+ module Capistrano
4
+
5
+ describe Application do
6
+ let(:app) { Application.new }
7
+ end
8
+ end
@@ -0,0 +1,15 @@
1
+ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
2
+ $LOAD_PATH.unshift(File.dirname(__FILE__))
3
+ require 'capistrano/all'
4
+ require 'rspec'
5
+ require 'mocha/api'
6
+
7
+ # Requires supporting files with custom matchers and macros, etc,
8
+ # in ./support/ and its subdirectories.
9
+ Dir['#{File.dirname(__FILE__)}/support/**/*.rb'].each {|f| require f}
10
+
11
+ RSpec.configure do |config|
12
+ config.treat_symbols_as_metadata_keys_with_true_values = true
13
+ config.mock_framework = :mocha
14
+ config.order = 'random'
15
+ end
@@ -0,0 +1 @@
1
+ .vagrant
@@ -0,0 +1,13 @@
1
+ Vagrant::Config.run do |config|
2
+
3
+ [:app].each_with_index do |role, i|
4
+ config.vm.define(role, primary: true) do |config|
5
+ config.vm.box = role
6
+ config.vm.box = 'precise64'
7
+ config.vm.box_url = 'http://files.vagrantup.com/precise64.box'
8
+ config.vm.forward_port 22, "222#{i}".to_i
9
+ config.vm.provision :shell, inline: 'yes | sudo apt-get install git-core'
10
+ end
11
+ end
12
+
13
+ end
@@ -0,0 +1,5 @@
1
+ RSpec::Matchers.define :be_a_symlink_to do |expected|
2
+ match do |actual|
3
+ File.identical?(expected, actual)
4
+ end
5
+ end
@@ -0,0 +1,11 @@
1
+ namespace :deploy do
2
+ namespace :check do
3
+ task :linked_files => 'config/database.yml'
4
+ end
5
+ end
6
+
7
+ remote_file 'config/database.yml' => '/tmp/database.yml', roles: :all
8
+
9
+ file '/tmp/database.yml' do |t|
10
+ sh "touch #{t.name}"
11
+ end
@@ -0,0 +1,138 @@
1
+ require 'fileutils'
2
+ module TestApp
3
+ extend self
4
+
5
+ def install
6
+ install_test_app_with(default_config)
7
+ end
8
+
9
+ def default_config
10
+ %{
11
+ set :stage, :#{stage}
12
+ set :deploy_to, '#{deploy_to}'
13
+ set :repo_url, 'git://github.com/capistrano/capistrano.git'
14
+ set :branch, 'v3'
15
+ set :ssh_options, { keys: "\#{ENV['HOME']}/.vagrant.d/insecure_private_key" }
16
+ server 'vagrant@localhost:2220', roles: %w{web app}
17
+ set :linked_files, #{linked_files}
18
+ set :linked_dirs, #{linked_dirs}
19
+ }
20
+ end
21
+
22
+ def linked_files
23
+ %w{config/database.yml}
24
+ end
25
+
26
+ def linked_file
27
+ shared_path.join(linked_files.first)
28
+ end
29
+
30
+ def linked_dirs
31
+ %w{bin log public/system vendor/bundle}
32
+ end
33
+
34
+ def create_test_app
35
+ FileUtils.rm_rf(test_app_path)
36
+ FileUtils.mkdir(test_app_path)
37
+
38
+ File.open(gemfile, 'w+') do |file|
39
+ file.write "gem 'capistrano', path: '#{path_to_cap}'"
40
+ end
41
+
42
+ Dir.chdir(test_app_path) do
43
+ %x[bundle]
44
+ end
45
+ end
46
+
47
+ def install_test_app_with(config)
48
+ create_test_app
49
+ Dir.chdir(test_app_path) do
50
+ %x[bundle exec cap install STAGES=#{stage}]
51
+ end
52
+ write_local_deploy_file(config)
53
+ end
54
+
55
+ def write_local_deploy_file(config)
56
+ File.open(test_stage_path, 'w') do |file|
57
+ file.write config
58
+ end
59
+ end
60
+
61
+ def create_shared_directory(path)
62
+ FileUtils.mkdir_p(shared_path.join(path))
63
+ end
64
+
65
+ def create_shared_file(path)
66
+ File.open(shared_path.join(path), 'w')
67
+ end
68
+
69
+ def cap(task)
70
+ Dir.chdir(test_app_path) do
71
+ %x[bundle exec cap #{stage} #{task}]
72
+ end
73
+ end
74
+
75
+ def stage
76
+ 'test'
77
+ end
78
+
79
+ def test_stage_path
80
+ test_app_path.join('config/deploy/test.rb')
81
+ end
82
+
83
+ def test_app_path
84
+ Pathname.new('/tmp/test_app')
85
+ end
86
+
87
+ def deploy_to
88
+ Pathname.new('/home/vagrant/var/www/deploy')
89
+ end
90
+
91
+ def shared_path
92
+ deploy_to.join('shared')
93
+ end
94
+
95
+ def current_path
96
+ deploy_to.join('current')
97
+ end
98
+
99
+ def releases_path
100
+ deploy_to.join('releases')
101
+ end
102
+
103
+ def release_path
104
+ releases_path.join(timestamp)
105
+ end
106
+
107
+ def timestamp
108
+ Time.now.utc.strftime("%Y%m%d%H%M%S")
109
+ end
110
+
111
+ def repo_path
112
+ deploy_to.join('repo')
113
+ end
114
+
115
+ def path_to_cap
116
+ File.expand_path('.')
117
+ end
118
+
119
+ def gemfile
120
+ test_app_path.join('Gemfile')
121
+ end
122
+
123
+ def capfile
124
+ test_app_path.join('Capfile')
125
+ end
126
+
127
+ def current_user
128
+ `whoami`.chomp
129
+ end
130
+
131
+ def task_dir
132
+ test_app_path.join('lib/capistrano/tasks')
133
+ end
134
+
135
+ def copy_task_to_test_app(source)
136
+ FileUtils.cp(source, task_dir)
137
+ end
138
+ end