Commit 699844d9 authored by Heinrich Lee Yu's avatar Heinrich Lee Yu

Merge branch 'qa-danger-pajamas-migration' into 'master'

Add Danger rule for deprecated components

See merge request gitlab-org/gitlab!39666
parents 7a3cd972 b8443c51
# frozen_string_literal: true
PATTERNS = %w[
createFlash
gl-deprecated-button
loading-button
pagination-button
gl-deprecated-dropdown
gl-deprecated-dropdown-divider
gl-deprecated-dropdown-header
gl-deprecated-dropdown-item
initDeprecatedJQueryDropdown
].freeze
def get_added_lines(files)
lines = []
files.each do |file|
lines += helper.changed_lines(file).select { |line| %r{^[+]}.match?(line) }
end
lines
end
changed_vue_haml_files = helper.changed_files(/.vue$|.haml$/)
return if changed_vue_haml_files.empty?
changed_lines_in_mr = get_added_lines(changed_vue_haml_files)
has_deprecated_components = changed_lines_in_mr.select { |i| i[/#{PATTERNS.join("|")}/] }
deprecated_components_in_mr = PATTERNS.select { |s| has_deprecated_components.join(" ")[s] }
return if deprecated_components_in_mr.empty?
warn "This merge request contains deprecated components. Please consider using Pajamas components instead."
markdown(<<~MARKDOWN)
## Deprecated components
The following components are deprecated:
* #{deprecated_components_in_mr.join("\n* ")}
Please consider using [Pajamas components](https://design.gitlab.com/components/status/) instead.
MARKDOWN
......@@ -13,6 +13,7 @@ class GitlabDanger
commit_messages
telemetry
utility_css
pajamas
].freeze
CI_ONLY_RULES ||= %w[
......
......@@ -9,7 +9,7 @@ RSpec.describe GitlabDanger do
describe '.local_warning_message' do
it 'returns an informational message with rules that can run' do
expect(described_class.local_warning_message).to eq('==> Only the following Danger rules can be run locally: changes_size, documentation, frozen_string, duplicate_yarn_dependencies, prettier, eslint, karma, database, commit_messages, telemetry, utility_css')
expect(described_class.local_warning_message).to eq('==> Only the following Danger rules can be run locally: changes_size, documentation, frozen_string, duplicate_yarn_dependencies, prettier, eslint, karma, database, commit_messages, telemetry, utility_css, pajamas')
end
end
......
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