capistrano-didi 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/.document +5 -0
- data/Gemfile +16 -0
- data/Gemfile.lock +40 -0
- data/LICENSE.txt +20 -0
- data/README.rdoc +19 -0
- data/Rakefile +53 -0
- data/VERSION +1 -0
- data/bin/didi +4 -0
- data/bin/didify +97 -0
- data/capistrano-didi.gemspec +71 -0
- data/lib/didi/recipes/didi.rb +248 -0
- data/test/helper.rb +18 -0
- data/test/test_didi.rb +7 -0
- metadata +188 -0
data/.document
ADDED
data/Gemfile
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
source "http://rubygems.org"
|
2
|
+
# Add dependencies required to use your gem here.
|
3
|
+
# Example:
|
4
|
+
# gem "activesupport", ">= 2.3.5"
|
5
|
+
|
6
|
+
# Add dependencies to develop your gem here.
|
7
|
+
# Include everything needed to run rake, tests, features, etc.
|
8
|
+
group :development do
|
9
|
+
gem "railsless-deploy", ">= 1.0.2"
|
10
|
+
gem "capistrano-ext", ">= 1.2.1"
|
11
|
+
gem "capistrano", ">= 2.9.0"
|
12
|
+
gem "shoulda", ">= 0"
|
13
|
+
gem "bundler", "~> 1.0.0"
|
14
|
+
gem "jeweler", "~> 1.6.4"
|
15
|
+
gem "rcov", ">= 0"
|
16
|
+
end
|
data/Gemfile.lock
ADDED
@@ -0,0 +1,40 @@
|
|
1
|
+
GEM
|
2
|
+
remote: http://rubygems.org/
|
3
|
+
specs:
|
4
|
+
capistrano (2.9.0)
|
5
|
+
highline
|
6
|
+
net-scp (>= 1.0.0)
|
7
|
+
net-sftp (>= 2.0.0)
|
8
|
+
net-ssh (>= 2.0.14)
|
9
|
+
net-ssh-gateway (>= 1.1.0)
|
10
|
+
capistrano-ext (1.2.1)
|
11
|
+
capistrano (>= 1.0.0)
|
12
|
+
git (1.2.5)
|
13
|
+
highline (1.6.2)
|
14
|
+
jeweler (1.6.4)
|
15
|
+
bundler (~> 1.0)
|
16
|
+
git (>= 1.2.5)
|
17
|
+
rake
|
18
|
+
net-scp (1.0.4)
|
19
|
+
net-ssh (>= 1.99.1)
|
20
|
+
net-sftp (2.0.5)
|
21
|
+
net-ssh (>= 2.0.9)
|
22
|
+
net-ssh (2.2.1)
|
23
|
+
net-ssh-gateway (1.1.0)
|
24
|
+
net-ssh (>= 1.99.1)
|
25
|
+
railsless-deploy (1.0.2)
|
26
|
+
rake (0.9.2.2)
|
27
|
+
rcov (0.9.11)
|
28
|
+
shoulda (2.11.3)
|
29
|
+
|
30
|
+
PLATFORMS
|
31
|
+
ruby
|
32
|
+
|
33
|
+
DEPENDENCIES
|
34
|
+
bundler (~> 1.0.0)
|
35
|
+
capistrano (>= 2.9.0)
|
36
|
+
capistrano-ext (>= 1.2.1)
|
37
|
+
jeweler (~> 1.6.4)
|
38
|
+
railsless-deploy (>= 1.0.2)
|
39
|
+
rcov
|
40
|
+
shoulda
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2011 Koen Van Winckel
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.rdoc
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
= didi
|
2
|
+
|
3
|
+
Description goes here.
|
4
|
+
|
5
|
+
== Contributing to didi
|
6
|
+
|
7
|
+
* Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet
|
8
|
+
* Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it
|
9
|
+
* Fork the project
|
10
|
+
* Start a feature/bugfix branch
|
11
|
+
* Commit and push until you are happy with your contribution
|
12
|
+
* Make sure to add tests for it. This is important so I don't break it in a future version unintentionally.
|
13
|
+
* Please try not to mess with the Rakefile, version, or history. If you want to have your own version, or is otherwise necessary, that is fine, but please isolate to its own commit so I can cherry-pick around it.
|
14
|
+
|
15
|
+
== Copyright
|
16
|
+
|
17
|
+
Copyright (c) 2011 Koen Van Winckel. See LICENSE.txt for
|
18
|
+
further details.
|
19
|
+
|
data/Rakefile
ADDED
@@ -0,0 +1,53 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
require 'rubygems'
|
4
|
+
require 'bundler'
|
5
|
+
begin
|
6
|
+
Bundler.setup(:default, :development)
|
7
|
+
rescue Bundler::BundlerError => e
|
8
|
+
$stderr.puts e.message
|
9
|
+
$stderr.puts "Run `bundle install` to install missing gems"
|
10
|
+
exit e.status_code
|
11
|
+
end
|
12
|
+
require 'rake'
|
13
|
+
|
14
|
+
require 'jeweler'
|
15
|
+
Jeweler::Tasks.new do |gem|
|
16
|
+
# gem is a Gem::Specification... see http://docs.rubygems.org/read/chapter/20 for more options
|
17
|
+
gem.name = "capistrano-didi"
|
18
|
+
gem.homepage = "http://github.com/koenvw/didi"
|
19
|
+
gem.license = "MIT"
|
20
|
+
gem.summary = %Q{didi - drupal deployment script based on capistrano}
|
21
|
+
gem.description = %Q{didi is a collection of recipes for capistrano that allow drupal to be deployed, tested and used in a CI environment}
|
22
|
+
gem.email = "koenvw@gmail.com"
|
23
|
+
gem.authors = ["Koen Van Winckel"]
|
24
|
+
# dependencies defined in Gemfile
|
25
|
+
end
|
26
|
+
Jeweler::RubygemsDotOrgTasks.new
|
27
|
+
|
28
|
+
require 'rake/testtask'
|
29
|
+
Rake::TestTask.new(:test) do |test|
|
30
|
+
test.libs << 'lib' << 'test'
|
31
|
+
test.pattern = 'test/**/test_*.rb'
|
32
|
+
test.verbose = true
|
33
|
+
end
|
34
|
+
|
35
|
+
require 'rcov/rcovtask'
|
36
|
+
Rcov::RcovTask.new do |test|
|
37
|
+
test.libs << 'test'
|
38
|
+
test.pattern = 'test/**/test_*.rb'
|
39
|
+
test.verbose = true
|
40
|
+
test.rcov_opts << '--exclude "gems/*"'
|
41
|
+
end
|
42
|
+
|
43
|
+
task :default => :test
|
44
|
+
|
45
|
+
require 'rake/rdoctask'
|
46
|
+
Rake::RDocTask.new do |rdoc|
|
47
|
+
version = File.exist?('VERSION') ? File.read('VERSION') : ""
|
48
|
+
|
49
|
+
rdoc.rdoc_dir = 'rdoc'
|
50
|
+
rdoc.title = "didi #{version}"
|
51
|
+
rdoc.rdoc_files.include('README*')
|
52
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
53
|
+
end
|
data/VERSION
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
0.1.0
|
data/bin/didi
ADDED
data/bin/didify
ADDED
@@ -0,0 +1,97 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require 'optparse'
|
4
|
+
require 'fileutils'
|
5
|
+
|
6
|
+
OptionParser.new do |opts|
|
7
|
+
opts.banner = "Usage: #{File.basename($0)} [path]"
|
8
|
+
|
9
|
+
opts.on("-h", "--help", "Displays this help info") do
|
10
|
+
puts opts
|
11
|
+
exit 0
|
12
|
+
end
|
13
|
+
|
14
|
+
begin
|
15
|
+
opts.parse!(ARGV)
|
16
|
+
rescue OptionParser::ParseError => e
|
17
|
+
warn e.message
|
18
|
+
puts opts
|
19
|
+
exit 1
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
if ARGV.empty?
|
24
|
+
abort "Please specify the directory to didify, e.g. `#{File.basename($0)} .'"
|
25
|
+
elsif !File.exists?(ARGV.first)
|
26
|
+
abort "`#{ARGV.first}' does not exist."
|
27
|
+
elsif !File.directory?(ARGV.first)
|
28
|
+
abort "`#{ARGV.first}' is not a directory."
|
29
|
+
elsif ARGV.length > 1
|
30
|
+
abort "Too many arguments; please specify only the directory to didify."
|
31
|
+
end
|
32
|
+
|
33
|
+
def unindent(string)
|
34
|
+
indentation = string[/\A\s*/]
|
35
|
+
string.strip.gsub(/^#{indentation}/, "")
|
36
|
+
end
|
37
|
+
|
38
|
+
files = {
|
39
|
+
"Capfile" => unindent(<<-FILE),
|
40
|
+
require 'railsless-deploy' # gem install railsless-deploy
|
41
|
+
require 'capistrano/ext/multistage' # gem install capistrano-ext
|
42
|
+
require 'didi/recipes/didi.rb' # gem install capistrano-didi
|
43
|
+
load 'config/deploy'
|
44
|
+
FILE
|
45
|
+
|
46
|
+
"config/deploy.rb" => 'set :default_stage, "staging"
|
47
|
+
set :stages, %w(staging production)
|
48
|
+
set :application, "set your application name here"
|
49
|
+
set :repository, "set your repository location here"
|
50
|
+
set :drupal_path, "drupal" # change this to your drupal folder
|
51
|
+
',
|
52
|
+
"config/deploy/staging.rb" => 'set :user, "set your shell user here"
|
53
|
+
server "set your server hostname here", :app, :web, :db, :primary => true
|
54
|
+
|
55
|
+
set :deploy_to, "the path on the remote server"
|
56
|
+
set :branch, "master"
|
57
|
+
|
58
|
+
set :db_type, "mysql"
|
59
|
+
set :db_name, "set database name"
|
60
|
+
set :db_username, "set database user name"
|
61
|
+
set :db_password, "set database password"
|
62
|
+
|
63
|
+
set :profile, "minimal"
|
64
|
+
set :site, "apache vhost here"
|
65
|
+
set :sitemail, "drupal site email address"
|
66
|
+
set :adminpass, "drupal admin pass"
|
67
|
+
set :sitesubdir, "default"
|
68
|
+
|
69
|
+
set :baseline, "drupal feature to activate after fresh install"
|
70
|
+
'}
|
71
|
+
|
72
|
+
base = ARGV.shift
|
73
|
+
files.each do |file, content|
|
74
|
+
file = File.join(base, file)
|
75
|
+
if File.exists?(file)
|
76
|
+
warn "[skip] '#{file}' already exists"
|
77
|
+
elsif File.exists?(file.downcase)
|
78
|
+
warn "[skip] '#{file.downcase}' exists, which could conflict with `#{file}'"
|
79
|
+
else
|
80
|
+
unless File.exists?(File.dirname(file))
|
81
|
+
puts "[add] making directory '#{File.dirname(file)}'"
|
82
|
+
FileUtils.mkdir_p(File.dirname(file))
|
83
|
+
end
|
84
|
+
puts "[add] writing '#{file}'"
|
85
|
+
File.open(file, "w") { |f| f.write(content) }
|
86
|
+
end
|
87
|
+
end
|
88
|
+
|
89
|
+
puts "[done] didified!"
|
90
|
+
|
91
|
+
unless File.exists?("drupal")
|
92
|
+
puts 'WARNING: drupal folder not found! install drupal in folder "drupal" or change the :drupal_path variable.'
|
93
|
+
puts 'WARNING: for example: drush dl drupal --drupal-project-rename="drupal"'
|
94
|
+
end
|
95
|
+
|
96
|
+
puts ""
|
97
|
+
puts 'After editing your config files just run: didi deploy:setup and then didi deploy'
|
@@ -0,0 +1,71 @@
|
|
1
|
+
# Generated by jeweler
|
2
|
+
# DO NOT EDIT THIS FILE DIRECTLY
|
3
|
+
# Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
|
4
|
+
# -*- encoding: utf-8 -*-
|
5
|
+
|
6
|
+
Gem::Specification.new do |s|
|
7
|
+
s.name = %q{capistrano-didi}
|
8
|
+
s.version = "0.1.0"
|
9
|
+
|
10
|
+
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
|
+
s.authors = ["Koen Van Winckel"]
|
12
|
+
s.date = %q{2011-10-25}
|
13
|
+
s.description = %q{didi is a collection of recipes for capistrano that allow drupal to be deployed, tested and used in a CI environment}
|
14
|
+
s.email = %q{koenvw@gmail.com}
|
15
|
+
s.executables = ["didify", "didi"]
|
16
|
+
s.extra_rdoc_files = [
|
17
|
+
"LICENSE.txt",
|
18
|
+
"README.rdoc"
|
19
|
+
]
|
20
|
+
s.files = [
|
21
|
+
".document",
|
22
|
+
"Gemfile",
|
23
|
+
"Gemfile.lock",
|
24
|
+
"LICENSE.txt",
|
25
|
+
"README.rdoc",
|
26
|
+
"Rakefile",
|
27
|
+
"VERSION",
|
28
|
+
"bin/didi",
|
29
|
+
"bin/didify",
|
30
|
+
"capistrano-didi.gemspec",
|
31
|
+
"lib/didi/recipes/didi.rb",
|
32
|
+
"test/helper.rb",
|
33
|
+
"test/test_didi.rb"
|
34
|
+
]
|
35
|
+
s.homepage = %q{http://github.com/koenvw/didi}
|
36
|
+
s.licenses = ["MIT"]
|
37
|
+
s.require_paths = ["lib"]
|
38
|
+
s.rubygems_version = %q{1.6.2}
|
39
|
+
s.summary = %q{didi - drupal deployment script based on capistrano}
|
40
|
+
|
41
|
+
if s.respond_to? :specification_version then
|
42
|
+
s.specification_version = 3
|
43
|
+
|
44
|
+
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
45
|
+
s.add_development_dependency(%q<railsless-deploy>, [">= 1.0.2"])
|
46
|
+
s.add_development_dependency(%q<capistrano-ext>, [">= 1.2.1"])
|
47
|
+
s.add_development_dependency(%q<capistrano>, [">= 2.9.0"])
|
48
|
+
s.add_development_dependency(%q<shoulda>, [">= 0"])
|
49
|
+
s.add_development_dependency(%q<bundler>, ["~> 1.0.0"])
|
50
|
+
s.add_development_dependency(%q<jeweler>, ["~> 1.6.4"])
|
51
|
+
s.add_development_dependency(%q<rcov>, [">= 0"])
|
52
|
+
else
|
53
|
+
s.add_dependency(%q<railsless-deploy>, [">= 1.0.2"])
|
54
|
+
s.add_dependency(%q<capistrano-ext>, [">= 1.2.1"])
|
55
|
+
s.add_dependency(%q<capistrano>, [">= 2.9.0"])
|
56
|
+
s.add_dependency(%q<shoulda>, [">= 0"])
|
57
|
+
s.add_dependency(%q<bundler>, ["~> 1.0.0"])
|
58
|
+
s.add_dependency(%q<jeweler>, ["~> 1.6.4"])
|
59
|
+
s.add_dependency(%q<rcov>, [">= 0"])
|
60
|
+
end
|
61
|
+
else
|
62
|
+
s.add_dependency(%q<railsless-deploy>, [">= 1.0.2"])
|
63
|
+
s.add_dependency(%q<capistrano-ext>, [">= 1.2.1"])
|
64
|
+
s.add_dependency(%q<capistrano>, [">= 2.9.0"])
|
65
|
+
s.add_dependency(%q<shoulda>, [">= 0"])
|
66
|
+
s.add_dependency(%q<bundler>, ["~> 1.0.0"])
|
67
|
+
s.add_dependency(%q<jeweler>, ["~> 1.6.4"])
|
68
|
+
s.add_dependency(%q<rcov>, [">= 0"])
|
69
|
+
end
|
70
|
+
end
|
71
|
+
|
@@ -0,0 +1,248 @@
|
|
1
|
+
Capistrano::Configuration.instance.load do
|
2
|
+
|
3
|
+
# =============================================
|
4
|
+
# Script variables. These must be set in client capfile.
|
5
|
+
# =============================================
|
6
|
+
_cset(:db_type) { abort "Please specify the Drupal database type (:db_type)." }
|
7
|
+
_cset(:db_name) { abort "Please specify the Drupal database name (:db_name)." }
|
8
|
+
_cset(:db_username) { abort "Please specify the Drupal database username (:db_username)." }
|
9
|
+
_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
|
+
|
12
|
+
_cset(:profile) { abort "Please specify the Drupal install profile (:profile)." }
|
13
|
+
_cset(:site) { abort "Please specify the Drupal site (:site)." }
|
14
|
+
_cset(:sitemail) { abort "Please specify the Drupal site mail (:sitemail)." }
|
15
|
+
_cset(:adminpass) { abort "Please specify the Drupal admin password (:adminpass)." }
|
16
|
+
_cset(:sitesubdir) { abort "Please specify the Drupal site subdir (:sitemail)." } # FIXME: files folder needs to be symlinked ??
|
17
|
+
_cset(:baseline) { abort "Please specify the Baseline feature (:baseline)." }
|
18
|
+
|
19
|
+
|
20
|
+
# Fixed defaults. Change these at your own risk, (well tested) support for different values is left for future versions.
|
21
|
+
set :scm, :git
|
22
|
+
set :deploy_via, :remote_cache
|
23
|
+
set :drupal_version, '7'
|
24
|
+
# Only bother to keep the last five releases
|
25
|
+
set :keep_releases, 5
|
26
|
+
set :use_sudo, false
|
27
|
+
|
28
|
+
# ==============================================
|
29
|
+
# Defaults. You may change these to your projects convenience
|
30
|
+
# ==============================================
|
31
|
+
#ssh_options[:verbose] = :debug #FIXME
|
32
|
+
_cset :domain, 'default'
|
33
|
+
_cset :db_host, 'localhost'
|
34
|
+
_cset :drupal_path, 'drupal'
|
35
|
+
_cset :srv_usr, 'www-data'
|
36
|
+
#_cset :srv_password, 'www-data' #FIXME
|
37
|
+
|
38
|
+
# ===============================================
|
39
|
+
# Script constants. These should not be changed
|
40
|
+
# ===============================================
|
41
|
+
set :settings, 'settings.php'
|
42
|
+
set :files, 'files'
|
43
|
+
set :dbbackups, 'db_backups'
|
44
|
+
set :shared_children, [domain, File.join(domain, files)]
|
45
|
+
|
46
|
+
_cset(:shared_settings) { File.join(shared_path, domain, settings) }
|
47
|
+
_cset(:shared_files) { File.join(shared_path, domain, files) }
|
48
|
+
_cset(:dbbackups_path) { File.join(deploy_to, dbbackups, domain) }
|
49
|
+
_cset(:drush) { "drush -r #{current_path}" + (domain == 'default' ? '' : " -l #{domain}") }
|
50
|
+
|
51
|
+
_cset(:release_settings) { File.join(release_path, drupal_path, 'sites', domain, settings) }
|
52
|
+
_cset(:release_files) { File.join(release_path, drupal_path, 'sites', domain, files) }
|
53
|
+
_cset(:release_domain) { File.join(release_path, drupal_path, 'sites', domain) }
|
54
|
+
|
55
|
+
_cset(:previous_release_settings) { releases.length > 1 ? File.join(previous_release, drupal_path, 'sites', domain, settings) : nil }
|
56
|
+
_cset(:previous_release_files) { releases.length > 1 ? File.join(previous_release, drupal_path, 'sites', domain, files) : nil }
|
57
|
+
_cset(:previous_release_domain) { releases.length > 1 ? File.join(previous_release, drupal_path, 'sites', domain) : nil }
|
58
|
+
|
59
|
+
# =========================================================================
|
60
|
+
# Overwrites to the DEPLOY tasks in the capistrano library.
|
61
|
+
# =========================================================================
|
62
|
+
|
63
|
+
namespace :deploy do
|
64
|
+
|
65
|
+
desc <<-DESC
|
66
|
+
Deploys your Drupal site. It supposes that the Setup task was already executed.
|
67
|
+
This overrides the default Capistrano Deploy task to handle database operations and backups,
|
68
|
+
all of them via Drush.
|
69
|
+
DESC
|
70
|
+
task :default do
|
71
|
+
update
|
72
|
+
cleanup
|
73
|
+
end
|
74
|
+
#before "deploy:update", "tests:php_lint_test"
|
75
|
+
|
76
|
+
desc "Deploys latest code and rebuild the database"
|
77
|
+
task :rebuild do
|
78
|
+
default
|
79
|
+
end
|
80
|
+
after "deploy:rebuild", "drush:si"
|
81
|
+
|
82
|
+
desc <<-DESC
|
83
|
+
Prepares one or more servers for deployment.
|
84
|
+
Creates the necessary file structure and the shared Drupal settings file.
|
85
|
+
DESC
|
86
|
+
task :setup, :except => { :no_release => true } do
|
87
|
+
#try to create configuration file before writing directories to server
|
88
|
+
configuration = drupal_settings(drupal_version)
|
89
|
+
|
90
|
+
#Create shared directories
|
91
|
+
dirs = [deploy_to, releases_path, shared_path, dbbackups_path]
|
92
|
+
dirs += shared_children.map { |d| File.join(shared_path, d) }
|
93
|
+
run <<-CMD
|
94
|
+
mkdir -p #{dirs.join(' ')} &&
|
95
|
+
#{try_sudo} chown #{user}:#{srv_usr} #{shared_files}
|
96
|
+
CMD
|
97
|
+
|
98
|
+
#create drupal config file
|
99
|
+
put configuration, shared_settings
|
100
|
+
end
|
101
|
+
|
102
|
+
desc "Rebuild files and settings symlinks"
|
103
|
+
task :finalize_update, :except => { :no_release => true } do
|
104
|
+
on_rollback do
|
105
|
+
if previous_release
|
106
|
+
run "ln -nfs #{shared_files} #{previous_release_files} && ln -nfs #{shared_settings} #{previous_release_settings}"
|
107
|
+
else
|
108
|
+
logger.important "no previous release to rollback to, rollback of drupal shared data skipped."
|
109
|
+
end
|
110
|
+
end
|
111
|
+
|
112
|
+
|
113
|
+
run "if [[ ! -d #{release_domain} ]]; then mkdir #{release_domain}; fi" # in case the default is not versioned
|
114
|
+
|
115
|
+
run <<-CMD
|
116
|
+
ln -nfs #{shared_files} #{release_files} &&
|
117
|
+
ln -nfs #{shared_settings} #{release_settings}
|
118
|
+
CMD
|
119
|
+
|
120
|
+
if previous_release
|
121
|
+
run "if [[ -d #{previous_release_domain} ]]; then chmod 777 #{previous_release_domain}; fi" # if drupal changed the permissions of the folder
|
122
|
+
run <<-CMD
|
123
|
+
rm -f #{previous_release_settings} &&
|
124
|
+
rm -f #{previous_release_files}
|
125
|
+
CMD
|
126
|
+
end
|
127
|
+
end
|
128
|
+
|
129
|
+
end
|
130
|
+
|
131
|
+
# =========================
|
132
|
+
# Drush namespace tasks
|
133
|
+
# =========================
|
134
|
+
namespace :drush do
|
135
|
+
|
136
|
+
desc "Clear the Drupal site cache"
|
137
|
+
task :cc do
|
138
|
+
run "cd #{current_path}/#{drupal_path} && drush cache-clear all"
|
139
|
+
end
|
140
|
+
|
141
|
+
desc "Revert all enabled feature module on your site"
|
142
|
+
task :fra do
|
143
|
+
run "cd #{current_path}/#{drupal_path} && drush features-revert-all -y"
|
144
|
+
end
|
145
|
+
|
146
|
+
desc "Install Drupal along with modules/themes/configuration using the specified install profile"
|
147
|
+
task :si do
|
148
|
+
dburl = "#{db_type}://#{db_username}:#{db_password}@localhost/#{db_name}"
|
149
|
+
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"
|
150
|
+
bl
|
151
|
+
end
|
152
|
+
|
153
|
+
desc "Enable the baseline feature"
|
154
|
+
task :bl do
|
155
|
+
run "cd #{current_path}/#{drupal_path} && drush pm-enable #{baseline} -y"
|
156
|
+
cc
|
157
|
+
end
|
158
|
+
|
159
|
+
desc "Apply any database updates required (as with running update.php)"
|
160
|
+
task :updb do
|
161
|
+
run "cd #{current_path}/#{drupal_path} && drush updatedb -y"
|
162
|
+
end
|
163
|
+
|
164
|
+
desc "Update via drush, runs fra, updb and cc"
|
165
|
+
task :update do
|
166
|
+
fra
|
167
|
+
updb
|
168
|
+
cc
|
169
|
+
end
|
170
|
+
|
171
|
+
after "deploy:symlink", "drush:update"
|
172
|
+
#after "deploy:setup", "drush:si"
|
173
|
+
|
174
|
+
end
|
175
|
+
|
176
|
+
# =========================
|
177
|
+
# Tests methods
|
178
|
+
# =========================
|
179
|
+
|
180
|
+
namespace :tests do
|
181
|
+
|
182
|
+
desc "Test php lint"
|
183
|
+
task :php_lint_test do
|
184
|
+
errors = []
|
185
|
+
|
186
|
+
test_files = Dir.glob( File.join( drupal_path, 'sites', '**', '*.{engine,inc,info,install,make,module,php,profile,test,theme,tpl,xtmpl}' ) )
|
187
|
+
if test_files.any?
|
188
|
+
test_files.each do |test_file|
|
189
|
+
begin
|
190
|
+
fail unless system("php -l '#{test_file}' > /dev/null")
|
191
|
+
rescue
|
192
|
+
errors << test_file
|
193
|
+
end
|
194
|
+
end
|
195
|
+
end
|
196
|
+
|
197
|
+
puts "Commit tests failed on files:\n" + errors.join( "\n" ) unless errors.empty?
|
198
|
+
exit 1 unless errors.empty?
|
199
|
+
end
|
200
|
+
|
201
|
+
desc "Core hack detection"
|
202
|
+
task :checksum_core_test do
|
203
|
+
|
204
|
+
end
|
205
|
+
|
206
|
+
desc 'Runs unit tests for given site'
|
207
|
+
task :unit do
|
208
|
+
test_files = Dir.glob( File.join( drupal_path, 'sites', '**', '*.test' ) )
|
209
|
+
puts test_files
|
210
|
+
if test_files.any?
|
211
|
+
test_files.each do |test_file|
|
212
|
+
fail 'Unit tests failed' unless system("php ./drupal/scripts/run-tests.sh --url http://#{site} --file '#{test_file}'")
|
213
|
+
end
|
214
|
+
end
|
215
|
+
end
|
216
|
+
|
217
|
+
end
|
218
|
+
|
219
|
+
# =========================
|
220
|
+
# Helper methods
|
221
|
+
# =========================
|
222
|
+
|
223
|
+
# Builds initial contents of the Drupal website's settings file
|
224
|
+
def drupal_settings(version)
|
225
|
+
if version == '6'
|
226
|
+
settings = <<-STRING
|
227
|
+
<?php
|
228
|
+
$db_url = "#{db_type}://#{db_username}:#{db_password}@#{db_host}/#{db_name}";
|
229
|
+
STRING
|
230
|
+
elsif version == '7'
|
231
|
+
settings = <<-STRING
|
232
|
+
<?php
|
233
|
+
$databases = array ('default' => array ('default' => array (
|
234
|
+
'database' => '#{db_name}',
|
235
|
+
'username' => '#{db_username}',
|
236
|
+
'password' => '#{db_password}',
|
237
|
+
'host' => '#{db_host}',
|
238
|
+
'port' => '',
|
239
|
+
'driver' => '#{db_type}',
|
240
|
+
'prefix' => '',
|
241
|
+
)));
|
242
|
+
STRING
|
243
|
+
else
|
244
|
+
abort "Unsupported Drupal version #{version}."
|
245
|
+
end
|
246
|
+
end
|
247
|
+
|
248
|
+
end
|
data/test/helper.rb
ADDED
@@ -0,0 +1,18 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'bundler'
|
3
|
+
begin
|
4
|
+
Bundler.setup(:default, :development)
|
5
|
+
rescue Bundler::BundlerError => e
|
6
|
+
$stderr.puts e.message
|
7
|
+
$stderr.puts "Run `bundle install` to install missing gems"
|
8
|
+
exit e.status_code
|
9
|
+
end
|
10
|
+
require 'test/unit'
|
11
|
+
require 'shoulda'
|
12
|
+
|
13
|
+
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
|
14
|
+
$LOAD_PATH.unshift(File.dirname(__FILE__))
|
15
|
+
require 'didi'
|
16
|
+
|
17
|
+
class Test::Unit::TestCase
|
18
|
+
end
|
data/test/test_didi.rb
ADDED
metadata
ADDED
@@ -0,0 +1,188 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: capistrano-didi
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
hash: 27
|
5
|
+
prerelease:
|
6
|
+
segments:
|
7
|
+
- 0
|
8
|
+
- 1
|
9
|
+
- 0
|
10
|
+
version: 0.1.0
|
11
|
+
platform: ruby
|
12
|
+
authors:
|
13
|
+
- Koen Van Winckel
|
14
|
+
autorequire:
|
15
|
+
bindir: bin
|
16
|
+
cert_chain: []
|
17
|
+
|
18
|
+
date: 2011-10-25 00:00:00 +02:00
|
19
|
+
default_executable:
|
20
|
+
dependencies:
|
21
|
+
- !ruby/object:Gem::Dependency
|
22
|
+
prerelease: false
|
23
|
+
type: :development
|
24
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ">="
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
hash: 19
|
30
|
+
segments:
|
31
|
+
- 1
|
32
|
+
- 0
|
33
|
+
- 2
|
34
|
+
version: 1.0.2
|
35
|
+
name: railsless-deploy
|
36
|
+
version_requirements: *id001
|
37
|
+
- !ruby/object:Gem::Dependency
|
38
|
+
prerelease: false
|
39
|
+
type: :development
|
40
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - ">="
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
hash: 29
|
46
|
+
segments:
|
47
|
+
- 1
|
48
|
+
- 2
|
49
|
+
- 1
|
50
|
+
version: 1.2.1
|
51
|
+
name: capistrano-ext
|
52
|
+
version_requirements: *id002
|
53
|
+
- !ruby/object:Gem::Dependency
|
54
|
+
prerelease: false
|
55
|
+
type: :development
|
56
|
+
requirement: &id003 !ruby/object:Gem::Requirement
|
57
|
+
none: false
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
hash: 43
|
62
|
+
segments:
|
63
|
+
- 2
|
64
|
+
- 9
|
65
|
+
- 0
|
66
|
+
version: 2.9.0
|
67
|
+
name: capistrano
|
68
|
+
version_requirements: *id003
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
prerelease: false
|
71
|
+
type: :development
|
72
|
+
requirement: &id004 !ruby/object:Gem::Requirement
|
73
|
+
none: false
|
74
|
+
requirements:
|
75
|
+
- - ">="
|
76
|
+
- !ruby/object:Gem::Version
|
77
|
+
hash: 3
|
78
|
+
segments:
|
79
|
+
- 0
|
80
|
+
version: "0"
|
81
|
+
name: shoulda
|
82
|
+
version_requirements: *id004
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
prerelease: false
|
85
|
+
type: :development
|
86
|
+
requirement: &id005 !ruby/object:Gem::Requirement
|
87
|
+
none: false
|
88
|
+
requirements:
|
89
|
+
- - ~>
|
90
|
+
- !ruby/object:Gem::Version
|
91
|
+
hash: 23
|
92
|
+
segments:
|
93
|
+
- 1
|
94
|
+
- 0
|
95
|
+
- 0
|
96
|
+
version: 1.0.0
|
97
|
+
name: bundler
|
98
|
+
version_requirements: *id005
|
99
|
+
- !ruby/object:Gem::Dependency
|
100
|
+
prerelease: false
|
101
|
+
type: :development
|
102
|
+
requirement: &id006 !ruby/object:Gem::Requirement
|
103
|
+
none: false
|
104
|
+
requirements:
|
105
|
+
- - ~>
|
106
|
+
- !ruby/object:Gem::Version
|
107
|
+
hash: 7
|
108
|
+
segments:
|
109
|
+
- 1
|
110
|
+
- 6
|
111
|
+
- 4
|
112
|
+
version: 1.6.4
|
113
|
+
name: jeweler
|
114
|
+
version_requirements: *id006
|
115
|
+
- !ruby/object:Gem::Dependency
|
116
|
+
prerelease: false
|
117
|
+
type: :development
|
118
|
+
requirement: &id007 !ruby/object:Gem::Requirement
|
119
|
+
none: false
|
120
|
+
requirements:
|
121
|
+
- - ">="
|
122
|
+
- !ruby/object:Gem::Version
|
123
|
+
hash: 3
|
124
|
+
segments:
|
125
|
+
- 0
|
126
|
+
version: "0"
|
127
|
+
name: rcov
|
128
|
+
version_requirements: *id007
|
129
|
+
description: didi is a collection of recipes for capistrano that allow drupal to be deployed, tested and used in a CI environment
|
130
|
+
email: koenvw@gmail.com
|
131
|
+
executables:
|
132
|
+
- didify
|
133
|
+
- didi
|
134
|
+
extensions: []
|
135
|
+
|
136
|
+
extra_rdoc_files:
|
137
|
+
- LICENSE.txt
|
138
|
+
- README.rdoc
|
139
|
+
files:
|
140
|
+
- .document
|
141
|
+
- Gemfile
|
142
|
+
- Gemfile.lock
|
143
|
+
- LICENSE.txt
|
144
|
+
- README.rdoc
|
145
|
+
- Rakefile
|
146
|
+
- VERSION
|
147
|
+
- bin/didi
|
148
|
+
- bin/didify
|
149
|
+
- capistrano-didi.gemspec
|
150
|
+
- lib/didi/recipes/didi.rb
|
151
|
+
- test/helper.rb
|
152
|
+
- test/test_didi.rb
|
153
|
+
has_rdoc: true
|
154
|
+
homepage: http://github.com/koenvw/didi
|
155
|
+
licenses:
|
156
|
+
- MIT
|
157
|
+
post_install_message:
|
158
|
+
rdoc_options: []
|
159
|
+
|
160
|
+
require_paths:
|
161
|
+
- lib
|
162
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
163
|
+
none: false
|
164
|
+
requirements:
|
165
|
+
- - ">="
|
166
|
+
- !ruby/object:Gem::Version
|
167
|
+
hash: 3
|
168
|
+
segments:
|
169
|
+
- 0
|
170
|
+
version: "0"
|
171
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
172
|
+
none: false
|
173
|
+
requirements:
|
174
|
+
- - ">="
|
175
|
+
- !ruby/object:Gem::Version
|
176
|
+
hash: 3
|
177
|
+
segments:
|
178
|
+
- 0
|
179
|
+
version: "0"
|
180
|
+
requirements: []
|
181
|
+
|
182
|
+
rubyforge_project:
|
183
|
+
rubygems_version: 1.6.2
|
184
|
+
signing_key:
|
185
|
+
specification_version: 3
|
186
|
+
summary: didi - drupal deployment script based on capistrano
|
187
|
+
test_files: []
|
188
|
+
|