2011-07-15 03:48:10 -04:00
|
|
|
#!/usr/bin/env ruby
|
2017-08-13 09:07:54 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2016-08-06 13:21:29 -04:00
|
|
|
require "fileutils"
|
2011-07-15 03:48:10 -04:00
|
|
|
include FileUtils
|
|
|
|
|
|
|
|
commands = [
|
2017-07-18 20:59:00 -04:00
|
|
|
'mysql -e "create user rails@localhost;"',
|
|
|
|
'mysql -e "grant all privileges on activerecord_unittest.* to rails@localhost;"',
|
|
|
|
'mysql -e "grant all privileges on activerecord_unittest2.* to rails@localhost;"',
|
|
|
|
'mysql -e "grant all privileges on inexistent_activerecord_unittest.* to rails@localhost;"',
|
2011-07-15 03:48:10 -04:00
|
|
|
'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|
|
2017-07-26 11:28:12 -04:00
|
|
|
system(command, [1, 2] => File::NULL)
|
2011-07-15 03:48:10 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
class Build
|
|
|
|
MAP = {
|
2016-08-06 13:21:29 -04:00
|
|
|
"railties" => "railties",
|
|
|
|
"ap" => "actionpack",
|
|
|
|
"am" => "actionmailer",
|
|
|
|
"amo" => "activemodel",
|
|
|
|
"as" => "activesupport",
|
|
|
|
"ar" => "activerecord",
|
|
|
|
"av" => "actionview",
|
|
|
|
"aj" => "activejob",
|
|
|
|
"ac" => "actioncable",
|
2017-08-10 15:58:30 -04:00
|
|
|
"ast" => "activestorage",
|
2016-08-06 13:21:29 -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)
|
2017-02-21 13:41:17 -05:00
|
|
|
|
2011-07-15 03:48:10 -04:00
|
|
|
Dir.chdir(dir) do
|
|
|
|
announce(heading)
|
2017-02-21 13:41:17 -05:00
|
|
|
|
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?
|
2016-08-06 13:21:29 -04:00
|
|
|
heading.join(" ")
|
2011-07-15 03:48:10 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
def tasks
|
|
|
|
if activerecord?
|
2015-12-18 23:45:40 -05:00
|
|
|
tasks = ["#{adapter}:#{'isolated_' if isolated?}test"]
|
|
|
|
case adapter
|
2016-08-06 13:21:29 -04:00
|
|
|
when "mysql2"
|
|
|
|
tasks.unshift "db:mysql:rebuild"
|
|
|
|
when "postgresql"
|
|
|
|
tasks.unshift "db:postgresql:rebuild"
|
2015-12-18 23:45:40 -05:00
|
|
|
end
|
|
|
|
tasks
|
2011-07-15 03:48:10 -04:00
|
|
|
else
|
2017-02-21 13:41:17 -05:00
|
|
|
["test", ("isolated" if isolated?), ("integration" if integration?), ("ujs" if ujs?)].compact.join(":")
|
2011-07-15 03:48:10 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
def key
|
|
|
|
key = [gem]
|
|
|
|
key << adapter if activerecord?
|
2016-08-06 13:21:29 -04:00
|
|
|
key << "isolated" if isolated?
|
|
|
|
key.join(":")
|
2011-07-15 03:48:10 -04:00
|
|
|
end
|
|
|
|
|
2015-11-26 05:52:00 -05:00
|
|
|
def activesupport?
|
2016-08-06 13:21:29 -04:00
|
|
|
gem == "activesupport"
|
2015-11-26 05:52:00 -05:00
|
|
|
end
|
|
|
|
|
2011-07-15 03:48:10 -04:00
|
|
|
def activerecord?
|
2016-08-06 13:21:29 -04:00
|
|
|
gem == "activerecord"
|
2011-07-15 03:48:10 -04:00
|
|
|
end
|
|
|
|
|
2015-06-05 16:28:11 -04:00
|
|
|
def guides?
|
2016-08-06 13:21:29 -04:00
|
|
|
gem == "guides"
|
2015-06-05 16:28:11 -04:00
|
|
|
end
|
|
|
|
|
2017-02-21 13:41:17 -05:00
|
|
|
def ujs?
|
|
|
|
component.split(":").last == "ujs"
|
|
|
|
end
|
|
|
|
|
2011-07-15 03:48:10 -04:00
|
|
|
def isolated?
|
|
|
|
options[:isolated]
|
|
|
|
end
|
|
|
|
|
2014-08-18 03:19:41 -04:00
|
|
|
def integration?
|
2016-08-06 13:21:29 -04:00
|
|
|
component.split(":").last == "integration"
|
2014-08-18 03:19:41 -04:00
|
|
|
end
|
|
|
|
|
2011-07-15 03:48:10 -04:00
|
|
|
def gem
|
2016-08-06 13:21:29 -04:00
|
|
|
MAP[component.split(":").first]
|
2011-07-15 03:48:10 -04:00
|
|
|
end
|
|
|
|
alias :dir :gem
|
|
|
|
|
|
|
|
def adapter
|
2016-08-06 13:21:29 -04:00
|
|
|
component.split(":").last
|
2011-07-15 03:48:10 -04:00
|
|
|
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?
|
2016-05-04 12:22:23 -04:00
|
|
|
# There is a known issue with the listen tests that causes files to be
|
2016-05-24 13:12:49 -04:00
|
|
|
# incorrectly GC'ed even when they are still in-use. The current solution
|
2017-11-28 13:27:43 -05:00
|
|
|
# is to only run them in isolation to avoid random failures of our test suite.
|
2016-08-06 13:21:29 -04:00
|
|
|
{ "LISTEN" => "0" }
|
2015-11-27 04:29:53 -05:00
|
|
|
else
|
|
|
|
{}
|
|
|
|
end
|
2015-11-26 05:52:00 -05:00
|
|
|
end
|
|
|
|
|
2015-06-05 16:28:11 -04:00
|
|
|
def run_bug_report_templates
|
2016-08-06 13:21:29 -04:00
|
|
|
Dir.glob("bug_report_templates/*.rb").all? do |file|
|
|
|
|
system(Gem.ruby, "-w", file)
|
2015-06-05 16:28:11 -04:00
|
|
|
end
|
|
|
|
end
|
2011-07-15 03:48:10 -04:00
|
|
|
end
|
|
|
|
|
2016-10-28 23:05:58 -04:00
|
|
|
if ENV["GEM"] == "aj:integration"
|
2016-08-06 13:55:02 -04: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 03:19:41 -04:00
|
|
|
end
|
|
|
|
|
2011-07-15 03:48:10 -04:00
|
|
|
results = {}
|
|
|
|
|
2016-08-06 13:21:29 -04:00
|
|
|
ENV["GEM"].split(",").each do |gem|
|
2011-07-15 03:48:10 -04:00
|
|
|
[false, true].each do |isolated|
|
2016-08-06 13:21:29 -04:00
|
|
|
next if ENV["TRAVIS_PULL_REQUEST"] && ENV["TRAVIS_PULL_REQUEST"] != "false" && isolated
|
2018-01-24 18:25:10 -05:00
|
|
|
next if RUBY_VERSION < "2.5" && isolated
|
2016-08-06 13:21:29 -04:00
|
|
|
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
|
2017-02-21 13:41:17 -05:00
|
|
|
next if gem == "av:ujs" && isolated
|
2017-08-10 15:58:30 -04:00
|
|
|
next if gem == "ast" && isolated
|
2011-07-15 03:48:10 -04:00
|
|
|
|
2016-08-06 13:40:54 -04:00
|
|
|
build = Build.new(gem, isolated: isolated)
|
2011-07-15 03:48:10 -04:00
|
|
|
results[build.key] = build.run!
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
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
|