diff options
author | Rémy Coutable <remy@rymai.me> | 2018-02-12 18:34:07 +0100 |
---|---|---|
committer | Rémy Coutable <remy@rymai.me> | 2018-02-14 17:34:34 +0100 |
commit | 2f0d2ab55b6deac79f81834f6724a676ceae94ae (patch) | |
tree | f4aa6c1946ceb13933c5ad378813c47312f2d5a0 /lib/tasks/lint.rake | |
parent | e4990b66df64f2e23502d161f411335c9a771a43 (diff) | |
download | gitlab-ce-2f0d2ab55b6deac79f81834f6724a676ceae94ae.tar.gz |
Run lint:all tasks in forks42050-combine-all-rake-based-lints-in-one-rake-process-in-ci
Signed-off-by: Rémy Coutable <remy@rymai.me>
Diffstat (limited to 'lib/tasks/lint.rake')
-rw-r--r-- | lib/tasks/lint.rake | 43 |
1 files changed, 32 insertions, 11 deletions
diff --git a/lib/tasks/lint.rake b/lib/tasks/lint.rake index e7812ff3568..fe5032cae18 100644 --- a/lib/tasks/lint.rake +++ b/lib/tasks/lint.rake @@ -20,7 +20,6 @@ unless Rails.env.production? desc "GitLab | lint | Run several lint checks" task :all do status = 0 - original_stdout = $stdout %w[ config_lint @@ -30,19 +29,41 @@ unless Rails.env.production? gettext:lint lint:static_verification ].each do |task| - begin - $stdout = StringIO.new - Rake::Task[task].invoke - rescue RuntimeError, SystemExit => ex - raise ex if ex.is_a?(RuntimeError) && task != 'haml_lint' - original_stdout << $stdout.string - status = 1 - ensure - $stdout = original_stdout + pid = Process.fork do + rd, wr = IO.pipe + stdout = $stdout.dup + stderr = $stderr.dup + $stdout.reopen(wr) + $stderr.reopen(wr) + + begin + begin + Rake::Task[task].invoke + rescue RuntimeError # The haml_lint tasks raise a RuntimeError + exit(1) + end + rescue SystemExit => ex + msg = "*** Rake task #{task} failed with the following error(s):" + raise ex + ensure + $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 + + Process.waitpid(pid) + status += $?.exitstatus end - exit status + exit(status) end end end |