##// END OF EJS Templates
add .travis.yml and switch database user/password by environments...
Toshi MARUYAMA -
r12390:1951aeac7897
parent child
Show More
@@ -0,0 +1,41
1 # Redmine runs tests on own continuous integration server.
2 # http://www.redmine.org/projects/redmine/wiki/Continuous_integration
3 # You can also run on tests on your environment.
4 language: ruby
5 rvm:
6 - 1.8.7
7 - 1.9.3
8 - 2.0.0
9 - 2.1.0
10 - jruby-18mode
11 - jruby-19mode
12 env:
13 - "TEST_SUITE=units DATABASE_ADAPTER=postgresql"
14 - "TEST_SUITE=functionals DATABASE_ADAPTER=postgresql"
15 - "TEST_SUITE=integration DATABASE_ADAPTER=postgresql"
16 - "TEST_SUITE=units DATABASE_ADAPTER=mysql"
17 - "TEST_SUITE=functionals DATABASE_ADAPTER=mysql"
18 - "TEST_SUITE=integration DATABASE_ADAPTER=mysql"
19 - "TEST_SUITE=units DATABASE_ADAPTER=sqlite3"
20 - "TEST_SUITE=functionals DATABASE_ADAPTER=sqlite3"
21 - "TEST_SUITE=integration DATABASE_ADAPTER=sqlite3"
22 matrix:
23 allow_failures:
24 - rvm: jruby-19mode
25 env: "TEST_SUITE=units DATABASE_ADAPTER=postgresql"
26 - rvm: jruby-19mode
27 env: "TEST_SUITE=functionals DATABASE_ADAPTER=postgresql"
28 - rvm: jruby-19mode
29 env: "TEST_SUITE=integration DATABASE_ADAPTER=postgresql"
30 before_install:
31 - "sudo apt-get update -qq"
32 - "sudo apt-get --no-install-recommends install bzr cvs git mercurial subversion"
33 script:
34 - "SCMS=bazaar,cvs,subversion,git,mercurial,filesystem"
35 - "export SCMS"
36 - "bundle install"
37 - "RUN_ON_NOT_OFFICIAL='' RUBY_VER=1.9 BRANCH=trunk bundle exec rake config/database.yml"
38 - "bundle install"
39 - "JRUBY_OPTS=-J-Xmx1024m bundle exec rake ci"
40 notifications:
41 email: false
@@ -1,82 +1,92
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 if test_suite = ENV['TEST_SUITE']
31 if test_suite = ENV['TEST_SUITE']
32 Rake::Task["test:#{test_suite}"].invoke
32 Rake::Task["test:#{test_suite}"].invoke
33 else
33 else
34 Rake::Task["test"].invoke
34 Rake::Task["test"].invoke
35 end
35 end
36 # Rake::Task["test:ui"].invoke if RUBY_VERSION >= '1.9.3'
36 # Rake::Task["test:ui"].invoke if RUBY_VERSION >= '1.9.3'
37 end
37 end
38
38
39 desc "Finish the build"
39 desc "Finish the build"
40 task :teardown do
40 task :teardown do
41 end
41 end
42 end
42 end
43
43
44 desc "Creates database.yml for the CI server"
44 desc "Creates database.yml for the CI server"
45 file 'config/database.yml' do
45 file 'config/database.yml' do
46 require 'yaml'
46 require 'yaml'
47 database = ENV['DATABASE_ADAPTER']
47 database = ENV['DATABASE_ADAPTER']
48 ruby = ENV['RUBY_VER'].gsub('.', '').gsub('-', '')
48 ruby = ENV['RUBY_VER'].gsub('.', '').gsub('-', '')
49 branch = ENV['BRANCH'].gsub('.', '').gsub('-', '')
49 branch = ENV['BRANCH'].gsub('.', '').gsub('-', '')
50 dev_db_name = "ci_#{branch}_#{ruby}_dev"
50 dev_db_name = "ci_#{branch}_#{ruby}_dev"
51 test_db_name = "ci_#{branch}_#{ruby}_test"
51 test_db_name = "ci_#{branch}_#{ruby}_test"
52
52
53 case database
53 case database
54 when 'mysql'
54 when 'mysql'
55 dev_conf = {'adapter' => (RUBY_VERSION >= '1.9' ? 'mysql2' : 'mysql'),
55 dev_conf = {'adapter' => (RUBY_VERSION >= '1.9' ? 'mysql2' : 'mysql'),
56 'database' => dev_db_name, 'host' => 'localhost',
56 'database' => dev_db_name, 'host' => 'localhost',
57 'username' => 'jenkins', 'password' => 'jenkins',
58 'encoding' => 'utf8'}
57 'encoding' => 'utf8'}
58 if ENV['RUN_ON_NOT_OFFICIAL']
59 dev_conf['username'] = 'root'
60 else
61 dev_conf['username'] = 'jenkins'
62 dev_conf['password'] = 'jenkins'
63 end
59 test_conf = dev_conf.merge('database' => test_db_name)
64 test_conf = dev_conf.merge('database' => test_db_name)
60 when 'postgresql'
65 when 'postgresql'
61 dev_conf = {'adapter' => 'postgresql', 'database' => dev_db_name,
66 dev_conf = {'adapter' => 'postgresql', 'database' => dev_db_name,
62 'host' => 'localhost',
67 'host' => 'localhost'}
63 'username' => 'jenkins', 'password' => 'jenkins'}
68 if ENV['RUN_ON_NOT_OFFICIAL']
69 dev_conf['username'] = 'postgres'
70 else
71 dev_conf['username'] = 'jenkins'
72 dev_conf['password'] = 'jenkins'
73 end
64 test_conf = dev_conf.merge('database' => test_db_name)
74 test_conf = dev_conf.merge('database' => test_db_name)
65 when /sqlite3/
75 when /sqlite3/
66 dev_conf = {'adapter' => (Object.const_defined?(:JRUBY_VERSION) ?
76 dev_conf = {'adapter' => (Object.const_defined?(:JRUBY_VERSION) ?
67 'jdbcsqlite3' : 'sqlite3'),
77 'jdbcsqlite3' : 'sqlite3'),
68 'database' => "db/#{dev_db_name}.sqlite3"}
78 'database' => "db/#{dev_db_name}.sqlite3"}
69 test_conf = dev_conf.merge('database' => "db/#{test_db_name}.sqlite3")
79 test_conf = dev_conf.merge('database' => "db/#{test_db_name}.sqlite3")
70 when 'sqlserver'
80 when 'sqlserver'
71 dev_conf = {'adapter' => 'sqlserver', 'database' => dev_db_name,
81 dev_conf = {'adapter' => 'sqlserver', 'database' => dev_db_name,
72 'host' => 'mssqlserver', 'port' => 1433,
82 'host' => 'mssqlserver', 'port' => 1433,
73 'username' => 'jenkins', 'password' => 'jenkins'}
83 'username' => 'jenkins', 'password' => 'jenkins'}
74 test_conf = dev_conf.merge('database' => test_db_name)
84 test_conf = dev_conf.merge('database' => test_db_name)
75 else
85 else
76 abort "Unknown database"
86 abort "Unknown database"
77 end
87 end
78
88
79 File.open('config/database.yml', 'w') do |f|
89 File.open('config/database.yml', 'w') do |f|
80 f.write YAML.dump({'development' => dev_conf, 'test' => test_conf})
90 f.write YAML.dump({'development' => dev_conf, 'test' => test_conf})
81 end
91 end
82 end
92 end
General Comments 0
You need to be logged in to leave comments. Login now