2021-02-05 07:09:31 -05:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
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
|
|
|
|
|
2020-01-23 01:08:32 -05:00
|
|
|
desc "GitLab | Lint | Static verification"
|
2017-12-25 05:20:50 -05:00
|
|
|
task static_verification: %w[
|
|
|
|
lint:static_verification_env
|
|
|
|
dev:load
|
|
|
|
] do
|
|
|
|
Gitlab::Utils::Override.verify!
|
2021-10-10 23:11:46 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
desc "GitLab | Lint | Static verification with database"
|
|
|
|
task static_verification_with_database: %w[
|
|
|
|
lint:static_verification_env
|
|
|
|
dev:load
|
|
|
|
] do
|
2021-09-21 05:12:21 -04:00
|
|
|
Gitlab::Utils::DelegatorOverride.verify!
|
2017-12-25 05:20:50 -05:00
|
|
|
end
|
|
|
|
|
2020-01-23 01:08:32 -05:00
|
|
|
desc "GitLab | Lint | Lint JavaScript files using ESLint"
|
2016-07-22 18:06:17 -04:00
|
|
|
task :javascript do
|
|
|
|
Rake::Task['eslint'].invoke
|
|
|
|
end
|
2018-01-26 09:23:46 -05:00
|
|
|
|
2020-01-23 01:08:32 -05:00
|
|
|
desc "GitLab | Lint | Lint HAML files"
|
2018-06-19 13:13:11 -04:00
|
|
|
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
|
|
|
|
|
2020-01-23 01:08:32 -05:00
|
|
|
desc "GitLab | Lint | Run several lint checks"
|
2018-01-26 09:23:46 -05:00
|
|
|
task :all do
|
|
|
|
status = 0
|
|
|
|
|
2019-09-19 07:50:12 -04:00
|
|
|
tasks = %w[
|
2018-01-26 09:23:46 -05:00
|
|
|
config_lint
|
2018-06-19 13:13:11 -04:00
|
|
|
lint:haml
|
2018-01-26 09:23:46 -05:00
|
|
|
gettext:lint
|
|
|
|
lint:static_verification
|
2020-01-22 07:08:40 -05:00
|
|
|
gitlab:sidekiq:all_queues_yml:check
|
2019-09-19 07:50:12 -04:00
|
|
|
]
|
|
|
|
|
|
|
|
if Gitlab.ee?
|
2020-01-24 13:09:00 -05:00
|
|
|
# These tasks will fail on FOSS installations
|
|
|
|
# (e.g. gitlab-org/gitlab-foss) since they test against a single
|
|
|
|
# file that is generated by an EE installation, which can
|
|
|
|
# contain values that a FOSS installation won't find. To work
|
|
|
|
# around this we will only enable this task on EE installations.
|
2019-09-19 07:50:12 -04:00
|
|
|
tasks << 'gettext:updated_check'
|
2020-01-24 13:09:00 -05:00
|
|
|
tasks << 'gitlab:sidekiq:sidekiq_queues_yml:check'
|
2019-09-19 07:50:12 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
tasks.each do |task|
|
2018-02-12 12:34:07 -05:00
|
|
|
pid = Process.fork do
|
2019-05-17 05:34:40 -04:00
|
|
|
puts "*** Running rake task: #{task} ***"
|
|
|
|
|
|
|
|
Rake::Task[task].invoke
|
|
|
|
rescue SystemExit => ex
|
|
|
|
warn "!!! Rake task #{task} exited:"
|
|
|
|
raise ex
|
|
|
|
rescue StandardError, ScriptError => ex
|
|
|
|
warn "!!! Rake task #{task} raised #{ex.class}:"
|
|
|
|
raise ex
|
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
|