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