2011-07-15 07:48:10 +00:00
|
|
|
#!/usr/bin/env ruby
|
2016-08-06 17:21:29 +00:00
|
|
|
require "fileutils"
|
2011-07-15 07:48:10 +00:00
|
|
|
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 = {
|
2016-08-06 17:21:29 +00:00
|
|
|
"railties" => "railties",
|
|
|
|
"ap" => "actionpack",
|
|
|
|
"am" => "actionmailer",
|
|
|
|
"amo" => "activemodel",
|
|
|
|
"as" => "activesupport",
|
|
|
|
"ar" => "activerecord",
|
|
|
|
"av" => "actionview",
|
|
|
|
"aj" => "activejob",
|
|
|
|
"ac" => "actioncable",
|
|
|
|
"guides" => "guides"
|
2011-07-15 07:48:10 +00: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 20:28:11 +00:00
|
|
|
if guides?
|
|
|
|
run_bug_report_templates
|
|
|
|
else
|
|
|
|
rake(*tasks)
|
|
|
|
end
|
2011-07-15 07:48:10 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
def announce(heading)
|
|
|
|
puts "\n\e[1;33m[Travis CI] #{heading}\e[m\n"
|
|
|
|
end
|
|
|
|
|
|
|
|
def heading
|
|
|
|
heading = [gem]
|
2012-03-02 03:10:06 +00:00
|
|
|
heading << "with #{adapter}" if activerecord?
|
2011-07-15 07:48:10 +00:00
|
|
|
heading << "in isolation" if isolated?
|
2014-08-18 07:19:41 +00:00
|
|
|
heading << "integration" if integration?
|
2016-08-06 17:21:29 +00:00
|
|
|
heading.join(" ")
|
2011-07-15 07:48:10 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
def tasks
|
|
|
|
if activerecord?
|
2015-12-19 04:45:40 +00:00
|
|
|
tasks = ["#{adapter}:#{'isolated_' if isolated?}test"]
|
|
|
|
case adapter
|
2016-08-06 17:21:29 +00:00
|
|
|
when "mysql2"
|
|
|
|
tasks.unshift "db:mysql:rebuild"
|
|
|
|
when "postgresql"
|
|
|
|
tasks.unshift "db:postgresql:rebuild"
|
2015-12-19 04:45:40 +00:00
|
|
|
end
|
|
|
|
tasks
|
2011-07-15 07:48:10 +00:00
|
|
|
else
|
2016-08-06 17:21:29 +00:00
|
|
|
["test", ("isolated" if isolated?), ("integration" if integration?)].compact.join(":")
|
2011-07-15 07:48:10 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
def key
|
|
|
|
key = [gem]
|
|
|
|
key << adapter if activerecord?
|
2016-08-06 17:21:29 +00:00
|
|
|
key << "isolated" if isolated?
|
|
|
|
key.join(":")
|
2011-07-15 07:48:10 +00:00
|
|
|
end
|
|
|
|
|
2015-11-26 10:52:00 +00:00
|
|
|
def activesupport?
|
2016-08-06 17:21:29 +00:00
|
|
|
gem == "activesupport"
|
2015-11-26 10:52:00 +00:00
|
|
|
end
|
|
|
|
|
2011-07-15 07:48:10 +00:00
|
|
|
def activerecord?
|
2016-08-06 17:21:29 +00:00
|
|
|
gem == "activerecord"
|
2011-07-15 07:48:10 +00:00
|
|
|
end
|
|
|
|
|
2015-06-05 20:28:11 +00:00
|
|
|
def guides?
|
2016-08-06 17:21:29 +00:00
|
|
|
gem == "guides"
|
2015-06-05 20:28:11 +00:00
|
|
|
end
|
|
|
|
|
2011-07-15 07:48:10 +00:00
|
|
|
def isolated?
|
|
|
|
options[:isolated]
|
|
|
|
end
|
|
|
|
|
2014-08-18 07:19:41 +00:00
|
|
|
def integration?
|
2016-08-06 17:21:29 +00:00
|
|
|
component.split(":").last == "integration"
|
2014-08-18 07:19:41 +00:00
|
|
|
end
|
|
|
|
|
2011-07-15 07:48:10 +00:00
|
|
|
def gem
|
2016-08-06 17:21:29 +00:00
|
|
|
MAP[component.split(":").first]
|
2011-07-15 07:48:10 +00:00
|
|
|
end
|
|
|
|
alias :dir :gem
|
|
|
|
|
|
|
|
def adapter
|
2016-08-06 17:21:29 +00:00
|
|
|
component.split(":").last
|
2011-07-15 07:48:10 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
def rake(*tasks)
|
|
|
|
tasks.each do |task|
|
|
|
|
cmd = "bundle exec rake #{task}"
|
|
|
|
puts "Running command: #{cmd}"
|
2015-11-26 10:52:00 +00:00
|
|
|
return false unless system(env, cmd)
|
2011-07-15 07:48:10 +00:00
|
|
|
end
|
|
|
|
true
|
|
|
|
end
|
2015-06-05 20:28:11 +00:00
|
|
|
|
2015-11-26 10:52:00 +00:00
|
|
|
def env
|
2015-11-27 09:29:53 +00:00
|
|
|
if activesupport? && !isolated?
|
2016-05-04 16:22:23 +00:00
|
|
|
# There is a known issue with the listen tests that causes files to be
|
2016-05-24 17:12:49 +00:00
|
|
|
# incorrectly GC'ed even when they are still in-use. The current solution
|
|
|
|
# is to only run them in isolation to avoid randomly failing our test suite.
|
2016-08-06 17:21:29 +00:00
|
|
|
{ "LISTEN" => "0" }
|
2015-11-27 09:29:53 +00:00
|
|
|
else
|
|
|
|
{}
|
|
|
|
end
|
2015-11-26 10:52:00 +00:00
|
|
|
end
|
|
|
|
|
2015-06-05 20:28:11 +00:00
|
|
|
def run_bug_report_templates
|
2016-08-06 17:21:29 +00:00
|
|
|
Dir.glob("bug_report_templates/*.rb").all? do |file|
|
|
|
|
system(Gem.ruby, "-w", file)
|
2015-06-05 20:28:11 +00:00
|
|
|
end
|
|
|
|
end
|
2011-07-15 07:48:10 +00:00
|
|
|
end
|
|
|
|
|
2016-08-06 17:21:29 +00:00
|
|
|
if ENV["GEM"]=="aj:integration"
|
2016-08-06 17:55:02 +00:00
|
|
|
ENV["QC_DATABASE_URL"] = "postgres://postgres@localhost/active_jobs_qc_int_test"
|
|
|
|
ENV["QUE_DATABASE_URL"] = "postgres://postgres@localhost/active_jobs_que_int_test"
|
2014-08-18 07:19:41 +00:00
|
|
|
end
|
|
|
|
|
2011-07-15 07:48:10 +00:00
|
|
|
results = {}
|
|
|
|
|
2016-08-06 17:21:29 +00:00
|
|
|
ENV["GEM"].split(",").each do |gem|
|
2011-07-15 07:48:10 +00:00
|
|
|
[false, true].each do |isolated|
|
2016-08-06 17:21:29 +00:00
|
|
|
next if ENV["TRAVIS_PULL_REQUEST"] && ENV["TRAVIS_PULL_REQUEST"] != "false" && isolated
|
|
|
|
next if gem == "railties" && isolated
|
|
|
|
next if gem == "ac" && isolated
|
|
|
|
next if gem == "ac:integration" && isolated
|
|
|
|
next if gem == "aj:integration" && isolated
|
|
|
|
next if gem == "guides" && isolated
|
2011-07-15 07:48:10 +00:00
|
|
|
|
2016-08-06 17:40:54 +00:00
|
|
|
build = Build.new(gem, isolated: isolated)
|
2011-07-15 07:48:10 +00:00
|
|
|
results[build.key] = build.run!
|
|
|
|
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2013-03-21 05:27:52 +00:00
|
|
|
failures = results.select { |key, value| !value }
|
2011-07-15 07:48:10 +00:00
|
|
|
|
|
|
|
if failures.empty?
|
|
|
|
puts
|
2011-11-28 14:45:40 +00:00
|
|
|
puts "Rails build finished successfully"
|
2011-07-15 07:48:10 +00:00
|
|
|
exit(true)
|
|
|
|
else
|
|
|
|
puts
|
|
|
|
puts "Rails build FAILED"
|
2014-10-27 16:28:53 +00:00
|
|
|
puts "Failed components: #{failures.map(&:first).join(', ')}"
|
2011-07-15 07:48:10 +00:00
|
|
|
exit(false)
|
|
|
|
end
|