capistrano 3.4.1 → 3.5.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +7 -5
- data/.rubocop.yml +49 -0
- data/.travis.yml +5 -4
- data/CHANGELOG.md +72 -9
- data/CONTRIBUTING.md +61 -93
- data/DEVELOPMENT.md +122 -0
- data/Gemfile +2 -2
- data/LICENSE.txt +1 -1
- data/README.md +121 -43
- data/RELEASING.md +16 -0
- data/Rakefile +4 -1
- data/bin/cap +1 -1
- data/capistrano.gemspec +16 -21
- data/features/doctor.feature +11 -0
- data/features/step_definitions/assertions.rb +17 -17
- data/features/step_definitions/cap_commands.rb +0 -1
- data/features/step_definitions/setup.rb +12 -8
- data/features/support/env.rb +5 -5
- data/features/support/remote_command_helpers.rb +8 -6
- data/features/support/vagrant_helpers.rb +5 -4
- data/issue_template.md +21 -0
- data/lib/Capfile +5 -1
- data/lib/capistrano/all.rb +9 -10
- data/lib/capistrano/application.rb +36 -26
- data/lib/capistrano/configuration.rb +56 -41
- data/lib/capistrano/configuration/empty_filter.rb +9 -0
- data/lib/capistrano/configuration/filter.rb +18 -47
- data/lib/capistrano/configuration/host_filter.rb +30 -0
- data/lib/capistrano/configuration/null_filter.rb +9 -0
- data/lib/capistrano/configuration/plugin_installer.rb +33 -0
- data/lib/capistrano/configuration/question.rb +10 -7
- data/lib/capistrano/configuration/role_filter.rb +30 -0
- data/lib/capistrano/configuration/server.rb +22 -23
- data/lib/capistrano/configuration/servers.rb +6 -7
- data/lib/capistrano/configuration/variables.rb +136 -0
- data/lib/capistrano/defaults.rb +13 -3
- data/lib/capistrano/deploy.rb +1 -1
- data/lib/capistrano/doctor.rb +5 -0
- data/lib/capistrano/doctor/environment_doctor.rb +19 -0
- data/lib/capistrano/doctor/gems_doctor.rb +45 -0
- data/lib/capistrano/doctor/output_helpers.rb +79 -0
- data/lib/capistrano/doctor/variables_doctor.rb +66 -0
- data/lib/capistrano/dotfile.rb +1 -2
- data/lib/capistrano/dsl.rb +12 -14
- data/lib/capistrano/dsl/env.rb +11 -42
- data/lib/capistrano/dsl/paths.rb +12 -13
- data/lib/capistrano/dsl/stages.rb +2 -4
- data/lib/capistrano/dsl/task_enhancements.rb +5 -7
- data/lib/capistrano/framework.rb +1 -1
- data/lib/capistrano/git.rb +17 -9
- data/lib/capistrano/hg.rb +4 -4
- data/lib/capistrano/i18n.rb +24 -24
- data/lib/capistrano/immutable_task.rb +29 -0
- data/lib/capistrano/install.rb +1 -1
- data/lib/capistrano/plugin.rb +95 -0
- data/lib/capistrano/scm.rb +7 -20
- data/lib/capistrano/setup.rb +19 -5
- data/lib/capistrano/svn.rb +9 -5
- data/lib/capistrano/tasks/console.rake +4 -8
- data/lib/capistrano/tasks/deploy.rake +75 -62
- data/lib/capistrano/tasks/doctor.rake +19 -0
- data/lib/capistrano/tasks/framework.rake +13 -14
- data/lib/capistrano/tasks/git.rake +10 -11
- data/lib/capistrano/tasks/hg.rake +7 -7
- data/lib/capistrano/tasks/install.rake +14 -15
- data/lib/capistrano/tasks/svn.rake +7 -7
- data/lib/capistrano/templates/Capfile +3 -3
- data/lib/capistrano/templates/deploy.rb.erb +6 -5
- data/lib/capistrano/upload_task.rb +1 -1
- data/lib/capistrano/version.rb +1 -1
- data/lib/capistrano/version_validator.rb +4 -6
- data/spec/integration/dsl_spec.rb +286 -239
- data/spec/integration_spec_helper.rb +3 -5
- data/spec/lib/capistrano/application_spec.rb +22 -14
- data/spec/lib/capistrano/configuration/empty_filter_spec.rb +17 -0
- data/spec/lib/capistrano/configuration/filter_spec.rb +82 -84
- data/spec/lib/capistrano/configuration/host_filter_spec.rb +61 -0
- data/spec/lib/capistrano/configuration/null_filter_spec.rb +17 -0
- data/spec/lib/capistrano/configuration/question_spec.rb +12 -16
- data/spec/lib/capistrano/configuration/role_filter_spec.rb +64 -0
- data/spec/lib/capistrano/configuration/server_spec.rb +102 -110
- data/spec/lib/capistrano/configuration/servers_spec.rb +124 -141
- data/spec/lib/capistrano/configuration_spec.rb +150 -61
- data/spec/lib/capistrano/doctor/environment_doctor_spec.rb +44 -0
- data/spec/lib/capistrano/doctor/gems_doctor_spec.rb +61 -0
- data/spec/lib/capistrano/doctor/output_helpers_spec.rb +47 -0
- data/spec/lib/capistrano/doctor/variables_doctor_spec.rb +79 -0
- data/spec/lib/capistrano/dsl/paths_spec.rb +58 -50
- data/spec/lib/capistrano/dsl/task_enhancements_spec.rb +62 -32
- data/spec/lib/capistrano/dsl_spec.rb +6 -8
- data/spec/lib/capistrano/git_spec.rb +35 -7
- data/spec/lib/capistrano/hg_spec.rb +14 -5
- data/spec/lib/capistrano/immutable_task_spec.rb +31 -0
- data/spec/lib/capistrano/plugin_spec.rb +84 -0
- data/spec/lib/capistrano/scm_spec.rb +6 -7
- data/spec/lib/capistrano/svn_spec.rb +40 -14
- data/spec/lib/capistrano/upload_task_spec.rb +7 -7
- data/spec/lib/capistrano/version_validator_spec.rb +37 -45
- data/spec/lib/capistrano_spec.rb +2 -3
- data/spec/spec_helper.rb +8 -8
- data/spec/support/Vagrantfile +9 -10
- data/spec/support/tasks/database.rake +3 -3
- data/spec/support/tasks/fail.rake +4 -3
- data/spec/support/tasks/failed.rake +2 -2
- data/spec/support/tasks/plugin.rake +6 -0
- data/spec/support/tasks/root.rake +4 -4
- data/spec/support/test_app.rb +31 -30
- metadata +93 -14
@@ -1,19 +1,18 @@
|
|
1
|
-
require
|
1
|
+
require "spec_helper"
|
2
2
|
|
3
3
|
module Capistrano
|
4
|
-
|
5
4
|
describe VersionValidator do
|
6
5
|
let(:validator) { VersionValidator.new(version) }
|
7
6
|
let(:version) { stub }
|
8
7
|
|
9
8
|
describe '#new' do
|
10
|
-
it
|
9
|
+
it "takes a version" do
|
11
10
|
expect(validator)
|
12
11
|
end
|
13
12
|
end
|
14
13
|
|
15
14
|
describe '#verify' do
|
16
|
-
let(:current_version) {
|
15
|
+
let(:current_version) { "3.0.1" }
|
17
16
|
|
18
17
|
subject { validator.verify }
|
19
18
|
|
@@ -21,83 +20,76 @@ module Capistrano
|
|
21
20
|
validator.stubs(:current_version).returns(current_version)
|
22
21
|
end
|
23
22
|
|
24
|
-
context
|
25
|
-
context
|
26
|
-
let(:version) {
|
23
|
+
context "with exact version" do
|
24
|
+
context "valid" do
|
25
|
+
let(:version) { "3.0.1" }
|
27
26
|
it { expect(subject).to be_truthy }
|
28
27
|
end
|
29
28
|
|
30
|
-
context
|
31
|
-
let(:version) {
|
29
|
+
context "invalid - lower" do
|
30
|
+
let(:version) { "3.0.0" }
|
32
31
|
|
33
|
-
it
|
34
|
-
expect { subject }.to raise_error
|
32
|
+
it "fails" do
|
33
|
+
expect { subject }.to raise_error(RuntimeError)
|
35
34
|
end
|
36
35
|
end
|
37
36
|
|
38
|
-
context
|
39
|
-
let(:version) {
|
37
|
+
context "invalid - higher" do
|
38
|
+
let(:version) { "3.0.2" }
|
40
39
|
|
41
|
-
it
|
42
|
-
expect { subject }.to raise_error
|
40
|
+
it "fails" do
|
41
|
+
expect { subject }.to raise_error(RuntimeError)
|
43
42
|
end
|
44
43
|
end
|
45
|
-
|
46
44
|
end
|
47
45
|
|
48
|
-
context
|
49
|
-
context
|
50
|
-
let(:version) {
|
46
|
+
context "with optimistic versioning" do
|
47
|
+
context "valid" do
|
48
|
+
let(:version) { ">= 3.0.0" }
|
51
49
|
it { expect(subject).to be_truthy }
|
52
50
|
end
|
53
51
|
|
54
|
-
context
|
55
|
-
let(:version) {
|
52
|
+
context "invalid - lower" do
|
53
|
+
let(:version) { "<= 2.0.0" }
|
56
54
|
|
57
|
-
it
|
58
|
-
expect { subject }.to raise_error
|
55
|
+
it "fails" do
|
56
|
+
expect { subject }.to raise_error(RuntimeError)
|
59
57
|
end
|
60
58
|
end
|
61
59
|
end
|
62
60
|
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
context 'valid' do
|
68
|
-
let(:version) { '~> 3.0.0' }
|
61
|
+
context "with pessimistic versioning" do
|
62
|
+
context "2 decimal places" do
|
63
|
+
context "valid" do
|
64
|
+
let(:version) { "~> 3.0.0" }
|
69
65
|
it { expect(subject).to be_truthy }
|
70
66
|
end
|
71
67
|
|
72
|
-
context
|
73
|
-
let(:version) {
|
68
|
+
context "invalid" do
|
69
|
+
let(:version) { "~> 3.1.0" }
|
74
70
|
|
75
|
-
it
|
76
|
-
expect { subject }.to raise_error
|
71
|
+
it "fails" do
|
72
|
+
expect { subject }.to raise_error(RuntimeError)
|
77
73
|
end
|
78
74
|
end
|
79
75
|
end
|
80
76
|
|
81
|
-
context
|
82
|
-
let(:current_version) {
|
77
|
+
context "1 decimal place" do
|
78
|
+
let(:current_version) { "3.5.0" }
|
83
79
|
|
84
|
-
context
|
85
|
-
let(:version) {
|
80
|
+
context "valid" do
|
81
|
+
let(:version) { "~> 3.1" }
|
86
82
|
it { expect(subject).to be_truthy }
|
87
83
|
end
|
88
84
|
|
89
|
-
context
|
90
|
-
let(:version) {
|
91
|
-
it
|
92
|
-
expect { subject }.to raise_error
|
85
|
+
context "invalid" do
|
86
|
+
let(:version) { "~> 3.6" }
|
87
|
+
it "fails" do
|
88
|
+
expect { subject }.to raise_error(RuntimeError)
|
93
89
|
end
|
94
90
|
end
|
95
91
|
end
|
96
|
-
|
97
92
|
end
|
98
|
-
|
99
93
|
end
|
100
|
-
|
101
94
|
end
|
102
|
-
|
103
95
|
end
|
data/spec/lib/capistrano_spec.rb
CHANGED
data/spec/spec_helper.rb
CHANGED
@@ -1,16 +1,16 @@
|
|
1
|
-
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__),
|
1
|
+
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), "..", "lib"))
|
2
2
|
$LOAD_PATH.unshift(File.dirname(__FILE__))
|
3
|
-
require
|
4
|
-
require
|
5
|
-
require
|
6
|
-
require
|
3
|
+
require "capistrano/all"
|
4
|
+
require "rspec"
|
5
|
+
require "mocha/api"
|
6
|
+
require "time"
|
7
7
|
|
8
8
|
# Requires supporting files with custom matchers and macros, etc,
|
9
9
|
# in ./support/ and its subdirectories.
|
10
|
-
Dir['#{File.dirname(__FILE__)}/support/**/*.rb'].each {|f| require f}
|
10
|
+
Dir['#{File.dirname(__FILE__)}/support/**/*.rb'].each { |f| require f }
|
11
11
|
|
12
12
|
RSpec.configure do |config|
|
13
|
-
|
13
|
+
config.raise_errors_for_deprecations!
|
14
14
|
config.mock_framework = :mocha
|
15
|
-
config.order =
|
15
|
+
config.order = "random"
|
16
16
|
end
|
data/spec/support/Vagrantfile
CHANGED
@@ -1,20 +1,19 @@
|
|
1
|
-
require
|
1
|
+
require "open-uri"
|
2
2
|
|
3
3
|
Vagrant.configure("2") do |config|
|
4
|
-
|
5
4
|
config.ssh.insert_key = false
|
6
5
|
|
7
6
|
[:app].each_with_index do |role, i|
|
8
|
-
config.vm.define(role, primary: true) do |
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
7
|
+
config.vm.define(role, primary: true) do |primary|
|
8
|
+
primary.vm.define role
|
9
|
+
primary.vm.box = "hashicorp/precise64"
|
10
|
+
primary.vm.network "forwarded_port", guest: 22, host: "222#{i}".to_i
|
11
|
+
primary.vm.provision :shell, inline: "sudo apt-get -y install git-core"
|
13
12
|
|
14
|
-
vagrantkey = open("https://raw.githubusercontent.com/mitchellh/vagrant/master/keys/vagrant.pub", "r"
|
13
|
+
vagrantkey = open("https://raw.githubusercontent.com/mitchellh/vagrant/master/keys/vagrant.pub", "r", &:read)
|
15
14
|
|
16
|
-
|
17
|
-
|
15
|
+
primary.vm.provision :shell,
|
16
|
+
inline: <<-INLINE
|
18
17
|
install -d -m 700 /root/.ssh
|
19
18
|
echo -e "#{vagrantkey}" > /root/.ssh/authorized_keys
|
20
19
|
chmod 0600 /root/.ssh/authorized_keys
|
@@ -1,11 +1,11 @@
|
|
1
1
|
namespace :deploy do
|
2
2
|
namespace :check do
|
3
|
-
task :
|
3
|
+
task linked_files: "config/database.yml"
|
4
4
|
end
|
5
5
|
end
|
6
6
|
|
7
|
-
remote_file
|
7
|
+
remote_file "config/database.yml" => "/tmp/database.yml", :roles => :all
|
8
8
|
|
9
|
-
file
|
9
|
+
file "/tmp/database.yml" do |t|
|
10
10
|
sh "touch #{t.name}"
|
11
11
|
end
|
@@ -1,7 +1,8 @@
|
|
1
|
-
set :fail, proc {
|
2
|
-
before
|
1
|
+
set :fail, proc { raise }
|
2
|
+
before "deploy:starting", :fail do
|
3
3
|
on roles :all do
|
4
|
-
execute :
|
4
|
+
execute :mkdir, "-p", shared_path
|
5
|
+
execute :touch, shared_path.join("fail")
|
5
6
|
end
|
6
7
|
fetch(:fail)
|
7
8
|
end
|
@@ -1,11 +1,11 @@
|
|
1
1
|
task :am_i_root do
|
2
2
|
on roles(:all) do |host|
|
3
|
-
host.user =
|
4
|
-
ident = capture :id,
|
3
|
+
host.user = "root"
|
4
|
+
ident = capture :id, "-a"
|
5
5
|
info "I am #{ident}"
|
6
6
|
end
|
7
|
-
on roles(:all) do |
|
8
|
-
ident = capture :id,
|
7
|
+
on roles(:all) do |_host|
|
8
|
+
ident = capture :id, "-a"
|
9
9
|
info "I am #{ident}"
|
10
10
|
end
|
11
11
|
end
|
data/spec/support/test_app.rb
CHANGED
@@ -1,5 +1,6 @@
|
|
1
|
-
require
|
2
|
-
require
|
1
|
+
require "English"
|
2
|
+
require "fileutils"
|
3
|
+
require "pathname"
|
3
4
|
|
4
5
|
module TestApp
|
5
6
|
extend self
|
@@ -9,7 +10,7 @@ module TestApp
|
|
9
10
|
end
|
10
11
|
|
11
12
|
def default_config
|
12
|
-
|
13
|
+
<<-CONFIG
|
13
14
|
set :deploy_to, '#{deploy_to}'
|
14
15
|
set :repo_url, 'git://github.com/capistrano/capistrano.git'
|
15
16
|
set :branch, 'master'
|
@@ -17,7 +18,8 @@ module TestApp
|
|
17
18
|
server 'vagrant@localhost:2220', roles: %w{web app}
|
18
19
|
set :linked_files, #{linked_files}
|
19
20
|
set :linked_dirs, #{linked_dirs}
|
20
|
-
|
21
|
+
set :format_options, log_file: nil
|
22
|
+
CONFIG
|
21
23
|
end
|
22
24
|
|
23
25
|
def linked_files
|
@@ -29,45 +31,45 @@ module TestApp
|
|
29
31
|
end
|
30
32
|
|
31
33
|
def linked_dirs
|
32
|
-
%w{bin log public/system
|
34
|
+
%w{bin log public/system}
|
33
35
|
end
|
34
36
|
|
35
37
|
def create_test_app
|
36
38
|
FileUtils.rm_rf(test_app_path)
|
37
39
|
FileUtils.mkdir(test_app_path)
|
38
40
|
|
39
|
-
File.open(gemfile,
|
41
|
+
File.open(gemfile, "w+") do |file|
|
40
42
|
file.write "gem 'capistrano', path: '#{path_to_cap}'"
|
41
43
|
end
|
42
44
|
|
43
45
|
Dir.chdir(test_app_path) do
|
44
|
-
|
46
|
+
`bundle`
|
45
47
|
end
|
46
48
|
end
|
47
49
|
|
48
50
|
def install_test_app_with(config)
|
49
51
|
create_test_app
|
50
52
|
Dir.chdir(test_app_path) do
|
51
|
-
|
53
|
+
`bundle exec cap install STAGES=#{stage}`
|
52
54
|
end
|
53
55
|
write_local_deploy_file(config)
|
54
56
|
end
|
55
57
|
|
56
58
|
def write_local_deploy_file(config)
|
57
|
-
File.open(test_stage_path,
|
59
|
+
File.open(test_stage_path, "w") do |file|
|
58
60
|
file.write config
|
59
61
|
end
|
60
62
|
end
|
61
63
|
|
62
64
|
def append_to_deploy_file(config)
|
63
|
-
File.open(test_stage_path,
|
65
|
+
File.open(test_stage_path, "a") do |file|
|
64
66
|
file.write config + "\n"
|
65
67
|
end
|
66
68
|
end
|
67
69
|
|
68
70
|
def prepend_to_capfile(config)
|
69
71
|
current_capfile = File.read(capfile)
|
70
|
-
File.open(capfile,
|
72
|
+
File.open(capfile, "w") do |file|
|
71
73
|
file.write config
|
72
74
|
file.write current_capfile
|
73
75
|
end
|
@@ -78,7 +80,7 @@ module TestApp
|
|
78
80
|
end
|
79
81
|
|
80
82
|
def create_shared_file(path)
|
81
|
-
File.open(shared_path.join(path),
|
83
|
+
File.open(shared_path.join(path), "w")
|
82
84
|
end
|
83
85
|
|
84
86
|
def cap(task)
|
@@ -88,37 +90,37 @@ module TestApp
|
|
88
90
|
def run(command)
|
89
91
|
output = nil
|
90
92
|
Dir.chdir(test_app_path) do
|
91
|
-
output =
|
93
|
+
output = `#{command}`
|
92
94
|
end
|
93
|
-
[
|
95
|
+
[$CHILD_STATUS.success?, output]
|
94
96
|
end
|
95
97
|
|
96
98
|
def stage
|
97
|
-
|
99
|
+
"test"
|
98
100
|
end
|
99
101
|
|
100
102
|
def test_stage_path
|
101
|
-
test_app_path.join(
|
103
|
+
test_app_path.join("config/deploy/test.rb")
|
102
104
|
end
|
103
105
|
|
104
106
|
def test_app_path
|
105
|
-
Pathname.new(
|
107
|
+
Pathname.new("/tmp/test_app")
|
106
108
|
end
|
107
109
|
|
108
110
|
def deploy_to
|
109
|
-
Pathname.new(
|
111
|
+
Pathname.new("/home/vagrant/var/www/deploy")
|
110
112
|
end
|
111
113
|
|
112
114
|
def shared_path
|
113
|
-
deploy_to.join(
|
115
|
+
deploy_to.join("shared")
|
114
116
|
end
|
115
117
|
|
116
118
|
def current_path
|
117
|
-
deploy_to.join(
|
119
|
+
deploy_to.join("current")
|
118
120
|
end
|
119
121
|
|
120
122
|
def releases_path
|
121
|
-
deploy_to.join(
|
123
|
+
deploy_to.join("releases")
|
122
124
|
end
|
123
125
|
|
124
126
|
def release_path
|
@@ -130,19 +132,19 @@ module TestApp
|
|
130
132
|
end
|
131
133
|
|
132
134
|
def repo_path
|
133
|
-
deploy_to.join(
|
135
|
+
deploy_to.join("repo")
|
134
136
|
end
|
135
137
|
|
136
138
|
def path_to_cap
|
137
|
-
File.expand_path(
|
139
|
+
File.expand_path(".")
|
138
140
|
end
|
139
141
|
|
140
142
|
def gemfile
|
141
|
-
test_app_path.join(
|
143
|
+
test_app_path.join("Gemfile")
|
142
144
|
end
|
143
145
|
|
144
146
|
def capfile
|
145
|
-
test_app_path.join(
|
147
|
+
test_app_path.join("Capfile")
|
146
148
|
end
|
147
149
|
|
148
150
|
def current_user
|
@@ -150,7 +152,7 @@ module TestApp
|
|
150
152
|
end
|
151
153
|
|
152
154
|
def task_dir
|
153
|
-
test_app_path.join(
|
155
|
+
test_app_path.join("lib/capistrano/tasks")
|
154
156
|
end
|
155
157
|
|
156
158
|
def copy_task_to_test_app(source)
|
@@ -158,20 +160,19 @@ module TestApp
|
|
158
160
|
end
|
159
161
|
|
160
162
|
def config_path
|
161
|
-
test_app_path.join(
|
163
|
+
test_app_path.join("config")
|
162
164
|
end
|
163
165
|
|
164
166
|
def move_configuration_to_custom_location(location)
|
165
167
|
prepend_to_capfile(
|
166
|
-
|
168
|
+
<<-CONFIG
|
167
169
|
set :stage_config_path, "app/config/deploy"
|
168
170
|
set :deploy_config_path, "app/config/deploy.rb"
|
169
|
-
|
171
|
+
CONFIG
|
170
172
|
)
|
171
173
|
|
172
174
|
location = test_app_path.join(location)
|
173
175
|
FileUtils.mkdir_p(location)
|
174
176
|
FileUtils.mv(config_path, location)
|
175
177
|
end
|
176
|
-
|
177
178
|
end
|