Skip to content

CI: Allow warning emitted by scripts/static-analysis

Peter Leitzen requested to merge pl-allow-warning-script-static-analysis into master

What does this MR do and why?

When scripts/static-analysis sees a warning it prints it on stderr along with the following banner:

**** bin/rake config_lint had the following warning(s):

Since we are filtering certain warnings via fail_on_warnings we need to filter this line as well.

Refs https://gitlab.com/gitlab-org/gitlab/-/jobs/3525067604.

Fixes #386693 (closed).

Screenshots or screen recordings

Pass Fail
Screenshot_from_2022-12-27_08-14-12 Screenshot_from_2022-12-27_08-16-00

How to set up and validate locally

  1. Apply diff (see #386693 (comment 1221387251) for what and why)
Diff
diff --git a/Gemfile b/Gemfile
index 7fd4b4d45c44..cbb5d58cb638 100644
--- a/Gemfile
+++ b/Gemfile
@@ -296,6 +296,7 @@ gem 'charlock_holmes', '~> 0.7.7'
 
 # Detect mime content type from content
 gem 'ruby-magic', '~> 0.5'
+gem 'mime-types', github: 'mime-types/ruby-mime-types', ref: 'main'
 
 # Faster blank
 gem 'fast_blank'
diff --git a/Gemfile.lock b/Gemfile.lock
index 74f745ff7ac7..a2237743c5af 100644
--- a/Gemfile.lock
+++ b/Gemfile.lock
@@ -1,3 +1,11 @@
+GIT
+  remote: https://github.com/mime-types/ruby-mime-types.git
+  revision: 3ba14a9a96d5156dc5f670239b7cf42171b86528
+  ref: main
+  specs:
+    mime-types (3.4.1)
+      mime-types-data (~> 3.2015)
+
 PATH
   remote: vendor/gems/attr_encrypted
   specs:
@@ -894,8 +902,6 @@ GEM
     memoist (0.16.2)
     memory_profiler (1.0.1)
     method_source (1.0.0)
-    mime-types (3.4.1)
-      mime-types-data (~> 3.2015)
     mime-types-data (3.2022.0105)
     mini_histogram (0.3.1)
     mini_magick (4.10.1)
@@ -1731,6 +1737,7 @@ DEPENDENCIES
   marginalia (~> 1.11.1)
   memory_profiler (~> 1.0)
   microsoft_graph_mailer (~> 0.1.0)!
+  mime-types!
   mini_magick (~> 4.10.1)
   minitest (~> 5.11.0)
   multi_json (~> 1.14.1)
diff --git a/scripts/static-analysis b/scripts/static-analysis
index 0d03dd42c73c..a7451bfd3867 100755
--- a/scripts/static-analysis
+++ b/scripts/static-analysis
@@ -38,21 +38,7 @@ class StaticAnalysis
   # contain values that a FOSS installation won't find. To work
   # around this we will only enable this task on EE installations.
   TASKS_WITH_DURATIONS_SECONDS = [
-    (Gitlab.ee? ? Task.new(%w[bin/rake gettext:updated_check], 360) : nil),
-    Task.new(%w[yarn run lint:prettier], 200),
-    Task.new(%w[bin/rake gettext:lint], 105),
-    Task.new(%W[scripts/license-check.sh #{project_path}], 200),
-    Task.new(%w[bin/rake lint:static_verification], 40),
     Task.new(%w[bin/rake config_lint], 10),
-    Task.new(%w[bin/rake gitlab:sidekiq:all_queues_yml:check], 15),
-    (Gitlab.ee? ? Task.new(%w[bin/rake gitlab:sidekiq:sidekiq_queues_yml:check], 11) : nil),
-    Task.new(%w[yarn run internal:stylelint], 8),
-    Task.new(%w[scripts/lint-conflicts.sh], 1),
-    Task.new(%w[yarn run block-dependencies], 1),
-    Task.new(%w[yarn run check-dependencies], 1),
-    Task.new(%w[scripts/lint-rugged], 1),
-    Task.new(%w[scripts/gemfile_lock_changed.sh], 1),
-    Task.new(%w[scripts/lint-vendored-gems.sh], 1)
   ].compact.freeze
 
   def run_tasks!(options = {})
  1. Run
$ bundle

$ bash # subshell
$ source scripts/utils.sh
$ fail_on_warnings scripts/static-analysis

Total expected time: 10.0; ideal time per job: 10.0.

Tasks to distribute:
* bin/rake config_lint (10s)

Assigning tasks optimally.
Assigning ["bin/rake", "config_lint"] (10s) to node #1. Node total duration: 10s.

Expected duration for node 1: 10 seconds
* bin/rake config_lint (10s)

$ bin/rake config_lint
==> Finished in 3.598974265 seconds (expected 10 seconds)


===================================================
Node finished running all tasks in 3.599086129 seconds (expected 10)


All static analyses passed successfully with warnings.

$ echo $?
0
  1. Tweak allowed warnings scripts/allowed_warnings.txt and change last line
  2. Run again
$ fail_on_warnings scripts/static-analysis
Total expected time: 10.0; ideal time per job: 10.0.

Tasks to distribute:
* bin/rake config_lint (10s)

Assigning tasks optimally.
Assigning ["bin/rake", "config_lint"] (10s) to node #1. Node total duration: 10s.

Expected duration for node 1: 10 seconds
* bin/rake config_lint (10s)

$ bin/rake config_lint
==> Finished in 3.623855854 seconds (expected 10 seconds)


===================================================
Node finished running all tasks in 3.623919657 seconds (expected 10)


All static analyses passed successfully with warnings.

There were warnings:
======================== Filtered warnings =====================================
**** bin/rake config_lint had the following warning(s):
======================= Unfiltered warnings ====================================
**** bin/rake config_lint had the following warning(s):
Type application/netcdf is already registered as a variant of application/netcdf.
================================================================================

MR acceptance checklist

This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.

Edited by Peter Leitzen

Merge request reports