Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100755 132 lines (109 sloc) 2.763 kb
d664eba @joshk Added a .travis.yml config and travis specific ci script.
joshk authored
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 'as' => 'activesupport',
23 'ar' => 'activerecord'
24 }
25
26 attr_reader :component, :options
27
28 def initialize(component, options = {})
29 @component = component
30 @options = options
31 end
32
33 def run!(options = {})
34 self.options.update(options)
35 Dir.chdir(dir) do
36 announce(heading)
37 rake(*tasks)
38 end
39 end
40
41 def announce(heading)
42 puts "\n\e[1;33m[Travis CI] #{heading}\e[m\n"
43 end
44
45 def heading
46 heading = [gem]
a8dd21d @carlosantoniodasilva Remove IdentityMap
carlosantoniodasilva authored
47 heading << "with #{adapter}" if activerecord?
d664eba @joshk Added a .travis.yml config and travis specific ci script.
joshk authored
48 heading << "in isolation" if isolated?
49 heading.join(' ')
50 end
51
52 def tasks
53 if activerecord?
54 ['mysql:rebuild_databases', "#{adapter}:#{'isolated_' if isolated?}test"]
55 else
56 ["test#{':isolated' if isolated?}"]
57 end
58 end
59
60 def key
61 key = [gem]
62 key << adapter if activerecord?
63 key << 'isolated' if isolated?
64 key.join(':')
65 end
66
67 def activerecord?
68 gem == 'activerecord'
69 end
70
71 def isolated?
72 options[:isolated]
73 end
74
75 def gem
76 MAP[component.split(':').first]
77 end
78 alias :dir :gem
79
80 def adapter
81 component.split(':').last
82 end
83
84 def rake(*tasks)
85 tasks.each do |task|
86 cmd = "bundle exec rake #{task}"
87 puts "Running command: #{cmd}"
88 return false unless system(cmd)
89 end
90 true
91 end
92 end
93
94 results = {}
95
96 ENV['GEM'].split(',').each do |gem|
97 [false, true].each do |isolated|
98 next if gem == 'railties' && isolated
99
100 build = Build.new(gem, :isolated => isolated)
101 results[build.key] = build.run!
102
103 end
104 end
105
106 # puts
107 # puts "Build environment:"
108 # puts " #{`cat /etc/issue`}"
109 # puts " #{`uname -a`}"
110 # puts " #{`ruby -v`}"
111 # puts " #{`mysql --version`}"
112 # # puts " #{`pg_config --version`}"
113 # puts " SQLite3: #{`sqlite3 -version`}"
114 # `gem env`.each_line {|line| print " #{line}"}
115 # puts " Bundled gems:"
116 # `bundle show`.each_line {|line| print " #{line}"}
117 # puts " Local gems:"
118 # `gem list`.each_line {|line| print " #{line}"}
119
120 failures = results.select { |key, value| value == false }
121
122 if failures.empty?
123 puts
cc5f68d @HeeL fixed a typo in a message when there is no failuresin a build
HeeL authored
124 puts "Rails build finished successfully"
d664eba @joshk Added a .travis.yml config and travis specific ci script.
joshk authored
125 exit(true)
126 else
127 puts
128 puts "Rails build FAILED"
129 puts "Failed components: #{failures.map { |component| component.first }.join(', ')}"
130 exit(false)
131 end
Something went wrong with that request. Please try again.