2017-04-28 15:31:18 +00:00
|
|
|
#!/usr/bin/env ruby
|
|
|
|
|
2018-01-23 12:12:51 +00:00
|
|
|
# We don't have auto-loading here
|
|
|
|
require_relative '../lib/gitlab/popen'
|
|
|
|
require_relative '../lib/gitlab/popen/runner'
|
|
|
|
|
|
|
|
def emit_warnings(static_analysis)
|
|
|
|
static_analysis.warned_results.each do |result|
|
|
|
|
puts
|
|
|
|
puts "**** #{result.cmd.join(' ')} had the following warnings:"
|
|
|
|
puts
|
|
|
|
puts result.stderr
|
|
|
|
puts
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
def emit_errors(static_analysis)
|
|
|
|
static_analysis.failed_results.each do |result|
|
|
|
|
puts
|
|
|
|
puts "**** #{result.cmd.join(' ')} failed with the following error:"
|
|
|
|
puts
|
|
|
|
puts result.stdout
|
|
|
|
puts result.stderr
|
|
|
|
puts
|
|
|
|
end
|
|
|
|
end
|
2017-04-28 15:31:18 +00:00
|
|
|
|
|
|
|
tasks = [
|
|
|
|
%w[bundle exec rake config_lint],
|
|
|
|
%w[bundle exec rake flay],
|
|
|
|
%w[bundle exec rake haml_lint],
|
|
|
|
%w[bundle exec rake scss_lint],
|
|
|
|
%w[bundle exec license_finder],
|
|
|
|
%w[yarn run eslint],
|
2017-11-03 16:00:49 +00:00
|
|
|
%w[bundle exec rubocop --parallel],
|
2017-09-27 08:52:03 +00:00
|
|
|
%w[bundle exec rake gettext:lint],
|
2017-12-25 10:20:50 +00:00
|
|
|
%w[bundle exec rake lint:static_verification],
|
2018-01-23 17:42:10 +00:00
|
|
|
%w[scripts/lint-conflicts.sh],
|
|
|
|
%w[scripts/lint-rugged]
|
2017-04-28 15:31:18 +00:00
|
|
|
]
|
|
|
|
|
2018-01-23 12:12:51 +00:00
|
|
|
static_analysis = Gitlab::Popen::Runner.new
|
2017-04-28 15:31:18 +00:00
|
|
|
|
2018-01-23 12:12:51 +00:00
|
|
|
static_analysis.run(tasks) do |cmd, &run|
|
2017-11-03 16:00:49 +00:00
|
|
|
puts
|
2018-01-23 12:12:51 +00:00
|
|
|
puts "$ #{cmd.join(' ')}"
|
2017-04-28 15:31:18 +00:00
|
|
|
|
2018-01-23 12:12:51 +00:00
|
|
|
result = run.call
|
2017-04-28 15:31:18 +00:00
|
|
|
|
2018-01-23 12:12:51 +00:00
|
|
|
puts "==> Finished in #{result.duration} seconds"
|
|
|
|
puts
|
2017-04-28 15:31:18 +00:00
|
|
|
end
|
|
|
|
|
2017-11-03 16:00:49 +00:00
|
|
|
puts
|
|
|
|
puts '==================================================='
|
|
|
|
puts
|
|
|
|
puts
|
|
|
|
|
2018-01-24 13:05:01 +00:00
|
|
|
if static_analysis.all_success_and_clean?
|
2017-04-28 15:31:18 +00:00
|
|
|
puts 'All static analyses passed successfully.'
|
2018-01-24 13:05:01 +00:00
|
|
|
elsif static_analysis.all_success?
|
2018-01-23 12:12:51 +00:00
|
|
|
puts 'All static analyses passed successfully, but we have warnings:'
|
|
|
|
puts
|
|
|
|
|
|
|
|
emit_warnings(static_analysis)
|
|
|
|
|
|
|
|
exit 2
|
2017-04-28 15:31:18 +00:00
|
|
|
else
|
2017-11-03 16:00:49 +00:00
|
|
|
puts 'Some static analyses failed:'
|
2017-04-28 15:31:18 +00:00
|
|
|
|
2018-01-23 12:12:51 +00:00
|
|
|
emit_warnings(static_analysis)
|
|
|
|
emit_errors(static_analysis)
|
2017-04-28 15:31:18 +00:00
|
|
|
|
|
|
|
exit 1
|
|
|
|
end
|