Skip to content

Commit d664eba

Browse files
committed
Added a .travis.yml config and travis specific ci script.
Don't install ruby-debug if running the test suite on Travis, linecache19 is the main offender, very very slow. And do not install pg if Travis is bundling the gems, pg will be setup on Travis soon.
1 parent f88e9d8 commit d664eba

File tree

3 files changed

+157
-3
lines changed

3 files changed

+157
-3
lines changed

.travis.yml

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
script: 'ci/travis.rb'
2+
notifications:
3+
disabled: true
4+
rvm:
5+
- 1.8.7
6+
- 1.9.2
7+
env:
8+
- "GEM=railties"
9+
- "GEM=ap,am,amo,ares,as"
10+
- "GEM=ar:mysql"
11+
- "GEM=ar:mysql2"
12+
- "GEM=ar:sqlite3"

Gemfile

+3-3
Original file line numberDiff line numberDiff line change
@@ -31,13 +31,13 @@ gem "memcache-client", ">= 1.8.5"
3131

3232
platforms :mri_18 do
3333
gem "system_timer"
34-
gem "ruby-debug", ">= 0.10.3"
34+
gem "ruby-debug", ">= 0.10.3" unless ENV['TRAVIS']
3535
gem "json"
3636
end
3737

3838
platforms :mri_19 do
3939
# TODO: Remove the conditional when ruby-debug19 supports Ruby >= 1.9.3
40-
gem "ruby-debug19", :require => "ruby-debug" if RUBY_VERSION < "1.9.3"
40+
gem "ruby-debug19", :require => "ruby-debug" unless RUBY_VERSION > "1.9.2" || ENV['TRAVIS']
4141
end
4242

4343
platforms :ruby do
@@ -56,7 +56,7 @@ platforms :ruby do
5656
gem "sqlite3", "~> 1.3.3"
5757

5858
group :db do
59-
gem "pg", ">= 0.11.0"
59+
gem "pg", ">= 0.11.0" unless ENV['TRAVIS'] # once pg is on travis this can be removed
6060
gem "mysql", ">= 2.8.1"
6161
gem "mysql2", ">= 0.3.6"
6262
end

ci/travis.rb

+142
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,142 @@
1+
#!/usr/bin/env ruby
2+
require 'fileutils'
3+
include FileUtils
4+
5+
commands = [
6+
'mysql -e "create database activerecord_unittest;"',
7+
'mysql -e "create database activerecord_unittest2;"',
8+
'psql -c "create database activerecord_unittest;" -U postgres',
9+
'psql -c "create database activerecord_unittest2;" -U postgres'
10+
]
11+
12+
commands.each do |command|
13+
system("#{command} > /dev/null 2>&1")
14+
end
15+
16+
class Build
17+
MAP = {
18+
'railties' => 'railties',
19+
'ap' => 'actionpack',
20+
'am' => 'actionmailer',
21+
'amo' => 'activemodel',
22+
'ares' => 'activeresource',
23+
'as' => 'activesupport',
24+
'ar' => 'activerecord'
25+
}
26+
27+
attr_reader :component, :options
28+
29+
def initialize(component, options = {})
30+
@component = component
31+
@options = options
32+
end
33+
34+
def run!(options = {})
35+
self.options.update(options)
36+
Dir.chdir(dir) do
37+
announce(heading)
38+
ENV['IM'] = identity_map?.inspect
39+
rake(*tasks)
40+
end
41+
end
42+
43+
def announce(heading)
44+
puts "\n\e[1;33m[Travis CI] #{heading}\e[m\n"
45+
end
46+
47+
def heading
48+
heading = [gem]
49+
heading << "with #{adapter} IM #{identity_map? ? 'enabled' : 'disabled'}" if activerecord?
50+
heading << "in isolation" if isolated?
51+
heading.join(' ')
52+
end
53+
54+
def tasks
55+
if activerecord?
56+
['mysql:rebuild_databases', "#{adapter}:#{'isolated_' if isolated?}test"]
57+
else
58+
["test#{':isolated' if isolated?}"]
59+
end
60+
end
61+
62+
def key
63+
key = [gem]
64+
key << adapter if activerecord?
65+
key << 'IM' if identity_map?
66+
key << 'isolated' if isolated?
67+
key.join(':')
68+
end
69+
70+
def activerecord?
71+
gem == 'activerecord'
72+
end
73+
74+
def identity_map?
75+
options[:identity_map]
76+
end
77+
78+
def isolated?
79+
options[:isolated]
80+
end
81+
82+
def gem
83+
MAP[component.split(':').first]
84+
end
85+
alias :dir :gem
86+
87+
def adapter
88+
component.split(':').last
89+
end
90+
91+
def rake(*tasks)
92+
tasks.each do |task|
93+
cmd = "bundle exec rake #{task}"
94+
puts "Running command: #{cmd}"
95+
return false unless system(cmd)
96+
end
97+
true
98+
end
99+
end
100+
101+
results = {}
102+
103+
ENV['GEM'].split(',').each do |gem|
104+
[false, true].each do |isolated|
105+
next if gem == 'railties' && isolated
106+
107+
build = Build.new(gem, :isolated => isolated)
108+
results[build.key] = build.run!
109+
110+
if build.activerecord?
111+
build.options[:identity_map] = true
112+
results[build.key] = build.run!
113+
end
114+
end
115+
end
116+
117+
# puts
118+
# puts "Build environment:"
119+
# puts " #{`cat /etc/issue`}"
120+
# puts " #{`uname -a`}"
121+
# puts " #{`ruby -v`}"
122+
# puts " #{`mysql --version`}"
123+
# # puts " #{`pg_config --version`}"
124+
# puts " SQLite3: #{`sqlite3 -version`}"
125+
# `gem env`.each_line {|line| print " #{line}"}
126+
# puts " Bundled gems:"
127+
# `bundle show`.each_line {|line| print " #{line}"}
128+
# puts " Local gems:"
129+
# `gem list`.each_line {|line| print " #{line}"}
130+
131+
failures = results.select { |key, value| value == false }
132+
133+
if failures.empty?
134+
puts
135+
puts "Rails build finished sucessfully"
136+
exit(true)
137+
else
138+
puts
139+
puts "Rails build FAILED"
140+
puts "Failed components: #{failures.map { |component| component.first }.join(', ')}"
141+
exit(false)
142+
end

0 commit comments

Comments
 (0)