diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-10-21 07:08:36 +0000 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-10-21 07:08:36 +0000 |
commit | 48aff82709769b098321c738f3444b9bdaa694c6 (patch) | |
tree | e00c7c43e2d9b603a5a6af576b1685e400410dee /danger | |
parent | 879f5329ee916a948223f8f43d77fba4da6cd028 (diff) | |
download | gitlab-ce-48aff82709769b098321c738f3444b9bdaa694c6.tar.gz |
Add latest changes from gitlab-org/gitlab@13-5-stable-eev13.5.0-rc42
Diffstat (limited to 'danger')
-rw-r--r-- | danger/ci_templates/Dangerfile | 30 | ||||
-rw-r--r-- | danger/documentation/Dangerfile | 3 | ||||
-rw-r--r-- | danger/metadata/Dangerfile | 7 | ||||
-rw-r--r-- | danger/pajamas/Dangerfile | 65 | ||||
-rw-r--r-- | danger/product_analytics/Dangerfile | 48 | ||||
-rw-r--r-- | danger/specialization_labels/Dangerfile | 3 | ||||
-rw-r--r-- | danger/telemetry/Dangerfile | 38 |
7 files changed, 135 insertions, 59 deletions
diff --git a/danger/ci_templates/Dangerfile b/danger/ci_templates/Dangerfile new file mode 100644 index 00000000000..34b4bbff7a5 --- /dev/null +++ b/danger/ci_templates/Dangerfile @@ -0,0 +1,30 @@ +# frozen_string_literal: true + +gitlab_danger = GitlabDanger.new(helper.gitlab_helper) + +TEMPLATE_MESSAGE = <<~MSG +This merge request requires a CI/CD Template review. To make sure these +changes are reviewed, take the following steps: + +1. Ensure the merge request has the ~"ci::templates" label. + If the merge request modifies CI/CD Template files, Danger will do this for you. +1. Prepare your MR for a CI/CD Template review according to the + [template development guide](https://docs.gitlab.com/ee/development/cicd/templates.html). +1. Assign and `@` mention the CI/CD Template reviewer suggested by Reviewer Roulette. +MSG + +TEMPLATE_FILES_MESSAGE = <<~MSG +The following files require a review from the CI/CD Templates maintainers: +MSG + +return unless gitlab_danger.ci? + +template_paths_to_review = helper.changes_by_category[:ci_template] + +if gitlab.mr_labels.include?('ci::templates') || template_paths_to_review.any? + message 'This merge request adds or changes files that require a ' \ + 'review from the CI/CD Templates maintainers.' + + markdown(TEMPLATE_MESSAGE) + markdown(TEMPLATE_FILES_MESSAGE + helper.markdown_list(template_paths_to_review)) if template_paths_to_review.any? +end diff --git a/danger/documentation/Dangerfile b/danger/documentation/Dangerfile index 16d22969fbd..dc43e9d1843 100644 --- a/danger/documentation/Dangerfile +++ b/danger/documentation/Dangerfile @@ -8,8 +8,7 @@ docs_paths_to_review = helper.changes_by_category[:docs] return if docs_paths_to_review.empty? -message 'This merge request adds or changes files that require a review ' \ - 'from the Technical Writing team.' +message 'This merge request adds or changes documentation files. A review from the Technical Writing team before you merge is **recommended**. Reviews can happen after you merge.' return unless gitlab_danger.ci? diff --git a/danger/metadata/Dangerfile b/danger/metadata/Dangerfile index 1d7f863c201..b98d10d0654 100644 --- a/danger/metadata/Dangerfile +++ b/danger/metadata/Dangerfile @@ -40,10 +40,3 @@ has_pick_into_stable_label = gitlab.mr_labels.find { |label| label.start_with?(' if gitlab.branch_for_base != "master" && !has_pick_into_stable_label && !helper.security_mr? warn "Most of the time, merge requests should target `master`. Otherwise, please set the relevant `Pick into X.Y` label." end - -if gitlab.mr_json['title'].length > 72 - warn 'The title of this merge request is longer than 72 characters and ' \ - 'would violate our commit message rules when using the Squash on Merge ' \ - 'feature. Please consider adjusting the title, or rebase the ' \ - "commits manually and don't use Squash on Merge." -end diff --git a/danger/pajamas/Dangerfile b/danger/pajamas/Dangerfile index 34dcbc21941..36bf7672cbf 100644 --- a/danger/pajamas/Dangerfile +++ b/danger/pajamas/Dangerfile @@ -1,15 +1,43 @@ # frozen_string_literal: true +# rubocop:disable Style/SignalException PATTERNS = %w[ + %a.btn.btn- + %button.btn.btn- + .alert + .alert-danger + .alert-dismissible + .alert-info + .alert-link + .alert-primary + .alert-success + .alert-warning + .nav-tabs + .toolbar-button-icon + .tooltip + .tooltip-inner + <button + <tabs + bs-callout createFlash + deprecated-modal gl-deprecated-button - loading-button - pagination-button gl-deprecated-dropdown gl-deprecated-dropdown-divider gl-deprecated-dropdown-header gl-deprecated-dropdown-item + has-tooltip + has_tooltip initDeprecatedJQueryDropdown + loading-button + v-popover + v-tooltip + with_tooltip +].freeze + +BLOCKING_PATTERNS = %w[ + pagination-button + graphql_pagination ].freeze def get_added_lines(files) @@ -25,19 +53,34 @@ 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? +deprecated_components_in_mr = PATTERNS.select { |pattern| changed_lines_in_mr.any? { |line| line[pattern] } } +blocking_components_in_mr = BLOCKING_PATTERNS.select { |pattern| changed_lines_in_mr.any? { |line| line[pattern] } } -warn "This merge request contains deprecated components. Please consider using Pajamas components instead." +return if (deprecated_components_in_mr + blocking_components_in_mr).empty? markdown(<<~MARKDOWN) ## Deprecated components - The following components are deprecated: +MARKDOWN - * #{deprecated_components_in_mr.join("\n* ")} +if blocking_components_in_mr.any? + markdown(<<~MARKDOWN) + These deprecated components have already been migrated and can no longer be used. Please use [Pajamas components](https://design.gitlab.com/components/status/) instead. - Please consider using [Pajamas components](https://design.gitlab.com/components/status/) instead. -MARKDOWN + * #{blocking_components_in_mr.join("\n* ")} + + MARKDOWN + + fail "This merge request contains deprecated components that have been migrated and can no longer be used. Please use Pajamas components instead." +end + +if deprecated_components_in_mr.any? + markdown(<<~MARKDOWN) + These deprecated components are in the process of being migrated. Please consider using [Pajamas components](https://design.gitlab.com/components/status/) instead. + + * #{deprecated_components_in_mr.join("\n* ")} + + MARKDOWN + + warn "This merge request contains deprecated components. Please consider using Pajamas components instead." +end diff --git a/danger/product_analytics/Dangerfile b/danger/product_analytics/Dangerfile new file mode 100644 index 00000000000..fb441d6e467 --- /dev/null +++ b/danger/product_analytics/Dangerfile @@ -0,0 +1,48 @@ +# frozen_string_literal: true + +PRODUCT_ANALYTICS_CHANGED_FILES_MESSAGE = <<~MSG +For the following files, a review from the [Data team and Product Analytics team](https://gitlab.com/groups/gitlab-org/growth/product_analytics/engineers/-/group_members?with_inherited_permissions=exclude) is recommended +Please check the ~"product analytics(telemetry)" [guide](https://docs.gitlab.com/ee/development/product_analytics/usage_ping.html) and reach out to %<product_analytics_engineers_group>s group for a review. + + +%<changed_files>s + +MSG + +UPDATE_METRICS_DEFINITIONS_MESSAGE = <<~MSG + When adding, changing, or updating metrics, please update the [Event dictionary Usage Ping table](https://docs.gitlab.com/ee/development/product_analytics/event_dictionary.html#usage-ping). + +MSG + +PRODUCT_ANALYTICS_ENGINEERS_GROUP = '@gitlab-org/growth/product_analytics/engineers' + +tracking_files = [ + 'lib/gitlab/tracking.rb', + 'spec/lib/gitlab/tracking_spec.rb', + 'app/helpers/tracking_helper.rb', + 'spec/helpers/tracking_helper_spec.rb', + 'app/assets/javascripts/tracking.js', + 'spec/frontend/tracking_spec.js' +] + +usage_data_changed_files = helper.changed_files(/usage_data/) +snowplow_events_changed_files = git.modified_files & tracking_files + +changed_files = (usage_data_changed_files + snowplow_events_changed_files) + +if changed_files.any? + + mention = if helper.draft_mr? + "`#{PRODUCT_ANALYTICS_ENGINEERS_GROUP}`" + else + PRODUCT_ANALYTICS_ENGINEERS_GROUP + end + + warn format(PRODUCT_ANALYTICS_CHANGED_FILES_MESSAGE, changed_files: helper.markdown_list(changed_files), product_analytics_engineers_group: mention) + warn format(UPDATE_METRICS_DEFINITIONS_MESSAGE) unless helper.changed_files(/usage_ping\.md/).any? + + product_analytics_labels = ['product analytics(telemetry)'] + product_analytics_labels << 'product analytics(telemetry)::review pending' unless helper.mr_has_labels?('product analytics(telemetry)::reviewed') + + markdown(helper.prepare_labels_for_mr(product_analytics_labels)) +end diff --git a/danger/specialization_labels/Dangerfile b/danger/specialization_labels/Dangerfile index 919f7313b49..ac93eb4c3e1 100644 --- a/danger/specialization_labels/Dangerfile +++ b/danger/specialization_labels/Dangerfile @@ -10,7 +10,8 @@ SPECIALIZATIONS = { frontend: 'frontend', docs: 'documentation', qa: 'QA', - engineering_productivity: 'Engineering Productivity' + engineering_productivity: 'Engineering Productivity', + ci_template: 'ci::templates' }.freeze labels_to_add = helper.changes_by_category.each_with_object([]) do |(category, _changes), memo| diff --git a/danger/telemetry/Dangerfile b/danger/telemetry/Dangerfile deleted file mode 100644 index 6cfc1a005c3..00000000000 --- a/danger/telemetry/Dangerfile +++ /dev/null @@ -1,38 +0,0 @@ -# frozen_string_literal: true - -TELEMETRY_CHANGED_FILES_MESSAGE = <<~MSG -For the following files, a review from the [Data team and Telemetry team](https://gitlab.com/groups/gitlab-org/growth/telemetry/engineers/-/group_members?with_inherited_permissions=exclude) is recommended -Please check the ~telemetry [guide](https://docs.gitlab.com/ee/development/telemetry/usage_ping.html) and reach out to @gitlab-org/growth/telemetry/engineers group for a review. - -%<changed_files>s - -MSG - -UPDATE_METRICS_DEFINITIONS_MESSAGE = <<~MSG - When adding, changing, or updating metrics, please update the [Event dictionary Usage Ping table](https://docs.gitlab.com/ee/development/telemetry/event_dictionary.html#usage-ping). - -MSG - -tracking_files = [ - 'lib/gitlab/tracking.rb', - 'spec/lib/gitlab/tracking_spec.rb', - 'app/helpers/tracking_helper.rb', - 'spec/helpers/tracking_helper_spec.rb', - 'app/assets/javascripts/tracking.js', - 'spec/frontend/tracking_spec.js' -] - -usage_data_changed_files = helper.changed_files(/usage_data/) -snowplow_events_changed_files = git.modified_files & tracking_files - -changed_files = (usage_data_changed_files + snowplow_events_changed_files) - -if changed_files.any? - warn format(TELEMETRY_CHANGED_FILES_MESSAGE, changed_files: helper.markdown_list(changed_files)) - warn format(UPDATE_METRICS_DEFINITIONS_MESSAGE) unless helper.changed_files(/usage_ping\.md/).any? - - telemetry_labels = ['telemetry'] - telemetry_labels << 'telemetry::review pending' unless helper.mr_has_labels?('telemetry::reviewed') - - markdown(helper.prepare_labels_for_mr(telemetry_labels)) -end |