##// END OF EJS Templates
CI tasks cleanup....
Jean-Philippe Lang -
r11053:d215cc136c3c
parent child
Show More
@@ -8,14 +8,14 task :ci do
8 Rake::Task["ci:teardown"].invoke
8 Rake::Task["ci:teardown"].invoke
9 end
9 end
10
10
11 # Tasks can be hooked into by redefining them in a plugin
12 namespace :ci do
11 namespace :ci do
13 desc "Setup Redmine for a new build."
12 desc "Setup Redmine for a new build"
14 task :setup do
13 task :setup do
15 Rake::Task["ci:dump_environment"].invoke
14 Rake::Task["log:clear"].invoke
16 Rake::Task["db:create"].invoke
15 Rake::Task["db:create"].invoke
17 Rake::Task["db:migrate"].invoke
16 Rake::Task["db:migrate"].invoke
18 Rake::Task["db:schema:dump"].invoke
17 Rake::Task["db:schema:dump"].invoke
18 Rake::Task["test:scm:setup:all"].invoke
19 Rake::Task["test:scm:update"].invoke
19 Rake::Task["test:scm:update"].invoke
20 end
20 end
21
21
@@ -24,58 +24,38 namespace :ci do
24 Rake::Task["test"].invoke
24 Rake::Task["test"].invoke
25 end
25 end
26
26
27 # Use this to cleanup after building or run post-build analysis.
28 desc "Finish the build"
27 desc "Finish the build"
29 task :teardown do
28 task :teardown do
30 end
29 end
30 end
31
31
32 desc "Creates and configures the databases for the CI server"
32 desc "Creates database.yml for the CI server"
33 task :database do
33 file 'config/database.yml' do
34 path = 'config/database.yml'
34 require 'yaml'
35 unless File.exists?(path)
35 database = ENV['DATABASE_ADAPTER']
36 database = ENV['DATABASE_ADAPTER']
36 ruby = ENV['RUBY_VER'].gsub('.', '').gsub('-', '')
37 ruby = ENV['RUBY_VER'].gsub('.', '').gsub('-', '')
37 branch = ENV['BRANCH'].gsub('.', '').gsub('-', '')
38 branch = ENV['BRANCH'].gsub('.', '').gsub('-', '')
38 dev_db_name = "ci_#{branch}_#{ruby}_dev"
39 dev_db_name = "ci_#{branch}_#{ruby}_dev"
39 test_db_name = "ci_#{branch}_#{ruby}_test"
40 test_db_name = "ci_#{branch}_#{ruby}_test"
40
41
41 case database
42 case database
42 when 'mysql'
43 when 'mysql'
43 dev_conf = {'adapter' => (RUBY_VERSION >= '1.9' ? 'mysql2' : 'mysql'), 'database' => dev_db_name, 'host' => 'localhost', 'username' => 'jenkins', 'password' => 'jenkins', 'encoding' => 'utf8'}
44 raise "Error creating databases" unless
44 test_conf = dev_conf.merge('database' => test_db_name)
45 system(%|mysql -u jenkins --password=jenkins -e 'create database #{dev_db_name} character set utf8;'|) &&
45 when 'postgresql'
46 system(%|mysql -u jenkins --password=jenkins -e 'create database #{test_db_name} character set utf8;'|)
46 dev_conf = {'adapter' => 'postgresql', 'database' => dev_db_name, 'host' => 'localhost', 'username' => 'jenkins', 'password' => 'jenkins'}
47 dev_conf = { 'adapter' => (RUBY_VERSION >= '1.9' ? 'mysql2' : 'mysql'), 'database' => dev_db_name, 'host' => 'localhost', 'username' => 'jenkins', 'password' => 'jenkins', 'encoding' => 'utf8' }
47 test_conf = dev_conf.merge('database' => test_db_name)
48 test_conf = { 'adapter' => (RUBY_VERSION >= '1.9' ? 'mysql2' : 'mysql'), 'database' => test_db_name, 'host' => 'localhost', 'username' => 'jenkins', 'password' => 'jenkins', 'encoding' => 'utf8' }
48 when 'sqlite3'
49 when 'postgresql'
49 dev_conf = {'adapter' => 'sqlite3', 'database' => "db/#{dev_db_name}.sqlite3"}
50 raise "Error creating databases" unless
50 test_conf = dev_conf.merge('database' => "db/#{test_db_name}.sqlite3")
51 system(%|psql -U jenkins -d postgres -c "create database #{dev_db_name} owner jenkins encoding 'UTF8';"|) &&
51 when 'sqlserver'
52 system(%|psql -U jenkins -d postgres -c "create database #{test_db_name} owner jenkins encoding 'UTF8';"|)
52 dev_conf = {'adapter' => 'sqlserver', 'database' => dev_db_name, 'host' => 'mssqlserver', 'port' => 1433, 'username' => 'jenkins', 'password' => 'jenkins'}
53 dev_conf = { 'adapter' => 'postgresql', 'database' => dev_db_name, 'host' => 'localhost', 'username' => 'jenkins', 'password' => 'jenkins' }
53 test_conf = dev_conf.merge('database' => test_db_name)
54 test_conf = { 'adapter' => 'postgresql', 'database' => test_db_name, 'host' => 'localhost', 'username' => 'jenkins', 'password' => 'jenkins' }
54 else
55 when 'sqlite3'
55 abort "Unknown database"
56 dev_conf = { 'adapter' => 'sqlite3', 'database' => "db/#{dev_db_name}.sqlite3" }
57 test_conf = { 'adapter' => 'sqlite3', 'database' => "db/#{test_db_name}.sqlite3" }
58 when 'sqlserver'
59 dev_conf = { 'adapter' => 'sqlserver', 'database' => dev_db_name, 'host' => 'mssqlserver', 'port' => 1433, 'username' => 'jenkins', 'password' => 'jenkins' }
60 test_conf = { 'adapter' => 'sqlserver', 'database' => test_db_name, 'host' => 'mssqlserver', 'port' => 1433, 'username' => 'jenkins', 'password' => 'jenkins' }
61 else
62 raise "Unknown database"
63 end
64
65 File.open(path, 'w') do |f|
66 f.write YAML.dump({'development' => dev_conf, 'test' => test_conf})
67 end
68 end
69 end
56 end
70
57
71 desc "Dump the environment information to a BUILD_ENVIRONMENT ENV variable for debugging"
58 File.open('config/database.yml', 'w') do |f|
72 task :dump_environment do
59 f.write YAML.dump({'development' => dev_conf, 'test' => test_conf})
73
74 ENV['BUILD_ENVIRONMENT'] = ['ruby -v', 'gem -v', 'gem list'].collect do |command|
75 result = `#{command}`
76 "$ #{command}\n#{result}"
77 end.join("\n")
78
79 end
60 end
80 end
61 end
81
@@ -102,6 +102,7 namespace :test do
102 Rake::Task['test:rdm_routing'].comment = "Run the routing tests"
102 Rake::Task['test:rdm_routing'].comment = "Run the routing tests"
103
103
104 Rake::TestTask.new(:ui => "db:test:prepare") do |t|
104 Rake::TestTask.new(:ui => "db:test:prepare") do |t|
105 abort "ruby1.9 is required to run test:ui" if RUBY_VERSION < '1.9'
105 t.libs << "test"
106 t.libs << "test"
106 t.verbose = true
107 t.verbose = true
107 t.test_files = FileList['test/ui/**/*_test.rb']
108 t.test_files = FileList['test/ui/**/*_test.rb']
General Comments 0
You need to be logged in to leave comments. Login now