Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/danger
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2020-11-19 11:27:35 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2020-11-19 11:27:35 +0300
commit7e9c479f7de77702622631cff2628a9c8dcbc627 (patch)
treec8f718a08e110ad7e1894510980d2155a6549197 /danger
parente852b0ae16db4052c1c567d9efa4facc81146e88 (diff)
Add latest changes from gitlab-org/gitlab@13-6-stable-eev13.6.0-rc42
Diffstat (limited to 'danger')
-rw-r--r--danger/commit_messages/Dangerfile21
-rw-r--r--danger/documentation/Dangerfile22
-rw-r--r--danger/product_analytics/Dangerfile8
3 files changed, 37 insertions, 14 deletions
diff --git a/danger/commit_messages/Dangerfile b/danger/commit_messages/Dangerfile
index 174fc10eef3..4e17db60471 100644
--- a/danger/commit_messages/Dangerfile
+++ b/danger/commit_messages/Dangerfile
@@ -37,7 +37,8 @@ def build_message(commit, message, more_info: true)
end
def squash_mr?
- gitlab_danger.ci? ? gitlab.mr_json['squash'] : false
+ # Locally, we assume the MR is set to be squashed so that the user only sees warnings instead of errors.
+ gitlab_danger.ci? ? gitlab.mr_json['squash'] : true
end
def wip_mr?
@@ -100,25 +101,27 @@ end
def lint_commits(commits)
commit_linters = commits.map { |commit| lint_commit(commit) }
- failed_commit_linters = commit_linters.select { |commit_linter| commit_linter.failed? }
- warn_or_fail_commits(failed_commit_linters, default_to_fail: !squash_mr?)
-
- if count_non_fixup_commits(commit_linters) > MAX_COMMITS_COUNT
- self.warn(format(MAX_COMMITS_COUNT_EXCEEDED_MESSAGE, max_commits_count: MAX_COMMITS_COUNT))
- end
if squash_mr?
multi_line_commit_linter = commit_linters.detect { |commit_linter| !commit_linter.merge? && commit_linter.multi_line? }
if multi_line_commit_linter && multi_line_commit_linter.failed?
warn_or_fail_commits(multi_line_commit_linter)
- else
+ commit_linters.delete(multi_line_commit_linter) # Don't show an error (here) and a warning (below)
+ elsif gitlab_danger.ci? # We don't have access to the MR title locally
title_linter = lint_mr_title(gitlab.mr_json['title'])
if title_linter.failed?
warn_or_fail_commits(title_linter)
end
end
+ else
+ if count_non_fixup_commits(commit_linters) > MAX_COMMITS_COUNT
+ self.warn(format(MAX_COMMITS_COUNT_EXCEEDED_MESSAGE, max_commits_count: MAX_COMMITS_COUNT))
+ end
end
+
+ failed_commit_linters = commit_linters.select { |commit_linter| commit_linter.failed? }
+ warn_or_fail_commits(failed_commit_linters, default_to_fail: !squash_mr?)
end
def warn_or_fail_commits(failed_linters, default_to_fail: true)
@@ -127,7 +130,7 @@ def warn_or_fail_commits(failed_linters, default_to_fail: true)
Array(failed_linters).each do |linter|
linter.problems.each do |problem_key, problem_desc|
case problem_key
- when :subject_above_warning
+ when :subject_too_short, :subject_above_warning
warn_commit(linter.commit, problem_desc)
else
self.__send__("#{level}_commit", linter.commit, problem_desc) # rubocop:disable GitlabSecurity/PublicSend
diff --git a/danger/documentation/Dangerfile b/danger/documentation/Dangerfile
index dc43e9d1843..240c374435c 100644
--- a/danger/documentation/Dangerfile
+++ b/danger/documentation/Dangerfile
@@ -4,9 +4,29 @@ def gitlab_danger
@gitlab_danger ||= GitlabDanger.new(helper.gitlab_helper)
end
+def feature_mr?
+ return false unless helper.gitlab_helper&.mr_labels
+
+ (helper.gitlab_helper.mr_labels & %w[feature::addition feature::enhancement]).any?
+end
+
+DOCUMENTATION_UPDATE_MISSING = <<~MSG
+~"feature::addition" and ~"feature::enhancement" merge requests normally have a documentation change. Consider adding a documentation update or confirming the documentation plan with the [Technical Writer counterpart](https://about.gitlab.com/handbook/engineering/ux/technical-writing/#designated-technical-writers).
+
+For more information, see:
+
+- The Handbook page on [throughput implementation](https://about.gitlab.com/handbook/engineering/management/throughput/#implementation).
+- The [definition of done](https://docs.gitlab.com/ee/development/contributing/merge_request_workflow.html#definition-of-done) documentation.
+MSG
+
docs_paths_to_review = helper.changes_by_category[:docs]
-return if docs_paths_to_review.empty?
+# Documentation should be updated for feature::addition and feature::enhancement
+if docs_paths_to_review.empty?
+ warn(DOCUMENTATION_UPDATE_MISSING) if feature_mr?
+
+ return
+end
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.'
diff --git a/danger/product_analytics/Dangerfile b/danger/product_analytics/Dangerfile
index fb441d6e467..b2144e7f034 100644
--- a/danger/product_analytics/Dangerfile
+++ b/danger/product_analytics/Dangerfile
@@ -2,7 +2,7 @@
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.
+Please check the ~"product analytics" [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
@@ -10,7 +10,7 @@ Please check the ~"product analytics(telemetry)" [guide](https://docs.gitlab.com
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).
+ When adding, changing, or updating metrics, please update the [Event dictionary Usage Ping table](https://about.gitlab.com/handbook/product/product-analytics-guide#event-dictionary).
MSG
@@ -41,8 +41,8 @@ if changed_files.any?
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')
+ product_analytics_labels = ['product analytics']
+ product_analytics_labels << 'product analytics::review pending' unless helper.mr_has_labels?('product analytics::reviewed')
markdown(helper.prepare_labels_for_mr(product_analytics_labels))
end