Skip to content

Commit

Permalink
Merge branch 'feature/make_check_a_wd_option' into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
rick committed Sep 7, 2010
2 parents 8bea7f9 + bc9603a commit 158845c
Show file tree
Hide file tree
Showing 4 changed files with 96 additions and 3 deletions.
4 changes: 2 additions & 2 deletions README.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -206,9 +206,9 @@ 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')

check='yes' wd deploy --to=foobar:production
wd deploy --check --to=foobar:production


### Configuration Repository ###
Expand Down
1 change: 0 additions & 1 deletion TODO.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
- make sure that deployments don't require ruby or rake on the target machine
- 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)
Expand Down
5 changes: 5 additions & 0 deletions bin/wd
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
89 changes: 89 additions & 0 deletions spec/wd_command_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 158845c

Please sign in to comment.