2016-07-22 18:06:17 -04:00
|
|
|
unless Rails.env.production?
|
|
|
|
namespace :lint do
|
2017-12-25 05:20:50 -05:00
|
|
|
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
|
|
|
|
|
2016-07-22 18:06:17 -04:00
|
|
|
desc "GitLab | lint | Lint JavaScript files using ESLint"
|
|
|
|
task :javascript do
|
|
|
|
Rake::Task['eslint'].invoke
|
|
|
|
end
|
2018-01-26 09:23:46 -05:00
|
|
|
|
2018-06-19 13:13:11 -04:00
|
|
|
desc "GitLab | lint | Lint HAML files"
|
|
|
|
task :haml do
|
2019-03-13 09:42:43 -04:00
|
|
|
Rake::Task['haml_lint'].invoke
|
|
|
|
rescue RuntimeError # The haml_lint tasks raise a RuntimeError
|
|
|
|
exit(1)
|
2018-06-19 13:13:11 -04:00
|
|
|
end
|
|
|
|
|
2018-01-26 09:23:46 -05:00
|
|
|
desc "GitLab | lint | Run several lint checks"
|
|
|
|
task :all do
|
|
|
|
status = 0
|
|
|
|
|
|
|
|
%w[
|
|
|
|
config_lint
|
2018-06-19 13:13:11 -04:00
|
|
|
lint:haml
|
2018-01-26 09:23:46 -05:00
|
|
|
scss_lint
|
|
|
|
gettext:lint
|
2018-05-07 12:39:46 -04:00
|
|
|
gettext:updated_check
|
2018-01-26 09:23:46 -05:00
|
|
|
lint:static_verification
|
|
|
|
].each do |task|
|
2018-02-12 12:34:07 -05:00
|
|
|
pid = Process.fork do
|
2018-05-31 14:04:55 -04:00
|
|
|
rd_out, wr_out = IO.pipe
|
|
|
|
rd_err, wr_err = IO.pipe
|
2018-02-12 12:34:07 -05:00
|
|
|
stdout = $stdout.dup
|
|
|
|
stderr = $stderr.dup
|
2018-05-31 14:04:55 -04:00
|
|
|
$stdout.reopen(wr_out)
|
|
|
|
$stderr.reopen(wr_err)
|
2018-02-12 12:34:07 -05:00
|
|
|
|
|
|
|
begin
|
2018-06-19 13:13:11 -04:00
|
|
|
Rake::Task[task].invoke
|
2018-02-12 12:34:07 -05:00
|
|
|
rescue SystemExit => ex
|
2018-06-19 13:13:11 -04:00
|
|
|
msg = "*** Rake task #{task} exited:"
|
|
|
|
raise ex
|
|
|
|
rescue => ex
|
|
|
|
msg = "*** Rake task #{task} raised #{ex.class}:"
|
2018-02-12 12:34:07 -05:00
|
|
|
raise ex
|
|
|
|
ensure
|
|
|
|
$stdout.reopen(stdout)
|
|
|
|
$stderr.reopen(stderr)
|
2018-05-31 14:04:55 -04:00
|
|
|
wr_out.close
|
|
|
|
wr_err.close
|
2018-02-12 12:34:07 -05:00
|
|
|
|
2018-05-31 14:04:55 -04:00
|
|
|
warn "\n#{msg}\n\n" if msg
|
|
|
|
|
|
|
|
IO.copy_stream(rd_out, $stdout)
|
|
|
|
IO.copy_stream(rd_err, $stderr)
|
2018-02-12 12:34:07 -05:00
|
|
|
end
|
2018-01-26 09:23:46 -05:00
|
|
|
end
|
2018-02-12 12:34:07 -05:00
|
|
|
|
|
|
|
Process.waitpid(pid)
|
|
|
|
status += $?.exitstatus
|
2018-01-26 09:23:46 -05:00
|
|
|
end
|
|
|
|
|
2018-02-12 12:34:07 -05:00
|
|
|
exit(status)
|
2018-01-26 09:23:46 -05:00
|
|
|
end
|
2016-07-22 18:06:17 -04:00
|
|
|
end
|
|
|
|
end
|