Commit 70e1b685 authored by Stan Hu's avatar Stan Hu

Fix static-analysis failure due to caniuse-lite dependency

As seen in https://gitlab.com/gitlab-org/gitlab/-/jobs/394057944,
static-analysis is failing with:

```
Browserslist: caniuse-lite is outdated. Please run next command
`yarn upgrade`
```

The problem may be occurring because browserslist is detecting that
caniuse-list is approximately 6 months old and outputs a warning using
console.warn.

To fix this, we change static-analysis to filter this warning message
when deciding to exit with error code 2. Older GitLab backports
shouldn't fail because we need to upgrade this dependency.

Closes https://gitlab.com/gitlab-org/gitlab/issues/194788
parent ff30cda5
......@@ -26,6 +26,19 @@ def emit_errors(static_analysis)
end
end
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`"
].freeze
def warning_count(static_analysis)
static_analysis.warned_results
.reject { |result| ALLOWED_WARNINGS.include?(result.stderr.strip) }
.count
end
def jobs_to_run(node_index, node_total)
all_tasks = [
%w[bin/rake lint:all],
......@@ -81,7 +94,7 @@ elsif static_analysis.all_success?
emit_warnings(static_analysis)
exit 2
exit 2 if warning_count(static_analysis).nonzero?
else
puts 'Some static analyses failed:'
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment