Browse Source

Add validate-dco-license role

This role can be used to validate all commits have --signedoff header.

Change-Id: I737d3efd730d20c6dd9f4a7cda2aa99125eaa0a0
Signed-off-by: Paul Belanger <pabelanger@redhat.com>
changes/65/629565/1
Paul Belanger 5 months ago
parent
commit
3525e04cc5

+ 12
- 0
roles/validate-dco-license/README.rst View File

@@ -0,0 +1,12 @@
1
+Validate all commits have Signed-off-by header
2
+
3
+**Role Variables**
4
+
5
+.. zuul:rolevar:: dco_license_failure
6
+
7
+   Message to display when Signed-off-by header is missing.
8
+
9
+.. zuul:rolevar:: zuul_work_dir
10
+   :default: {{ zuul.project.src_dir }}
11
+
12
+   Directory to DCO license check in.

+ 9
- 0
roles/validate-dco-license/defaults/main.yaml View File

@@ -0,0 +1,9 @@
1
+---
2
+dco_license_failure: |
3
+  One or more commits have not been signed properly using --signoff.
4
+
5
+  The meaning of a signoff depends on the project, but it typically certifies
6
+  that committer has the rights to submit this work under the same license and
7
+  agrees to a Developer Certificate of Origin
8
+  (see http://developercertificate.org/ for more information).
9
+zuul_work_dir: "{{ zuul.project.src_dir }}"

+ 25
- 0
roles/validate-dco-license/tasks/main.yaml View File

@@ -0,0 +1,25 @@
1
+- name: Developer Certificate of Origin (DCO) license check
2
+  shell:
3
+    cmd: |
4
+      set -e
5
+      result=0
6
+      for commit in $(git cherry -v origin/{{ zuul.branch }} HEAD | cut -d " " -f2)
7
+      do
8
+        if ! git show -s $commit | grep -q "Signed-off-by:"; then
9
+          echo "---"
10
+          git show -s $commit
11
+          echo "---"
12
+          echo "does not have a Signed-off-by header"
13
+          result=1
14
+        fi
15
+      done
16
+      exit $result
17
+    chdir: "{{ zuul_work_dir }}"
18
+    executable: /bin/bash
19
+  register: _dco
20
+  failed_when: _dco.rc > 1
21
+
22
+- name: License check failed
23
+  fail:
24
+    msg: "{{ dco_license_failure }}"
25
+  when: _dco.rc != 0

Loading…
Cancel
Save