Add rubocop to our build. (#5004)

This commit is contained in:
Guo Xiang Tan
2017-07-28 10:20:09 +09:00
committed by GitHub
parent ff4e295c4f
commit 5012d46cbd
871 changed files with 5480 additions and 6056 deletions

View File

@ -64,7 +64,6 @@ end
@timings = {}
def measure(name)
start = Time.now
yield
@ -100,7 +99,6 @@ unless $? == 0
abort "Apache Bench is not installed. Try: apt-get install apache2-utils or brew install ab"
end
unless File.exists?("config/database.yml")
puts "Copying database.yml.development.sample to database.yml"
`cp config/database.yml.development-sample config/database.yml`
@ -108,7 +106,6 @@ end
ENV["RAILS_ENV"] = "profile"
discourse_env_vars = %w(DISCOURSE_DUMP_HEAP RUBY_GC_HEAP_INIT_SLOTS RUBY_GC_HEAP_FREE_SLOTS RUBY_GC_HEAP_GROWTH_FACTOR RUBY_GC_HEAP_GROWTH_MAX_SLOTS RUBY_GC_MALLOC_LIMIT RUBY_GC_OLDMALLOC_LIMIT RUBY_GC_MALLOC_LIMIT_MAX RUBY_GC_OLDMALLOC_LIMIT_MAX RUBY_GC_MALLOC_LIMIT_GROWTH_FACTOR RUBY_GC_OLDMALLOC_LIMIT_GROWTH_FACTOR RUBY_GC_HEAP_OLDOBJECT_LIMIT_FACTOR)
if @include_env
@ -124,7 +121,7 @@ else
end
end
def port_available? port
def port_available?(port)
server = TCPServer.open("0.0.0.0", port)
server.close
true
@ -174,13 +171,14 @@ begin
puts "precompiling assets"
run("bundle exec rake assets:precompile")
pid = if @unicorn
ENV['UNICORN_PORT'] = @port.to_s
FileUtils.mkdir_p(File.join('tmp', 'pids'))
spawn("bundle exec unicorn -c config/unicorn.conf.rb")
else
spawn("bundle exec thin start -p #{@port}")
end
pid =
if @unicorn
ENV['UNICORN_PORT'] = @port.to_s
FileUtils.mkdir_p(File.join('tmp', 'pids'))
spawn("bundle exec unicorn -c config/unicorn.conf.rb")
else
spawn("bundle exec thin start -p #{@port}")
end
while port_available? @port
sleep 1
@ -199,7 +197,7 @@ begin
# ["user", "/u/admin1/activity"],
]
tests = tests.map{|k,url| ["#{k}_admin", "#{url}#{append}"]} + tests
tests = tests.map { |k, url| ["#{k}_admin", "#{url}#{append}"] } + tests
# NOTE: we run the most expensive page first in the bench
@ -210,15 +208,13 @@ begin
a[50] < b[50] ? a : b
end
results = {}
@best_of.times do
tests.each do |name, url|
results[name] = best_of(bench(url, name),results[name])
results[name] = best_of(bench(url, name), results[name])
end
end
puts "Your Results: (note for timings- percentile is first, duration is second in millisecs)"
# Prevent using external facts because it breaks when running in the
@ -226,8 +222,8 @@ begin
Facter::Util::Config.external_facts_dirs = []
facts = Facter.to_hash
facts.delete_if{|k,v|
!["operatingsystem","architecture","kernelversion",
facts.delete_if { |k, v|
!["operatingsystem", "architecture", "kernelversion",
"memorysize", "physicalprocessorcount", "processor0",
"virtual"].include?(k)
}
@ -238,15 +234,12 @@ begin
YAML.load `ruby script/memstats.rb #{pid} --yaml`
end
mem = get_mem(pid)
results = results.merge({
"timings" => @timings,
"ruby-version" => "#{RUBY_VERSION}-p#{RUBY_PATCHLEVEL}",
"rss_kb" => mem["rss_kb"],
"pss_kb" => mem["pss_kb"]
}).merge(facts)
results = results.merge("timings" => @timings,
"ruby-version" => "#{RUBY_VERSION}-p#{RUBY_PATCHLEVEL}",
"rss_kb" => mem["rss_kb"],
"pss_kb" => mem["pss_kb"]).merge(facts)
if @unicorn
child_pids = `ps --ppid #{pid} | awk '{ print $1; }' | grep -v PID`.split("\n")
@ -270,7 +263,7 @@ begin
end
if @result_file
File.open(@result_file,"wb") do |f|
File.open(@result_file, "wb") do |f|
f.write(results)
end
end