summaryrefslogtreecommitdiffstats
path: root/Dangerfile
diff options
context:
space:
mode:
authorMichal Nowikowski <godfryd@isc.org>2019-06-14 06:20:58 +0200
committerMichal Nowikowski <godfryd@isc.org>2019-12-19 13:13:46 +0100
commit8bc8f7872f5177104cdb59dfa6121717bd4fa88f (patch)
treec8fa5fe35103ffd9f6eb34df3b3a2f7dfb5f72bd /Dangerfile
parent[#1060] Hooks version bumped to 12. (diff)
downloadkea-8bc8f7872f5177104cdb59dfa6121717bd4fa88f.tar.xz
kea-8bc8f7872f5177104cdb59dfa6121717bd4fa88f.zip
[#672] added danger for checking commits compliance
Diffstat (limited to 'Dangerfile')
-rw-r--r--Dangerfile42
1 files changed, 42 insertions, 0 deletions
diff --git a/Dangerfile b/Dangerfile
new file mode 100644
index 0000000000..c8d391dd30
--- /dev/null
+++ b/Dangerfile
@@ -0,0 +1,42 @@
+fail "Please provide a summary in the Merge Request description to help your colleagues to understand the MR purpose." if gitlab.mr_body.length < 5
+
+if git.modified_files.include? "Dangerfile"
+ warn "This MR modifies Dangerfile! Watch for the rules!"
+end
+
+# Checking MR size
+if not gitlab.mr_body.include?("#huge-sorry")
+ warn("Split the MR into separate ones. It's really big.") if git.lines_of_code > 3000
+ fail("Do not submit MRs over 5000 lines of code.") if git.lines_of_code > 5000
+end
+
+# Note when MRs don't reference a milestone, make the warning stick around on subsequent runs
+has_milestone = gitlab.mr_json["milestone"] != nil
+warn("This MR does not refer to an existing milestone", sticky: true) unless has_milestone
+
+# check commits' comments
+commit_lint.check warn: :all
+
+# check gitlab issue in commit message
+git.commits.each do |c|
+ m = c.message.match(/^\[\#(\d+)\]\ (.*)/)
+ if not m
+ warn "No GitLab issue in commit message: #{c}"
+ gl_issue_msg = nil
+ else
+ gl_issue_msg = m.captures[0]
+ end
+
+ mr_branch = gitlab.branch_for_head
+ m = mr_branch.match(/^(\d+).*/)
+ if not m
+ warn "Branch name does not start with GitLab issue: #{mr_branch}"
+ gl_issue_br = nil
+ else
+ gl_issue_br = m.captures[0]
+ end
+
+ if gl_issue_msg and gl_issue_br and gl_issue_msg != gl_issue_br
+ warn "GitLab issue ##{gl_issue_msg} in msg of commit #{c} and issue ##{gl_issue_br} from branch #{mr_branch} do not match"
+ end
+end