summaryrefslogtreecommitdiff
path: root/danger
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2021-05-19 15:44:42 +0000
committerGitLab Bot <gitlab-bot@gitlab.com>2021-05-19 15:44:42 +0000
commit4555e1b21c365ed8303ffb7a3325d773c9b8bf31 (patch)
tree5423a1c7516cffe36384133ade12572cf709398d /danger
parente570267f2f6b326480d284e0164a6464ba4081bc (diff)
downloadgitlab-ce-4555e1b21c365ed8303ffb7a3325d773c9b8bf31.tar.gz
Add latest changes from gitlab-org/gitlab@13-12-stable-eev13.12.0-rc42
Diffstat (limited to 'danger')
-rw-r--r--danger/changelog/Dangerfile98
-rw-r--r--danger/changes_size/Dangerfile19
-rw-r--r--danger/database/Dangerfile2
-rw-r--r--danger/feature_flag/Dangerfile2
-rw-r--r--danger/product_intelligence/Dangerfile14
5 files changed, 13 insertions, 122 deletions
diff --git a/danger/changelog/Dangerfile b/danger/changelog/Dangerfile
index 6f045d7b5ab..83c6f68869b 100644
--- a/danger/changelog/Dangerfile
+++ b/danger/changelog/Dangerfile
@@ -1,99 +1,3 @@
# frozen_string_literal: true
-# rubocop:disable Style/SignalException
-require 'yaml'
-
-SEE_DOC = "See the [changelog documentation](https://docs.gitlab.com/ee/development/changelog.html)."
-
-SUGGEST_MR_COMMENT = <<~SUGGEST_COMMENT
-```suggestion
-merge_request: %<mr_iid>s
-```
-
-#{SEE_DOC}
-SUGGEST_COMMENT
-
-def check_changelog_yaml(path)
- raw_file = File.read(path)
- yaml = YAML.safe_load(raw_file)
-
- fail "`title` should be set, in #{helper.html_link(path)}! #{SEE_DOC}" if yaml["title"].nil?
- fail "`type` should be set, in #{helper.html_link(path)}! #{SEE_DOC}" if yaml["type"].nil?
-
- return if helper.security_mr?
- return if helper.mr_iid.to_s.empty?
-
- cherry_pick_against_stable_branch = helper.cherry_pick_mr? && helper.stable_branch?
-
- if yaml["merge_request"].nil?
- mr_line = raw_file.lines.find_index("merge_request:\n")
-
- if mr_line
- markdown(format(SUGGEST_MR_COMMENT, mr_iid: helper.mr_iid), file: path, line: mr_line.succ)
- else
- message "Consider setting `merge_request` to #{helper.mr_iid} in #{helper.html_link(path)}. #{SEE_DOC}"
- end
- elsif yaml["merge_request"] != helper.mr_iid && !cherry_pick_against_stable_branch
- fail "Merge request ID was not set to #{helper.mr_iid}! #{SEE_DOC}"
- end
-rescue Psych::Exception
- # YAML could not be parsed, fail the build.
- fail "#{helper.html_link(path)} isn't valid YAML! #{SEE_DOC}"
-rescue StandardError => e
- warn "There was a problem trying to check the Changelog. Exception: #{e.class.name} - #{e.message}"
-end
-
-def check_changelog_path(path)
- ee_changes = project_helper.all_ee_changes.dup
- ee_changes.delete(path)
-
- if ee_changes.any? && !changelog.ee_changelog? && !changelog.required?
- warn "This MR has a Changelog file outside `ee/`, but code changes in `ee/`. Consider moving the Changelog file into `ee/`."
- end
-
- if ee_changes.empty? && changelog.ee_changelog?
- warn "This MR has a Changelog file in `ee/`, but no code changes in `ee/`. Consider moving the Changelog file outside `ee/`."
- end
-
- if ee_changes.any? && changelog.ee_changelog? && changelog.required_reasons.include?(:db_changes)
- warn "This MR has a Changelog file inside `ee/`, but there are database changes which [requires](https://docs.gitlab.com/ee/development/changelog.html#what-warrants-a-changelog-entry) the Changelog placement to be outside of `ee/`. Consider moving the Changelog file outside `ee/`."
- end
-end
-
-if git.modified_files.include?("CHANGELOG.md")
- fail changelog.modified_text
-end
-
-changelog_found = changelog.found
-
-if changelog_found
- check_changelog_yaml(changelog_found)
- check_changelog_path(changelog_found)
-elsif changelog.required?
- changelog.required_texts.each { |_, text| fail(text) } # rubocop:disable Lint/UnreachableLoop
-elsif changelog.optional?
- message changelog.optional_text
-end
-
-message <<~MSG
- We are in the process of rolling out a new workflow for adding changelog entries. This new workflow uses Git commit subjects and Git trailers to generate changelogs. This new approach will soon replace the current YAML based approach.
-
- To ease the transition process, we recommend you start using both the old and new approach in parallel. This is not required at this time, but will make it easier to transition to the new approach in the future. To do so, pick the commit that should go in the changelog and add a `Changelog` trailer to it. For example:
-
- ```
- This is my commit's subject line
-
- This is the optional commit body.
-
- Changelog: added
- ```
-
- The value of the `Changelog` trailer should be one of the following: added, fixed, changed, deprecated, removed, security, performance, other.
-
- For more information, take a look at the following resources:
-
- - https://gitlab.com/gitlab-com/gl-infra/delivery/-/issues/1564
- - https://docs.gitlab.com/ee/api/repositories.html#generate-changelog-data
-
- If you'd like to see the new approach in action, take a look at the commits in [the Omnibus repository](https://gitlab.com/gitlab-org/omnibus-gitlab/-/commits/master).
-MSG
+changelog.check!
diff --git a/danger/changes_size/Dangerfile b/danger/changes_size/Dangerfile
deleted file mode 100644
index 52e6cb65d04..00000000000
--- a/danger/changes_size/Dangerfile
+++ /dev/null
@@ -1,19 +0,0 @@
-# frozen_string_literal: true
-
-# FIXME: git.info_for_file raises the following error
-# /usr/local/bundle/gems/git-1.4.0/lib/git/lib.rb:956:in `command': (Danger::DSLError)
-# [!] Invalid `Dangerfile` file:
-# [!] Invalid `Dangerfile` file: git '--git-dir=/builds/gitlab-org/gitlab/.git' '--work-tree=/builds/gitlab-org/gitlab' cat-file '-t' '' 2>&1:fatal: Not a valid object name
-# This seems to be the same as https://github.com/danger/danger/issues/535.
-
-# locale_files_updated = git.modified_files.select { |path| path.start_with?('locale') }
-# locale_files_updated.each do |locale_file_updated|
-# git_stats = git.info_for_file(locale_file_updated)
-# message "Git stats for #{locale_file_updated}: #{git_stats[:insertions]} insertions, #{git_stats[:deletions]} insertions"
-# end
-
-if git.lines_of_code > 2_000
- warn "This merge request is definitely too big (#{git.lines_of_code} lines changed), please split it into multiple merge requests."
-elsif git.lines_of_code > 500
- warn "This merge request is quite big (#{git.lines_of_code} lines changed), please consider splitting it into multiple merge requests."
-end
diff --git a/danger/database/Dangerfile b/danger/database/Dangerfile
index af4d6ed513d..cd56ea8dd22 100644
--- a/danger/database/Dangerfile
+++ b/danger/database/Dangerfile
@@ -55,7 +55,7 @@ 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?
- unless helper.has_database_scoped_labels?(gitlab.mr_labels)
+ unless helper.has_database_scoped_labels?
gitlab.api.update_merge_request(gitlab.mr_json['project_id'],
gitlab.mr_json['iid'],
add_labels: 'database::review pending')
diff --git a/danger/feature_flag/Dangerfile b/danger/feature_flag/Dangerfile
index d14dd97380f..88ce6393b64 100644
--- a/danger/feature_flag/Dangerfile
+++ b/danger/feature_flag/Dangerfile
@@ -13,7 +13,7 @@ group: "%<group>s"
SUGGEST_COMMENT
def check_feature_flag_yaml(feature_flag)
- mr_group_label = helper.group_label(gitlab.mr_labels)
+ mr_group_label = helper.group_label
if feature_flag.group.nil?
message_for_feature_flag_missing_group!(feature_flag: feature_flag, mr_group_label: mr_group_label)
diff --git a/danger/product_intelligence/Dangerfile b/danger/product_intelligence/Dangerfile
index d2bed7629ff..3867aed84d5 100644
--- a/danger/product_intelligence/Dangerfile
+++ b/danger/product_intelligence/Dangerfile
@@ -81,13 +81,19 @@ matching_changed_files = usage_data_changed_files +
snowplow_changed_files
if matching_changed_files.any?
-
warn format(CHANGED_FILES_MESSAGE, changed_files: helper.markdown_list(matching_changed_files))
fail format(UPDATE_DICTIONARY_MESSAGE) if required_dictionary_update_changed_files.any? && dictionary_changed_file.empty?
- labels = ['product intelligence']
- labels << 'product intelligence::review pending' unless helper.mr_has_labels?('product intelligence::approved')
+ return unless helper.ci?
+
+ labels = []
+ labels << 'product intelligence' unless helper.mr_has_labels?('product intelligence')
+ labels << 'product intelligence::review pending' unless helper.mr_has_labels?(['product intelligence::approved', 'product intelligence::review pending'])
- markdown(helper.prepare_labels_for_mr(labels))
+ if labels.any?
+ gitlab.api.update_merge_request(gitlab.mr_json['project_id'],
+ gitlab.mr_json['iid'],
+ add_labels: labels)
+ end
end