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

gitlab.com/gitlab-org/gitaly.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/danger
diff options
context:
space:
mode:
authorYorick Peterse <yorick@yorickpeterse.com>2021-04-27 15:05:07 +0300
committerYorick Peterse <yorick@yorickpeterse.com>2021-04-27 15:13:08 +0300
commit5ca77983480861729d8768c5a22ff3ce9a77dabe (patch)
tree6925e8e3deedc5629cb4e9f951e44d2d0108af6a /danger
parent67520d7b374eea77f7412600271a90193bdd2e8a (diff)
Prepare for upcoming changelog workflow changes
This adds a configuration file for generating changelogs using the GitLab API (done using Release Tools), as well as change Danger to remind developers of these upcoming changes (similar to what we're doing in gitlab-org/gitlab). Omnibus, Pages and Helm are already using this new approach. Our current plan is to also roll this out to remaining projects (GitLab Rails and Gitaly) per May 22nd. See https://gitlab.com/gitlab-com/gl-infra/delivery/-/issues/1564 for more information.
Diffstat (limited to 'danger')
-rw-r--r--danger/changelog/Dangerfile58
1 files changed, 58 insertions, 0 deletions
diff --git a/danger/changelog/Dangerfile b/danger/changelog/Dangerfile
index d2facce07..1a7029768 100644
--- a/danger/changelog/Dangerfile
+++ b/danger/changelog/Dangerfile
@@ -29,6 +29,28 @@ merge_request: %<mr_iid>s
#{SEE_DOC}
SUGGEST_COMMENT
+CATEGORIES = YAML
+ .load_file(File.expand_path('../../.gitlab/changelog_config.yml', __dir__))
+ .fetch('categories')
+ .keys
+ .freeze
+
+def check_changelog_trailer(commit)
+ trailer = commit.message.match(/^Changelog:\s*(?<category>.+)$/)
+
+ return :missing if trailer.nil? || trailer[:category].nil?
+
+ category = trailer[:category]
+
+ return :valid if CATEGORIES.include?(category)
+
+ self.fail(
+ "Commit #{commit.sha} uses an invalid changelog category: #{category}"
+ )
+
+ :invalid
+end
+
def check_changelog(path)
raw_file = File.read(path)
yaml = YAML.safe_load(raw_file)
@@ -75,4 +97,40 @@ elsif changelog_needed
format(CREATE_CHANGELOG_MESSAGE, mr_iid: gitlab.mr_json["iid"], mr_title: mr_title, labels: presented_no_changelog_labels)
end
+if changelog_needed
+ checked = 0
+
+ git.commits.each do |commit|
+ case check_changelog_trailer(commit)
+ when :valid, :invalid
+ checked += 1
+ end
+ end
+
+ if checked == 0
+ 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
+ end
+end
+
# vim: ft=ruby