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