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