diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2022-04-20 10:00:54 +0000 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2022-04-20 10:00:54 +0000 |
commit | 3cccd102ba543e02725d247893729e5c73b38295 (patch) | |
tree | f36a04ec38517f5deaaacb5acc7d949688d1e187 /danger | |
parent | 205943281328046ef7b4528031b90fbda70c75ac (diff) | |
download | gitlab-ce-3cccd102ba543e02725d247893729e5c73b38295.tar.gz |
Add latest changes from gitlab-org/gitlab@14-10-stable-eev14.10.0-rc42
Diffstat (limited to 'danger')
-rw-r--r-- | danger/Dangerfile-bundle_size (renamed from danger/bundle_size/Dangerfile) | 1 | ||||
-rw-r--r-- | danger/ci_templates/Dangerfile | 2 | ||||
-rw-r--r-- | danger/database/Dangerfile | 4 | ||||
-rw-r--r-- | danger/feature_flag/Dangerfile | 8 | ||||
-rw-r--r-- | danger/product_intelligence/Dangerfile | 21 | ||||
-rw-r--r-- | danger/specialization_labels/Dangerfile | 4 | ||||
-rw-r--r-- | danger/specs/Dangerfile | 2 | ||||
-rw-r--r-- | danger/z_metadata/Dangerfile | 10 |
8 files changed, 17 insertions, 35 deletions
diff --git a/danger/bundle_size/Dangerfile b/danger/Dangerfile-bundle_size index b824edb5dab..23ab726096e 100644 --- a/danger/bundle_size/Dangerfile +++ b/danger/Dangerfile-bundle_size @@ -1,4 +1,5 @@ # frozen_string_literal: true +# This file isn't named "Dangerfile" so that it's not imported by default since it's only meant to be run in the `bundle-size-review` job. analysis_result = "./bundle-size-review/analysis.json" markdown_result = "./bundle-size-review/comparison.md" diff --git a/danger/ci_templates/Dangerfile b/danger/ci_templates/Dangerfile index 3d57436ef94..ace9905e91d 100644 --- a/danger/ci_templates/Dangerfile +++ b/danger/ci_templates/Dangerfile @@ -19,7 +19,7 @@ return unless helper.ci? template_paths_to_review = helper.changes_by_category[:ci_template] -if gitlab.mr_labels.include?('ci::templates') || template_paths_to_review.any? +if helper.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.' diff --git a/danger/database/Dangerfile b/danger/database/Dangerfile index 0128f0fa195..f94184263ad 100644 --- a/danger/database/Dangerfile +++ b/danger/database/Dangerfile @@ -49,11 +49,11 @@ if geo_migration_created && !geo_db_schema_updated end return unless helper.ci? -return if gitlab.mr_labels.include?(DATABASE_APPROVED_LABEL) +return if helper.mr_labels.include?(DATABASE_APPROVED_LABEL) db_paths_to_review = helper.changes_by_category[:database] -if gitlab.mr_labels.include?('database') || db_paths_to_review.any? +if helper.mr_labels.include?('database') || db_paths_to_review.any? message 'This merge request adds or changes files that require a ' \ 'review from the [Database team](https://gitlab.com/groups/gl-database/-/group_members).' diff --git a/danger/feature_flag/Dangerfile b/danger/feature_flag/Dangerfile index 5fe9d42a7a1..d5b907377aa 100644 --- a/danger/feature_flag/Dangerfile +++ b/danger/feature_flag/Dangerfile @@ -22,21 +22,21 @@ def check_feature_flag_yaml(feature_flag) end rescue Psych::Exception # YAML could not be parsed, fail the build. - fail "#{gitlab.html_link(feature_flag.path)} isn't valid YAML! #{SEE_DOC}" + fail "#{helper.html_link(feature_flag.path)} isn't valid YAML! #{SEE_DOC}" rescue StandardError => e warn "There was a problem trying to check the Feature Flag file. Exception: #{e.class.name} - #{e.message}" end def message_for_feature_flag_missing_group!(feature_flag:, mr_group_label:) if mr_group_label.nil? - warn "Consider setting `group` in #{gitlab.html_link(feature_flag.path)}. #{SEE_DOC}" + warn "Consider setting `group` in #{helper.html_link(feature_flag.path)}. #{SEE_DOC}" else mr_line = feature_flag.raw.lines.find_index("group:\n") if mr_line markdown(format(SUGGEST_MR_COMMENT, group: mr_group_label), file: feature_flag.path, line: mr_line.succ) else - warn %(Consider setting `group: "#{mr_group_label}"` in #{gitlab.html_link(feature_flag.path)}. #{SEE_DOC}) + warn %(Consider setting `group: "#{mr_group_label}"` in #{helper.html_link(feature_flag.path)}. #{SEE_DOC}) end end end @@ -60,7 +60,7 @@ def message_for_feature_flag_with_group!(feature_flag:, mr_group_label:) if mr_group_label.nil? helper.labels_to_add << feature_flag.group else - fail %(`group` is set to ~"#{feature_flag.group}" in #{gitlab.html_link(feature_flag.path)}, which does not match ~"#{mr_group_label}" set on the MR!) + fail %(`group` is set to ~"#{feature_flag.group}" in #{helper.html_link(feature_flag.path)}, which does not match ~"#{mr_group_label}" set on the MR!) end end diff --git a/danger/product_intelligence/Dangerfile b/danger/product_intelligence/Dangerfile index 8f782e3de65..c38d87604cc 100644 --- a/danger/product_intelligence/Dangerfile +++ b/danger/product_intelligence/Dangerfile @@ -1,22 +1,3 @@ # frozen_string_literal: true -# rubocop:disable Style/SignalException -CHANGED_FILES_MESSAGE = <<~MSG -For the following files, a review from the [Data team and Product Intelligence team](https://gitlab.com/groups/gitlab-org/growth/product-intelligence/engineers/-/group_members?with_inherited_permissions=exclude) is recommended -Please check the ~"product intelligence" [guide](https://docs.gitlab.com/ee/development/usage_ping.html). - -For MR review guidelines, see the [Service Ping review guidelines](https://docs.gitlab.com/ee/development/usage_ping/review_guidelines.html) or the [Snowplow review guidelines](https://docs.gitlab.com/ee/development/snowplow/review_guidelines.html). - -%<changed_files>s - -MSG - -# exit if not matching files or if no product intelligence labels -product_intelligence_paths_to_review = helper.changes_by_category[:product_intelligence] -labels_to_add = product_intelligence.missing_labels - -return if product_intelligence_paths_to_review.empty? || product_intelligence.skip_review? - -warn format(CHANGED_FILES_MESSAGE, changed_files: helper.markdown_list(product_intelligence_paths_to_review)) unless product_intelligence.has_approved_label? - -helper.labels_to_add.concat(labels_to_add) unless labels_to_add.empty? +product_intelligence.check! diff --git a/danger/specialization_labels/Dangerfile b/danger/specialization_labels/Dangerfile index f161c470f36..615ceb8625d 100644 --- a/danger/specialization_labels/Dangerfile +++ b/danger/specialization_labels/Dangerfile @@ -16,11 +16,11 @@ SPECIALIZATIONS = { labels_to_add = helper.changes_by_category.each_with_object([]) do |(category, _changes), memo| label = SPECIALIZATIONS[category] next unless label - next if gitlab.mr_labels.include?(label) + next if helper.mr_labels.include?(label) # Don't override already-set scoped labels. label_scope = label.split('::')[0...-1].join('::') - next if !label_scope.empty? && gitlab.mr_labels.any? { |mr_label| mr_label.start_with?(label_scope) } + next if !label_scope.empty? && helper.has_scoped_label_with_scope?(label_scope) memo << label end diff --git a/danger/specs/Dangerfile b/danger/specs/Dangerfile index 8ef046f7bc1..dc9809b20b5 100644 --- a/danger/specs/Dangerfile +++ b/danger/specs/Dangerfile @@ -37,7 +37,7 @@ has_ee_app_changes = all_changed_files.grep(%r{\Aee/(app|lib|db/(geo/)?(post_)?m spec_changes = specs.changed_specs_files(ee: :exclude) has_spec_changes = spec_changes.any? has_ee_spec_changes = specs.changed_specs_files(ee: :only).any? -new_specs_needed = (gitlab.mr_labels & NO_SPECS_LABELS).empty? +new_specs_needed = (helper.mr_labels & NO_SPECS_LABELS).empty? if (has_app_changes || has_ee_app_changes) && !(has_spec_changes || has_ee_spec_changes) && new_specs_needed warn format(NO_NEW_SPEC_MESSAGE, labels: helper.labels_list(NO_SPECS_LABELS)), sticky: false diff --git a/danger/z_metadata/Dangerfile b/danger/z_metadata/Dangerfile index 546fdc8de5f..9140bb7d988 100644 --- a/danger/z_metadata/Dangerfile +++ b/danger/z_metadata/Dangerfile @@ -2,7 +2,7 @@ # rubocop:disable Style/SignalException -DEFAULT_BRANCH = 'master' +default_branch = ENV['CI_DEFAULT_BRANCH'] || 'main' if gitlab.mr_body.size < 5 fail "Please provide a proper merge request description." @@ -14,12 +14,12 @@ end has_milestone = !gitlab.mr_json["milestone"].nil? -unless has_milestone || (helper.security_mr? && gitlab.branch_for_base == DEFAULT_BRANCH) +unless has_milestone || (helper.security_mr? && helper.mr_target_branch == default_branch) warn "This merge request does not refer to an existing milestone.", sticky: false end -has_pick_into_stable_label = gitlab.mr_labels.find { |label| label.start_with?('Pick into') } +has_pick_into_stable_label = helper.mr_labels.find { |label| label.start_with?('Pick into') } -if gitlab.branch_for_base != DEFAULT_BRANCH && !has_pick_into_stable_label && !helper.security_mr? - warn "Most of the time, merge requests should target `#{DEFAULT_BRANCH}`. Otherwise, please set the relevant `Pick into X.Y` label." +if helper.mr_target_branch != default_branch && !has_pick_into_stable_label && !helper.security_mr? + warn "Most of the time, merge requests should target `#{default_branch}`. Otherwise, please set the relevant `Pick into X.Y` label." end |