whiskey_disk 0.6.16 → 0.6.17
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG +28 -0
- data/README.markdown +23 -6
- data/VERSION +1 -1
- data/bin/wd +18 -3
- data/lib/whiskey_disk/config.rb +4 -0
- data/lib/whiskey_disk.rb +18 -9
- data/spec/spec_helper.rb +6 -4
- data/spec/wd_command_spec.rb +90 -1
- data/spec/whiskey_disk/config_spec.rb +37 -0
- data/spec/whiskey_disk_spec.rb +125 -70
- data/whiskey_disk.gemspec +2 -2
- metadata +4 -4
data/CHANGELOG
CHANGED
@@ -1,4 +1,32 @@
|
|
1
1
|
|
2
|
+
0.6.17 / 2011-03-25
|
3
|
+
==================
|
4
|
+
|
5
|
+
* updating contributor info in README
|
6
|
+
* updating specs to pass under new --debug regime
|
7
|
+
* deployment status message shouldn't appear in spec run output
|
8
|
+
* Refactoring WhiskeyDisk.reset in whiskey_disk_spec.rb
|
9
|
+
* spec helper should keep debugging on for test runs
|
10
|
+
* Make deployment status message more readable
|
11
|
+
* Only run post deploy|setup script with -x in debug mode
|
12
|
+
* Only rake --trace in debug mode
|
13
|
+
* Suppressing git output unless debug mode
|
14
|
+
* Adding log mesage for rsync configuration
|
15
|
+
* Only show rsync verbose and progress if debug enabled
|
16
|
+
* Print out a log message to indicate which host is currently being deployed
|
17
|
+
* Only run set -x in debug mode, also don't use bash -c
|
18
|
+
* Refactor a spec to use build_command directly
|
19
|
+
* Fix spec description for ENV['debug']
|
20
|
+
* Only run ssh with -v if in debug mode
|
21
|
+
* Refactor run to use a #ssh command
|
22
|
+
* Add WhiskeyDisk::Config.debug?
|
23
|
+
* Add -d, --debug to bin/wd
|
24
|
+
* change raise to abort for cleaner help output when doing `wd -h`
|
25
|
+
* change raise to abort for cleaner help output
|
26
|
+
* add --version option to wd
|
27
|
+
* Add support section to README
|
28
|
+
|
29
|
+
|
2
30
|
0.6.16 / 2011-03-08
|
3
31
|
==================
|
4
32
|
|
data/README.markdown
CHANGED
@@ -439,6 +439,13 @@ are in an environment where the 'app' role is active but the 'web' role is not:
|
|
439
439
|
% wd deploy --to=foo:qa --path=https://github.com/username/project/raw/master/path/to/configs/deploy.yml
|
440
440
|
% wd deploy --to=foo:qa --only=myhost.example.com
|
441
441
|
|
442
|
+
% wd --help
|
443
|
+
% wd --version
|
444
|
+
|
445
|
+
|
446
|
+
|
447
|
+
Also, `--debug` can be used to enable verbose output when running `wd setup` or `wd deploy`.
|
448
|
+
|
442
449
|
Note that the wd command (unlike rake, which requires a Rakefile in the current directory) can be run from anywhere, so you can deploy any project, working from any path, and can even specify where to find the deployment YAML configuration file.
|
443
450
|
|
444
451
|
The --path argument can take either a file or a directory. When given a file it will use that file as the configuration file. When given a directory it will look in that directory for deploy/<project>/<target>.yml, then deploy/<project>.yml, then deploy/<target>.yml, then <target>.yml, and finally, deploy.yml.
|
@@ -757,12 +764,22 @@ to see what we have in mind for the near future.
|
|
757
764
|
- [http://github.com/mislav/git-deploy](http://github.com/mislav/git-deploy)
|
758
765
|
- [http://toroid.org/ams/git-website-howto](http://toroid.org/ams/git-website-howto)
|
759
766
|
|
767
|
+
### Support ###
|
768
|
+
|
769
|
+
The [bug tracker](https://github.com/flogic/whiskey_disk/issues)
|
770
|
+
is available here:
|
771
|
+
|
772
|
+
- [https://github.com/flogic/whiskey_disk/issues](https://github.com/flogic/whiskey_disk/issues)
|
773
|
+
|
774
|
+
The IRC channel is #whiskey_disk on freenode.
|
760
775
|
|
761
776
|
### Contributors ###
|
762
777
|
|
763
|
-
- Rick Bradley
|
764
|
-
-
|
765
|
-
-
|
766
|
-
-
|
767
|
-
-
|
768
|
-
-
|
778
|
+
- [Rick Bradley](https://github.com/rick): author
|
779
|
+
- [Rein Henrichs](https://github.com/reinh): design help, code
|
780
|
+
- [Jeremy Holland](https://github.com/awebneck): code
|
781
|
+
- [Kevin Barnes](https://github.com/vinbarnes): design help, code
|
782
|
+
- [Alex Sharp](https://github.com/ajsharp): issues, real-world usage cases, design help
|
783
|
+
- [Yossef Mendelssohn](https://github.com/ymendel): design help, proofreading
|
784
|
+
- [Josh Moore](https://github.com/joshsmoore): bug-hunting
|
785
|
+
- [Cristi Balan](https://github.com/evilchelu): feedback, proofreading
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.6.
|
1
|
+
0.6.17
|
data/bin/wd
CHANGED
@@ -22,13 +22,27 @@ op = OptionParser.new do |opts|
|
|
22
22
|
opts.on('-c', '--check', "do a staleness check before deploying") do |path|
|
23
23
|
options[:check] = 'true'
|
24
24
|
end
|
25
|
+
|
26
|
+
opts.on('-d', '--debug', "turn on debug mode (ssh -v and rake --trace)") do
|
27
|
+
options[:debug] = 'true'
|
28
|
+
end
|
25
29
|
|
30
|
+
opts.on('--version', 'show current version') do
|
31
|
+
puts File.read(File.expand_path(File.join(File.dirname(__FILE__), '..', 'VERSION')))
|
32
|
+
exit 0
|
33
|
+
end
|
34
|
+
|
26
35
|
opts.on_tail('-h', '--help', 'show this message') do
|
27
|
-
|
36
|
+
abort opts.to_s
|
28
37
|
end
|
29
38
|
end
|
30
39
|
|
31
|
-
|
40
|
+
begin
|
41
|
+
rest = op.parse(ARGV)
|
42
|
+
rescue
|
43
|
+
abort op.to_s
|
44
|
+
end
|
45
|
+
|
32
46
|
raise op.to_s unless options[:target]
|
33
47
|
raise op.to_s unless rest and rest.size == 1
|
34
48
|
command = rest.first
|
@@ -38,9 +52,10 @@ ENV['to'] = options[:target]
|
|
38
52
|
ENV['path'] = options[:path]
|
39
53
|
ENV['only'] = options[:only]
|
40
54
|
ENV['check'] = options[:check]
|
55
|
+
ENV['debug'] = options[:debug]
|
41
56
|
|
42
57
|
if command == 'deploy'
|
43
58
|
Rake::Task['deploy:now'].invoke
|
44
59
|
else
|
45
60
|
Rake::Task['deploy:setup'].invoke
|
46
|
-
end
|
61
|
+
end
|
data/lib/whiskey_disk/config.rb
CHANGED
@@ -28,6 +28,10 @@ class WhiskeyDisk
|
|
28
28
|
def check_staleness?
|
29
29
|
!!(ENV['check'] && ENV['check'] =~ /^(?:t(?:rue)?|y(?:es)?|1)$/)
|
30
30
|
end
|
31
|
+
|
32
|
+
def debug?
|
33
|
+
!!(ENV['debug'] && ENV['debug'] =~ /^(?:t(?:rue)?|y(?:es)?|1)$/)
|
34
|
+
end
|
31
35
|
|
32
36
|
def domain_limit
|
33
37
|
return false unless ENV['only'] and ENV['only'] != ''
|
data/lib/whiskey_disk.rb
CHANGED
@@ -129,11 +129,17 @@ class WhiskeyDisk
|
|
129
129
|
end
|
130
130
|
|
131
131
|
def build_command(domain, cmd)
|
132
|
-
"set -x; " + encode_roles(domain[:roles]) + cmd
|
132
|
+
"#{'set -x; ' if Config.debug?}" + encode_roles(domain[:roles]) + cmd
|
133
133
|
end
|
134
134
|
|
135
135
|
def run(domain, cmd)
|
136
|
-
|
136
|
+
ssh(domain, cmd)
|
137
|
+
end
|
138
|
+
|
139
|
+
def ssh(domain, cmd)
|
140
|
+
args = [domain[:name], build_command(domain, cmd)]
|
141
|
+
args.unshift '-v' if Config.debug?
|
142
|
+
system('ssh', *args)
|
137
143
|
end
|
138
144
|
|
139
145
|
def shell(domain, cmd)
|
@@ -144,6 +150,7 @@ class WhiskeyDisk
|
|
144
150
|
needs(:domain)
|
145
151
|
self[:domain].each do |domain|
|
146
152
|
next unless domain_of_interest?(domain[:name])
|
153
|
+
puts "Deploying #{domain[:name]}..."
|
147
154
|
status = remote?(domain[:name]) ? run(domain, bundle) : shell(domain, bundle)
|
148
155
|
record_result(domain[:name], status)
|
149
156
|
end
|
@@ -202,15 +209,16 @@ class WhiskeyDisk
|
|
202
209
|
|
203
210
|
def refresh_checkout(path, repo_branch)
|
204
211
|
enqueue "cd #{path}"
|
205
|
-
enqueue "git fetch origin +refs/heads/#{repo_branch}:refs/remotes/origin/#{repo_branch}"
|
206
|
-
enqueue "git checkout #{repo_branch}"
|
207
|
-
enqueue "git reset --hard origin/#{repo_branch}"
|
212
|
+
enqueue "git fetch origin +refs/heads/#{repo_branch}:refs/remotes/origin/#{repo_branch} #{'&>/dev/null' unless Config.debug?}"
|
213
|
+
enqueue "git checkout #{repo_branch} #{'&>/dev/null' unless Config.debug?}"
|
214
|
+
enqueue "git reset --hard origin/#{repo_branch} #{'&>/dev/null' unless Config.debug?}"
|
208
215
|
end
|
209
216
|
|
210
217
|
def run_rake_task(path, task_name)
|
218
|
+
enqueue "echo Running rake #{task_name}..."
|
211
219
|
enqueue "cd #{path}"
|
212
220
|
enqueue(if_file_present("#{self[:deploy_to]}/Rakefile",
|
213
|
-
if_task_defined(task_name, "#{env_vars} rake --trace #{task_name} to=#{self[:environment]}")))
|
221
|
+
if_task_defined(task_name, "#{env_vars} rake #{'--trace' if Config.debug?} #{task_name} to=#{self[:environment]}")))
|
214
222
|
end
|
215
223
|
|
216
224
|
def build_path(path)
|
@@ -220,7 +228,7 @@ class WhiskeyDisk
|
|
220
228
|
|
221
229
|
def run_script(script)
|
222
230
|
return unless script
|
223
|
-
enqueue(%Q<cd #{self[:deploy_to]}; echo "Running post script..."; #{env_vars} bash -x #{build_path(script)}>)
|
231
|
+
enqueue(%Q<cd #{self[:deploy_to]}; echo "Running post script..."; #{env_vars} bash #{'-x' if Config.debug?} #{build_path(script)}>)
|
224
232
|
end
|
225
233
|
|
226
234
|
def ensure_main_parent_path_is_present
|
@@ -256,7 +264,8 @@ class WhiskeyDisk
|
|
256
264
|
def refresh_configuration
|
257
265
|
needs(:deploy_to, :deploy_config_to)
|
258
266
|
raise "Must specify project name when using a configuration repository." unless project_name_specified?
|
259
|
-
enqueue
|
267
|
+
enqueue "echo Rsyncing configuration..."
|
268
|
+
enqueue("rsync -a#{'v --progress' if Config.debug?} #{self[:deploy_config_to]}/#{self[:project]}/#{self[:config_target]}/ #{self[:deploy_to]}/")
|
260
269
|
end
|
261
270
|
|
262
271
|
def run_post_setup_hooks
|
@@ -271,4 +280,4 @@ class WhiskeyDisk
|
|
271
280
|
run_rake_task(self[:deploy_to], "deploy:post_deploy")
|
272
281
|
end
|
273
282
|
end
|
274
|
-
end
|
283
|
+
end
|
data/spec/spec_helper.rb
CHANGED
@@ -24,10 +24,11 @@ def setup_deployment_area
|
|
24
24
|
end
|
25
25
|
|
26
26
|
# run a wd setup using the provided arguments string
|
27
|
-
def run_setup(arguments)
|
27
|
+
def run_setup(arguments, debugging = true)
|
28
28
|
wd_path = File.join(File.dirname(__FILE__), '..', 'bin', 'wd')
|
29
29
|
lib_path = File.join(File.dirname(__FILE__), '..', 'lib')
|
30
|
-
|
30
|
+
debug = debugging ? '--debug' : ''
|
31
|
+
system("/usr/bin/env ruby -I #{lib_path} -r whiskey_disk -rubygems #{wd_path} setup #{debug} #{arguments} > #{integration_log} 2> #{integration_log}")
|
31
32
|
end
|
32
33
|
|
33
34
|
def integration_log
|
@@ -35,10 +36,11 @@ def integration_log
|
|
35
36
|
end
|
36
37
|
|
37
38
|
# run a wd setup using the provided arguments string
|
38
|
-
def run_deploy(arguments)
|
39
|
+
def run_deploy(arguments, debugging = true)
|
39
40
|
wd_path = File.join(File.dirname(__FILE__), '..', 'bin', 'wd')
|
40
41
|
lib_path = File.join(File.dirname(__FILE__), '..', 'lib')
|
41
|
-
|
42
|
+
debug = debugging ? '--debug' : ''
|
43
|
+
status = system("/usr/bin/env ruby -I #{lib_path} -r whiskey_disk -rubygems #{wd_path} deploy #{debug} #{arguments} > #{integration_log} 2> #{integration_log}")
|
42
44
|
status
|
43
45
|
end
|
44
46
|
|
data/spec/wd_command_spec.rb
CHANGED
@@ -25,6 +25,20 @@ describe 'wd command' do
|
|
25
25
|
lambda { run_command }.should.raise
|
26
26
|
end
|
27
27
|
end
|
28
|
+
|
29
|
+
it 'should output usage without a backtrace when --help is specified' do
|
30
|
+
Object.send(:remove_const, :ARGV)
|
31
|
+
ARGV = ['--help']
|
32
|
+
self.stub!(:abort).and_raise(SystemExit) # primarily to drop extraneous output
|
33
|
+
lambda { run_command }.should.raise(SystemExit)
|
34
|
+
end
|
35
|
+
|
36
|
+
it 'should output usage without a backtrace when garbage options are specified' do
|
37
|
+
Object.send(:remove_const, :ARGV)
|
38
|
+
ARGV = ['--slkjfsdflkj']
|
39
|
+
self.stub!(:abort).and_raise(SystemExit) # primarily to drop extraneous output
|
40
|
+
lambda { run_command }.should.raise(SystemExit)
|
41
|
+
end
|
28
42
|
|
29
43
|
describe "when the 'setup' command is specified" do
|
30
44
|
before do
|
@@ -42,6 +56,7 @@ describe 'wd command' do
|
|
42
56
|
lambda { run_command }.should.raise
|
43
57
|
end
|
44
58
|
end
|
59
|
+
|
45
60
|
|
46
61
|
describe 'and a --to argument is specified' do
|
47
62
|
before do
|
@@ -184,6 +199,80 @@ describe 'wd command' do
|
|
184
199
|
lambda { run_command }.should.not.raise
|
185
200
|
end
|
186
201
|
end
|
202
|
+
|
203
|
+
describe 'and a --debug argument is specified' do
|
204
|
+
before do
|
205
|
+
ARGV.push '--debug'
|
206
|
+
end
|
207
|
+
|
208
|
+
it 'should run the deploy:now rake task' do
|
209
|
+
@rake.should.receive(:invoke)
|
210
|
+
run_command
|
211
|
+
end
|
212
|
+
|
213
|
+
it 'should make the specified target available as a "debug" argument to the rake task' do
|
214
|
+
run_command
|
215
|
+
ENV['debug'].should == 'true'
|
216
|
+
end
|
217
|
+
|
218
|
+
it 'should fail if the rake task fails' do
|
219
|
+
@rake.stub!(:invoke).and_raise(RuntimeError)
|
220
|
+
lambda { run_command }.should.raise
|
221
|
+
end
|
222
|
+
|
223
|
+
it 'should not fail if the rake task succeeds' do
|
224
|
+
@rake.stub!(:invoke).and_return(true)
|
225
|
+
lambda { run_command }.should.not.raise
|
226
|
+
end
|
227
|
+
end
|
228
|
+
|
229
|
+
describe 'and a -d argument is specified' do
|
230
|
+
before do
|
231
|
+
ARGV.push '-d'
|
232
|
+
end
|
233
|
+
|
234
|
+
it 'should run the deploy:now rake task' do
|
235
|
+
@rake.should.receive(:invoke)
|
236
|
+
run_command
|
237
|
+
end
|
238
|
+
|
239
|
+
it 'should make the specified target available as a "debug" argument to the rake task' do
|
240
|
+
run_command
|
241
|
+
ENV['debug'].should == 'true'
|
242
|
+
end
|
243
|
+
|
244
|
+
it 'should fail if the rake task fails' do
|
245
|
+
@rake.stub!(:invoke).and_raise(RuntimeError)
|
246
|
+
lambda { run_command }.should.raise
|
247
|
+
end
|
248
|
+
|
249
|
+
it 'should not fail if the rake task succeeds' do
|
250
|
+
@rake.stub!(:invoke).and_return(true)
|
251
|
+
lambda { run_command }.should.not.raise
|
252
|
+
end
|
253
|
+
end
|
254
|
+
|
255
|
+
describe 'and no --debug or -d argument is specified' do
|
256
|
+
it 'should not make a "debug" argument available to the rake task' do
|
257
|
+
run_command
|
258
|
+
ENV['debug'].should.be.nil
|
259
|
+
end
|
260
|
+
|
261
|
+
it 'should run the deploy:now rake task' do
|
262
|
+
@rake.should.receive(:invoke)
|
263
|
+
run_command
|
264
|
+
end
|
265
|
+
|
266
|
+
it 'should fail if the rake task fails' do
|
267
|
+
@rake.stub!(:invoke).and_raise(RuntimeError)
|
268
|
+
lambda { run_command }.should.raise
|
269
|
+
end
|
270
|
+
|
271
|
+
it 'should not fail if the rake task succeeds' do
|
272
|
+
@rake.stub!(:invoke).and_return(true)
|
273
|
+
lambda { run_command }.should.not.raise
|
274
|
+
end
|
275
|
+
end
|
187
276
|
end
|
188
277
|
|
189
278
|
describe 'and a -t argument is specified' do
|
@@ -790,4 +879,4 @@ describe 'wd command' do
|
|
790
879
|
lambda { run_command }.should.raise
|
791
880
|
end
|
792
881
|
end
|
793
|
-
end
|
882
|
+
end
|
@@ -107,6 +107,43 @@ describe WhiskeyDisk::Config do
|
|
107
107
|
end
|
108
108
|
end
|
109
109
|
|
110
|
+
describe 'when determining whether to turn debug mode on' do
|
111
|
+
it 'should return false when there is no ENV["debug"] setting' do
|
112
|
+
ENV['debug'] = nil
|
113
|
+
WhiskeyDisk::Config.debug?.should == false
|
114
|
+
end
|
115
|
+
|
116
|
+
it 'should return false when the ENV["debug"] setting is blank' do
|
117
|
+
ENV['debug'] = ''
|
118
|
+
WhiskeyDisk::Config.debug?.should == false
|
119
|
+
end
|
120
|
+
|
121
|
+
it 'should return true if the ENV["debug"] setting is "t"' do
|
122
|
+
ENV['debug'] = 't'
|
123
|
+
WhiskeyDisk::Config.debug?.should == true
|
124
|
+
end
|
125
|
+
|
126
|
+
it 'should return true if the ENV["debug"] setting is "true"' do
|
127
|
+
ENV['debug'] = 'true'
|
128
|
+
WhiskeyDisk::Config.debug?.should == true
|
129
|
+
end
|
130
|
+
|
131
|
+
it 'should return true if the ENV["debug"] setting is "y"' do
|
132
|
+
ENV['debug'] = 'y'
|
133
|
+
WhiskeyDisk::Config.debug?.should == true
|
134
|
+
end
|
135
|
+
|
136
|
+
it 'should return true if the ENV["debug"] setting is "yes"' do
|
137
|
+
ENV['debug'] = 'yes'
|
138
|
+
WhiskeyDisk::Config.debug?.should == true
|
139
|
+
end
|
140
|
+
|
141
|
+
it 'should return true if the ENV["debug"] setting is "1"' do
|
142
|
+
ENV['debug'] = '1'
|
143
|
+
WhiskeyDisk::Config.debug?.should == true
|
144
|
+
end
|
145
|
+
end
|
146
|
+
|
110
147
|
describe 'when fetching configuration' do
|
111
148
|
describe 'and path specified is an URL' do
|
112
149
|
before do
|
data/spec/whiskey_disk_spec.rb
CHANGED
@@ -39,6 +39,10 @@ describe 'requiring the main library' do
|
|
39
39
|
end
|
40
40
|
|
41
41
|
describe 'WhiskeyDisk' do
|
42
|
+
before do
|
43
|
+
WhiskeyDisk.reset
|
44
|
+
end
|
45
|
+
|
42
46
|
describe 'determining if the deployment is remote' do
|
43
47
|
before do
|
44
48
|
@parameters = { 'deploy_to' => '/path/to/main/repo' }
|
@@ -131,7 +135,6 @@ describe 'WhiskeyDisk' do
|
|
131
135
|
|
132
136
|
describe 'enabling staleness checks' do
|
133
137
|
it 'should ensure that staleness checks are activated' do
|
134
|
-
WhiskeyDisk.reset
|
135
138
|
WhiskeyDisk.enable_staleness_checks
|
136
139
|
WhiskeyDisk.staleness_checks_enabled?.should == true
|
137
140
|
end
|
@@ -139,12 +142,10 @@ describe 'WhiskeyDisk' do
|
|
139
142
|
|
140
143
|
describe 'when checking staleness checks' do
|
141
144
|
it 'should return false if staleness checks have not been enabled' do
|
142
|
-
WhiskeyDisk.reset
|
143
145
|
WhiskeyDisk.staleness_checks_enabled?.should == false
|
144
146
|
end
|
145
147
|
|
146
148
|
it 'should return true if staleness checks have been enabled' do
|
147
|
-
WhiskeyDisk.reset
|
148
149
|
WhiskeyDisk.enable_staleness_checks
|
149
150
|
WhiskeyDisk.staleness_checks_enabled?.should == true
|
150
151
|
end
|
@@ -411,6 +412,7 @@ describe 'WhiskeyDisk' do
|
|
411
412
|
describe 'running post setup hooks' do
|
412
413
|
before do
|
413
414
|
WhiskeyDisk.configuration = { 'deploy_to' => '/path/to/main/repo' }
|
415
|
+
ENV['debug'] = nil
|
414
416
|
end
|
415
417
|
|
416
418
|
it 'should fail if the deployment path is not specified' do
|
@@ -426,53 +428,67 @@ describe 'WhiskeyDisk' do
|
|
426
428
|
describe 'when a post setup script is specified' do
|
427
429
|
describe 'and the script path does not start with a "/"' do
|
428
430
|
before do
|
429
|
-
WhiskeyDisk.configuration = { 'deploy_to' => '/path/to/main/repo', 'post_setup_script' => '
|
431
|
+
WhiskeyDisk.configuration = { 'deploy_to' => '/path/to/main/repo', 'post_setup_script' => 'path/to/setup/script', 'rake_env' => { 'FOO' => 'BAR' } }
|
430
432
|
end
|
431
433
|
|
432
|
-
it 'should
|
434
|
+
it 'should cd to the deploy_to path prior to running the script' do
|
433
435
|
WhiskeyDisk.run_post_setup_hooks
|
434
|
-
WhiskeyDisk.buffer.join(' ').should.match(%r{
|
436
|
+
WhiskeyDisk.buffer.join(' ').should.match(%r{cd /path/to/main/repo;.*bash /path/to/main/repo/path/to/setup/script})
|
437
|
+
end
|
438
|
+
|
439
|
+
it 'should attempt to run the post setup script with the deployment path prepended' do
|
440
|
+
WhiskeyDisk.run_post_setup_hooks
|
441
|
+
WhiskeyDisk.buffer.join(' ').should.match(%r{bash /path/to/main/repo/path/to/setup/script})
|
435
442
|
end
|
436
443
|
|
437
444
|
it 'should pass any environment variables when running the post setup script' do
|
438
445
|
WhiskeyDisk.run_post_setup_hooks
|
439
|
-
WhiskeyDisk.buffer.join(' ').should.match(%r{FOO='BAR' bash
|
446
|
+
WhiskeyDisk.buffer.join(' ').should.match(%r{FOO='BAR' bash /path/to/main/repo/path/to/setup/script})
|
440
447
|
end
|
441
448
|
|
442
|
-
it 'should
|
449
|
+
it 'should enable shell verbosity when debugging is enabled' do
|
450
|
+
ENV['debug'] = 'true'
|
443
451
|
WhiskeyDisk.run_post_setup_hooks
|
444
|
-
WhiskeyDisk.buffer.join(' ').should.match(%r{
|
452
|
+
WhiskeyDisk.buffer.join(' ').should.match(%r{bash -x /path/to/main/repo/path/to/setup/script})
|
445
453
|
end
|
446
|
-
|
447
|
-
it 'should
|
454
|
+
|
455
|
+
it 'should disable shell verbosity when debugging is not enabled' do
|
456
|
+
ENV['debug'] = 'false'
|
448
457
|
WhiskeyDisk.run_post_setup_hooks
|
449
|
-
WhiskeyDisk.buffer.join(' ').should.match(%r{bash
|
458
|
+
WhiskeyDisk.buffer.join(' ').should.match(%r{bash /path/to/main/repo/path/to/setup/script})
|
450
459
|
end
|
451
460
|
end
|
452
461
|
|
453
|
-
describe 'and the script path
|
462
|
+
describe 'and the script path starts with a "/"' do
|
454
463
|
before do
|
455
|
-
WhiskeyDisk.configuration = { 'deploy_to' => '/path/to/main/repo', 'post_setup_script' => 'path/to/setup/script', 'rake_env' => { 'FOO' => 'BAR' } }
|
464
|
+
WhiskeyDisk.configuration = { 'deploy_to' => '/path/to/main/repo', 'post_setup_script' => '/path/to/setup/script', 'rake_env' => { 'FOO' => 'BAR' } }
|
456
465
|
end
|
457
466
|
|
458
|
-
it 'should
|
467
|
+
it 'should cd to the deploy_to path prior to running the script' do
|
459
468
|
WhiskeyDisk.run_post_setup_hooks
|
460
|
-
WhiskeyDisk.buffer.join(' ').should.match(%r{
|
469
|
+
WhiskeyDisk.buffer.join(' ').should.match(%r{cd /path/to/main/repo;.*bash /path/to/setup/script})
|
461
470
|
end
|
462
471
|
|
472
|
+
it 'should run the post setup script using its absolute path' do
|
473
|
+
WhiskeyDisk.run_post_setup_hooks
|
474
|
+
WhiskeyDisk.buffer.join(' ').should.match(%r{bash /path/to/setup/script})
|
475
|
+
end
|
476
|
+
|
463
477
|
it 'should pass any environment variables when running the post setup script' do
|
464
478
|
WhiskeyDisk.run_post_setup_hooks
|
465
|
-
WhiskeyDisk.buffer.join(' ').should.match(%r{FOO='BAR' bash
|
479
|
+
WhiskeyDisk.buffer.join(' ').should.match(%r{FOO='BAR' bash /path/to/setup/script})
|
466
480
|
end
|
467
481
|
|
468
|
-
it 'should
|
482
|
+
it 'should enable shell verbosity when debugging is enabled' do
|
483
|
+
ENV['debug'] = 'true'
|
469
484
|
WhiskeyDisk.run_post_setup_hooks
|
470
|
-
WhiskeyDisk.buffer.join(' ').should.match(%r{
|
485
|
+
WhiskeyDisk.buffer.join(' ').should.match(%r{bash -x /path/to/setup/script})
|
471
486
|
end
|
472
|
-
|
473
|
-
it 'should
|
487
|
+
|
488
|
+
it 'should disable shell verbosity when debugging is not enabled' do
|
489
|
+
ENV['debug'] = 'false'
|
474
490
|
WhiskeyDisk.run_post_setup_hooks
|
475
|
-
WhiskeyDisk.buffer.join(' ').should.match(%r{bash
|
491
|
+
WhiskeyDisk.buffer.join(' ').should.match(%r{bash /path/to/setup/script})
|
476
492
|
end
|
477
493
|
end
|
478
494
|
end
|
@@ -519,6 +535,7 @@ describe 'WhiskeyDisk' do
|
|
519
535
|
describe 'running post deployment hooks' do
|
520
536
|
before do
|
521
537
|
WhiskeyDisk.configuration = { 'deploy_to' => '/path/to/main/repo' }
|
538
|
+
ENV['debug'] = nil
|
522
539
|
end
|
523
540
|
|
524
541
|
it 'should fail if the deployment path is not specified' do
|
@@ -534,53 +551,67 @@ describe 'WhiskeyDisk' do
|
|
534
551
|
describe 'when a post deployment script is specified' do
|
535
552
|
describe 'and the script path does not start with a "/"' do
|
536
553
|
before do
|
537
|
-
WhiskeyDisk.configuration = { 'deploy_to' => '/path/to/main/repo', 'post_deploy_script' => '
|
554
|
+
WhiskeyDisk.configuration = { 'deploy_to' => '/path/to/main/repo', 'post_deploy_script' => 'path/to/deployment/script', 'rake_env' => { 'FOO' => 'BAR' } }
|
538
555
|
end
|
539
556
|
|
540
|
-
it 'should
|
557
|
+
it 'should cd to the deploy_to path prior to running the script' do
|
558
|
+
WhiskeyDisk.run_post_deploy_hooks
|
559
|
+
WhiskeyDisk.buffer.join(' ').should.match(%r{cd /path/to/main/repo;.*bash /path/to/main/repo/path/to/deployment/script})
|
560
|
+
end
|
561
|
+
|
562
|
+
it 'should attempt to run the post deployment script with the deployment path prepended' do
|
541
563
|
WhiskeyDisk.run_post_deploy_hooks
|
542
|
-
WhiskeyDisk.buffer.join(' ').should.match(%r{bash
|
564
|
+
WhiskeyDisk.buffer.join(' ').should.match(%r{bash /path/to/main/repo/path/to/deployment/script})
|
543
565
|
end
|
544
566
|
|
545
567
|
it 'should pass any environment variables when running the post deploy script' do
|
546
568
|
WhiskeyDisk.run_post_deploy_hooks
|
547
|
-
WhiskeyDisk.buffer.join(' ').should.match(%r{FOO='BAR' bash
|
569
|
+
WhiskeyDisk.buffer.join(' ').should.match(%r{FOO='BAR' bash /path/to/main/repo/path/to/deployment/script})
|
548
570
|
end
|
549
571
|
|
550
|
-
it 'should
|
572
|
+
it 'should enable shell verbosity when debugging is enabled' do
|
573
|
+
ENV['debug'] = 'true'
|
551
574
|
WhiskeyDisk.run_post_deploy_hooks
|
552
|
-
WhiskeyDisk.buffer.join(' ').should.match(%r{
|
575
|
+
WhiskeyDisk.buffer.join(' ').should.match(%r{bash -x /path/to/main/repo/path/to/deployment/script})
|
553
576
|
end
|
554
|
-
|
555
|
-
it 'should
|
577
|
+
|
578
|
+
it 'should disable shell verbosity when debugging is not enabled' do
|
579
|
+
ENV['debug'] = 'false'
|
556
580
|
WhiskeyDisk.run_post_deploy_hooks
|
557
|
-
WhiskeyDisk.buffer.join(' ').should.match(%r{bash
|
581
|
+
WhiskeyDisk.buffer.join(' ').should.match(%r{bash /path/to/main/repo/path/to/deployment/script})
|
558
582
|
end
|
559
583
|
end
|
560
584
|
|
561
|
-
describe 'and the script path
|
585
|
+
describe 'and the script path starts with a "/"' do
|
562
586
|
before do
|
563
|
-
WhiskeyDisk.configuration = { 'deploy_to' => '/path/to/main/repo', 'post_deploy_script' => 'path/to/deployment/script', 'rake_env' => { 'FOO' => 'BAR' } }
|
587
|
+
WhiskeyDisk.configuration = { 'deploy_to' => '/path/to/main/repo', 'post_deploy_script' => '/path/to/deployment/script', 'rake_env' => { 'FOO' => 'BAR' } }
|
588
|
+
end
|
589
|
+
|
590
|
+
it 'should cd to the deploy_to path prior to running the script' do
|
591
|
+
WhiskeyDisk.run_post_deploy_hooks
|
592
|
+
WhiskeyDisk.buffer.join(' ').should.match(%r{cd /path/to/main/repo;.*bash /path/to/deployment/script})
|
564
593
|
end
|
565
594
|
|
566
|
-
it 'should attempt to run the post deployment script' do
|
595
|
+
it 'should attempt to run the post deployment script using its absolute path' do
|
567
596
|
WhiskeyDisk.run_post_deploy_hooks
|
568
|
-
WhiskeyDisk.buffer.join(' ').should.match(%r{bash
|
597
|
+
WhiskeyDisk.buffer.join(' ').should.match(%r{bash /path/to/deployment/script})
|
569
598
|
end
|
570
599
|
|
571
600
|
it 'should pass any environment variables when running the post deploy script' do
|
572
601
|
WhiskeyDisk.run_post_deploy_hooks
|
573
|
-
WhiskeyDisk.buffer.join(' ').should.match(%r{FOO='BAR' bash
|
602
|
+
WhiskeyDisk.buffer.join(' ').should.match(%r{FOO='BAR' bash /path/to/deployment/script})
|
574
603
|
end
|
575
604
|
|
576
|
-
it 'should
|
605
|
+
it 'should enable shell verbosity when debugging is enabled' do
|
606
|
+
ENV['debug'] = 'true'
|
577
607
|
WhiskeyDisk.run_post_deploy_hooks
|
578
|
-
WhiskeyDisk.buffer.join(' ').should.match(%r{
|
608
|
+
WhiskeyDisk.buffer.join(' ').should.match(%r{bash -x /path/to/deployment/script})
|
579
609
|
end
|
580
|
-
|
581
|
-
it 'should
|
610
|
+
|
611
|
+
it 'should disable shell verbosity when debugging is not enabled' do
|
612
|
+
ENV['debug'] = 'false'
|
582
613
|
WhiskeyDisk.run_post_deploy_hooks
|
583
|
-
WhiskeyDisk.buffer.join(' ').should.match(%r{bash
|
614
|
+
WhiskeyDisk.buffer.join(' ').should.match(%r{bash /path/to/deployment/script})
|
584
615
|
end
|
585
616
|
end
|
586
617
|
end
|
@@ -625,10 +656,6 @@ describe 'WhiskeyDisk' do
|
|
625
656
|
end
|
626
657
|
|
627
658
|
describe 'bundling up buffered commands for execution' do
|
628
|
-
before do
|
629
|
-
WhiskeyDisk.reset
|
630
|
-
end
|
631
|
-
|
632
659
|
describe 'when staleness checks are disabled' do
|
633
660
|
it 'should return an empty string if there are no commands' do
|
634
661
|
WhiskeyDisk.bundle.should == ''
|
@@ -866,6 +893,7 @@ describe 'WhiskeyDisk' do
|
|
866
893
|
WhiskeyDisk.stub!(:domain_of_interest?).and_return(true)
|
867
894
|
WhiskeyDisk.stub!(:bundle).and_return(@cmd)
|
868
895
|
WhiskeyDisk.stub!(:system)
|
896
|
+
WhiskeyDisk.stub!(:puts)
|
869
897
|
end
|
870
898
|
|
871
899
|
it 'should fail if the domain path is not specified' do
|
@@ -899,7 +927,6 @@ describe 'WhiskeyDisk' do
|
|
899
927
|
|
900
928
|
describe 'when running a command string locally' do
|
901
929
|
before do
|
902
|
-
WhiskeyDisk.reset
|
903
930
|
@domain_name = 'local'
|
904
931
|
@domain = { :name => @domain_name }
|
905
932
|
WhiskeyDisk.configuration = { 'domain' => [ @domain ] }
|
@@ -913,23 +940,42 @@ describe 'WhiskeyDisk' do
|
|
913
940
|
it 'should require a domain and a command string' do
|
914
941
|
lambda { WhiskeyDisk.shell(@domain) }.should.raise(ArgumentError)
|
915
942
|
end
|
943
|
+
|
944
|
+
describe 'when debugging is enabled' do
|
945
|
+
before { ENV['debug'] = 'true' }
|
916
946
|
|
917
|
-
|
918
|
-
|
919
|
-
|
947
|
+
it 'should pass the string to the shell with verbosity enabled' do
|
948
|
+
WhiskeyDisk.should.receive(:system).with('bash', '-c', "set -x; ls")
|
949
|
+
WhiskeyDisk.shell(@domain, 'ls')
|
950
|
+
end
|
951
|
+
|
952
|
+
it 'should include domain role settings when the domain has roles' do
|
953
|
+
@domain = { :name => @domain_name, :roles => [ 'web', 'db' ] }
|
954
|
+
WhiskeyDisk.configuration = { 'domain' => [ @domain ] }
|
955
|
+
WhiskeyDisk.should.receive(:system).with('bash', '-c', "set -x; export WD_ROLES='web:db'; ls")
|
956
|
+
WhiskeyDisk.shell(@domain, 'ls')
|
957
|
+
end
|
920
958
|
end
|
959
|
+
|
960
|
+
describe 'when debugging is not enabled' do
|
961
|
+
before { ENV['debug'] = 'false' }
|
962
|
+
|
963
|
+
it 'should pass the string to the shell without verbosity enabled' do
|
964
|
+
WhiskeyDisk.should.receive(:system).with('bash', '-c', "ls")
|
965
|
+
WhiskeyDisk.shell(@domain, 'ls')
|
966
|
+
end
|
921
967
|
|
922
|
-
|
923
|
-
|
924
|
-
|
925
|
-
|
926
|
-
|
968
|
+
it 'should include domain role settings when the domain has roles' do
|
969
|
+
@domain = { :name => @domain_name, :roles => [ 'web', 'db' ] }
|
970
|
+
WhiskeyDisk.configuration = { 'domain' => [ @domain ] }
|
971
|
+
WhiskeyDisk.should.receive(:system).with('bash', '-c', "export WD_ROLES='web:db'; ls")
|
972
|
+
WhiskeyDisk.shell(@domain, 'ls')
|
973
|
+
end
|
927
974
|
end
|
928
975
|
end
|
929
976
|
|
930
977
|
describe 'when running a command string remotely' do
|
931
978
|
before do
|
932
|
-
WhiskeyDisk.reset
|
933
979
|
@domain_name = 'ogc@ogtastic.com'
|
934
980
|
@domain = { :name => @domain_name }
|
935
981
|
WhiskeyDisk.configuration = { 'domain' => [ @domain ] }
|
@@ -944,24 +990,34 @@ describe 'WhiskeyDisk' do
|
|
944
990
|
lambda { WhiskeyDisk.run(@domain) }.should.raise(ArgumentError)
|
945
991
|
end
|
946
992
|
|
947
|
-
|
948
|
-
|
949
|
-
|
993
|
+
describe "building a command" do
|
994
|
+
it 'should include domain role settings when the domain has roles' do
|
995
|
+
@domain = { :name => @domain_name, :roles => [ 'web', 'db' ] }
|
996
|
+
WhiskeyDisk.configuration = { 'domain' => [ @domain ] }
|
997
|
+
WhiskeyDisk.build_command(@domain, 'ls').should.match /export WD_ROLES='web:db'; ls/
|
998
|
+
end
|
950
999
|
end
|
951
|
-
|
952
|
-
|
953
|
-
|
954
|
-
|
955
|
-
|
956
|
-
|
1000
|
+
|
1001
|
+
describe 'when debugging is enabled' do
|
1002
|
+
before { ENV['debug'] = 'true' }
|
1003
|
+
|
1004
|
+
it 'should pass the string to ssh for the domain, with verbosity enabled' do
|
1005
|
+
WhiskeyDisk.should.receive(:system).with('ssh', '-v', @domain_name, "set -x; ls")
|
1006
|
+
WhiskeyDisk.run(@domain, 'ls')
|
1007
|
+
end
|
1008
|
+
end
|
1009
|
+
|
1010
|
+
describe 'when debugging is not enabled' do
|
1011
|
+
before { ENV['debug'] = 'false' }
|
1012
|
+
|
1013
|
+
it 'should pass the string to ssh for the domain, with verbosity disabled' do
|
1014
|
+
WhiskeyDisk.should.receive(:system).with('ssh', @domain_name, "ls")
|
1015
|
+
WhiskeyDisk.run(@domain, 'ls')
|
1016
|
+
end
|
957
1017
|
end
|
958
1018
|
end
|
959
|
-
|
1019
|
+
|
960
1020
|
describe 'determining if all the deployments succeeded' do
|
961
|
-
before do
|
962
|
-
WhiskeyDisk.reset
|
963
|
-
end
|
964
|
-
|
965
1021
|
it 'should work without arguments' do
|
966
1022
|
lambda { WhiskeyDisk.success? }.should.not.raise(ArgumentError)
|
967
1023
|
end
|
@@ -991,7 +1047,6 @@ describe 'WhiskeyDisk' do
|
|
991
1047
|
|
992
1048
|
describe 'summarizing the results of a run' do
|
993
1049
|
before do
|
994
|
-
WhiskeyDisk.reset
|
995
1050
|
WhiskeyDisk.stub!(:puts)
|
996
1051
|
end
|
997
1052
|
|
data/whiskey_disk.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{whiskey_disk}
|
8
|
-
s.version = "0.6.
|
8
|
+
s.version = "0.6.17"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Rick Bradley"]
|
12
|
-
s.date = %q{2011-03-
|
12
|
+
s.date = %q{2011-03-25}
|
13
13
|
s.description = %q{Opinionated gem for doing fast git-based server deployments.}
|
14
14
|
s.email = %q{rick@rickbradley.com}
|
15
15
|
s.executables = ["wd_role", "wd"]
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: whiskey_disk
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 37
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 6
|
9
|
-
-
|
10
|
-
version: 0.6.
|
9
|
+
- 17
|
10
|
+
version: 0.6.17
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Rick Bradley
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2011-03-
|
18
|
+
date: 2011-03-25 00:00:00 -05:00
|
19
19
|
default_executable:
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|