mirror of
https://github.com/gitlabhq/gitlabhq.git
synced 2025-08-20 16:30:26 +00:00
Add a danger rule to suggest docs-
prefixes
If an MR only changes files within `doc/` we can save valueable CI time by prepending a branch name with `docs-`. This danger rule helps educate people about that fact. On the other hand, if someone has a branch with a `docs` prefix or suffix, the branch shouldn't contain any changes outside of the `docs` directory
This commit is contained in:
@ -19,4 +19,5 @@ unless helper.release_automation?
|
|||||||
danger.import_dangerfile(path: 'danger/single_codebase')
|
danger.import_dangerfile(path: 'danger/single_codebase')
|
||||||
danger.import_dangerfile(path: 'danger/gitlab_ui_wg')
|
danger.import_dangerfile(path: 'danger/gitlab_ui_wg')
|
||||||
danger.import_dangerfile(path: 'danger/ce_ee_vue_templates')
|
danger.import_dangerfile(path: 'danger/ce_ee_vue_templates')
|
||||||
|
danger.import_dangerfile(path: 'danger/only_documentation')
|
||||||
end
|
end
|
||||||
|
24
danger/only_documentation/Dangerfile
Normal file
24
danger/only_documentation/Dangerfile
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
# rubocop:disable Style/SignalException
|
||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
|
has_only_docs_changes = helper.all_changed_files.all? { |file| file.start_with?('doc/') }
|
||||||
|
is_docs_only_branch = gitlab.branch_for_head =~ /(^docs[\/-].*|.*-docs$)/
|
||||||
|
|
||||||
|
if is_docs_only_branch && !has_only_docs_changes
|
||||||
|
fail "It seems like your branch name has a `docs` prefix or suffix. "\
|
||||||
|
"The CI won't run the full pipeline, but you also have changed non-docs files. "\
|
||||||
|
"Please recreate this MR with a new branch name."
|
||||||
|
end
|
||||||
|
|
||||||
|
if has_only_docs_changes && !is_docs_only_branch
|
||||||
|
markdown(<<~MARKDOWN)
|
||||||
|
|
||||||
|
## Documentation only changes
|
||||||
|
|
||||||
|
Hey! Seems your merge request contains only docs changes.
|
||||||
|
Tired of waiting 2 hours for the pipeline to finish?
|
||||||
|
Next time, prepend `docs-` to [your branch name](https://docs.gitlab.com/ee/development/documentation/#branch-naming)
|
||||||
|
and the pipeline will finish before you say GitLab (x300)!
|
||||||
|
|
||||||
|
MARKDOWN
|
||||||
|
end
|
Reference in New Issue
Block a user