capistrano-didi 0.3.0 → 0.3.1

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.3.0
1
+ 0.3.1
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = "capistrano-didi"
8
- s.version = "0.3.0"
8
+ s.version = "0.3.1"
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-24"
12
+ s.date = "2012-01-04"
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,6 +1,6 @@
1
1
  Capistrano::Configuration.instance.load do
2
-
3
- require 'FileUtils'
2
+
3
+ #require 'FileUtils'
4
4
 
5
5
  # =========================================================================
6
6
  # These variables MUST be set in the client capfiles. If they are not set,
@@ -15,15 +15,15 @@ _cset(:profile) { abort "Please specify the Drupal install profile (:pro
15
15
  _cset(:site) { abort "Please specify the Drupal site (:site)." }
16
16
  _cset(:sitemail) { abort "Please specify the Drupal site mail (:sitemail)." }
17
17
  _cset(:adminpass) { abort "Please specify the Drupal admin password (:adminpass)." }
18
- _cset(:sitesubdir) { abort "Please specify the Drupal site subdir (:sitemail)." } # FIXME: files folder needs to be symlinked ??
19
- _cset(:baseline) { abort "Please specify the Baseline feature (:baseline)." }
18
+ _cset(:sitesubdir) { abort "Please specify the Drupal site subdir (:sitesubdir)." } # FIXME: files folder needs to be symlinked ??
19
+ _cset(:baseline) { abort "Please specify the Baseline feature (:baseline)." }
20
20
 
21
21
 
22
22
  # =========================================================================
23
23
  # These variables may be set in the client capfile if their default values
24
24
  # are not sufficient.
25
25
  # =========================================================================
26
- set :scm, :git
26
+ set :scm, :git
27
27
  set :deploy_via, :remote_cache
28
28
  set :drupal_version, '7'
29
29
  set :keep_releases, 5
@@ -44,13 +44,13 @@ ssh_options[:forward_agent] = true
44
44
  # =========================================================================
45
45
  _cset :settings, 'settings.php'
46
46
  _cset :files, 'files'
47
- _cset :dbbackups, 'db_backups'
48
- _cset :shared_children, [domain, File.join(domain, files)]
47
+ _cset :dbbackups, 'db_backups'
48
+ _cset :shared_children, [domain, File.join(domain, files)]
49
49
 
50
50
  _cset(:shared_settings) { File.join(shared_path, domain, settings) }
51
51
  _cset(:shared_files) { File.join(shared_path, domain, files) }
52
52
  _cset(:dbbackups_path) { File.join(deploy_to, dbbackups, domain) }
53
- _cset(:drush) { "drush -r #{current_path}" + (domain == 'default' ? '' : " -l #{domain}") }
53
+ _cset(:drush) { "drush -r #{current_path}" + (domain == 'default' ? '' : " -l #{domain}") } # FIXME: not in use?
54
54
 
55
55
  _cset(:release_settings) { File.join(release_path, drupal_path, 'sites', domain, settings) }
56
56
  _cset(:release_files) { File.join(release_path, drupal_path, 'sites', domain, files) }
@@ -60,12 +60,19 @@ _cset(:previous_release_settings) { releases.length > 1 ? File.join(previous
60
60
  _cset(:previous_release_files) { releases.length > 1 ? File.join(previous_release, drupal_path, 'sites', domain, files) : nil }
61
61
  _cset(:previous_release_domain) { releases.length > 1 ? File.join(previous_release, drupal_path, 'sites', domain) : nil }
62
62
 
63
+ # =========================================================================
64
+ # Extra dependecy checks
65
+ # =========================================================================
66
+ depend :local, :command, "drush"
67
+ depend :remote, :command, "drush"
68
+
69
+
63
70
  # =========================================================================
64
71
  # Overwrites to the DEPLOY tasks in the capistrano library.
65
72
  # =========================================================================
66
73
 
67
74
  namespace :deploy do
68
-
75
+
69
76
  desc <<-DESC
70
77
  Deploys your Drupal site. It supposes that the Setup task was already executed.
71
78
  This overrides the default Capistrano Deploy task to handle database operations and backups,
@@ -87,15 +94,15 @@ namespace :deploy do
87
94
  end
88
95
  end
89
96
  after "deploy:cold", "drush:si"
90
-
97
+
91
98
  desc "Deploys latest code and rebuild the database"
92
99
  task :rebuild do
93
- update_code
100
+ update_code
94
101
  symlink
95
102
  manage.dbdump_previous
96
103
  end
97
104
  after "deploy:rebuild", "drush:si"
98
-
105
+
99
106
  desc <<-DESC
100
107
  Prepares one or more servers for deployment.
101
108
  Creates the necessary file structure and the shared Drupal settings file.
@@ -105,7 +112,7 @@ namespace :deploy do
105
112
  configuration = drupal_settings(drupal_version)
106
113
 
107
114
  #Create shared directories
108
- dirs = [deploy_to, releases_path, shared_path, dbbackups_path]
115
+ dirs = [deploy_to, releases_path, shared_path, dbbackups_path, shared_files]
109
116
  dirs += shared_children.map { |d| File.join(shared_path, d) }
110
117
  run <<-CMD
111
118
  mkdir -p #{dirs.join(' ')} &&
@@ -116,7 +123,7 @@ namespace :deploy do
116
123
  #create drupal config file
117
124
  put configuration, shared_settings
118
125
  end
119
-
126
+
120
127
  desc "[internal] Rebuild files and settings symlinks"
121
128
  task :finalize_update, :except => { :no_release => true } do
122
129
  on_rollback do
@@ -127,23 +134,23 @@ namespace :deploy do
127
134
  end
128
135
  end
129
136
 
130
-
131
- run "if [[ ! -d #{release_domain} ]]; then mkdir #{release_domain}; fi" # in case the default is not versioned
132
-
133
- run <<-CMD
137
+
138
+ run "if [ ! -d #{release_domain} ]; then mkdir #{release_domain}; fi" # in case the default is not versioned
139
+
140
+ run <<-CMD
134
141
  ln -nfs #{shared_files} #{release_files} &&
135
142
  ln -nfs #{shared_settings} #{release_settings}
136
143
  CMD
137
144
 
138
145
  if previous_release
139
- run "if [[ -d #{previous_release_domain} ]]; then chmod 777 #{previous_release_domain}; fi" # if drupal changed the permissions of the folder
146
+ run "if [ -d #{previous_release_domain} ]; then chmod 777 #{previous_release_domain}; fi" # if drupal changed the permissions of the folder
140
147
  run <<-CMD
141
148
  rm -f #{previous_release_settings} &&
142
149
  rm -f #{previous_release_files}
143
150
  CMD
144
- end
151
+ end
145
152
  end
146
-
153
+
147
154
  desc <<-DESC
148
155
  Removes old releases and corresponding DB backups.
149
156
  DESC
@@ -160,9 +167,9 @@ namespace :deploy do
160
167
  run "rm -rf #{directories} #{databases}"
161
168
  end
162
169
  end
163
-
164
- namespace :rollback do
165
-
170
+
171
+ namespace :rollback do
172
+
166
173
  desc <<-DESC
167
174
  [internal] Removes the most recently deployed release.
168
175
  This is called by the rollback sequence, and should rarely
@@ -172,7 +179,7 @@ namespace :deploy do
172
179
  # chmod 777 #{release_settings} #{release_files} &&
173
180
  run "if [ `readlink #{current_path}` != #{current_release} ]; then rm -rf #{current_release}; fi"
174
181
  end
175
-
182
+
176
183
  desc <<-DESC
177
184
  [internal] Points the current, files, and settings symlinks at the previous revision.
178
185
  DESC
@@ -222,24 +229,24 @@ end
222
229
  # Drush namespace tasks
223
230
  # =========================
224
231
  namespace :drush do
225
-
232
+
226
233
  desc "Clear the Drupal site cache"
227
234
  task :cc do
228
235
  run "cd #{current_path}/#{drupal_path} && drush cache-clear all"
229
236
  end
230
-
237
+
231
238
  desc "Revert all enabled feature modules on your site"
232
239
  task :fra do
233
240
  run "cd #{current_path}/#{drupal_path} && drush features-revert-all -y"
234
241
  end
235
-
242
+
236
243
  desc "Install Drupal along with modules/themes/configuration using the specified install profile"
237
244
  task :si do
238
- dburl = "#{db_type}://#{db_username}:#{db_password}@localhost/#{db_name}"
239
- run "cd #{current_path}/#{drupal_path} && drush site-install #{profile} --db-url=#{dburl} --sites-subdir=default --account-name=admin --account-pass=#{adminpass} --account-mail=#{sitemail} --site-mail='#{sitemail}' --site-name='#{site}' -y"
245
+ dburl = "#{db_type}://#{db_username}:#{db_password}@#{db_host}/#{db_name}"
246
+ run "cd #{current_path}/#{drupal_path} && drush site-install #{profile} --db-url=#{dburl} --sites-subdir=default --account-name=admin --account-pass=#{adminpass} --account-mail=#{sitemail} --site-mail='#{sitemail}' --site-name='#{site}' -y"
240
247
  bl
241
248
  end
242
-
249
+
243
250
  desc "[internal] Enable the baseline feature"
244
251
  task :bl do
245
252
  run "cd #{current_path}/#{drupal_path} && drush pm-enable #{baseline} -y"
@@ -250,12 +257,12 @@ namespace :drush do
250
257
  run "cd #{current_path}/#{drupal_path} && drush pm-enable simpletest -y"
251
258
  cc
252
259
  end
253
-
260
+
254
261
  desc "Apply any database updates required (as with running update.php)"
255
262
  task :updb do
256
263
  run "cd #{current_path}/#{drupal_path} && drush updatedb -y"
257
264
  end
258
-
265
+
259
266
  desc "Update via drush, runs fra, updb and cc"
260
267
  task :update do
261
268
  updb
@@ -270,7 +277,7 @@ end
270
277
  # =========================
271
278
 
272
279
  namespace :tests do
273
-
280
+
274
281
  desc "Test php lint"
275
282
  task :php_lint_test do
276
283
  errors = []
@@ -290,9 +297,9 @@ namespace :tests do
290
297
 
291
298
  desc "Core hack detection"
292
299
  task :checksum_core_test do
293
-
300
+
294
301
  end
295
-
302
+
296
303
  desc 'Runs unit tests for given site'
297
304
  task :unit do
298
305
  run "mkdir -p #{current_path}/build/simpletest"
@@ -303,13 +310,28 @@ namespace :tests do
303
310
  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/')
304
311
  end
305
312
  end
313
+
306
314
  run "cd #{current_path}/build && tar czf simpletest.tgz simpletest"
307
- exec "if [[ ! -d build ]]; then mkdir build; fi" # create build folder locally if needed
315
+ system "if [ ! -d build ]; then mkdir build; fi" # create build folder locally if needed
308
316
  download "#{current_path}/build/simpletest.tgz", "build/", :once => true, :via => :scp
309
- exec "tar xzf build/simpletest.tgz -C build"
317
+ system "tar xzf build/simpletest.tgz -C build"
318
+
310
319
  end
311
320
  before "tests:unit", "drush:enst"
312
-
321
+
322
+ desc 'Runs all unit tests for given site'
323
+ task :unit_all do
324
+ run "mkdir -p #{current_path}/build/simpletest"
325
+ run "cd #{current_path}/#{drupal_path} && php scripts/run-tests.sh --url http://#{site} --xml '../build/simpletest' --all"
326
+
327
+ run "cd #{current_path}/build && tar czf simpletest.tgz simpletest"
328
+ system "if [ ! -d build ]; then mkdir build; fi" # create build folder locally if needed
329
+ download "#{current_path}/build/simpletest.tgz", "build/", :once => true, :via => :scp
330
+ system "tar xzf build/simpletest.tgz -C build"
331
+
332
+ end
333
+ before "tests:unit_all", "drush:enst"
334
+
313
335
  end
314
336
 
315
337
  # =========================
@@ -317,18 +339,34 @@ end
317
339
  # =========================
318
340
 
319
341
  namespace :manage do
320
-
342
+
321
343
  task :block_robots do
322
344
  put "User-agent: *\nDisallow: /", "#{current_path}/#{drupal_path}/robots.txt"
323
345
  end
324
-
346
+
325
347
  task :dbdump_previous do
326
- #Backup the previous release's database
348
+ #Backup the previous release's database
327
349
  if previous_release
328
350
  run "cd #{current_path}/#{drupal_path} && drush sql-dump > #{ File.join(dbbackups_path, "#{releases[-2]}.sql") }"
329
351
  end
330
352
  end
331
-
353
+
354
+ desc 'Dump remote database and restore locally'
355
+ task :pull_dump do
356
+ sql_file = File.join(dbbackups_path, "#{releases.last}-pull.sql")
357
+ # dump & gzip remote file
358
+ run "cd #{current_path}/#{drupal_path} && drush sql-dump > #{sql_file} && gzip -f #{sql_file}"
359
+ # copy to local
360
+ system "if [ ! -d build ]; then mkdir build; fi" # create build folder locally if needed
361
+ download "#{sql_file}.gz", "build/", :once => true, :via => :scp
362
+ run "rm #{sql_file}.gz"
363
+ # extract and restore
364
+ system "gunzip -f build/#{File.basename(sql_file)}.gz && mysql dotproject_oa_live < build/#{File.basename(sql_file)}"
365
+ end
366
+
367
+ task :push_dump do
368
+
369
+ end
332
370
  end
333
371
 
334
372
 
@@ -338,7 +376,7 @@ end
338
376
 
339
377
  # Builds initial contents of the Drupal website's settings file
340
378
  def drupal_settings(version)
341
- if version == '6'
379
+ if version.to_s == '6'
342
380
  settings = <<-STRING
343
381
  <?php
344
382
  $db_url = "#{db_type}://#{db_username}:#{db_password}@#{db_host}/#{db_name}";
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: 19
4
+ hash: 17
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 3
9
- - 0
10
- version: 0.3.0
9
+ - 1
10
+ version: 0.3.1
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-24 00:00:00 Z
18
+ date: 2012-01-04 00:00:00 Z
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
21
21
  requirement: &id001 !ruby/object:Gem::Requirement