summaryrefslogtreecommitdiff
path: root/scripts/static-analysis
blob: 51a2fd81a7995282fb06d3babf51ef9a4d76d58f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
#!/usr/bin/env ruby

require ::File.expand_path('../lib/gitlab/popen', __dir__)

tasks = [
  %w[bundle exec bundle-audit check --update],
  %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 rake brakeman],
  %w[bundle exec license_finder],
  %w[yarn run eslint],
  %w[bundle exec rubocop --parallel],
  %w[scripts/lint-conflicts.sh],
  %w[bundle exec rake gettext:lint],
  %w[scripts/lint-changelog-yaml]
]

failed_tasks = tasks.reduce({}) do |failures, task|
  start = Time.now
  puts
  puts "$ #{task.join(' ')}"

  output, status = Gitlab::Popen.popen(task)
  puts "==> Finished in #{Time.now - start} seconds"
  puts

  failures[task.join(' ')] = output unless status.zero?

  failures
end

puts
puts '==================================================='
puts
puts

if failed_tasks.empty?
  puts 'All static analyses passed successfully.'
else
  puts 'Some static analyses failed:'

  failed_tasks.each do |failed_task, output|
    puts
    puts "**** #{failed_task} failed with the following error:"
    puts
    puts output
  end

  exit 1
end