debian-mirror-gitlab/lib/tasks/lint.rake

78 lines
1.8 KiB
Ruby
Raw Normal View History

2017-08-17 22:00:37 +05:30
unless Rails.env.production?
namespace :lint do
2018-03-17 18:26:18 +05:30
task :static_verification_env do
ENV['STATIC_VERIFICATION'] = 'true'
end
desc "GitLab | lint | Static verification"
task static_verification: %w[
lint:static_verification_env
dev:load
] do
Gitlab::Utils::Override.verify!
end
2017-08-17 22:00:37 +05:30
desc "GitLab | lint | Lint JavaScript files using ESLint"
task :javascript do
Rake::Task['eslint'].invoke
end
2018-03-27 19:54:05 +05:30
2018-11-08 19:23:39 +05:30
desc "GitLab | lint | Lint HAML files"
task :haml do
begin
Rake::Task['haml_lint'].invoke
rescue RuntimeError # The haml_lint tasks raise a RuntimeError
exit(1)
end
end
2018-03-27 19:54:05 +05:30
desc "GitLab | lint | Run several lint checks"
task :all do
status = 0
%w[
config_lint
2018-11-08 19:23:39 +05:30
lint:haml
2018-03-27 19:54:05 +05:30
scss_lint
gettext:lint
2018-11-08 19:23:39 +05:30
gettext:updated_check
2018-03-27 19:54:05 +05:30
lint:static_verification
].each do |task|
pid = Process.fork do
2018-11-08 19:23:39 +05:30
rd_out, wr_out = IO.pipe
rd_err, wr_err = IO.pipe
2018-03-27 19:54:05 +05:30
stdout = $stdout.dup
stderr = $stderr.dup
2018-11-08 19:23:39 +05:30
$stdout.reopen(wr_out)
$stderr.reopen(wr_err)
2018-03-27 19:54:05 +05:30
begin
2018-11-08 19:23:39 +05:30
Rake::Task[task].invoke
2018-03-27 19:54:05 +05:30
rescue SystemExit => ex
2018-11-08 19:23:39 +05:30
msg = "*** Rake task #{task} exited:"
raise ex
rescue => ex
msg = "*** Rake task #{task} raised #{ex.class}:"
2018-03-27 19:54:05 +05:30
raise ex
ensure
$stdout.reopen(stdout)
$stderr.reopen(stderr)
2018-11-08 19:23:39 +05:30
wr_out.close
wr_err.close
warn "\n#{msg}\n\n" if msg
2018-03-27 19:54:05 +05:30
2018-11-08 19:23:39 +05:30
IO.copy_stream(rd_out, $stdout)
IO.copy_stream(rd_err, $stderr)
2018-03-27 19:54:05 +05:30
end
end
Process.waitpid(pid)
status += $?.exitstatus
end
exit(status)
end
2017-08-17 22:00:37 +05:30
end
end