##// END OF EJS Templates
use environment variable for extacting SCM repositories in ci.rake...
Toshi MARUYAMA -
r12151:694394b04e7a
parent child
Show More
@@ -1,72 +1,78
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["tmp:clear"].invoke
14 Rake::Task["tmp:clear"].invoke
15 Rake::Task["log:clear"].invoke
15 Rake::Task["log:clear"].invoke
16 Rake::Task["db:create:all"].invoke
16 Rake::Task["db:create:all"].invoke
17 Rake::Task["db:migrate"].invoke
17 Rake::Task["db:migrate"].invoke
18 Rake::Task["db:schema:dump"].invoke
18 Rake::Task["db:schema:dump"].invoke
19 Rake::Task["test:scm:setup:all"].invoke
19 if scms = ENV['SCMS']
20 scms.split(',').each do |scm|
21 Rake::Task["test:scm:setup:#{scm}"].invoke
22 end
23 else
24 Rake::Task["test:scm:setup:all"].invoke
25 end
20 Rake::Task["test:scm:update"].invoke
26 Rake::Task["test:scm:update"].invoke
21 end
27 end
22
28
23 desc "Build Redmine"
29 desc "Build Redmine"
24 task :build do
30 task :build do
25 Rake::Task["test"].invoke
31 Rake::Task["test"].invoke
26 # Rake::Task["test:ui"].invoke if RUBY_VERSION >= '1.9.3'
32 # Rake::Task["test:ui"].invoke if RUBY_VERSION >= '1.9.3'
27 end
33 end
28
34
29 desc "Finish the build"
35 desc "Finish the build"
30 task :teardown do
36 task :teardown do
31 end
37 end
32 end
38 end
33
39
34 desc "Creates database.yml for the CI server"
40 desc "Creates database.yml for the CI server"
35 file 'config/database.yml' do
41 file 'config/database.yml' do
36 require 'yaml'
42 require 'yaml'
37 database = ENV['DATABASE_ADAPTER']
43 database = ENV['DATABASE_ADAPTER']
38 ruby = ENV['RUBY_VER'].gsub('.', '').gsub('-', '')
44 ruby = ENV['RUBY_VER'].gsub('.', '').gsub('-', '')
39 branch = ENV['BRANCH'].gsub('.', '').gsub('-', '')
45 branch = ENV['BRANCH'].gsub('.', '').gsub('-', '')
40 dev_db_name = "ci_#{branch}_#{ruby}_dev"
46 dev_db_name = "ci_#{branch}_#{ruby}_dev"
41 test_db_name = "ci_#{branch}_#{ruby}_test"
47 test_db_name = "ci_#{branch}_#{ruby}_test"
42
48
43 case database
49 case database
44 when 'mysql'
50 when 'mysql'
45 dev_conf = {'adapter' => (RUBY_VERSION >= '1.9' ? 'mysql2' : 'mysql'),
51 dev_conf = {'adapter' => (RUBY_VERSION >= '1.9' ? 'mysql2' : 'mysql'),
46 'database' => dev_db_name, 'host' => 'localhost',
52 'database' => dev_db_name, 'host' => 'localhost',
47 'username' => 'jenkins', 'password' => 'jenkins',
53 'username' => 'jenkins', 'password' => 'jenkins',
48 'encoding' => 'utf8'}
54 'encoding' => 'utf8'}
49 test_conf = dev_conf.merge('database' => test_db_name)
55 test_conf = dev_conf.merge('database' => test_db_name)
50 when 'postgresql'
56 when 'postgresql'
51 dev_conf = {'adapter' => 'postgresql', 'database' => dev_db_name,
57 dev_conf = {'adapter' => 'postgresql', 'database' => dev_db_name,
52 'host' => 'localhost',
58 'host' => 'localhost',
53 'username' => 'jenkins', 'password' => 'jenkins'}
59 'username' => 'jenkins', 'password' => 'jenkins'}
54 test_conf = dev_conf.merge('database' => test_db_name)
60 test_conf = dev_conf.merge('database' => test_db_name)
55 when /sqlite3/
61 when /sqlite3/
56 dev_conf = {'adapter' => (Object.const_defined?(:JRUBY_VERSION) ?
62 dev_conf = {'adapter' => (Object.const_defined?(:JRUBY_VERSION) ?
57 'jdbcsqlite3' : 'sqlite3'),
63 'jdbcsqlite3' : 'sqlite3'),
58 'database' => "db/#{dev_db_name}.sqlite3"}
64 'database' => "db/#{dev_db_name}.sqlite3"}
59 test_conf = dev_conf.merge('database' => "db/#{test_db_name}.sqlite3")
65 test_conf = dev_conf.merge('database' => "db/#{test_db_name}.sqlite3")
60 when 'sqlserver'
66 when 'sqlserver'
61 dev_conf = {'adapter' => 'sqlserver', 'database' => dev_db_name,
67 dev_conf = {'adapter' => 'sqlserver', 'database' => dev_db_name,
62 'host' => 'mssqlserver', 'port' => 1433,
68 'host' => 'mssqlserver', 'port' => 1433,
63 'username' => 'jenkins', 'password' => 'jenkins'}
69 'username' => 'jenkins', 'password' => 'jenkins'}
64 test_conf = dev_conf.merge('database' => test_db_name)
70 test_conf = dev_conf.merge('database' => test_db_name)
65 else
71 else
66 abort "Unknown database"
72 abort "Unknown database"
67 end
73 end
68
74
69 File.open('config/database.yml', 'w') do |f|
75 File.open('config/database.yml', 'w') do |f|
70 f.write YAML.dump({'development' => dev_conf, 'test' => test_conf})
76 f.write YAML.dump({'development' => dev_conf, 'test' => test_conf})
71 end
77 end
72 end
78 end
General Comments 0
You need to be logged in to leave comments. Login now