whiskey_disk 0.5.0 → 0.5.2

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.
data/README.markdown CHANGED
@@ -5,6 +5,9 @@ A very opinionated deployment tool, designed to be as fast as technologically po
5
5
 
6
6
  Right-arrow through a short whiskey_disk presentation at [http://wd2010.rickbradley.com/](http://wd2010.rickbradley.com) (slide source available [here](http://github.com/rick/whiskey_disk_presentation).), covering the 0.2.*-era functionality.
7
7
 
8
+ You can also right-arrow through a shorter but more up-to-date whiskey_disk "lightning talk" presentation
9
+ (from the 2010 Ruby Hoedown) at [http://wdlightning.rickbradley.com/](http://wdlightning.rickbradley.com) (slide source available [here](http://github.com/rick/whiskey_disk_presentation/tree/lightning).), covering the 0.4.*-era functionality.
10
+
8
11
  ### Selling points ###
9
12
 
10
13
  - If you share the same opinions as we do there's almost no code involved, almost no
@@ -54,11 +57,7 @@ current local checkout.
54
57
  do hands-free automated deployments whenever code is pushed to your
55
58
  deployment branch of choice!
56
59
 
57
- #### Dependencies ####
58
-
59
- rake, ssh, git, rsync on the deployment target server (affectionately referred to as the "g-node" by vinbarnes), bash-ish shell on deployment server.
60
-
61
- #### Assumptions ####
60
+ ### Assumptions ###
62
61
 
63
62
  - your project is managed via git
64
63
  - you are deploying over ssh, or deploying locally and have a bash-compatible shell
@@ -66,6 +65,23 @@ rake, ssh, git, rsync on the deployment target server (affectionately referred t
66
65
  - you have an optional second git repository for per-application/per-target configuration files
67
66
  - you have an optional Rakefile in the top directory of your project's checkout
68
67
 
68
+ ### Dependencies ###
69
+
70
+ On the server from which the whiskey_disk process will be kicked off:
71
+
72
+ - ruby
73
+ - rake
74
+ - whiskey\_disk
75
+ - ssh (if doing a remote deployment).
76
+
77
+ On the deployment target server (which may be the same as the first server):
78
+
79
+ - a bash-compatible shell
80
+ - rsync (only if using a configuration repository)
81
+ - ruby, rake, whiskey\_disk (only if running post\_setup or post\_deploy hooks)
82
+
83
+ If you're running on OS X or Linux you probably have all of these installed already. Note that the deployment target system doesn't even have to have ruby installed unless post\_* rake hooks are being run.
84
+
69
85
  ### Installation ###
70
86
 
71
87
  As a gem:
@@ -116,7 +132,7 @@ of deploy:setup
116
132
  at the end of deploy:now
117
133
 
118
134
 
119
- #### post\_deploy\_script and post\_setup\_script ###
135
+ ### post\_deploy\_script and post\_setup\_script ###
120
136
 
121
137
  Whiskey\_disk provides rake task hooks (deploy:post\_setup and deploy:post\_deploy) to allow running custom
122
138
  code after setup or deployment. There are situations where it is desirable to run some commands prior to
@@ -149,24 +165,6 @@ The post\_deploy\_script will be run from /var/www/www.ogtastic.com/bin/post-dep
149
165
  target system.
150
166
 
151
167
 
152
-
153
- ### Running via rake ###
154
-
155
- In your Rakefile:
156
-
157
- require 'whiskey_disk/rake'
158
-
159
- Then, from the command-line:
160
-
161
- % rake deploy:setup to=<target> (e.g., "qa", "staging", "production", etc.)
162
- % rake deploy:now to=<target>
163
-
164
- or, specifying the project name:
165
-
166
- % rake deploy:setup to=<project>:<target> (e.g., "foo:qa", "bar:production", etc.)
167
- % rake deploy:now to=<project>:<target>
168
-
169
-
170
168
  ### Running from the command-line ###
171
169
 
172
170
  % wd setup --to=<target>
@@ -194,6 +192,24 @@ deployed). Whiskey\_disk provides the basic deploy:post\_setup and deploy:post\
194
192
  You can also define these tasks yourself if you want to eliminate the dependency on whiskey\_disk on the
195
193
  deployment target system.
196
194
 
195
+
196
+ ### Running via rake ###
197
+
198
+ In your Rakefile:
199
+
200
+ require 'whiskey_disk/rake'
201
+
202
+ Then, from the command-line:
203
+
204
+ % rake deploy:setup to=<target> (e.g., "qa", "staging", "production", etc.)
205
+ % rake deploy:now to=<target>
206
+
207
+ or, specifying the project name:
208
+
209
+ % rake deploy:setup to=<project>:<target> (e.g., "foo:qa", "bar:production", etc.)
210
+ % rake deploy:now to=<project>:<target>
211
+
212
+
197
213
  ### Staleness checks ###
198
214
 
199
215
  Enabling staleness checking will cause whiskey\_disk to check whether the deployed checkout of the repository
@@ -203,9 +219,14 @@ If the checkouts are already up-to-date the deployment process will print an up-
203
219
  than proceeding with any of the deployment actions. This makes it easy to simply run whiskey\_disk out of cron
204
220
  so that it will automatically perform a deployment whenever changes are pushed to the upstream git repositories.
205
221
 
206
- To turn on staleness checking, simply set the 'check' environment variable:
222
+ To turn on staleness checking, simply specify the '--check' flag when deploying (or the shorter '-c')
223
+
224
+ wd deploy --check --to=foobar:production
225
+
226
+ If running whiskey\_disk purely via rake, you can also enable staleness checking. This works by setting the 'check'
227
+ environment variable to the string 'true' or 'yes':
207
228
 
208
- check='yes' wd deploy --to=foobar:production
229
+ % check='true' to='whiskey_disk:testing' rake deploy:now
209
230
 
210
231
 
211
232
  ### Configuration Repository ###
data/TODO.txt CHANGED
@@ -1,6 +1,3 @@
1
- - make sure that deployments don't require ruby or rake on the target machine
2
- - we should probably do --depth 1 on setup, for even fastertude
3
- - support 'check=yes' as a wd --check flag
4
1
  - if someone specifies :project in a config repo block in a localized config (say a RAILS app), then use that for determining which project to use when loading the config repo
5
2
 
6
3
  - batch deployments (--batch=/etc/deploy/hourly.yml)
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.5.0
1
+ 0.5.2
data/bin/wd CHANGED
@@ -15,6 +15,10 @@ op = OptionParser.new do |opts|
15
15
  options[:path] = path
16
16
  end
17
17
 
18
+ opts.on('-c', '--check', "do a staleness check before deploying") do |path|
19
+ options[:check] = 'true'
20
+ end
21
+
18
22
  opts.on_tail('-h', '--help', 'show this message') do
19
23
  raise opts.to_s
20
24
  end
@@ -28,6 +32,7 @@ raise op.to_s unless ['deploy', 'setup'].include?(command)
28
32
 
29
33
  ENV['to'] = options[:target]
30
34
  ENV['path'] = options[:path]
35
+ ENV['check'] = options[:check]
31
36
 
32
37
  if command == 'deploy'
33
38
  Rake::Task['deploy:now'].invoke
data/lib/whiskey_disk.rb CHANGED
@@ -125,7 +125,7 @@ class WhiskeyDisk
125
125
  def clone_repository(repo, path)
126
126
  enqueue "cd #{parent_path(path)}"
127
127
  enqueue("if [ -e #{path} ]; then echo 'Repository already cloned to [#{path}]. Skipping.'; " +
128
- "else git clone #{repo} #{tail_path(path)} ; fi")
128
+ "else git clone --depth 1 #{repo} #{tail_path(path)} ; fi")
129
129
  end
130
130
 
131
131
  def refresh_checkout(path, repo_branch)
@@ -244,6 +244,51 @@ describe 'wd command' do
244
244
  run_command
245
245
  ENV['to'].should == 'foo'
246
246
  end
247
+
248
+ describe 'and a --check argument is specified' do
249
+ before do
250
+ ARGV.push '--check'
251
+ @rake = Rake::Task['deploy:now']
252
+ @rake.stub!(:invoke)
253
+ end
254
+
255
+ it 'should not fail' do
256
+ lambda { run_command }.should.not.raise
257
+ end
258
+
259
+ it 'should run the deploy:now rake task' do
260
+ @rake.should.receive(:invoke)
261
+ run_command
262
+ end
263
+
264
+ it 'should make the specified target available as a "check" argument to the rake task' do
265
+ run_command
266
+ ENV['check'].should == 'true'
267
+ end
268
+ end
269
+
270
+ describe 'and a -c argument is specified' do
271
+ before do
272
+ ARGV.push '-c'
273
+ @rake = Rake::Task['deploy:now']
274
+ @rake.stub!(:invoke)
275
+ end
276
+
277
+ it 'should not fail' do
278
+ lambda { run_command }.should.not.raise
279
+ end
280
+
281
+ it 'should run the deploy:now rake task' do
282
+ @rake.should.receive(:invoke)
283
+ run_command
284
+ end
285
+
286
+ it 'should make the specified target available as a "check" argument to the rake task' do
287
+ run_command
288
+ ENV['check'].should == 'true'
289
+ end
290
+ end
291
+
247
292
  describe 'and a --path argument is specified' do
248
293
  before do
249
294
  ARGV.push '--path=/path/to/foo'
@@ -325,6 +370,50 @@ describe 'wd command' do
325
370
  run_command
326
371
  ENV['to'].should == 'foo'
327
372
  end
373
+
374
+ describe 'and a --check argument is specified' do
375
+ before do
376
+ ARGV.push '--check'
377
+ @rake = Rake::Task['deploy:now']
378
+ @rake.stub!(:invoke)
379
+ end
380
+
381
+ it 'should not fail' do
382
+ lambda { run_command }.should.not.raise
383
+ end
384
+
385
+ it 'should run the deploy:now rake task' do
386
+ @rake.should.receive(:invoke)
387
+ run_command
388
+ end
389
+
390
+ it 'should make the specified target available as a "check" argument to the rake task' do
391
+ run_command
392
+ ENV['check'].should == 'true'
393
+ end
394
+ end
395
+
396
+ describe 'and a -c argument is specified' do
397
+ before do
398
+ ARGV.push '-c'
399
+ @rake = Rake::Task['deploy:now']
400
+ @rake.stub!(:invoke)
401
+ end
402
+
403
+ it 'should not fail' do
404
+ lambda { run_command }.should.not.raise
405
+ end
406
+
407
+ it 'should run the deploy:now rake task' do
408
+ @rake.should.receive(:invoke)
409
+ run_command
410
+ end
411
+
412
+ it 'should make the specified target available as a "check" argument to the rake task' do
413
+ run_command
414
+ ENV['check'].should == 'true'
415
+ end
416
+ end
328
417
 
329
418
  describe 'and a --path argument is specified' do
330
419
  before do
@@ -169,15 +169,15 @@ describe 'WhiskeyDisk' do
169
169
  WhiskeyDisk.buffer.join(' ').should.match(%r{cd /path/to/main})
170
170
  WhiskeyDisk.buffer.join(' ').should.not.match(%r{cd /path/to/main/repo})
171
171
  end
172
-
173
- it 'should make the main repository clone conditional on the lack of a main repository checkout' do
172
+
173
+ it 'should attempt to shallow clone the main repository to the repository checkout path' do
174
174
  WhiskeyDisk.checkout_main_repository
175
- WhiskeyDisk.buffer.join(' ').should.match(%r{if \[ -e #{@parameters['deploy_to']} \]; then .*; fi})
175
+ WhiskeyDisk.buffer.join(' ').should.match(%r{clone --depth 1 #{@parameters['repository']} repo})
176
176
  end
177
177
 
178
- it 'should attempt to clone the main repository to the repository checkout path' do
178
+ it 'should make the main repository clone conditional on the lack of a main repository checkout' do
179
179
  WhiskeyDisk.checkout_main_repository
180
- WhiskeyDisk.buffer.join(' ').should.match(%r{clone #{@parameters['repository']} repo})
180
+ WhiskeyDisk.buffer.join(' ').should.match(%r{if \[ -e #{@parameters['deploy_to']} \]; then .*; fi})
181
181
  end
182
182
  end
183
183
 
@@ -205,16 +205,16 @@ describe 'WhiskeyDisk' do
205
205
  WhiskeyDisk.buffer.join(' ').should.match(%r{cd /path/to/config})
206
206
  WhiskeyDisk.buffer.join(' ').should.not.match(%r{cd /path/to/config/repo})
207
207
  end
208
+
209
+ it 'should attempt to shallow clone the configuration repository to the repository checkout path' do
210
+ WhiskeyDisk.checkout_configuration_repository
211
+ WhiskeyDisk.buffer.join(' ').should.match(%r{clone --depth 1 #{@parameters['config_repository']} repo})
212
+ end
208
213
 
209
214
  it 'should make the configuration repository clone conditional on the lack of a main repository checkout' do
210
215
  WhiskeyDisk.checkout_configuration_repository
211
216
  WhiskeyDisk.buffer.join(' ').should.match(%r{if \[ -e #{@parameters['deploy_config_to']} \]; then .*; fi})
212
217
  end
213
-
214
- it 'should attempt to clone the configuration repository to the repository checkout path' do
215
- WhiskeyDisk.checkout_configuration_repository
216
- WhiskeyDisk.buffer.join(' ').should.match(%r{clone #{@parameters['config_repository']} repo})
217
- end
218
218
  end
219
219
 
220
220
  describe 'updating the main repository checkout' do
data/whiskey_disk.gemspec CHANGED
@@ -5,7 +5,7 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{whiskey_disk}
8
- s.version = "0.5.0"
8
+ s.version = "0.5.2"
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"]
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: 11
4
+ hash: 15
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 5
9
- - 0
10
- version: 0.5.0
9
+ - 2
10
+ version: 0.5.2
11
11
  platform: ruby
12
12
  authors:
13
13
  - Rick Bradley