]> git.ipfire.org Git - thirdparty/kea.git/commitdiff
added danger for checking commits compliance danger-gitlab
authorMichal Nowikowski <godfryd@isc.org>
Fri, 14 Jun 2019 04:20:58 +0000 (06:20 +0200)
committerMichal Nowikowski <godfryd@isc.org>
Tue, 10 Sep 2019 14:06:16 +0000 (16:06 +0200)
.gitlab-ci.yml
Dangerfile [new file with mode: 0644]

index 65067ae42d574b80c436602e6bdab4a3bc47b16c..56cdc8c7e93a0bc0e88af5a9e62d47a4eae3fb9c 100644 (file)
@@ -1,24 +1,24 @@
-
-
 variables:
   # Not normally needed, but may be if some script uses `apt-get install`.
   DEBIAN_FRONTEND: noninteractive
-# Locale settings do not affect the build, but might affect tests.
+  # Locale settings do not affect the build, but might affect tests.
   LC_ALL: C
 
   CI_REGISTRY_IMAGE: registry.gitlab.isc.org/isc-projects/images/bind9
 
-# Disabled warnings:
-# SC2039 - complains about local var: In POSIX sh, 'local' is undefined.
+  # Disabled warnings:
+  # SC2039 - complains about local var: In POSIX sh, 'local' is undefined.
   SHELLCHECK_OPTS: "--exclude=SC2039"
 
 stages:
+  - danger
   - test
 
 shellcheck:
   stage: test
   image: "$CI_REGISTRY_IMAGE:debian-stretch-amd64"
   before_script:
+    - sudo apt-get update
     - sudo apt-get -y install shellcheck
   script:
     - SCRIPTS="src/bin/keactrl/keactrl.in "
@@ -27,3 +27,18 @@ shellcheck:
     - SCRIPTS+="tools/cql_config "
     - SCRIPTS+="tools/sysrepo_config "
     - shellcheck ${SCRIPTS} ${SHELLCHECK_OPTS}
+
+danger:
+  stage: danger
+  image: inloopx/danger-gitlab
+  before_script:
+    - export CI_MERGE_REQUEST_ID=$(git ls-remote -q origin merge-requests\*\head | grep $CI_COMMIT_SHA | sed 's/.*refs\/merge-requests\/\([0-9]*\)\/head/\1/g')
+    - export CI_PROJECT_PATH=$CI_PROJECT_ID #some version of gitlab has problems with searching by project path
+    - export DANGER_GITLAB_HOST=gitlab.isc.org
+    - export DANGER_GITLAB_API_BASE_URL=https://gitlab.isc.org/api/v4
+    - sysctl -w net.ipv6.conf.all.disable_ipv6=1
+    - sysctl -w net.ipv6.conf.default.disable_ipv6=1
+  script:
+    - echo '149.20.48.126 gitlab.isc.org' >> /etc/hosts
+    - gem install danger-commit_lint
+    - danger --fail-on-errors=true --new-comment
diff --git a/Dangerfile b/Dangerfile
new file mode 100644 (file)
index 0000000..770d87a
--- /dev/null
@@ -0,0 +1,19 @@
+# Make it more obvious that a PR is a work in progress and shouldn't be merged yet
+warn "MR is classed as Work in Progress" if gitlab.mr_title.include? "WIP"
+
+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
+warn("Split the MR into separate ones. It's really big.") if git.lines_of_code > 400
+fail("Do not submit MRs over 1000 lines of code.") if git.lines_of_code > 1000
+
+# 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