Commit 2f0d2ab5 authored by Rémy Coutable's avatar Rémy Coutable

Run lint:all tasks in forks

Signed-off-by: default avatarRémy Coutable <remy@rymai.me>
parent e4990b66
...@@ -20,7 +20,6 @@ unless Rails.env.production? ...@@ -20,7 +20,6 @@ unless Rails.env.production?
desc "GitLab | lint | Run several lint checks" desc "GitLab | lint | Run several lint checks"
task :all do task :all do
status = 0 status = 0
original_stdout = $stdout
%w[ %w[
config_lint config_lint
...@@ -30,19 +29,41 @@ unless Rails.env.production? ...@@ -30,19 +29,41 @@ unless Rails.env.production?
gettext:lint gettext:lint
lint:static_verification lint:static_verification
].each do |task| ].each do |task|
pid = Process.fork do
rd, wr = IO.pipe
stdout = $stdout.dup
stderr = $stderr.dup
$stdout.reopen(wr)
$stderr.reopen(wr)
begin
begin begin
$stdout = StringIO.new
Rake::Task[task].invoke Rake::Task[task].invoke
rescue RuntimeError, SystemExit => ex rescue RuntimeError # The haml_lint tasks raise a RuntimeError
raise ex if ex.is_a?(RuntimeError) && task != 'haml_lint' exit(1)
original_stdout << $stdout.string end
status = 1 rescue SystemExit => ex
msg = "*** Rake task #{task} failed with the following error(s):"
raise ex
ensure ensure
$stdout = original_stdout $stdout.reopen(stdout)
$stderr.reopen(stderr)
wr.close
if msg
warn "\n#{msg}\n\n"
IO.copy_stream(rd, $stderr)
else
IO.copy_stream(rd, $stdout)
end end
end end
end
Process.waitpid(pid)
status += $?.exitstatus
end
exit status exit(status)
end end
end end
end end
...@@ -7,7 +7,7 @@ require_relative '../lib/gitlab/popen/runner' ...@@ -7,7 +7,7 @@ require_relative '../lib/gitlab/popen/runner'
def emit_warnings(static_analysis) def emit_warnings(static_analysis)
static_analysis.warned_results.each do |result| static_analysis.warned_results.each do |result|
puts puts
puts "**** #{result.cmd.join(' ')} had the following warnings:" puts "**** #{result.cmd.join(' ')} had the following warning(s):"
puts puts
puts result.stderr puts result.stderr
puts puts
...@@ -17,7 +17,7 @@ end ...@@ -17,7 +17,7 @@ end
def emit_errors(static_analysis) def emit_errors(static_analysis)
static_analysis.failed_results.each do |result| static_analysis.failed_results.each do |result|
puts puts
puts "**** #{result.cmd.join(' ')} failed with the following error:" puts "**** #{result.cmd.join(' ')} failed with the following error(s):"
puts puts
puts result.stdout puts result.stdout
puts result.stderr puts result.stderr
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment