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

85 lines
2.2 KiB
Ruby
Raw Normal View History

2021-03-11 19:13:27 +05:30
# frozen_string_literal: true
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
2020-03-13 15:44:24 +05:30
desc "GitLab | Lint | Static verification"
2018-03-17 18:26:18 +05:30
task static_verification: %w[
lint:static_verification_env
dev:load
] do
Gitlab::Utils::Override.verify!
end
2021-11-18 22:05:49 +05:30
desc "GitLab | Lint | Static verification with database"
task static_verification_with_database: %w[
lint:static_verification_env
dev:load
] do
Gitlab::Utils::DelegatorOverride.verify!
end
2020-03-13 15:44:24 +05:30
desc "GitLab | Lint | Lint JavaScript files using ESLint"
2017-08-17 22:00:37 +05:30
task :javascript do
Rake::Task['eslint'].invoke
end
2018-03-27 19:54:05 +05:30
2020-03-13 15:44:24 +05:30
desc "GitLab | Lint | Lint HAML files"
2018-11-08 19:23:39 +05:30
task :haml do
2019-07-07 11:18:12 +05:30
Rake::Task['haml_lint'].invoke
rescue RuntimeError # The haml_lint tasks raise a RuntimeError
exit(1)
2018-11-08 19:23:39 +05:30
end
2023-04-23 21:23:45 +05:30
desc "GitLab | Lint | Lint docs Markdown files"
task :markdown do
sh "./scripts/lint-doc.sh"
end
2020-03-13 15:44:24 +05:30
desc "GitLab | Lint | Run several lint checks"
2018-03-27 19:54:05 +05:30
task :all do
status = 0
2019-12-04 20:38:33 +05:30
tasks = %w[
2018-03-27 19:54:05 +05:30
config_lint
2018-11-08 19:23:39 +05:30
lint:haml
2018-03-27 19:54:05 +05:30
gettext:lint
lint:static_verification
2020-03-13 15:44:24 +05:30
gitlab:sidekiq:all_queues_yml:check
2019-12-04 20:38:33 +05:30
]
if Gitlab.ee?
2020-03-13 15:44:24 +05:30
# 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-12-04 20:38:33 +05:30
tasks << 'gettext:updated_check'
2020-03-13 15:44:24 +05:30
tasks << 'gitlab:sidekiq:sidekiq_queues_yml:check'
2019-12-04 20:38:33 +05:30
end
tasks.each do |task|
2018-03-27 19:54:05 +05:30
pid = Process.fork do
2019-09-04 21:01:54 +05:30
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-03-27 19:54:05 +05:30
end
Process.waitpid(pid)
status += $?.exitstatus
end
exit(status)
end
2017-08-17 22:00:37 +05:30
end
end