capistrano-didi 0.2.3 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
data/README.rdoc CHANGED
@@ -17,3 +17,26 @@ Description goes here.
17
17
  Copyright (c) 2011 Koen Van Winckel. See LICENSE.txt for
18
18
  further details.
19
19
 
20
+
21
+
22
+ = TODO
23
+
24
+ * set :site, "apache vhost here" => not clear what this is
25
+ * set :sitesubdir, "default" => use :site here ?
26
+ * create default + multisite with :site
27
+ * sensible default: adminpass => default is admin admin
28
+ * server app, web, db => hide this db depends on settings.php so specified else where
29
+ * set :scm, "subversion" => document options => with svn url needs to be location of cap file
30
+ * set :baseline => should not be mandatory
31
+ * set :sitemail => should not be mandatory
32
+ * stages => reserverd names (eg. test)
33
+ * set :deploy_to => needs to be absolute (+what with trailing slash?)
34
+ * requirements: drush
35
+ * deploy:check => uitbreiden met control of repostioryu (svn / git) bereikbaar is) see "depend"
36
+ * deploy:check => ook mysql connectie controleren
37
+ * svn: problem with acceptance voor certificate
38
+ * scm_username, scm_password
39
+ * drush:si => ook feature revert all doen
40
+ * apache vhost opgeven en gesymlinked word
41
+ * railslessdeploy: run_locally
42
+ * robots.txt disallow all
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.2.3
1
+ 0.3.0
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = "capistrano-didi"
8
- s.version = "0.2.3"
8
+ s.version = "0.3.0"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Koen Van Winckel"]
12
- s.date = "2011-11-02"
12
+ s.date = "2011-11-24"
13
13
  s.description = "didi is a collection of recipes for capistrano that allow drupal to be deployed, tested and used in a CI environment"
14
14
  s.email = "koenvw@gmail.com"
15
15
  s.executables = ["didify", "didi"]
@@ -1,13 +1,15 @@
1
1
  Capistrano::Configuration.instance.load do
2
+
3
+ require 'FileUtils'
2
4
 
3
- # =============================================
4
- # Script variables. These must be set in client capfile.
5
- # =============================================
5
+ # =========================================================================
6
+ # These variables MUST be set in the client capfiles. If they are not set,
7
+ # the deploy will fail with an error.
8
+ # =========================================================================
6
9
  _cset(:db_type) { abort "Please specify the Drupal database type (:db_type)." }
7
10
  _cset(:db_name) { abort "Please specify the Drupal database name (:db_name)." }
8
11
  _cset(:db_username) { abort "Please specify the Drupal database username (:db_username)." }
9
12
  _cset(:db_password) { abort "Please specify the Drupal database password (:db_password)." }
10
- _cset(:drupal_version) { abort "Please specify the Drupal version (6 or 7) (:drupal_version)." }
11
13
 
12
14
  _cset(:profile) { abort "Please specify the Drupal install profile (:profile)." }
13
15
  _cset(:site) { abort "Please specify the Drupal site (:site)." }
