ci.rake
97 lines
| 3.0 KiB
| text/x-ruby
|
RubyLexer
|
r12819 | desc "Run the Continuous Integration tests for Redmine" | ||
|
r3805 | 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 | ||||
|
r13129 | desc "Display info about the build environment" | ||
task :about do | ||||
puts "Ruby version: #{RUBY_VERSION}-p#{RUBY_PATCHLEVEL} (#{RUBY_RELEASE_DATE}) [#{RUBY_PLATFORM}]" | ||||
end | ||||
|
r11053 | desc "Setup Redmine for a new build" | ||
|
r3805 | task :setup do | ||
|
r11159 | Rake::Task["tmp:clear"].invoke | ||
|
r11053 | Rake::Task["log:clear"].invoke | ||
|
r12031 | Rake::Task["db:create:all"].invoke | ||
|
r3805 | Rake::Task["db:migrate"].invoke | ||
Rake::Task["db:schema:dump"].invoke | ||||
|
r12151 | if scms = ENV['SCMS'] | ||
scms.split(',').each do |scm| | ||||
Rake::Task["test:scm:setup:#{scm}"].invoke | ||||
end | ||||
else | ||||
Rake::Task["test:scm:setup:all"].invoke | ||||
end | ||||
|
r4523 | Rake::Task["test:scm:update"].invoke | ||
|
r3805 | end | ||
desc "Build Redmine" | ||||
task :build do | ||||
|
r12162 | if test_suite = ENV['TEST_SUITE'] | ||
Rake::Task["test:#{test_suite}"].invoke | ||||
else | ||||
Rake::Task["test"].invoke | ||||
end | ||||
|
r13100 | # Rake::Task["test:ui"].invoke | ||
|
r3805 | end | ||
desc "Finish the build" | ||||
task :teardown do | ||||
end | ||||
|
r11053 | end | ||
|
r3805 | |||
|
r11053 | 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' | ||||
|
r13100 | dev_conf = {'adapter' => 'mysql2', | ||
|
r12036 | 'database' => dev_db_name, 'host' => 'localhost', | ||
'encoding' => 'utf8'} | ||||
|
r12390 | if ENV['RUN_ON_NOT_OFFICIAL'] | ||
dev_conf['username'] = 'root' | ||||
else | ||||
dev_conf['username'] = 'jenkins' | ||||
dev_conf['password'] = 'jenkins' | ||||
end | ||||
|
r11053 | test_conf = dev_conf.merge('database' => test_db_name) | ||
when 'postgresql' | ||||
|
r12027 | dev_conf = {'adapter' => 'postgresql', 'database' => dev_db_name, | ||
|
r12390 | 'host' => 'localhost'} | ||
if ENV['RUN_ON_NOT_OFFICIAL'] | ||||
dev_conf['username'] = 'postgres' | ||||
else | ||||
dev_conf['username'] = 'jenkins' | ||||
dev_conf['password'] = 'jenkins' | ||||
end | ||||
|
r11053 | test_conf = dev_conf.merge('database' => test_db_name) | ||
|
r12028 | when /sqlite3/ | ||
dev_conf = {'adapter' => (Object.const_defined?(:JRUBY_VERSION) ? | ||||
'jdbcsqlite3' : 'sqlite3'), | ||||
|
r12027 | 'database' => "db/#{dev_db_name}.sqlite3"} | ||
|
r11053 | test_conf = dev_conf.merge('database' => "db/#{test_db_name}.sqlite3") | ||
when 'sqlserver' | ||||
|
r12027 | dev_conf = {'adapter' => 'sqlserver', 'database' => dev_db_name, | ||
'host' => 'mssqlserver', 'port' => 1433, | ||||
'username' => 'jenkins', 'password' => 'jenkins'} | ||||
|
r11053 | test_conf = dev_conf.merge('database' => test_db_name) | ||
else | ||||
abort "Unknown database" | ||||
|
r9201 | end | ||
|
r11053 | File.open('config/database.yml', 'w') do |f| | ||
f.write YAML.dump({'development' => dev_conf, 'test' => test_conf}) | ||||
|
r3805 | end | ||
end | ||||