2017-04-28 11:31:18 -04:00
|
|
|
#!/usr/bin/env ruby
|
|
|
|
|
2018-01-23 07:12:51 -05: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 11:31:18 -04: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 12:00:49 -04:00
|
|
|
%w[bundle exec rubocop --parallel],
|
2017-09-27 04:52:03 -04:00
|
|
|
%w[bundle exec rake gettext:lint],
|
2017-12-25 05:20:50 -05:00
|
|
|
%w[bundle exec rake lint:static_verification],
|
2018-01-23 12:42:10 -05:00
|
|
|
%w[scripts/lint-conflicts.sh],
|
|
|
|
%w[scripts/lint-rugged]
|
2017-04-28 11:31:18 -04:00
|
|
|
]
|
|
|
|
|
2018-01-23 07:12:51 -05:00
|
|
|
static_analysis = Gitlab::Popen::Runner.new
|
2017-04-28 11:31:18 -04:00
|
|
|
|
2018-01-23 07:12:51 -05:00
|
|
|
static_analysis.run(tasks) do |cmd, &run|
|
2017-11-03 12:00:49 -04:00
|
|
|
puts
|
2018-01-23 07:12:51 -05:00
|
|
|
puts "$ #{cmd.join(' ')}"
|
2017-04-28 11:31:18 -04:00
|
|
|
|
2018-01-23 07:12:51 -05:00
|
|
|
result = run.call
|
2017-04-28 11:31:18 -04:00
|
|
|
|
2018-01-23 07:12:51 -05:00
|
|
|
puts "==> Finished in #{result.duration} seconds"
|
|
|
|
puts
|
2017-04-28 11:31:18 -04:00
|
|
|
end
|
|
|
|
|
2017-11-03 12:00:49 -04:00
|
|
|
puts
|
|
|
|
puts '==================================================='
|
|
|
|
puts
|
|
|
|
puts
|
|
|
|
|
2018-01-24 08:05:01 -05:00
|
|
|
if static_analysis.all_success_and_clean?
|
2017-04-28 11:31:18 -04:00
|
|
|
puts 'All static analyses passed successfully.'
|
2018-01-24 08:05:01 -05:00
|
|
|
elsif static_analysis.all_success?
|
2018-01-23 07:12:51 -05:00
|
|
|
puts 'All static analyses passed successfully, but we have warnings:'
|
|
|
|
puts
|
|
|
|
|
|
|
|
emit_warnings(static_analysis)
|
|
|
|
|
|
|
|
exit 2
|
2017-04-28 11:31:18 -04:00
|
|
|
else
|
2017-11-03 12:00:49 -04:00
|
|
|
puts 'Some static analyses failed:'
|
2017-04-28 11:31:18 -04:00
|
|
|
|
2018-01-23 07:12:51 -05:00
|
|
|
emit_warnings(static_analysis)
|
|
|
|
emit_errors(static_analysis)
|
2017-04-28 11:31:18 -04:00
|
|
|
|
|
|
|
exit 1
|
|
|
|
end
|