aboutsummaryrefslogtreecommitdiffstats
path: root/ci/ci_build.rb
blob: c3af1f017720562bd5a3ed2f259ac0d2c1ad44b7 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
#!/usr/bin/env ruby
require 'fileutils'
include FileUtils

def root_dir
  @root_dir ||= File.expand_path('../..', __FILE__)
end

def rake(*tasks)
  tasks.each do |task|
    cmd = "bundle exec rake #{task}"
    puts "Running command: #{cmd}"
    return false unless system(cmd)
  end
  true
end

puts "[CruiseControl] Rails build"
build_results = {}

# Install required version of bundler.
bundler_install_cmd = "sudo gem install bundler --no-ri --no-rdoc"
puts "Running command: #{bundler_install_cmd}"
build_results[:install_bundler] = system bundler_install_cmd

cd root_dir do
  puts
  puts "[CruiseControl] Bundling gems"
  puts
  build_results[:bundle] = system 'bundle update'
end

cd "#{root_dir}/activesupport" do
  puts
  puts "[CruiseControl] Building Active Support"
  puts
  build_results[:activesupport] = rake 'test'
  build_results[:activesupport_isolated] = rake 'test:isolated'
end

system "sudo rm -R #{root_dir}/railties/tmp"
cd "#{root_dir}/railties" do
  puts
  puts "[CruiseControl] Building Railties"
  puts
  build_results[:railties] = rake 'test'
end

cd "#{root_dir}/actionpack" do
  puts
  puts "[CruiseControl] Building Action Pack"
  puts
  build_results[:actionpack] = rake 'test'
  build_results[:actionpack_isolated] = rake 'test:isolated'
end

cd "#{root_dir}/actionmailer" do
  puts
  puts "[CruiseControl] Building Action Mailer"
  puts
  build_results[:actionmailer] = rake 'test'
  build_results[:actionmailer_isolated] = rake 'test:isolated'
end

cd "#{root_dir}/activemodel" do
  puts
  puts "[CruiseControl] Building Active Model"
  puts
  build_results[:activemodel] = rake 'test'
  build_results[:activemodel_isolated] = rake 'test:isolated'
end

rm_f "#{root_dir}/activeresource/debug.log"
cd "#{root_dir}/activeresource" do
  puts
  puts "[CruiseControl] Building Active Resource"
  puts
  build_results[:activeresource] = rake 'test'
  build_results[:activeresource_isolated] = rake 'test:isolated'
end

rm_f "#{root_dir}/activerecord/debug.log"
cd "#{root_dir}/activerecord" do
  puts
  puts "[CruiseControl] Building Active Record with MySQL IM enabled"
  puts
  ENV['IM'] = 'true'
  build_results[:activerecord_mysql] = rake 'mysql:rebuild_databases', 'mysql:test'
  build_results[:activerecord_mysql_isolated] = rake 'mysql:rebuild_databases', 'mysql:isolated_test'
end

cd "#{root_dir}/activerecord" do
  puts
  puts "[CruiseControl] Building Active Record with MySQL IM disabled"
  puts
  ENV['IM'] = 'false'
  build_results[:activerecord_mysql] = rake 'mysql:rebuild_databases', 'mysql:test'
  build_results[:activerecord_mysql_isolated] = rake 'mysql:rebuild_databases', 'mysql:isolated_test'
end

cd "#{root_dir}/activerecord" do
  puts
  puts "[CruiseControl] Building Active Record with MySQL2 IM enabled"
  puts
  ENV['IM'] = 'true'
  build_results[:activerecord_mysql2] = rake 'mysql:rebuild_databases', 'mysql2:test'
  build_results[:activerecord_mysql2_isolated] = rake 'mysql:rebuild_databases', 'mysql2:isolated_test'
end

cd "#{root_dir}/activerecord" do
  puts
  puts "[CruiseControl] Building Active Record with MySQL2 IM disabled"
  puts
  ENV['IM'] = 'false'
  build_results[:activerecord_mysql2] = rake 'mysql:rebuild_databases', 'mysql2:test'
  build_results[:activerecord_mysql2_isolated] = rake 'mysql:rebuild_databases', 'mysql2:isolated_test'
end

cd "#{root_dir}/activerecord" do
  puts
  puts "[CruiseControl] Building Active Record with PostgreSQL IM enabled"
  puts
  ENV['IM'] = 'true'
  build_results[:activerecord_postgresql8] = rake 'postgresql:rebuild_databases', 'postgresql:test'
  build_results[:activerecord_postgresql8_isolated] = rake 'postgresql:rebuild_databases', 'postgresql:isolated_test'
end

cd "#{root_dir}/activerecord" do
  puts
  puts "[CruiseControl] Building Active Record with PostgreSQL IM disabled"
  puts
  ENV['IM'] = 'false'
  build_results[:activerecord_postgresql8] = rake 'postgresql:rebuild_databases', 'postgresql:test'
  build_results[:activerecord_postgresql8_isolated] = rake 'postgresql:rebuild_databases', 'postgresql:isolated_test'
end

cd "#{root_dir}/activerecord" do
  puts
  puts "[CruiseControl] Building Active Record with SQLite 3 IM enabled"
  puts
  ENV['IM'] = 'true'
  build_results[:activerecord_sqlite3] = rake 'sqlite3:test'
  build_results[:activerecord_sqlite3_isolated] = rake 'sqlite3:isolated_test'
end

cd "#{root_dir}/activerecord" do
  puts
  puts "[CruiseControl] Building Active Record with SQLite 3 IM disabled"
  puts
  ENV['IM'] = 'false'
  build_results[:activerecord_sqlite3] = rake 'sqlite3:test'
  build_results[:activerecord_sqlite3_isolated] = rake 'sqlite3:isolated_test'
end


puts
puts "[CruiseControl] Build environment:"
puts "[CruiseControl]   #{`cat /etc/issue`}"
puts "[CruiseControl]   #{`uname -a`}"
puts "[CruiseControl]   #{`ruby -v`}"
puts "[CruiseControl]   #{`mysql --version`}"
puts "[CruiseControl]   #{`pg_config --version`}"
puts "[CruiseControl]   SQLite3: #{`sqlite3 -version`}"
`gem env`.each_line {|line| print "[CruiseControl]   #{line}"}
puts "[CruiseControl]   Bundled gems:"
`bundle show`.each_line {|line| print "[CruiseControl]     #{line}"}
puts "[CruiseControl]   Local gems:"
`gem list`.each_line {|line| print "[CruiseControl]     #{line}"}

failures = build_results.select { |key, value| value == false }

if failures.empty?
  puts
  puts "[CruiseControl] Rails build finished sucessfully"
  exit(0)
else
  puts
  puts "[CruiseControl] Rails build FAILED"
  puts "[CruiseControl] Failed components: #{failures.map { |component| component.first }.join(', ')}"
  exit(-1)
end