Permalink
Browse files

Merge branch 'release/0.5.2'

  • Loading branch information...
2 parents cb0079d + bf71951 commit bda95988888c058302a4e0f7301516008270656e @rick rick committed Sep 7, 2010
Showing with 154 additions and 42 deletions.
  1. +47 −26 README.markdown
  2. +0 −3 TODO.txt
  3. +1 −1 VERSION
  4. +5 −0 bin/wd
  5. +1 −1 lib/whiskey_disk.rb
  6. +89 −0 spec/wd_command_spec.rb
  7. +10 −10 spec/whiskey_disk_spec.rb
  8. +1 −1 whiskey_disk.gemspec
View
@@ -5,6 +5,9 @@ A very opinionated deployment tool, designed to be as fast as technologically po
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.
+You can also right-arrow through a shorter but more up-to-date whiskey_disk "lightning talk" presentation
+(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.
+
### Selling points ###
- If you share the same opinions as we do there's almost no code involved, almost no
@@ -54,18 +57,31 @@ current local checkout.
do hands-free automated deployments whenever code is pushed to your
deployment branch of choice!
-#### Dependencies ####
-
-rake, ssh, git, rsync on the deployment target server (affectionately referred to as the "g-node" by vinbarnes), bash-ish shell on deployment server.
-
-#### Assumptions ####
+### Assumptions ###
- your project is managed via git
- you are deploying over ssh, or deploying locally and have a bash-compatible shell
- you are comfortable defining (optional) post-setup and post-deployment actions with rake
- you have an optional second git repository for per-application/per-target configuration files
- you have an optional Rakefile in the top directory of your project's checkout
+### Dependencies ###
+
+On the server from which the whiskey_disk process will be kicked off:
+
+ - ruby
+ - rake
+ - whiskey\_disk
+ - ssh (if doing a remote deployment).
+
+On the deployment target server (which may be the same as the first server):
+
+ - a bash-compatible shell
+ - rsync (only if using a configuration repository)
+ - ruby, rake, whiskey\_disk (only if running post\_setup or post\_deploy hooks)
+
+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.
+
### Installation ###
As a gem:
@@ -116,7 +132,7 @@ of deploy:setup
at the end of deploy:now
-#### post\_deploy\_script and post\_setup\_script ###
+### post\_deploy\_script and post\_setup\_script ###
Whiskey\_disk provides rake task hooks (deploy:post\_setup and deploy:post\_deploy) to allow running custom
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
target system.
-
-### Running via rake ###
-
-In your Rakefile:
-
- require 'whiskey_disk/rake'
-
- Then, from the command-line:
-
- % rake deploy:setup to=<target> (e.g., "qa", "staging", "production", etc.)
- % rake deploy:now to=<target>
-
- or, specifying the project name:
-
- % rake deploy:setup to=<project>:<target> (e.g., "foo:qa", "bar:production", etc.)
- % rake deploy:now to=<project>:<target>
-
-
### Running from the command-line ###
% wd setup --to=<target>
@@ -194,6 +192,24 @@ deployed). Whiskey\_disk provides the basic deploy:post\_setup and deploy:post\
You can also define these tasks yourself if you want to eliminate the dependency on whiskey\_disk on the
deployment target system.
+
+### Running via rake ###
+
+In your Rakefile:
+
+ require 'whiskey_disk/rake'
+
+ Then, from the command-line:
+
+ % rake deploy:setup to=<target> (e.g., "qa", "staging", "production", etc.)
+ % rake deploy:now to=<target>
+
+ or, specifying the project name:
+
+ % rake deploy:setup to=<project>:<target> (e.g., "foo:qa", "bar:production", etc.)
+ % rake deploy:now to=<project>:<target>
+
+
### Staleness checks ###
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-
than proceeding with any of the deployment actions. This makes it easy to simply run whiskey\_disk out of cron
so that it will automatically perform a deployment whenever changes are pushed to the upstream git repositories.
-To turn on staleness checking, simply set the 'check' environment variable:
+To turn on staleness checking, simply specify the '--check' flag when deploying (or the shorter '-c')
+
+ wd deploy --check --to=foobar:production
+
+If running whiskey\_disk purely via rake, you can also enable staleness checking. This works by setting the 'check'
+environment variable to the string 'true' or 'yes':
- check='yes' wd deploy --to=foobar:production
+ % check='true' to='whiskey_disk:testing' rake deploy:now
### Configuration Repository ###
View
@@ -1,6 +1,3 @@
- - make sure that deployments don't require ruby or rake on the target machine
- - we should probably do --depth 1 on setup, for even fastertude
- - support 'check=yes' as a wd --check flag
- 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
- batch deployments (--batch=/etc/deploy/hourly.yml)
View
@@ -1 +1 @@
-0.5.0
+0.5.2
View
5 bin/wd
@@ -15,6 +15,10 @@ op = OptionParser.new do |opts|
options[:path] = path
end
+ opts.on('-c', '--check', "do a staleness check before deploying") do |path|
+ options[:check] = 'true'
+ end
+
opts.on_tail('-h', '--help', 'show this message') do
raise opts.to_s
end
@@ -28,6 +32,7 @@ raise op.to_s unless ['deploy', 'setup'].include?(command)
ENV['to'] = options[:target]
ENV['path'] = options[:path]
+ENV['check'] = options[:check]
if command == 'deploy'
Rake::Task['deploy:now'].invoke
View
@@ -125,7 +125,7 @@ def if_task_defined(task, cmd)
def clone_repository(repo, path)
enqueue "cd #{parent_path(path)}"
enqueue("if [ -e #{path} ]; then echo 'Repository already cloned to [#{path}]. Skipping.'; " +
- "else git clone #{repo} #{tail_path(path)} ; fi")
+ "else git clone --depth 1 #{repo} #{tail_path(path)} ; fi")
end
def refresh_checkout(path, repo_branch)
View
@@ -244,6 +244,51 @@ def run_command
run_command
ENV['to'].should == 'foo'
end
+
+ describe 'and a --check argument is specified' do
+ before do
+ ARGV.push '--check'
+ @rake = Rake::Task['deploy:now']
+ @rake.stub!(:invoke)
+ end
+
+ it 'should not fail' do
+ lambda { run_command }.should.not.raise
+ end
+
+ it 'should run the deploy:now rake task' do
+ @rake.should.receive(:invoke)
+ run_command
+ end
+
+ it 'should make the specified target available as a "check" argument to the rake task' do
+ run_command
+ ENV['check'].should == 'true'
+ end
+ end
+
+ describe 'and a -c argument is specified' do
+ before do
+ ARGV.push '-c'
+ @rake = Rake::Task['deploy:now']
+ @rake.stub!(:invoke)
+ end
+
+ it 'should not fail' do
+ lambda { run_command }.should.not.raise
+ end
+
+ it 'should run the deploy:now rake task' do
+ @rake.should.receive(:invoke)
+ run_command
+ end
+
+ it 'should make the specified target available as a "check" argument to the rake task' do
+ run_command
+ ENV['check'].should == 'true'
+ end
+ end
+
describe 'and a --path argument is specified' do
before do
ARGV.push '--path=/path/to/foo'
@@ -325,6 +370,50 @@ def run_command
run_command
ENV['to'].should == 'foo'
end
+
+ describe 'and a --check argument is specified' do
+ before do
+ ARGV.push '--check'
+ @rake = Rake::Task['deploy:now']
+ @rake.stub!(:invoke)
+ end
+
+ it 'should not fail' do
+ lambda { run_command }.should.not.raise
+ end
+
+ it 'should run the deploy:now rake task' do
+ @rake.should.receive(:invoke)
+ run_command
+ end
+
+ it 'should make the specified target available as a "check" argument to the rake task' do
+ run_command
+ ENV['check'].should == 'true'
+ end
+ end
+
+ describe 'and a -c argument is specified' do
+ before do
+ ARGV.push '-c'
+ @rake = Rake::Task['deploy:now']
+ @rake.stub!(:invoke)
+ end
+
+ it 'should not fail' do
+ lambda { run_command }.should.not.raise
+ end
+
+ it 'should run the deploy:now rake task' do
+ @rake.should.receive(:invoke)
+ run_command
+ end
+
+ it 'should make the specified target available as a "check" argument to the rake task' do
+ run_command
+ ENV['check'].should == 'true'
+ end
+ end
describe 'and a --path argument is specified' do
before do
View
@@ -169,15 +169,15 @@
WhiskeyDisk.buffer.join(' ').should.match(%r{cd /path/to/main})
WhiskeyDisk.buffer.join(' ').should.not.match(%r{cd /path/to/main/repo})
end
-
- it 'should make the main repository clone conditional on the lack of a main repository checkout' do
+
+ it 'should attempt to shallow clone the main repository to the repository checkout path' do
WhiskeyDisk.checkout_main_repository
- WhiskeyDisk.buffer.join(' ').should.match(%r{if \[ -e #{@parameters['deploy_to']} \]; then .*; fi})
+ WhiskeyDisk.buffer.join(' ').should.match(%r{clone --depth 1 #{@parameters['repository']} repo})
end
- it 'should attempt to clone the main repository to the repository checkout path' do
+ it 'should make the main repository clone conditional on the lack of a main repository checkout' do
WhiskeyDisk.checkout_main_repository
- WhiskeyDisk.buffer.join(' ').should.match(%r{clone #{@parameters['repository']} repo})
+ WhiskeyDisk.buffer.join(' ').should.match(%r{if \[ -e #{@parameters['deploy_to']} \]; then .*; fi})
end
end
@@ -205,16 +205,16 @@
WhiskeyDisk.buffer.join(' ').should.match(%r{cd /path/to/config})
WhiskeyDisk.buffer.join(' ').should.not.match(%r{cd /path/to/config/repo})
end
+
+ it 'should attempt to shallow clone the configuration repository to the repository checkout path' do
+ WhiskeyDisk.checkout_configuration_repository
+ WhiskeyDisk.buffer.join(' ').should.match(%r{clone --depth 1 #{@parameters['config_repository']} repo})
+ end
it 'should make the configuration repository clone conditional on the lack of a main repository checkout' do
WhiskeyDisk.checkout_configuration_repository
WhiskeyDisk.buffer.join(' ').should.match(%r{if \[ -e #{@parameters['deploy_config_to']} \]; then .*; fi})
end
-
- it 'should attempt to clone the configuration repository to the repository checkout path' do
- WhiskeyDisk.checkout_configuration_repository
- WhiskeyDisk.buffer.join(' ').should.match(%r{clone #{@parameters['config_repository']} repo})
- end
end
describe 'updating the main repository checkout' do
View
@@ -5,7 +5,7 @@
Gem::Specification.new do |s|
s.name = %q{whiskey_disk}
- s.version = "0.5.0"
+ s.version = "0.5.2"
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
s.authors = ["Rick Bradley"]

0 comments on commit bda9598

Please sign in to comment.