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
|
2019-07-22 15:11:50 +00:00
|
|
|
require_relative '../lib/gitlab'
|
2018-01-23 12:12:51 +00:00
|
|
|
require_relative '../lib/gitlab/popen'
|
|
|
|
require_relative '../lib/gitlab/popen/runner'
|
|
|
|
|
|
|
|
def emit_warnings(static_analysis)
|
|
|
|
static_analysis.warned_results.each do |result|
|
|
|
|
puts
|
2018-02-12 17:34:07 +00:00
|
|
|
puts "**** #{result.cmd.join(' ')} had the following warning(s):"
|
2018-01-23 12:12:51 +00:00
|
|
|
puts
|
|
|
|
puts result.stderr
|
|
|
|
puts
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
def emit_errors(static_analysis)
|
|
|
|
static_analysis.failed_results.each do |result|
|
|
|
|
puts
|
2018-02-12 17:34:07 +00:00
|
|
|
puts "**** #{result.cmd.join(' ')} failed with the following error(s):"
|
2018-01-23 12:12:51 +00:00
|
|
|
puts
|
|
|
|
puts result.stdout
|
|
|
|
puts result.stderr
|
|
|
|
puts
|
|
|
|
end
|
|
|
|
end
|
2017-04-28 15:31:18 +00:00
|
|
|
|
|
|
|
tasks = [
|
2018-01-26 14:23:46 +00:00
|
|
|
%w[bin/rake lint:all],
|
2017-04-28 15:31:18 +00:00
|
|
|
%w[bundle exec license_finder],
|
|
|
|
%w[yarn run eslint],
|
2019-02-14 13:40:42 +00:00
|
|
|
%w[yarn run stylelint],
|
2018-10-31 15:22:36 +00:00
|
|
|
%w[yarn run prettier-all],
|
2017-11-03 16:00:49 +00:00
|
|
|
%w[bundle exec rubocop --parallel],
|
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
|
|
|
]
|
|
|
|
|
2019-07-22 15:11:50 +00:00
|
|
|
if Gitlab.ee?
|
|
|
|
tasks.unshift(%w[ruby -rbundler/setup scripts/ee_specific_check/ee_specific_check.rb])
|
|
|
|
end
|
|
|
|
|
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
|