whiskey_disk 0.0.2 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
data/README CHANGED
@@ -45,6 +45,7 @@ Whiskey Disk -- embarrassingly fast deployments.
45
45
  - deploy_config_to: where to deploy the configuration repository
46
46
  - config_repository: git repository for configuration files
47
47
  - project: project name (used to compute path in configuration checkout)
48
+ - rake_env: hash of environment variables to set when running post_setup and post_deploy rake tasks
48
49
 
49
50
  - defining a deploy:<environment>:post_setup rake task (e.g., in lib/tasks/ or in
50
51
  your project's Rakefile) will cause that task to be run at the end of deploy:setup
@@ -62,52 +63,3 @@ Whiskey Disk -- embarrassingly fast deployments.
62
63
  - http://github.com/blog/470-deployment-script-spring-cleaning
63
64
  - http://github.com/mislav/git-deploy
64
65
  - http://toroid.org/ams/git-website-howto
65
-
66
- -----
67
-
68
-
69
- NOTES (aka the original README):
70
-
71
-
72
-
73
- The idea here is inspired by github's cleaned up deployment scripts, and mislav's git-deploy project. Only, we gave up on capistrano a long time ago, and after a few years of doing deployments on a few dozen projects, we realized that we really have very little variation on how we do things. That is, we can afford to have a very opinionated tool to do our deployments.
74
-
75
- Here are the features/constraints we're envisioning:
76
-
77
- - We need some sort of very basic "run this on a remote server" functionality. We've been using vlad for years now and this would suffice: it does what we're looking for and is much much smaller than capistrano. If we don't load the included recipes it's basically a fancy ruby ssh wrapper.
78
-
79
- - Setup should mostly just do a very fast remote git checkout in the right place. Deployment should very quickly update that checkout.
80
-
81
- - We have been considering a move towards tracking configuration data across our projects as a separate concern. So, if we can have a private repo that stores per-project and per-environment (here I mean staging vs. production, etc.) configuration files, and have our deployments overlay those files quickly, that would be ideal. I'm talking about hoptoad configs, database.yml files, AWS cert files, GeoKit API keys, etc., etc., etc.
82
-
83
- - We should be able to use the same "setup == clone" + "deploy == reset" technique to manage the per-project/per-environment config files.
84
-
85
- - Using rsync on the remote to those overlay config files on the deployed project would be a fast way to get them in place.
86
-
87
- - Get rid of a bunch of annoying symlinks and symlink-hoops-to-jump-through.
88
-
89
- - Get rid of a bunch of space (yeah yeah disk is cheap, but copying isn't) on the disk devoted to umpteen "releases".
90
-
91
- - Obviously reduce deployment time by doing less, ssh-ing less, and taking less time to do whatever.
92
-
93
- - should be rake based, and should provide a bare minimum of tasks -- like deploy:setup, deploy:now, and maybe a deploy:refresh_config_files.
94
-
95
- - While a very basic task or few would run after setup or after deployment (e.g., rake db:migrate if migrations were changed, or touch tmp/restart.txt if the web server needs a restart; see git-deploy for more examples), we should be able to declare optional rake tasks (e.g., "deploy:staging:post_deploy") and have them run on this project if they are declared.
96
-
97
- - Should work with projects that aren't remotely ruby.
98
-
99
- - Should be loadable as a gem, meaning that it doesn't need to live in your project's space. (see also non-ruby projects)
100
-
101
- - Should be able to use a non-ruby config, preferably yaml, for information for all environments. That could be stored in <project>/config/deploy.yml and saved with the project. Even if this is just shoved into vlad 'set' commands, it's still an improvement: we don't need ruby in the config file because we're opinionated.
102
-
103
- - should be able to override settings for an environment locally by declaring a <project>/config/deploy-<environment>.yml. Ideal for testing out deployments to different servers (or deploying locally). This also makes it possible to .gitignore your local settings, so everyone can have their config repos in different places.
104
-
105
- - should make it easier to do local development (e.g., on a laptop) by being able to overlay config files using the same rake tasks as used for remote deployments, just not running the functionality remotely.
106
-
107
- - dropping in a project Rakefile can add post-deploy / post-setup hooks transparently.
108
-
109
- - actually have meaningful error messages, unlike anything that ever seems to happen with cap or vlad. :-/
110
-
111
- - build this spec-first (whenever possible) so that there's a useful test suite.
112
-
113
- - M$ windows hasn't been a priority for me for over a decade, not starting now.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.0.2
1
+ 0.0.3
@@ -4,3 +4,5 @@ staging:
4
4
  repository: "git://github.com/clarkkent/suparsite.git"
5
5
  config_repository: "git@github.com:clarkkent/suparconfig.git"
6
6
  deploy_config_to: "/var/cache/git/suparconfig"
7
+ rake_env:
8
+ RAILS_ENV: 'development'
data/examples/deploy.yml CHANGED
@@ -5,8 +5,12 @@ staging:
5
5
  config_repository: "git@github.com:clarkkent/suparconfig.git"
6
6
  deploy_config_to: "/var/cache/git/suparconfig"
7
7
  branch: "production"
8
+ rake_env:
9
+ RAILS_ENV: "production"
8
10
  local:
9
11
  repository: "git://github.com/clarkkent/suparsite.git"
10
12
  config_repository: "git@github.com:clarkkent/suparconfig.git"
11
13
  deploy_to: "/Users/clark/git/suparsite"
12
14
  deploy_config_to: "/Users/clark/git/suparconfig"
15
+ rake_env:
16
+ RAILS_ENV: "production"
data/lib/whiskey_disk.rb CHANGED
@@ -105,14 +105,16 @@ class WhiskeyDisk
105
105
 
106
106
  def run_post_setup_hooks
107
107
  needs(:deploy_to)
108
+ env_vars = self[:rake_env] ? self[:rake_env].keys.inject('') {|b,k| b += "#{k}='#{self[:rake_env][k]}' "; b } : ''
108
109
  enqueue "cd #{self[:deploy_to]}"
109
- enqueue "rake --trace deploy:post_setup to=#{self[:environment]}"
110
+ enqueue "#{env_vars} rake --trace deploy:post_setup to=#{self[:environment]}"
110
111
  end
111
112
 
112
113
  def run_post_deploy_hooks
113
114
  needs(:deploy_to)
115
+ env_vars = self[:rake_env] ? self[:rake_env].keys.inject('') {|b,k| b += "#{k}='#{self[:rake_env][k]}' "; b } : ''
114
116
  enqueue "cd #{self[:deploy_to]}"
115
- enqueue "rake --trace deploy:post_deploy to=#{self[:environment]}"
117
+ enqueue "#{env_vars} rake --trace deploy:post_deploy to=#{self[:environment]}"
116
118
  end
117
119
  end
118
120
  end
@@ -277,6 +277,16 @@ describe 'WhiskeyDisk' do
277
277
  WhiskeyDisk.run_post_setup_hooks
278
278
  WhiskeyDisk.buffer.join(' ').should.match(%r{to=#{@env}})
279
279
  end
280
+
281
+ it 'should set any rake_env variables when running the rake tasks' do
282
+ @parameters = { 'deploy_to' => '/path/to/main/repo', 'rake_env' => { 'RAILS_ENV' => 'production', 'FOO' => 'bar' } }
283
+ WhiskeyDisk::Config.stub!(:fetch).and_return(@parameters)
284
+ WhiskeyDisk.reset
285
+ WhiskeyDisk.run_post_setup_hooks
286
+ @parameters['rake_env'].each_pair do |k,v|
287
+ WhiskeyDisk.buffer.join(' ').should.match(%r{#{k}='#{v}' })
288
+ end
289
+ end
280
290
  end
281
291
 
282
292
  describe 'running post deployment hooks' do
@@ -306,6 +316,16 @@ describe 'WhiskeyDisk' do
306
316
  WhiskeyDisk.run_post_deploy_hooks
307
317
  WhiskeyDisk.buffer.join(' ').should.match(%r{to=#{@env}})
308
318
  end
319
+
320
+ it 'should set any rake_env variables when running the rake tasks' do
321
+ @parameters = { 'deploy_to' => '/path/to/main/repo', 'rake_env' => { 'RAILS_ENV' => 'production', 'FOO' => 'bar' } }
322
+ WhiskeyDisk::Config.stub!(:fetch).and_return(@parameters)
323
+ WhiskeyDisk.reset
324
+ WhiskeyDisk.run_post_deploy_hooks
325
+ @parameters['rake_env'].each_pair do |k,v|
326
+ WhiskeyDisk.buffer.join(' ').should.match(%r{#{k}='#{v}' })
327
+ end
328
+ end
309
329
  end
310
330
 
311
331
  describe 'flushing changes' do
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: whiskey_disk
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Rick Bradley