Commit 7de4fdd7 authored by Bob Van Landuyt's avatar Bob Van Landuyt

Merge branch...

Merge branch '226929-automatically-label-mr-that-changes-doc-directory-with-documentation-label' into 'master'

Automatically add the documentation label via Danger

Closes #226929

See merge request gitlab-org/gitlab!36041
parents bca25c0b a8ac7a8d
# frozen_string_literal: true # frozen_string_literal: true
def gitlab_danger
@gitlab_danger ||= GitlabDanger.new(helper.gitlab_helper)
end
docs_paths_to_review = helper.changes_by_category[:docs] docs_paths_to_review = helper.changes_by_category[:docs]
unless docs_paths_to_review.empty? return if docs_paths_to_review.empty?
message 'This merge request adds or changes files that require a review ' \
'from the Technical Writing team.' message 'This merge request adds or changes files that require a review ' \
'from the Technical Writing team.'
return unless gitlab_danger.ci?
if GitlabDanger.new(helper.gitlab_helper).ci? markdown(<<~MARKDOWN)
markdown(<<~MARKDOWN) ## Documentation review
## Documentation review
The following files require a review from a technical writer: The following files require a review from a technical writer:
* #{docs_paths_to_review.map { |path| "`#{path}`" }.join("\n* ")} * #{docs_paths_to_review.map { |path| "`#{path}`" }.join("\n* ")}
The review does not need to block merging this merge request. See the: The review does not need to block merging this merge request. See the:
- [DevOps stages](https://about.gitlab.com/handbook/product/categories/#devops-stages) for the appropriate technical writer for this review. - [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. - [Documentation workflows](https://docs.gitlab.com/ee/development/documentation/workflow.html) for information on when to assign a merge request for review.
MARKDOWN MARKDOWN
unless gitlab.mr_labels.include?('documentation') unless gitlab.mr_labels.include?('documentation')
warn 'This merge request is missing the ~documentation label.' gitlab.api.update_merge_request(gitlab.mr_json['project_id'],
end gitlab.mr_json['iid'],
end labels: (gitlab.mr_labels + ['documentation']).join(','))
end end
...@@ -62,6 +62,8 @@ changes = helper.changes_by_category ...@@ -62,6 +62,8 @@ changes = helper.changes_by_category
# Ignore any files that are known but uncategorized. Prompt for any unknown files # Ignore any files that are known but uncategorized. Prompt for any unknown files
changes.delete(:none) changes.delete(:none)
# To reinstate roulette for documentation, remove this line.
changes.delete(:docs)
categories = changes.keys - [:unknown] categories = changes.keys - [:unknown]
# Ensure to spin for database reviewer/maintainer when ~database is applied (e.g. to review SQL queries) # Ensure to spin for database reviewer/maintainer when ~database is applied (e.g. to review SQL queries)
......
...@@ -102,8 +102,8 @@ module Gitlab ...@@ -102,8 +102,8 @@ module Gitlab
}.freeze }.freeze
# First-match win, so be sure to put more specific regex at the top... # First-match win, so be sure to put more specific regex at the top...
CATEGORIES = { CATEGORIES = {
%r{\Adoc/} => :none, # To reinstate roulette for documentation, set to `:docs`. %r{\Adoc/} => :docs,
%r{\A(CONTRIBUTING|LICENSE|MAINTENANCE|PHILOSOPHY|PROCESS|README)(\.md)?\z} => :none, # To reinstate roulette for documentation, set to `:docs`. %r{\A(CONTRIBUTING|LICENSE|MAINTENANCE|PHILOSOPHY|PROCESS|README)(\.md)?\z} => :docs,
%r{\A(ee/)?app/(assets|views)/} => :frontend, %r{\A(ee/)?app/(assets|views)/} => :frontend,
%r{\A(ee/)?public/} => :frontend, %r{\A(ee/)?public/} => :frontend,
......
...@@ -167,13 +167,13 @@ RSpec.describe Gitlab::Danger::Helper do ...@@ -167,13 +167,13 @@ RSpec.describe Gitlab::Danger::Helper do
describe '#categories_for_file' do describe '#categories_for_file' do
where(:path, :expected_categories) do where(:path, :expected_categories) do
'doc/foo' | [:none] 'doc/foo' | [:docs]
'CONTRIBUTING.md' | [:none] 'CONTRIBUTING.md' | [:docs]
'LICENSE' | [:none] 'LICENSE' | [:docs]
'MAINTENANCE.md' | [:none] 'MAINTENANCE.md' | [:docs]
'PHILOSOPHY.md' | [:none] 'PHILOSOPHY.md' | [:docs]
'PROCESS.md' | [:none] 'PROCESS.md' | [:docs]
'README.md' | [:none] 'README.md' | [:docs]
'ee/doc/foo' | [:unknown] 'ee/doc/foo' | [:unknown]
'ee/README' | [:unknown] 'ee/README' | [:unknown]
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment