capistrano 3.4.0 → 3.17.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/.circleci/config.yml +129 -0
- data/.github/issue_template.md +19 -0
- data/.github/pull_request_template.md +22 -0
- data/.github/release-drafter.yml +17 -0
- data/.github/workflows/push.yml +12 -0
- data/.gitignore +8 -5
- data/.rubocop.yml +62 -0
- data/CHANGELOG.md +1 -307
- data/CONTRIBUTING.md +63 -93
- data/DEVELOPMENT.md +127 -0
- data/Dangerfile +1 -0
- data/Gemfile +40 -3
- data/LICENSE.txt +1 -1
- data/README.md +127 -44
- data/RELEASING.md +17 -0
- data/Rakefile +13 -2
- data/UPGRADING-3.7.md +86 -0
- data/bin/cap +1 -1
- data/capistrano.gemspec +21 -24
- data/features/deploy.feature +35 -1
- data/features/doctor.feature +11 -0
- data/features/installation.feature +8 -3
- data/features/stage_failure.feature +9 -0
- data/features/step_definitions/assertions.rb +51 -18
- data/features/step_definitions/cap_commands.rb +9 -0
- data/features/step_definitions/setup.rb +53 -9
- data/features/subdirectory.feature +9 -0
- data/features/support/env.rb +5 -5
- data/features/support/remote_command_helpers.rb +12 -6
- data/features/support/vagrant_helpers.rb +17 -11
- data/lib/Capfile +1 -1
- data/lib/capistrano/all.rb +10 -10
- data/lib/capistrano/application.rb +47 -34
- data/lib/capistrano/configuration/empty_filter.rb +9 -0
- data/lib/capistrano/configuration/filter.rb +17 -47
- data/lib/capistrano/configuration/host_filter.rb +29 -0
- data/lib/capistrano/configuration/null_filter.rb +9 -0
- data/lib/capistrano/configuration/plugin_installer.rb +51 -0
- data/lib/capistrano/configuration/question.rb +31 -9
- data/lib/capistrano/configuration/role_filter.rb +29 -0
- data/lib/capistrano/configuration/scm_resolver.rb +149 -0
- data/lib/capistrano/configuration/server.rb +29 -23
- data/lib/capistrano/configuration/servers.rb +21 -14
- data/lib/capistrano/configuration/validated_variables.rb +110 -0
- data/lib/capistrano/configuration/variables.rb +112 -0
- data/lib/capistrano/configuration.rb +91 -44
- data/lib/capistrano/defaults.rb +26 -4
- data/lib/capistrano/deploy.rb +1 -1
- 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/servers_doctor.rb +105 -0
- data/lib/capistrano/doctor/variables_doctor.rb +74 -0
- data/lib/capistrano/doctor.rb +6 -0
- data/lib/capistrano/dotfile.rb +1 -2
- data/lib/capistrano/dsl/env.rb +9 -47
- data/lib/capistrano/dsl/paths.rb +11 -25
- data/lib/capistrano/dsl/stages.rb +14 -2
- data/lib/capistrano/dsl/task_enhancements.rb +7 -12
- data/lib/capistrano/dsl.rb +47 -16
- data/lib/capistrano/framework.rb +1 -1
- data/lib/capistrano/i18n.rb +32 -24
- data/lib/capistrano/immutable_task.rb +30 -0
- data/lib/capistrano/install.rb +1 -1
- data/lib/capistrano/plugin.rb +95 -0
- data/lib/capistrano/proc_helpers.rb +13 -0
- data/lib/capistrano/scm/git.rb +100 -0
- data/lib/capistrano/scm/hg.rb +55 -0
- data/lib/capistrano/scm/plugin.rb +13 -0
- data/lib/capistrano/scm/svn.rb +56 -0
- data/lib/capistrano/scm/tasks/git.rake +73 -0
- data/lib/capistrano/scm/tasks/hg.rake +53 -0
- data/lib/capistrano/scm/tasks/svn.rake +53 -0
- data/lib/capistrano/scm.rb +7 -20
- data/lib/capistrano/setup.rb +20 -6
- data/lib/capistrano/tasks/console.rake +4 -8
- data/lib/capistrano/tasks/deploy.rake +105 -73
- data/lib/capistrano/tasks/doctor.rake +24 -0
- data/lib/capistrano/tasks/framework.rake +13 -14
- data/lib/capistrano/tasks/install.rake +14 -15
- data/lib/capistrano/templates/Capfile +21 -10
- data/lib/capistrano/templates/deploy.rb.erb +17 -26
- data/lib/capistrano/templates/stage.rb.erb +9 -9
- data/lib/capistrano/upload_task.rb +1 -1
- data/lib/capistrano/version.rb +1 -1
- data/lib/capistrano/version_validator.rb +5 -10
- data/spec/integration/dsl_spec.rb +289 -240
- data/spec/integration_spec_helper.rb +3 -5
- data/spec/lib/capistrano/application_spec.rb +23 -39
- data/spec/lib/capistrano/configuration/empty_filter_spec.rb +17 -0
- data/spec/lib/capistrano/configuration/filter_spec.rb +83 -85
- data/spec/lib/capistrano/configuration/host_filter_spec.rb +71 -0
- data/spec/lib/capistrano/configuration/null_filter_spec.rb +17 -0
- data/spec/lib/capistrano/configuration/plugin_installer_spec.rb +98 -0
- data/spec/lib/capistrano/configuration/question_spec.rb +58 -26
- data/spec/lib/capistrano/configuration/role_filter_spec.rb +80 -0
- data/spec/lib/capistrano/configuration/scm_resolver_spec.rb +55 -0
- data/spec/lib/capistrano/configuration/server_spec.rb +106 -113
- data/spec/lib/capistrano/configuration/servers_spec.rb +129 -145
- data/spec/lib/capistrano/configuration_spec.rb +224 -63
- data/spec/lib/capistrano/doctor/environment_doctor_spec.rb +44 -0
- data/spec/lib/capistrano/doctor/gems_doctor_spec.rb +67 -0
- data/spec/lib/capistrano/doctor/output_helpers_spec.rb +47 -0
- data/spec/lib/capistrano/doctor/servers_doctor_spec.rb +86 -0
- data/spec/lib/capistrano/doctor/variables_doctor_spec.rb +89 -0
- data/spec/lib/capistrano/dsl/paths_spec.rb +97 -59
- data/spec/lib/capistrano/dsl/task_enhancements_spec.rb +57 -37
- data/spec/lib/capistrano/dsl_spec.rb +84 -11
- data/spec/lib/capistrano/immutable_task_spec.rb +31 -0
- data/spec/lib/capistrano/plugin_spec.rb +84 -0
- data/spec/lib/capistrano/scm/git_spec.rb +184 -0
- data/spec/lib/capistrano/scm/hg_spec.rb +109 -0
- data/spec/lib/capistrano/scm/svn_spec.rb +137 -0
- data/spec/lib/capistrano/scm_spec.rb +7 -8
- data/spec/lib/capistrano/upload_task_spec.rb +7 -7
- data/spec/lib/capistrano/version_validator_spec.rb +61 -46
- data/spec/lib/capistrano_spec.rb +2 -3
- data/spec/spec_helper.rb +21 -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 +64 -39
- metadata +100 -55
- data/.travis.yml +0 -13
- data/features/remote_file_task.feature +0 -14
- data/lib/capistrano/git.rb +0 -46
- data/lib/capistrano/hg.rb +0 -43
- data/lib/capistrano/svn.rb +0 -38
- data/lib/capistrano/tasks/git.rake +0 -81
- data/lib/capistrano/tasks/hg.rake +0 -52
- data/lib/capistrano/tasks/svn.rake +0 -52
- data/spec/lib/capistrano/git_spec.rb +0 -81
- data/spec/lib/capistrano/hg_spec.rb +0 -81
- data/spec/lib/capistrano/svn_spec.rb +0 -79
@@ -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
|
-
describe
|
10
|
-
it
|
8
|
+
describe "#new" do
|
9
|
+
it "takes a version" do
|
11
10
|
expect(validator)
|
12
11
|
end
|
13
12
|
end
|
14
13
|
|
15
|
-
describe
|
16
|
-
let(:current_version) {
|
14
|
+
describe "#verify" do
|
15
|
+
let(:current_version) { "3.0.1" }
|
17
16
|
|
18
17
|
subject { validator.verify }
|
19
18
|
|
@@ -21,83 +20,99 @@ 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
92
|
|
97
|
-
|
93
|
+
context "with multiple versions" do
|
94
|
+
let(:current_version) { "3.5.9" }
|
98
95
|
|
99
|
-
|
96
|
+
context "valid" do
|
97
|
+
let(:version) { [">= 3.5.0", "< 3.5.10"] }
|
98
|
+
it { is_expected.to be_truthy }
|
99
|
+
end
|
100
100
|
|
101
|
-
|
101
|
+
context "invalid" do
|
102
|
+
let(:version) { [">= 3.5.0", "< 3.5.8"] }
|
103
|
+
it "fails" do
|
104
|
+
expect { subject }.to raise_error(RuntimeError)
|
105
|
+
end
|
106
|
+
end
|
102
107
|
|
108
|
+
context "invalid" do
|
109
|
+
let(:version) { ["> 3.5.9", "< 3.5.13"] }
|
110
|
+
it "fails" do
|
111
|
+
expect { subject }.to raise_error(RuntimeError)
|
112
|
+
end
|
113
|
+
end
|
114
|
+
end
|
115
|
+
end
|
116
|
+
end
|
117
|
+
end
|
103
118
|
end
|
data/spec/lib/capistrano_spec.rb
CHANGED
data/spec/spec_helper.rb
CHANGED
@@ -1,16 +1,29 @@
|
|
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
|
+
|
17
|
+
config.around(:example, capture_io: true) do |example|
|
18
|
+
begin
|
19
|
+
Rake.application.options.trace_output = StringIO.new
|
20
|
+
$stdout = StringIO.new
|
21
|
+
$stderr = StringIO.new
|
22
|
+
example.run
|
23
|
+
ensure
|
24
|
+
Rake.application.options.trace_output = STDERR
|
25
|
+
$stdout = STDOUT
|
26
|
+
$stderr = STDERR
|
27
|
+
end
|
28
|
+
end
|
16
29
|
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/bionic64"
|
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,15 +10,17 @@ module TestApp
|
|
9
10
|
end
|
10
11
|
|
11
12
|
def default_config
|
12
|
-
|
13
|
+
<<-CONFIG
|
13
14
|
set :deploy_to, '#{deploy_to}'
|
14
|
-
set :repo_url, '
|
15
|
+
set :repo_url, 'https://github.com/capistrano/capistrano.git'
|
15
16
|
set :branch, 'master'
|
16
17
|
set :ssh_options, { keys: "\#{ENV['HOME']}/.vagrant.d/insecure_private_key", auth_methods: ['publickey'] }
|
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
|
+
set :local_user, #{current_user.inspect}
|
23
|
+
CONFIG
|
21
24
|
end
|
22
25
|
|
23
26
|
def linked_files
|
@@ -29,45 +32,52 @@ module TestApp
|
|
29
32
|
end
|
30
33
|
|
31
34
|
def linked_dirs
|
32
|
-
%w{bin log public/system
|
35
|
+
%w{bin log public/system}
|
33
36
|
end
|
34
37
|
|
35
38
|
def create_test_app
|
36
39
|
FileUtils.rm_rf(test_app_path)
|
37
40
|
FileUtils.mkdir(test_app_path)
|
38
41
|
|
39
|
-
File.open(gemfile,
|
42
|
+
File.open(gemfile, "w+") do |file|
|
43
|
+
file.write "source 'https://rubygems.org'\n"
|
40
44
|
file.write "gem 'capistrano', path: '#{path_to_cap}'"
|
41
45
|
end
|
42
46
|
|
43
47
|
Dir.chdir(test_app_path) do
|
44
|
-
|
48
|
+
run "bundle"
|
45
49
|
end
|
46
50
|
end
|
47
51
|
|
48
52
|
def install_test_app_with(config)
|
49
53
|
create_test_app
|
50
54
|
Dir.chdir(test_app_path) do
|
51
|
-
|
55
|
+
run "cap install STAGES=#{stage}"
|
52
56
|
end
|
53
57
|
write_local_deploy_file(config)
|
54
58
|
end
|
55
59
|
|
56
60
|
def write_local_deploy_file(config)
|
57
|
-
File.open(test_stage_path,
|
61
|
+
File.open(test_stage_path, "w") do |file|
|
58
62
|
file.write config
|
59
63
|
end
|
60
64
|
end
|
61
65
|
|
66
|
+
def write_local_stage_file(filename, config=nil)
|
67
|
+
File.open(test_app_path.join("config/deploy/#{filename}"), "w") do |file|
|
68
|
+
file.write(config) if config
|
69
|
+
end
|
70
|
+
end
|
71
|
+
|
62
72
|
def append_to_deploy_file(config)
|
63
|
-
File.open(test_stage_path,
|
73
|
+
File.open(test_stage_path, "a") do |file|
|
64
74
|
file.write config + "\n"
|
65
75
|
end
|
66
76
|
end
|
67
77
|
|
68
78
|
def prepend_to_capfile(config)
|
69
79
|
current_capfile = File.read(capfile)
|
70
|
-
File.open(capfile,
|
80
|
+
File.open(capfile, "w") do |file|
|
71
81
|
file.write config
|
72
82
|
file.write current_capfile
|
73
83
|
end
|
@@ -78,79 +88,81 @@ module TestApp
|
|
78
88
|
end
|
79
89
|
|
80
90
|
def create_shared_file(path)
|
81
|
-
File.open(shared_path.join(path),
|
91
|
+
File.open(shared_path.join(path), "w")
|
82
92
|
end
|
83
93
|
|
84
|
-
def cap(task)
|
85
|
-
run "
|
94
|
+
def cap(task, subdirectory=nil)
|
95
|
+
run "cap #{stage} #{task} --trace", subdirectory
|
86
96
|
end
|
87
97
|
|
88
|
-
def run(command)
|
98
|
+
def run(command, subdirectory=nil)
|
89
99
|
output = nil
|
90
|
-
|
91
|
-
|
100
|
+
command = "bundle exec #{command}" unless command =~ /^bundle\b/
|
101
|
+
dir = subdirectory ? test_app_path.join(subdirectory) : test_app_path
|
102
|
+
Dir.chdir(dir) do
|
103
|
+
output = with_clean_bundler_env { `#{command}` }
|
92
104
|
end
|
93
|
-
[
|
105
|
+
[$CHILD_STATUS.success?, output]
|
94
106
|
end
|
95
107
|
|
96
108
|
def stage
|
97
|
-
|
109
|
+
"test"
|
98
110
|
end
|
99
111
|
|
100
112
|
def test_stage_path
|
101
|
-
test_app_path.join(
|
113
|
+
test_app_path.join("config/deploy/test.rb")
|
102
114
|
end
|
103
115
|
|
104
116
|
def test_app_path
|
105
|
-
Pathname.new(
|
117
|
+
Pathname.new("/tmp/test_app")
|
106
118
|
end
|
107
119
|
|
108
120
|
def deploy_to
|
109
|
-
Pathname.new(
|
121
|
+
Pathname.new("/home/vagrant/var/www/deploy")
|
110
122
|
end
|
111
123
|
|
112
124
|
def shared_path
|
113
|
-
deploy_to.join(
|
125
|
+
deploy_to.join("shared")
|
114
126
|
end
|
115
127
|
|
116
128
|
def current_path
|
117
|
-
deploy_to.join(
|
129
|
+
deploy_to.join("current")
|
118
130
|
end
|
119
131
|
|
120
132
|
def releases_path
|
121
|
-
deploy_to.join(
|
133
|
+
deploy_to.join("releases")
|
122
134
|
end
|
123
135
|
|
124
|
-
def release_path
|
125
|
-
releases_path.join(
|
136
|
+
def release_path(t=timestamp)
|
137
|
+
releases_path.join(t)
|
126
138
|
end
|
127
139
|
|
128
|
-
def timestamp
|
129
|
-
Time.now.utc.strftime("%Y%m%d%H%M%S")
|
140
|
+
def timestamp(offset=0)
|
141
|
+
(Time.now.utc + offset).strftime("%Y%m%d%H%M%S")
|
130
142
|
end
|
131
143
|
|
132
144
|
def repo_path
|
133
|
-
deploy_to.join(
|
145
|
+
deploy_to.join("repo")
|
134
146
|
end
|
135
147
|
|
136
148
|
def path_to_cap
|
137
|
-
File.expand_path(
|
149
|
+
File.expand_path(".")
|
138
150
|
end
|
139
151
|
|
140
152
|
def gemfile
|
141
|
-
test_app_path.join(
|
153
|
+
test_app_path.join("Gemfile")
|
142
154
|
end
|
143
155
|
|
144
156
|
def capfile
|
145
|
-
test_app_path.join(
|
157
|
+
test_app_path.join("Capfile")
|
146
158
|
end
|
147
159
|
|
148
160
|
def current_user
|
149
|
-
|
161
|
+
"(GitHub Web Flow) via ShipIt"
|
150
162
|
end
|
151
163
|
|
152
164
|
def task_dir
|
153
|
-
test_app_path.join(
|
165
|
+
test_app_path.join("lib/capistrano/tasks")
|
154
166
|
end
|
155
167
|
|
156
168
|
def copy_task_to_test_app(source)
|
@@ -158,15 +170,15 @@ module TestApp
|
|
158
170
|
end
|
159
171
|
|
160
172
|
def config_path
|
161
|
-
test_app_path.join(
|
173
|
+
test_app_path.join("config")
|
162
174
|
end
|
163
175
|
|
164
176
|
def move_configuration_to_custom_location(location)
|
165
177
|
prepend_to_capfile(
|
166
|
-
|
178
|
+
<<-CONFIG
|
167
179
|
set :stage_config_path, "app/config/deploy"
|
168
180
|
set :deploy_config_path, "app/config/deploy.rb"
|
169
|
-
|
181
|
+
CONFIG
|
170
182
|
)
|
171
183
|
|
172
184
|
location = test_app_path.join(location)
|
@@ -174,4 +186,17 @@ module TestApp
|
|
174
186
|
FileUtils.mv(config_path, location)
|
175
187
|
end
|
176
188
|
|
189
|
+
def git_wrapper_path_glob
|
190
|
+
"/tmp/git-ssh-*.sh"
|
191
|
+
end
|
192
|
+
|
193
|
+
def with_clean_bundler_env(&block)
|
194
|
+
return yield unless defined?(Bundler)
|
195
|
+
|
196
|
+
if Bundler.respond_to?(:with_unbundled_env)
|
197
|
+
Bundler.with_unbundled_env(&block)
|
198
|
+
else
|
199
|
+
Bundler.with_clean_env(&block)
|
200
|
+
end
|
201
|
+
end
|
177
202
|
end
|