debian-mirror-gitlab/danger/documentation/Dangerfile

47 lines
2 KiB
Ruby
Raw Normal View History

2018-11-20 20:47:30 +05:30
# frozen_string_literal: true
2020-07-28 23:09:34 +05:30
def gitlab_danger
@gitlab_danger ||= GitlabDanger.new(helper.gitlab_helper)
end
2021-01-29 00:20:46 +05:30
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
2019-07-07 11:18:12 +05:30
docs_paths_to_review = helper.changes_by_category[:docs]
2018-11-20 20:47:30 +05:30
2021-01-29 00:20:46 +05:30
# 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
2020-07-28 23:09:34 +05:30
2021-01-03 14:25:43 +05:30
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.'
2020-07-28 23:09:34 +05:30
return unless gitlab_danger.ci?
2018-11-20 20:47:30 +05:30
2020-07-28 23:09:34 +05:30
markdown(<<~MARKDOWN)
## Documentation review
2018-11-20 20:47:30 +05:30
2020-07-28 23:09:34 +05:30
The following files require a review from a technical writer:
2018-11-20 20:47:30 +05:30
2020-07-28 23:09:34 +05:30
* #{docs_paths_to_review.map { |path| "`#{path}`" }.join("\n* ")}
2018-11-20 20:47:30 +05:30
2020-07-28 23:09:34 +05:30
The review does not need to block merging this merge request. See the:
2019-02-15 15:39:39 +05:30
2020-07-28 23:09:34 +05:30
- [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