##// END OF EJS Templates
Create all databases....
Jean-Philippe Lang -
r11093:25e1842f5fa9
parent child
Show More
@@ -1,62 +1,62
1 desc "Run the Continous Integration tests for Redmine"
1 desc "Run the Continous Integration tests for Redmine"
2 task :ci do
2 task :ci do
3 # RAILS_ENV and ENV[] can diverge so force them both to test
3 # RAILS_ENV and ENV[] can diverge so force them both to test
4 ENV['RAILS_ENV'] = 'test'
4 ENV['RAILS_ENV'] = 'test'
5 RAILS_ENV = 'test'
5 RAILS_ENV = 'test'
6 Rake::Task["ci:setup"].invoke
6 Rake::Task["ci:setup"].invoke
7 Rake::Task["ci:build"].invoke
7 Rake::Task["ci:build"].invoke
8 Rake::Task["ci:teardown"].invoke
8 Rake::Task["ci:teardown"].invoke
9 end
9 end
10
10
11 namespace :ci do
11 namespace :ci do
12 desc "Setup Redmine for a new build"
12 desc "Setup Redmine for a new build"
13 task :setup do
13 task :setup do
14 Rake::Task["log:clear"].invoke
14 Rake::Task["log:clear"].invoke
15 Rake::Task["db:create"].invoke
15 Rake::Task["db:create:all"].invoke
16 Rake::Task["db:migrate"].invoke
16 Rake::Task["db:migrate"].invoke
17 Rake::Task["db:schema:dump"].invoke
17 Rake::Task["db:schema:dump"].invoke
18 Rake::Task["test:scm:setup:all"].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
22 desc "Build Redmine"
22 desc "Build Redmine"
23 task :build do
23 task :build do
24 Rake::Task["test"].invoke
24 Rake::Task["test"].invoke
25 Rake::Task["test:ui"].invoke unless RUBY_VERSION < '1.9'
25 Rake::Task["test:ui"].invoke unless RUBY_VERSION < '1.9'
26 end
26 end
27
27
28 desc "Finish the build"
28 desc "Finish the build"
29 task :teardown do
29 task :teardown do
30 end
30 end
31 end
31 end
32
32
33 desc "Creates database.yml for the CI server"
33 desc "Creates database.yml for the CI server"
34 file 'config/database.yml' do
34 file 'config/database.yml' do
35 require 'yaml'
35 require 'yaml'
36 database = ENV['DATABASE_ADAPTER']
36 database = ENV['DATABASE_ADAPTER']
37 ruby = ENV['RUBY_VER'].gsub('.', '').gsub('-', '')
37 ruby = ENV['RUBY_VER'].gsub('.', '').gsub('-', '')
38 branch = ENV['BRANCH'].gsub('.', '').gsub('-', '')
38 branch = ENV['BRANCH'].gsub('.', '').gsub('-', '')
39 dev_db_name = "ci_#{branch}_#{ruby}_dev"
39 dev_db_name = "ci_#{branch}_#{ruby}_dev"
40 test_db_name = "ci_#{branch}_#{ruby}_test"
40 test_db_name = "ci_#{branch}_#{ruby}_test"
41
41
42 case database
42 case database
43 when 'mysql'
43 when 'mysql'
44 dev_conf = {'adapter' => (RUBY_VERSION >= '1.9' ? 'mysql2' : 'mysql'), 'database' => dev_db_name, 'host' => 'localhost', 'username' => 'jenkins', 'password' => 'jenkins', 'encoding' => 'utf8'}
44 dev_conf = {'adapter' => (RUBY_VERSION >= '1.9' ? 'mysql2' : 'mysql'), 'database' => dev_db_name, 'host' => 'localhost', 'username' => 'jenkins', 'password' => 'jenkins', 'encoding' => 'utf8'}
45 test_conf = dev_conf.merge('database' => test_db_name)
45 test_conf = dev_conf.merge('database' => test_db_name)
46 when 'postgresql'
46 when 'postgresql'
47 dev_conf = {'adapter' => 'postgresql', 'database' => dev_db_name, 'host' => 'localhost', 'username' => 'jenkins', 'password' => 'jenkins'}
47 dev_conf = {'adapter' => 'postgresql', 'database' => dev_db_name, 'host' => 'localhost', 'username' => 'jenkins', 'password' => 'jenkins'}
48 test_conf = dev_conf.merge('database' => test_db_name)
48 test_conf = dev_conf.merge('database' => test_db_name)
49 when 'sqlite3'
49 when 'sqlite3'
50 dev_conf = {'adapter' => 'sqlite3', 'database' => "db/#{dev_db_name}.sqlite3"}
50 dev_conf = {'adapter' => 'sqlite3', 'database' => "db/#{dev_db_name}.sqlite3"}
51 test_conf = dev_conf.merge('database' => "db/#{test_db_name}.sqlite3")
51 test_conf = dev_conf.merge('database' => "db/#{test_db_name}.sqlite3")
52 when 'sqlserver'
52 when 'sqlserver'
53 dev_conf = {'adapter' => 'sqlserver', 'database' => dev_db_name, 'host' => 'mssqlserver', 'port' => 1433, 'username' => 'jenkins', 'password' => 'jenkins'}
53 dev_conf = {'adapter' => 'sqlserver', 'database' => dev_db_name, 'host' => 'mssqlserver', 'port' => 1433, 'username' => 'jenkins', 'password' => 'jenkins'}
54 test_conf = dev_conf.merge('database' => test_db_name)
54 test_conf = dev_conf.merge('database' => test_db_name)
55 else
55 else
56 abort "Unknown database"
56 abort "Unknown database"
57 end
57 end
58
58
59 File.open('config/database.yml', 'w') do |f|
59 File.open('config/database.yml', 'w') do |f|
60 f.write YAML.dump({'development' => dev_conf, 'test' => test_conf})
60 f.write YAML.dump({'development' => dev_conf, 'test' => test_conf})
61 end
61 end
62 end
62 end
General Comments 0
You need to be logged in to leave comments. Login now