Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2022-12-22 18:09:14 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2022-12-22 18:09:14 +0300
commitaaf158bcb57386a043d8cb7dc491a2f306a4ac13 (patch)
treea421128fc10c4b12eaa48a0a18492bb7d64e98b3 /scripts
parenta59aa00d8aeea39a6360d9be12ffee564802c63c (diff)
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'scripts')
-rw-r--r--scripts/allowed_warnings.txt11
-rwxr-xr-xscripts/static-analysis28
-rw-r--r--scripts/utils.sh31
3 files changed, 50 insertions, 20 deletions
diff --git a/scripts/allowed_warnings.txt b/scripts/allowed_warnings.txt
new file mode 100644
index 00000000000..8162f45f760
--- /dev/null
+++ b/scripts/allowed_warnings.txt
@@ -0,0 +1,11 @@
+# List of ignored warnings used by `fail_on_warnings` in `scripts/utils.sh`.
+# Each line represents a match used by `grep --invert-match --file`.
+# Comments and empty lines are ignored.
+
+# https://github.com/browserslist/browserslist/blob/d0ec62eb48c41c218478cd3ac28684df051cc865/node.js#L329
+# warns if caniuse-lite package is older than 6 months. Ignore this
+# warning message so that GitLab backports don't fail.
+Browserslist: caniuse-lite is outdated. Please run next command `yarn upgrade`
+
+# https://github.com/mime-types/mime-types-data/pull/50#issuecomment-1060908930
+Type application/netcdf is already registered as a variant of application/netcdf.
diff --git a/scripts/static-analysis b/scripts/static-analysis
index 9a0057d8f4d..0d03dd42c73 100755
--- a/scripts/static-analysis
+++ b/scripts/static-analysis
@@ -7,14 +7,7 @@ require_relative '../lib/gitlab/popen'
require_relative '../lib/gitlab/popen/runner'
class StaticAnalysis
- ALLOWED_WARNINGS = [
- # https://github.com/browserslist/browserslist/blob/d0ec62eb48c41c218478cd3ac28684df051cc865/node.js#L329
- # warns if caniuse-lite package is older than 6 months. Ignore this
- # warning message so that GitLab backports don't fail.
- "Browserslist: caniuse-lite is outdated. Please run next command `yarn upgrade`",
- # https://github.com/mime-types/mime-types-data/pull/50#issuecomment-1060908930
- "Type application/netcdf is already registered as a variant of application/netcdf."
- ].freeze
+ # `ALLOWED_WARNINGS` moved to scripts/allowed_warnings.txt
Task = Struct.new(:command, :duration) do
def cmd
@@ -94,12 +87,12 @@ class StaticAnalysis
if static_analysis.all_success_and_clean?
puts 'All static analyses passed successfully.'
elsif static_analysis.all_success?
- puts 'All static analyses passed successfully, but we have warnings:'
+ puts 'All static analyses passed successfully with warnings.'
puts
emit_warnings(static_analysis)
- exit 2 if warning_count(static_analysis).nonzero?
+ # We used to exit 2 on warnings but `fail_on_warnings` takes care of it now.
else
puts 'Some static analyses failed:'
@@ -112,11 +105,11 @@ class StaticAnalysis
def emit_warnings(static_analysis)
static_analysis.warned_results.each do |result|
- puts
- puts "**** #{result.cmd.join(' ')} had the following warning(s):"
- puts
- puts result.stderr
- puts
+ warn
+ warn "**** #{result.cmd.join(' ')} had the following warning(s):"
+ warn
+ warn result.stderr
+ warn
end
end
@@ -131,11 +124,6 @@ class StaticAnalysis
end
end
- def warning_count(static_analysis)
- static_analysis.warned_results
- .count { |result| !ALLOWED_WARNINGS.include?(result.stderr.strip) } # rubocop:disable Rails/NegateInclude
- end
-
def tasks_to_run(node_total)
total_time = TASKS_WITH_DURATIONS_SECONDS.sum(&:duration).to_f
ideal_time_per_node = total_time / node_total
diff --git a/scripts/utils.sh b/scripts/utils.sh
index c9e4a6a487d..2bbe7e10de8 100644
--- a/scripts/utils.sh
+++ b/scripts/utils.sh
@@ -107,6 +107,37 @@ function install_junit_merge_gem() {
run_timed_command "gem install junit_merge --no-document --version 0.1.2"
}
+function fail_on_warnings() {
+ local cmd="$*"
+ local warning_file
+ warning_file="$(mktemp)"
+
+ local allowed_warning_file
+ allowed_warning_file="$(mktemp)"
+
+ eval "$cmd 2>$warning_file"
+ local ret=$?
+
+ # Filter out comments and empty lines from allowed warnings file.
+ grep --invert-match --extended-regexp "^#|^$" scripts/allowed_warnings.txt > "$allowed_warning_file"
+
+ local warnings
+ # Filter out allowed warnings from stderr.
+ # Turn grep errors into warnings so we fail later.
+ warnings=$(grep --invert-match --file "$allowed_warning_file" "$warning_file" 2>&1 || true)
+
+ rm -f "$warning_file" "$allowed_warning_file"
+
+ if [ "$warnings" != "" ]
+ then
+ echoerr "There were warnings:"
+ echoerr "$warnings"
+ return 1
+ fi
+
+ return $ret
+}
+
function run_timed_command() {
local cmd="${1}"
local metric_name="${2:-no}"