2017-08-17 22:00:37 +05:30
|
|
|
#!/usr/bin/env ruby
|
|
|
|
|
2018-03-17 18:26:18 +05:30
|
|
|
# We don't have auto-loading here
|
2019-10-12 21:52:04 +05:30
|
|
|
require_relative '../lib/gitlab'
|
2018-03-17 18:26:18 +05:30
|
|
|
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-03-27 19:54:05 +05:30
|
|
|
puts "**** #{result.cmd.join(' ')} had the following warning(s):"
|
2018-03-17 18:26:18 +05:30
|
|
|
puts
|
|
|
|
puts result.stderr
|
|
|
|
puts
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
def emit_errors(static_analysis)
|
|
|
|
static_analysis.failed_results.each do |result|
|
|
|
|
puts
|
2018-03-27 19:54:05 +05:30
|
|
|
puts "**** #{result.cmd.join(' ')} failed with the following error(s):"
|
2018-03-17 18:26:18 +05:30
|
|
|
puts
|
|
|
|
puts result.stdout
|
|
|
|
puts result.stderr
|
|
|
|
puts
|
|
|
|
end
|
|
|
|
end
|
2017-08-17 22:00:37 +05:30
|
|
|
|
2019-12-26 22:10:19 +05:30
|
|
|
def jobs_to_run(node_index, node_total)
|
|
|
|
all_tasks = [
|
|
|
|
%w[bin/rake lint:all],
|
|
|
|
%w[bundle exec license_finder],
|
|
|
|
%w[yarn run eslint],
|
|
|
|
%w[yarn run stylelint],
|
|
|
|
%w[yarn run prettier-all],
|
|
|
|
%w[bundle exec rubocop --parallel],
|
|
|
|
%w[scripts/lint-conflicts.sh],
|
2020-01-01 13:55:28 +05:30
|
|
|
%w[scripts/lint-rugged],
|
|
|
|
%w[scripts/frontend/check_no_partial_karma_jest.sh]
|
2019-12-26 22:10:19 +05:30
|
|
|
]
|
2017-08-17 22:00:37 +05:30
|
|
|
|
2019-12-26 22:10:19 +05:30
|
|
|
case node_total
|
|
|
|
when 1
|
|
|
|
all_tasks
|
|
|
|
when 2
|
|
|
|
rake_lint_all, *rest_jobs = all_tasks
|
|
|
|
case node_index
|
|
|
|
when 1
|
|
|
|
[rake_lint_all]
|
|
|
|
else
|
|
|
|
rest_jobs
|
|
|
|
end
|
|
|
|
else
|
|
|
|
raise "Parallelization > 2 (currently set to #{node_total}) isn't supported yet!"
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
tasks = jobs_to_run((ENV['CI_NODE_INDEX'] || 1).to_i, (ENV['CI_NODE_TOTAL'] || 1).to_i)
|
2018-03-17 18:26:18 +05:30
|
|
|
static_analysis = Gitlab::Popen::Runner.new
|
2017-08-17 22:00:37 +05:30
|
|
|
|
2018-03-17 18:26:18 +05:30
|
|
|
static_analysis.run(tasks) do |cmd, &run|
|
|
|
|
puts
|
|
|
|
puts "$ #{cmd.join(' ')}"
|
2017-08-17 22:00:37 +05:30
|
|
|
|
2018-03-17 18:26:18 +05:30
|
|
|
result = run.call
|
2017-08-17 22:00:37 +05:30
|
|
|
|
2018-03-17 18:26:18 +05:30
|
|
|
puts "==> Finished in #{result.duration} seconds"
|
|
|
|
puts
|
2017-08-17 22:00:37 +05:30
|
|
|
end
|
|
|
|
|
2018-03-17 18:26:18 +05:30
|
|
|
puts
|
|
|
|
puts '==================================================='
|
|
|
|
puts
|
|
|
|
puts
|
|
|
|
|
|
|
|
if static_analysis.all_success_and_clean?
|
2017-08-17 22:00:37 +05:30
|
|
|
puts 'All static analyses passed successfully.'
|
2018-03-17 18:26:18 +05:30
|
|
|
elsif static_analysis.all_success?
|
|
|
|
puts 'All static analyses passed successfully, but we have warnings:'
|
|
|
|
puts
|
|
|
|
|
|
|
|
emit_warnings(static_analysis)
|
|
|
|
|
|
|
|
exit 2
|
2017-08-17 22:00:37 +05:30
|
|
|
else
|
2018-03-17 18:26:18 +05:30
|
|
|
puts 'Some static analyses failed:'
|
2017-08-17 22:00:37 +05:30
|
|
|
|
2018-03-17 18:26:18 +05:30
|
|
|
emit_warnings(static_analysis)
|
|
|
|
emit_errors(static_analysis)
|
2017-08-17 22:00:37 +05:30
|
|
|
|
|
|
|
exit 1
|
|
|
|
end
|