2010-08-07 00:46:44 +04:00
|
|
|
desc "Run the Continous Integration tests for Redmine"
|
|
|
|
task :ci do
|
|
|
|
# RAILS_ENV and ENV[] can diverge so force them both to test
|
|
|
|
ENV['RAILS_ENV'] = 'test'
|
|
|
|
RAILS_ENV = 'test'
|
|
|
|
Rake::Task["ci:setup"].invoke
|
|
|
|
Rake::Task["ci:build"].invoke
|
|
|
|
Rake::Task["ci:teardown"].invoke
|
|
|
|
end
|
|
|
|
|
|
|
|
namespace :ci do
|
2013-01-29 21:34:35 +04:00
|
|
|
desc "Setup Redmine for a new build"
|
2010-08-07 00:46:44 +04:00
|
|
|
task :setup do
|
2013-01-29 21:34:35 +04:00
|
|
|
Rake::Task["log:clear"].invoke
|
2013-02-03 19:46:54 +04:00
|
|
|
Rake::Task["db:create:all"].invoke
|
2010-08-07 00:46:44 +04:00
|
|
|
Rake::Task["db:migrate"].invoke
|
|
|
|
Rake::Task["db:schema:dump"].invoke
|
2013-01-29 21:34:35 +04:00
|
|
|
Rake::Task["test:scm:setup:all"].invoke
|
2011-01-06 21:52:37 +03:00
|
|
|
Rake::Task["test:scm:update"].invoke
|
2010-08-07 00:46:44 +04:00
|
|
|
end
|
|
|
|
|
|
|
|
desc "Build Redmine"
|
|
|
|
task :build do
|
|
|
|
Rake::Task["test"].invoke
|
2013-01-29 22:49:33 +04:00
|
|
|
Rake::Task["test:ui"].invoke unless RUBY_VERSION < '1.9'
|
2010-08-07 00:46:44 +04:00
|
|
|
end
|
|
|
|
|
|
|
|
desc "Finish the build"
|
|
|
|
task :teardown do
|
|
|
|
end
|
2013-01-29 21:34:35 +04:00
|
|
|
end
|
2010-08-07 00:46:44 +04:00
|
|
|
|
2013-01-29 21:34:35 +04:00
|
|
|
desc "Creates database.yml for the CI server"
|
|
|
|
file 'config/database.yml' do
|
|
|
|
require 'yaml'
|
|
|
|
database = ENV['DATABASE_ADAPTER']
|
|
|
|
ruby = ENV['RUBY_VER'].gsub('.', '').gsub('-', '')
|
|
|
|
branch = ENV['BRANCH'].gsub('.', '').gsub('-', '')
|
|
|
|
dev_db_name = "ci_#{branch}_#{ruby}_dev"
|
|
|
|
test_db_name = "ci_#{branch}_#{ruby}_test"
|
|
|
|
|
|
|
|
case database
|
|
|
|
when 'mysql'
|
|
|
|
dev_conf = {'adapter' => (RUBY_VERSION >= '1.9' ? 'mysql2' : 'mysql'), 'database' => dev_db_name, 'host' => 'localhost', 'username' => 'jenkins', 'password' => 'jenkins', 'encoding' => 'utf8'}
|
|
|
|
test_conf = dev_conf.merge('database' => test_db_name)
|
|
|
|
when 'postgresql'
|
|
|
|
dev_conf = {'adapter' => 'postgresql', 'database' => dev_db_name, 'host' => 'localhost', 'username' => 'jenkins', 'password' => 'jenkins'}
|
|
|
|
test_conf = dev_conf.merge('database' => test_db_name)
|
|
|
|
when 'sqlite3'
|
|
|
|
dev_conf = {'adapter' => 'sqlite3', 'database' => "db/#{dev_db_name}.sqlite3"}
|
|
|
|
test_conf = dev_conf.merge('database' => "db/#{test_db_name}.sqlite3")
|
|
|
|
when 'sqlserver'
|
|
|
|
dev_conf = {'adapter' => 'sqlserver', 'database' => dev_db_name, 'host' => 'mssqlserver', 'port' => 1433, 'username' => 'jenkins', 'password' => 'jenkins'}
|
|
|
|
test_conf = dev_conf.merge('database' => test_db_name)
|
|
|
|
else
|
|
|
|
abort "Unknown database"
|
2012-04-06 13:36:07 +04:00
|
|
|
end
|
|
|
|
|
2013-01-29 21:34:35 +04:00
|
|
|
File.open('config/database.yml', 'w') do |f|
|
|
|
|
f.write YAML.dump({'development' => dev_conf, 'test' => test_conf})
|
2010-08-07 00:46:44 +04:00
|
|
|
end
|
|
|
|
end
|