diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-09-19 01:45:44 +0000 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-09-19 01:45:44 +0000 |
commit | 85dc423f7090da0a52c73eb66faf22ddb20efff9 (patch) | |
tree | 9160f299afd8c80c038f08e1545be119f5e3f1e1 /danger | |
parent | 15c2c8c66dbe422588e5411eee7e68f1fa440bb8 (diff) | |
download | gitlab-ce-85dc423f7090da0a52c73eb66faf22ddb20efff9.tar.gz |
Add latest changes from gitlab-org/gitlab@13-4-stable-ee
Diffstat (limited to 'danger')
-rw-r--r-- | danger/changelog/Dangerfile | 29 | ||||
-rw-r--r-- | danger/database/Dangerfile | 8 | ||||
-rw-r--r-- | danger/documentation/Dangerfile | 6 | ||||
-rw-r--r-- | danger/pajamas/Dangerfile | 43 | ||||
-rw-r--r-- | danger/roulette/Dangerfile | 2 | ||||
-rw-r--r-- | danger/specialization_labels/Dangerfile | 26 |
6 files changed, 78 insertions, 36 deletions
diff --git a/danger/changelog/Dangerfile b/danger/changelog/Dangerfile index f9e65bbf4c7..971c6a2a7b9 100644 --- a/danger/changelog/Dangerfile +++ b/danger/changelog/Dangerfile @@ -4,21 +4,6 @@ require 'yaml' SEE_DOC = "See the [changelog documentation](https://docs.gitlab.com/ee/development/changelog.html)." -CREATE_CHANGELOG_MESSAGE = <<~MSG -If you want to create a changelog entry for GitLab FOSS, run the following: - -``` -bin/changelog -m %<mr_iid>s "%<mr_title>s" -``` - -If you want to create a changelog entry for GitLab EE, run the following instead: - -``` -bin/changelog --ee -m %<mr_iid>s "%<mr_title>s" -``` - -If this merge request [doesn't need a CHANGELOG entry](https://docs.gitlab.com/ee/development/changelog.html#what-warrants-a-changelog-entry), feel free to ignore this message. -MSG SUGGEST_MR_COMMENT = <<~SUGGEST_COMMENT ```suggestion @@ -70,13 +55,8 @@ def check_changelog_path(path) end end -def sanitized_mr_title - helper.sanitize_mr_title(gitlab.mr_json["title"]) -end - if git.modified_files.include?("CHANGELOG.md") - fail "**CHANGELOG.md was edited.** Please remove the additions and create a CHANGELOG entry.\n\n" + - format(CREATE_CHANGELOG_MESSAGE, mr_iid: gitlab.mr_json["iid"], mr_title: sanitized_mr_title) + fail changelog.modified_text end changelog_found = changelog.found @@ -84,7 +64,8 @@ changelog_found = changelog.found if changelog_found check_changelog_yaml(changelog_found) check_changelog_path(changelog_found) -elsif changelog.needed? - message "**[CHANGELOG missing](https://docs.gitlab.com/ee/development/changelog.html)**:\n\n" + - format(CREATE_CHANGELOG_MESSAGE, mr_iid: gitlab.mr_json["iid"], mr_title: sanitized_mr_title) +elsif changelog.required? + fail changelog.required_text +elsif changelog.optional? + message changelog.optional_text end diff --git a/danger/database/Dangerfile b/danger/database/Dangerfile index 41ca2aa1978..2ccfdcffaea 100644 --- a/danger/database/Dangerfile +++ b/danger/database/Dangerfile @@ -59,11 +59,9 @@ if gitlab.mr_labels.include?('database') || db_paths_to_review.any? markdown(DB_MESSAGE) markdown(DB_FILES_MESSAGE + helper.markdown_list(db_paths_to_review)) if db_paths_to_review.any? - database_labels = helper.missing_database_labels(gitlab.mr_labels) - - if database_labels.any? + unless helper.has_database_scoped_labels?(gitlab.mr_labels) gitlab.api.update_merge_request(gitlab.mr_json['project_id'], - gitlab.mr_json['iid'], - labels: (gitlab.mr_labels + database_labels).join(',')) + gitlab.mr_json['iid'], + add_labels: 'database::review pending') end end diff --git a/danger/documentation/Dangerfile b/danger/documentation/Dangerfile index 1dd6d484968..16d22969fbd 100644 --- a/danger/documentation/Dangerfile +++ b/danger/documentation/Dangerfile @@ -25,9 +25,3 @@ markdown(<<~MARKDOWN) - [Technical Writers assignments](https://about.gitlab.com/handbook/engineering/technical-writing/#designated-technical-writers) for the appropriate technical writer for this review. - [Documentation workflows](https://docs.gitlab.com/ee/development/documentation/workflow.html) for information on when to assign a merge request for review. MARKDOWN - -unless gitlab.mr_labels.include?('documentation') - gitlab.api.update_merge_request(gitlab.mr_json['project_id'], - gitlab.mr_json['iid'], - labels: (gitlab.mr_labels + ['documentation']).join(',')) -end diff --git a/danger/pajamas/Dangerfile b/danger/pajamas/Dangerfile new file mode 100644 index 00000000000..34dcbc21941 --- /dev/null +++ b/danger/pajamas/Dangerfile @@ -0,0 +1,43 @@ +# 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 diff --git a/danger/roulette/Dangerfile b/danger/roulette/Dangerfile index 80e832da508..f49f6ad251c 100644 --- a/danger/roulette/Dangerfile +++ b/danger/roulette/Dangerfile @@ -56,7 +56,7 @@ def note_for_spin_role(spin, role) return OPTIONAL_REVIEW_TEMPLATE % { role: role.capitalize, category: helper.label_for_category(spin.category) } end - spin.public_send(role)&.markdown_name(timezone_experiment: spin.timezone_experiment, author: roulette.team_mr_author) # rubocop:disable GitlabSecurity/PublicSend + spin.public_send(role)&.markdown_name(author: roulette.team_mr_author) # rubocop:disable GitlabSecurity/PublicSend end def markdown_row_for_spins(category, spins_array) diff --git a/danger/specialization_labels/Dangerfile b/danger/specialization_labels/Dangerfile new file mode 100644 index 00000000000..919f7313b49 --- /dev/null +++ b/danger/specialization_labels/Dangerfile @@ -0,0 +1,26 @@ +# frozen_string_literal: true + +gitlab_danger = GitlabDanger.new(helper.gitlab_helper) + +return unless gitlab_danger.ci? + +SPECIALIZATIONS = { + database: 'database', + backend: 'backend', + frontend: 'frontend', + docs: 'documentation', + qa: 'QA', + engineering_productivity: 'Engineering Productivity' +}.freeze + +labels_to_add = helper.changes_by_category.each_with_object([]) do |(category, _changes), memo| + label = SPECIALIZATIONS[category] + + memo << label if label && !gitlab.mr_labels.include?(label) +end + +if labels_to_add.any? + gitlab.api.update_merge_request(gitlab.mr_json['project_id'], + gitlab.mr_json['iid'], + add_labels: labels_to_add.join(',')) +end |