Add rake tasks, provisioning, and templates
This commit is contained in:
parent
20bee0fac4
commit
cdf390f082
7 changed files with 193 additions and 11 deletions
106
rakelib/agaric.rake
Normal file
106
rakelib/agaric.rake
Normal file
|
@ -0,0 +1,106 @@
|
|||
# As agaric.rake did not know how to deploy to Drutopia,
|
||||
# all deployment features have been removed.
|
||||
# Use drutopia_host to deploy.
|
||||
|
||||
require 'date'
|
||||
require 'rake/clean'
|
||||
|
||||
CLEAN.include("#{BUILDDIR}")
|
||||
|
||||
ENVIRONMENTS.keys.each do |env|
|
||||
settings_source = "#{BUILDDIR}/#{env}/#{DRUPAL}/sites/default/#{env}.settings.php"
|
||||
settings_target = "#{BUILDDIR}/#{env}/#{DRUPAL}/sites/default/settings.php"
|
||||
|
||||
release_host = ENVIRONMENTS[env]["host"]
|
||||
release_path = ENVIRONMENTS[env]["path"]
|
||||
release_backups = ENVIRONMENTS[env]["backups"]
|
||||
release_tag = ENVIRONMENTS[env]["tag"]
|
||||
drush_path = ENVIRONMENTS[env]["drush"]
|
||||
drush_path = drush_path ? drush_path : "drush"
|
||||
|
||||
db_backup_task = "db_backup_#{env}".to_sym
|
||||
task db_backup_task do
|
||||
file = "#{release_backups}/backup-#{env}-#{DateTime.now}.sql.gz"
|
||||
sh "ssh #{release_host} '#{drush_path} -r #{release_path} sql-dump --structure-tables-key=common --gzip > #{file}'"
|
||||
end
|
||||
|
||||
db_drop_tables_task = "db_drop_tables_#{env}".to_sym
|
||||
task db_drop_tables_task => db_backup_task do
|
||||
sh "ssh #{release_host} #{drush_path} -y -r #{release_path} sql-drop"
|
||||
end
|
||||
|
||||
file_sync_task = "file_sync_#{env}_to_local".to_sym
|
||||
desc "Sync files from #{env} to local environment."
|
||||
task file_sync_task do
|
||||
sh "rsync -rz --stats --exclude styles --exclude css --exclude js --delete \
|
||||
#{release_host}:#{release_path}/sites/default/files/ \
|
||||
#{DRUPAL}/sites/default/files/"
|
||||
end
|
||||
|
||||
db_sync_task = "db_sync_#{env}_to_local".to_sym
|
||||
desc "Sync database from #{env} to local environment."
|
||||
task db_sync_task do
|
||||
sh "drush -y sql-drop"
|
||||
sh "ssh -C #{release_host} #{drush_path} -r #{release_path} \
|
||||
sql-dump --structure-tables-key=common | drush sql-cli"
|
||||
end
|
||||
|
||||
ENVIRONMENTS.keys.each do |e|
|
||||
unless e == env then
|
||||
from_host = ENVIRONMENTS[e]["host"]
|
||||
from_path = ENVIRONMENTS[e]["path"]
|
||||
from_drush = ENVIRONMENTS[e]["drush"]
|
||||
from_drush = from_drush ? from_drush : "drush"
|
||||
|
||||
file_sync_task = "file_sync_#{e}_to_#{env}".to_sym
|
||||
desc "Sync files from #{e} to #{env} environment."
|
||||
task file_sync_task do
|
||||
sh "ssh -A #{from_host} rsync -rz --stats --exclude styles \
|
||||
--exclude css --exclude js #{from_path}/sites/default/files/ \
|
||||
--delete " + (from_host == release_host ? "" : "#{release_host}:") + "#{release_path}/sites/default/files/"
|
||||
end
|
||||
db_sync_task = "db_sync_#{e}_to_#{env}".to_sym
|
||||
desc "Sync database from #{e} to #{env} environment."
|
||||
task db_sync_task => db_drop_tables_task do
|
||||
sh "ssh -C #{from_host} #{from_drush} -r #{from_path} \
|
||||
sql-dump --structure-tables-key=common | \
|
||||
ssh -C #{release_host} #{drush_path} -r #{release_path} sql-cli"
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
TAGNAMES.each do |tagname|
|
||||
desc "Tag a commit with #{tagname}."
|
||||
task "tag_#{tagname}".to_sym do
|
||||
sh "git fetch --tags"
|
||||
num = `git tag`.scan(Regexp.new(tagname + "-")).size + 1
|
||||
sh "git tag -am '#{tagname.upcase} Release #{num}' #{tagname}-#{num}"
|
||||
sh "git tag -afm 'Current #{tagname.upcase} Release' #{tagname}"
|
||||
sh "git push origin :refs/tags/#{tagname}"
|
||||
sh "git push origin --tags"
|
||||
end
|
||||
end
|
||||
|
||||
desc "Detect coding standard violations in profile and custom modules."
|
||||
task :sniff do
|
||||
files = ["web/profiles/#{PROFILE}", 'web/sites/all/modules/custom'].join(' ')
|
||||
extensions = ['module', 'profile', 'install', 'inc', 'php'].join(',')
|
||||
sh "phpcs --extensions=#{extensions} #{files}"
|
||||
end
|
||||
|
||||
namespace :tests do
|
||||
|
||||
desc "Run integration tests."
|
||||
task "integration" do
|
||||
sh "phpunit --process-isolation --bootstrap=tests/bootstrap.php tests/integration"
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
if defined? PROFILE
|
||||
desc "Delete and re-install a site from its installation profile."
|
||||
task "site_install" do
|
||||
sh "#{drush_path} -y site-install #{PROFILE}"
|
||||
end
|
||||
end
|
40
rakelib/init.rake
Normal file
40
rakelib/init.rake
Normal file
|
@ -0,0 +1,40 @@
|
|||
desc "Create a central bare repository from the local repository."
|
||||
task :init_repo do
|
||||
repo_id = File.basename(Dir.getwd)
|
||||
repo_path = "/srv/git/#{repo_id}.git"
|
||||
post_receive = "/usr/bin/kgb-client --git-reflog - --conf /etc/kgb-client/kgb.conf --repository git --repo-id #{repo_id}"
|
||||
|
||||
commands = [
|
||||
"mkdir #{repo_path}",
|
||||
"cd #{repo_path}",
|
||||
"git init --bare",
|
||||
# For HTTP access such as gitweb
|
||||
"mv hooks/post-update.sample hooks/post-update",
|
||||
# For KGB to send commit notifications over IRC.
|
||||
# This still requires additional server-side configuration, see
|
||||
# http://my.agaric.com/agaric/node/11694
|
||||
"echo #{post_receive} >> hooks/post-receive",
|
||||
"chmod a+x hooks/post-receive"
|
||||
].join(" && ")
|
||||
sh "ssh git.agaric.com '#{commands}'"
|
||||
sh "git remote add origin git.agaric.com:#{repo_path}"
|
||||
sh "git push origin master"
|
||||
end
|
||||
|
||||
desc "Add .gitignore file with basic project specific patterns."
|
||||
task ".gitignore" do
|
||||
open(".gitignore", "a") do |f|
|
||||
f.puts ".sass-cache/"
|
||||
f.puts ".vagrant/"
|
||||
f.puts "build/"
|
||||
f.puts "web/sites/default/settings.php"
|
||||
f.puts "web/sites/default/files/"
|
||||
end
|
||||
end
|
||||
|
||||
desc "Add .gitattributes file with basic project specific patterns."
|
||||
task ".gitattributes" do
|
||||
open(".gitattributes", "a") do |f|
|
||||
f.puts "etc export-ignore"
|
||||
end
|
||||
end
|
Loading…
Add table
Add a link
Reference in a new issue