To check out this repository please hg clone the following URL, or open the URL using EasyMercurial or your preferred Mercurial client.

Statistics Download as Zip
| Branch: | Tag: | Revision:

root / lib / tasks / ci.rake @ 1568:bc47b68a9487

History | View | Annotate | Download (2.86 KB)

1
desc "Run the Continous Integration tests for Redmine"
2
task :ci do
3
  # RAILS_ENV and ENV[] can diverge so force them both to test
4
  ENV['RAILS_ENV'] = 'test'
5
  RAILS_ENV = 'test'
6
  Rake::Task["ci:setup"].invoke
7
  Rake::Task["ci:build"].invoke
8
  Rake::Task["ci:teardown"].invoke
9
end
10

    
11
namespace :ci do
12
  desc "Setup Redmine for a new build"
13
  task :setup do
14
    Rake::Task["tmp:clear"].invoke
15
    Rake::Task["log:clear"].invoke
16
    Rake::Task["db:create:all"].invoke
17
    Rake::Task["db:migrate"].invoke
18
    Rake::Task["db:schema:dump"].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
26
    Rake::Task["test:scm:update"].invoke
27
  end
28

    
29
  desc "Build Redmine"
30
  task :build do
31
    if test_suite = ENV['TEST_SUITE']
32
      Rake::Task["test:#{test_suite}"].invoke
33
    else
34
      Rake::Task["test"].invoke
35
    end
36
    # Rake::Task["test:ui"].invoke if RUBY_VERSION >= '1.9.3'
37
  end
38

    
39
  desc "Finish the build"
40
  task :teardown do
41
  end
42
end
43

    
44
desc "Creates database.yml for the CI server"
45
file 'config/database.yml' do
46
  require 'yaml'
47
  database = ENV['DATABASE_ADAPTER']
48
  ruby = ENV['RUBY_VER'].gsub('.', '').gsub('-', '')
49
  branch = ENV['BRANCH'].gsub('.', '').gsub('-', '')
50
  dev_db_name = "ci_#{branch}_#{ruby}_dev"
51
  test_db_name = "ci_#{branch}_#{ruby}_test"
52

    
53
  case database
54
  when 'mysql'
55
    dev_conf =  {'adapter' => (RUBY_VERSION >= '1.9' ? 'mysql2' : 'mysql'),
56
                 'database' => dev_db_name, 'host' => 'localhost',
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
64
    test_conf = dev_conf.merge('database' => test_db_name)
65
  when 'postgresql'
66
    dev_conf =  {'adapter' => 'postgresql', 'database' => dev_db_name,
67
                 'host' => 'localhost'}
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
74
    test_conf = dev_conf.merge('database' => test_db_name)
75
  when /sqlite3/
76
    dev_conf =  {'adapter' => (Object.const_defined?(:JRUBY_VERSION) ?
77
                                 'jdbcsqlite3' : 'sqlite3'),
78
                 'database' => "db/#{dev_db_name}.sqlite3"}
79
    test_conf = dev_conf.merge('database' => "db/#{test_db_name}.sqlite3")
80
  when 'sqlserver'
81
    dev_conf =  {'adapter' => 'sqlserver', 'database' => dev_db_name,
82
                 'host' => 'mssqlserver', 'port' => 1433,
83
                 'username' => 'jenkins', 'password' => 'jenkins'}
84
    test_conf = dev_conf.merge('database' => test_db_name)
85
  else
86
    abort "Unknown database"
87
  end
88

    
89
  File.open('config/database.yml', 'w') do |f|
90
    f.write YAML.dump({'development' => dev_conf, 'test' => test_conf})
91
  end
92
end