2011-07-15 03:48:10 -04:00
|
|
|
#!/usr/bin/env ruby
|
|
|
|
require 'fileutils'
|
|
|
|
include FileUtils
|
|
|
|
|
|
|
|
commands = [
|
|
|
|
'mysql -e "create database activerecord_unittest;"',
|
|
|
|
'mysql -e "create database activerecord_unittest2;"',
|
|
|
|
'psql -c "create database activerecord_unittest;" -U postgres',
|
|
|
|
'psql -c "create database activerecord_unittest2;" -U postgres'
|
|
|
|
]
|
|
|
|
|
|
|
|
commands.each do |command|
|
|
|
|
system("#{command} > /dev/null 2>&1")
|
|
|
|
end
|
|
|
|
|
|
|
|
class Build
|
|
|
|
MAP = {
|
|
|
|
'railties' => 'railties',
|
2015-06-05 16:28:11 -04:00
|
|
|
'ap' => 'actionpack',
|
|
|
|
'am' => 'actionmailer',
|
|
|
|
'amo' => 'activemodel',
|
|
|
|
'as' => 'activesupport',
|
|
|
|
'ar' => 'activerecord',
|
|
|
|
'av' => 'actionview',
|
|
|
|
'aj' => 'activejob',
|
2015-12-14 11:44:51 -05:00
|
|
|
'ac' => 'actioncable',
|
2015-06-05 16:28:11 -04:00
|
|
|
'guides' => 'guides'
|
2011-07-15 03:48:10 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
attr_reader :component, :options
|
|
|
|
|
|
|
|
def initialize(component, options = {})
|
|
|
|
@component = component
|
|
|
|
@options = options
|
|
|
|
end
|
|
|
|
|
|
|
|
def run!(options = {})
|
|
|
|
self.options.update(options)
|
|
|
|
Dir.chdir(dir) do
|
|
|
|
announce(heading)
|
2015-06-05 16:28:11 -04:00
|
|
|
if guides?
|
|
|
|
run_bug_report_templates
|
|
|
|
else
|
|
|
|
rake(*tasks)
|
|
|
|
end
|
2011-07-15 03:48:10 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
def announce(heading)
|
|
|
|
puts "\n\e[1;33m[Travis CI] #{heading}\e[m\n"
|
|
|
|
end
|
|
|
|
|
|
|
|
def heading
|
|
|
|
heading = [gem]
|
2012-03-01 22:10:06 -05:00
|
|
|
heading << "with #{adapter}" if activerecord?
|
2011-07-15 03:48:10 -04:00
|
|
|
heading << "in isolation" if isolated?
|
2014-08-18 03:19:41 -04:00
|
|
|
heading << "integration" if integration?
|
2011-07-15 03:48:10 -04:00
|
|
|
heading.join(' ')
|
|
|
|
end
|
|
|
|
|
|
|
|
def tasks
|
|
|
|
if activerecord?
|
2015-12-18 23:45:40 -05:00
|
|
|
tasks = ["#{adapter}:#{'isolated_' if isolated?}test"]
|
|
|
|
case adapter
|
|
|
|
when 'mysql2'
|
|
|
|
tasks.unshift 'db:mysql:rebuild'
|
|
|
|
when 'postgresql'
|
|
|
|
tasks.unshift 'db:postgresql:rebuild'
|
|
|
|
end
|
|
|
|
tasks
|
2011-07-15 03:48:10 -04:00
|
|
|
else
|
2014-08-18 03:19:41 -04:00
|
|
|
["test", ('isolated' if isolated?), ('integration' if integration?)].compact.join(":")
|
2011-07-15 03:48:10 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
def key
|
|
|
|
key = [gem]
|
|
|
|
key << adapter if activerecord?
|
|
|
|
key << 'isolated' if isolated?
|
|
|
|
key.join(':')
|
|
|
|
end
|
|
|
|
|
2015-11-26 05:52:00 -05:00
|
|
|
def activesupport?
|
|
|
|
gem == 'activesupport'
|
|
|
|
end
|
|
|
|
|
2011-07-15 03:48:10 -04:00
|
|
|
def activerecord?
|
|
|
|
gem == 'activerecord'
|
|
|
|
end
|
|
|
|
|
2015-06-05 16:28:11 -04:00
|
|
|
def guides?
|
|
|
|
gem == 'guides'
|
|
|
|
end
|
|
|
|
|
2011-07-15 03:48:10 -04:00
|
|
|
def isolated?
|
|
|
|
options[:isolated]
|
|
|
|
end
|
|
|
|
|
2014-08-18 03:19:41 -04:00
|
|
|
def integration?
|
|
|
|
component.split(':').last == 'integration'
|
|
|
|
end
|
|
|
|
|
2011-07-15 03:48:10 -04:00
|
|
|
def gem
|
|
|
|
MAP[component.split(':').first]
|
|
|
|
end
|
|
|
|
alias :dir :gem
|
|
|
|
|
|
|
|
def adapter
|
|
|
|
component.split(':').last
|
|
|
|
end
|
|
|
|
|
|
|
|
def rake(*tasks)
|
|
|
|
tasks.each do |task|
|
|
|
|
cmd = "bundle exec rake #{task}"
|
|
|
|
puts "Running command: #{cmd}"
|
2015-11-26 05:52:00 -05:00
|
|
|
return false unless system(env, cmd)
|
2011-07-15 03:48:10 -04:00
|
|
|
end
|
|
|
|
true
|
|
|
|
end
|
2015-06-05 16:28:11 -04:00
|
|
|
|
2015-11-26 05:52:00 -05:00
|
|
|
def env
|
2015-11-27 04:29:53 -05:00
|
|
|
if activesupport? && !isolated?
|
|
|
|
# There is a known issue with the listen tests that casuses files to be
|
|
|
|
# incorrectly GC'ed even when they are still in-use. The current is to
|
|
|
|
# only run them in isolation to avoid randomly failing our test suite.
|
|
|
|
{ 'LISTEN' => '0' }
|
|
|
|
else
|
|
|
|
{}
|
|
|
|
end
|
2015-11-26 05:52:00 -05:00
|
|
|
end
|
|
|
|
|
2015-06-05 16:28:11 -04:00
|
|
|
def run_bug_report_templates
|
|
|
|
Dir.glob('bug_report_templates/*.rb').all? do |file|
|
|
|
|
system(Gem.ruby, '-w', file)
|
|
|
|
end
|
|
|
|
end
|
2011-07-15 03:48:10 -04:00
|
|
|
end
|
|
|
|
|
2014-08-18 03:19:41 -04:00
|
|
|
if ENV['GEM']=='aj:integration'
|
|
|
|
ENV['QC_DATABASE_URL'] = 'postgres://postgres@localhost/active_jobs_qc_int_test'
|
|
|
|
ENV['QUE_DATABASE_URL'] = 'postgres://postgres@localhost/active_jobs_que_int_test'
|
|
|
|
end
|
|
|
|
|
2011-07-15 03:48:10 -04:00
|
|
|
results = {}
|
|
|
|
|
|
|
|
ENV['GEM'].split(',').each do |gem|
|
|
|
|
[false, true].each do |isolated|
|
2014-09-20 05:47:12 -04:00
|
|
|
next if ENV['TRAVIS_PULL_REQUEST'] && ENV['TRAVIS_PULL_REQUEST'] != 'false' && isolated
|
2011-07-15 03:48:10 -04:00
|
|
|
next if gem == 'railties' && isolated
|
2015-12-14 13:02:31 -05:00
|
|
|
next if gem == 'ac' && isolated
|
2014-08-18 03:19:41 -04:00
|
|
|
next if gem == 'aj:integration' && isolated
|
2015-06-05 16:28:11 -04:00
|
|
|
next if gem == 'guides' && isolated
|
2011-07-15 03:48:10 -04:00
|
|
|
|
|
|
|
build = Build.new(gem, :isolated => isolated)
|
|
|
|
results[build.key] = build.run!
|
|
|
|
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
# puts
|
|
|
|
# puts "Build environment:"
|
|
|
|
# puts " #{`cat /etc/issue`}"
|
|
|
|
# puts " #{`uname -a`}"
|
|
|
|
# puts " #{`ruby -v`}"
|
|
|
|
# puts " #{`mysql --version`}"
|
2013-03-21 01:27:52 -04:00
|
|
|
# puts " #{`pg_config --version`}"
|
2011-07-15 03:48:10 -04:00
|
|
|
# puts " SQLite3: #{`sqlite3 -version`}"
|
|
|
|
# `gem env`.each_line {|line| print " #{line}"}
|
|
|
|
# puts " Bundled gems:"
|
|
|
|
# `bundle show`.each_line {|line| print " #{line}"}
|
|
|
|
# puts " Local gems:"
|
|
|
|
# `gem list`.each_line {|line| print " #{line}"}
|
|
|
|
|
2013-03-21 01:27:52 -04:00
|
|
|
failures = results.select { |key, value| !value }
|
2011-07-15 03:48:10 -04:00
|
|
|
|
|
|
|
if failures.empty?
|
|
|
|
puts
|
2011-11-28 09:45:40 -05:00
|
|
|
puts "Rails build finished successfully"
|
2011-07-15 03:48:10 -04:00
|
|
|
exit(true)
|
|
|
|
else
|
|
|
|
puts
|
|
|
|
puts "Rails build FAILED"
|
2014-10-27 12:28:53 -04:00
|
|
|
puts "Failed components: #{failures.map(&:first).join(', ')}"
|
2011-07-15 03:48:10 -04:00
|
|
|
exit(false)
|
|
|
|
end
|