@@ -17,32 +19,33 @@ _cset(:sitesubdir) { abort "Please specify the Drupal site subdir (:sitemai
17
19
  _cset(:baseline) { abort "Please specify the Baseline feature (:baseline)." }
18
20
 
19
21
 
20
- # Fixed defaults. Change these at your own risk, (well tested) support for different values is left for future versions.
22
+ # =========================================================================
23
+ # These variables may be set in the client capfile if their default values
24
+ # are not sufficient.
25
+ # =========================================================================
21
26
  set :scm, :git
22
27
  set :deploy_via, :remote_cache
23
28
  set :drupal_version, '7'
24
- # Only bother to keep the last five releases
25
29
  set :keep_releases, 5
26
30
  set :use_sudo, false
27
31
 
28
- # ==============================================
29
- # Defaults. You may change these to your projects convenience
30
- # ==============================================
31
- #ssh_options[:verbose] = :debug #FIXME
32
+ set :domain, 'default'
33
+ set :db_host, 'localhost'
34
+ set :drupal_path, 'drupal'
35
+ set :srv_usr, 'www-data'
36
+
32
37
  ssh_options[:forward_agent] = true
33
- _cset :domain, 'default'
34
- _cset :db_host, 'localhost'
35
- _cset :drupal_path, 'drupal'
36
- _cset :srv_usr, 'www-data'
37
- #_cset :srv_password, 'www-data' #FIXME
38
-
39
- # ===============================================
40
- # Script constants. These should not be changed
41
- # ===============================================
42
- set :settings, 'settings.php'
43
- set :files, 'files'
44
- set :dbbackups, 'db_backups'
45
- set :shared_children, [domain, File.join(domain, files)]
38
+ #ssh_options[:verbose] = :debug #FIXME
39
+
40
+ # =========================================================================
41
+ # These variables should NOT be changed unless you are very confident in
42
+ # what you are doing. Make sure you understand all the implications of your
43
+ # changes if you do decide to muck with these!
44
+ # =========================================================================
45
+ _cset :settings, 'settings.php'
46
+ _cset :files, 'files'
47
+ _cset :dbbackups, 'db_backups'
48
+ _cset :shared_children, [domain, File.join(domain, files)]
46
49
 
47
50
  _cset(:shared_settings) { File.join(shared_path, domain, settings) }
48
51
  _cset(:shared_files) { File.join(shared_path, domain, files) }
@@ -70,21 +73,26 @@ namespace :deploy do
70
73
  DESC
71
74
  task :default do
72
75
  update
76
+ manage.dbdump_previous
73
77
  cleanup
74
78
  end
75
- after "deploy:default", "drush:update"
79
+ after "deploy", "drush:update"
76
80
 
77
81
  desc "Setup a drupal site from scratch"
78
82
  task :cold do
79
- setup
80
- update_code
81
- symlink
83
+ transaction do
84
+ setup
85
+ update_code
86
+ symlink
87
+ end
82
88
  end
83
89
  after "deploy:cold", "drush:si"
84
90
 
85
91
  desc "Deploys latest code and rebuild the database"
86
92
  task :rebuild do
87
- default
93
+ update_code
94
+ symlink
95
+ manage.dbdump_previous
88
96
  end
89
97
  after "deploy:rebuild", "drush:si"
90
98
 
@@ -109,7 +117,7 @@ namespace :deploy do
109
117
  put configuration, shared_settings
110
118
  end
111
119
 
112
- desc "Rebuild files and settings symlinks"
120
+ desc "[internal] Rebuild files and settings symlinks"
113
121
  task :finalize_update, :except => { :no_release => true } do
114
122
  on_rollback do
115
123
  if previous_release
@@ -136,6 +144,78 @@ namespace :deploy do
136
144
  end
137
145
  end
138
146
 
147
+ desc <<-DESC
148
+ Removes old releases and corresponding DB backups.
149
+ DESC
150
+ task :cleanup, :except => { :no_release => true } do
151
+ count = fetch(:keep_releases, 5).to_i
152
+ if count >= releases.length
153
+ logger.important "No old releases to clean up"
154
+ else
155
+ logger.info "keeping #{count} of #{releases.length} deployed releases"
156
+ old_releases = (releases - releases.last(count))
157
+ directories = old_releases.map { |release| File.join(releases_path, release) }.join(" ")
158
+ databases = old_releases.map { |release| File.join(dbbackups_path, "#{release}.sql") }.join(" ")
159
+
160
+ run "rm -rf #{directories} #{databases}"
161
+ end
162
+ end
163
+
164
+ namespace :rollback do
165
+
166
+ desc <<-DESC
167
+ [internal] Removes the most recently deployed release.
168
+ This is called by the rollback sequence, and should rarely
169
+ (if ever) need to be called directly.
170
+ DESC
171
+ task :cleanup, :except => { :no_release => true } do
172
+ # chmod 777 #{release_settings} #{release_files} &&
173
+ run "if [ `readlink #{current_path}` != #{current_release} ]; then rm -rf #{current_release}; fi"
174
+ end
175
+
176
+ desc <<-DESC
177
+ [internal] Points the current, files, and settings symlinks at the previous revision.
178
+ DESC
179
+ task :revision, :except => { :no_release => true } do
180
+ if previous_release
181
+ run <<-CMD
182
+ rm #{current_path};
183
+ ln -s #{previous_release} #{current_path};
184
+ ln -nfs #{shared_files} #{previous_release_files};
185
+ ln -nfs #{shared_settings} #{previous_release_settings}
186
+ CMD
187
+ else
188
+ abort "could not rollback the code because there is no prior release"
189
+ end
190
+ end
191
+
192
+
193
+ desc <<-DESC
194
+ [internal] If a database backup from the previous release is found, dump the current
195
+ database and import the backup. This task should NEVER be called standalone.
196
+ DESC
197
+ task :db_rollback, :except => { :no_release => true } do
198
+ if previous_release
199
+ logger.info "Dumping current database and importing previous one (If one is found)."
200
+ previous_db = File.join(dbbackups_path, "#{releases[-2]}.sql")
201
+ import_cmd = "cd #{previous_release}/#{drupal_path} && drush sql-drop -y && drush sql-cli < #{previous_db} && rm #{previous_db}"
202
+ run "if [ -e #{previous_db} ]; then #{import_cmd}; fi"
203
+ else
204
+ abort "could not rollback the database because there is no prior release db backups"
205
+ end
206
+ end
207
+
208
+ desc <<-DESC
209
+ go back to the previous release (code and database)
210
+ DESC
211
+ task :default do
212
+ revision
213
+ db_rollback
214
+ cleanup
215
+ end
216
+
217
+ end
218
+
139
219
  end
140
220
 
141
221
  # =========================
@@ -148,7 +228,7 @@ namespace :drush do
148
228
  run "cd #{current_path}/#{drupal_path} && drush cache-clear all"
149
229
  end
150
230
 
151
- desc "Revert all enabled feature module on your site"
231
+ desc "Revert all enabled feature modules on your site"
152
232
  task :fra do
153
233
  run "cd #{current_path}/#{drupal_path} && drush features-revert-all -y"
154
234
  end
@@ -160,12 +240,12 @@ namespace :drush do
160
240
  bl
161
241
  end
162
242
 
163
- desc "Enable the baseline feature"
243
+ desc "[internal] Enable the baseline feature"
164
244
  task :bl do
165
245
  run "cd #{current_path}/#{drupal_path} && drush pm-enable #{baseline} -y"
166
246
  cc
167
247
  end
168
- desc "Enable the simpletest feature"
248
+ desc "[internal] Enable the simpletest feature"
169
249
  task :enst do
170
250
  run "cd #{current_path}/#{drupal_path} && drush pm-enable simpletest -y"
171
251
  cc
@@ -178,12 +258,11 @@ namespace :drush do
178
258
 
179
259
  desc "Update via drush, runs fra, updb and cc"
180
260
  task :update do
181
- fra
182
261
  updb
262
+ fra
183
263
  cc
184
264
  end
185
265
 
186
-
187
266
  end
188
267
 
189
268
  # =========================
@@ -221,7 +300,7 @@ namespace :tests do
221
300
  test_files.map! {|f| f.sub!(drupal_path + "/","")}
222
301
  if test_files.any?
223
302
  test_files.each do |test_file|
224
- run "cd #{current_path}/#{drupal_path} && php scripts/run-tests.sh --url http://#{site} --xml '../build/simpletest' --file '#{test_file}'"
303
+ run "cd #{current_path}/#{drupal_path} && php scripts/run-tests.sh --url http://#{site} --xml '../build/simpletest' --file '#{test_file}'" unless test_file.include?('/contrib/')
225
304
  end
226
305
  end
227
306
  run "cd #{current_path}/build && tar czf simpletest.tgz simpletest"
@@ -233,6 +312,26 @@ namespace :tests do
233
312
 
234
313
  end
235
314
 
315
+ # =========================
316
+ # Manage methods
317
+ # =========================
318
+
319
+ namespace :manage do
320
+
321
+ task :block_robots do
322
+ put "User-agent: *\nDisallow: /", "#{current_path}/#{drupal_path}/robots.txt"
323
+ end
324
+
325
+ task :dbdump_previous do
326
+ #Backup the previous release's database
327
+ if previous_release
328
+ run "cd #{current_path}/#{drupal_path} && drush sql-dump > #{ File.join(dbbackups_path, "#{releases[-2]}.sql") }"
329
+ end
330
+ end
331
+
332
+ end
333
+
334
+
236
335
  # =========================
237
336
  # Helper methods
238
337
  # =========================
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: capistrano-didi
3
3
  version: !ruby/object:Gem::Version
4
- hash: 17
4
+ hash: 19
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
- - 2
9
8
  - 3
10
- version: 0.2.3
9
+ - 0
10
+ version: 0.3.0
11
11
  platform: ruby
12
12
  authors:
13
13
  - Koen Van Winckel
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2011-11-02 00:00:00 Z
18
+ date: 2011-11-24 00:00:00 Z
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
21
21
  requirement: &id001 !ruby/object:Gem::Requirement