summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul Belanger <pabelanger@redhat.com>2019-01-09 11:39:02 -0500
committerPaul Belanger <pabelanger@redhat.com>2019-01-09 11:39:02 -0500
commit3525e04cc597e5f30243e4c882a4e316d8c95b43 (patch)
tree32a53083e0819066ec04c0e6b922513f71009c3f
parent0630797da82ce49b4904de90892d696ddb043d5d (diff)
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>
Notes
Notes (review): Code-Review+2: Jeremy Stanley <fungi@yuggoth.org> Code-Review+2: James E. Blair <corvus@inaugust.com> Code-Review+2: Clark Boylan <cboylan@sapwetik.org> Workflow+1: Clark Boylan <cboylan@sapwetik.org> Verified+2: Zuul Submitted-by: Zuul Submitted-at: Fri, 11 Jan 2019 18:16:59 +0000 Reviewed-on: https://review.openstack.org/629565 Project: openstack-infra/zuul-jobs Branch: refs/heads/master
-rw-r--r--roles/validate-dco-license/README.rst12
-rw-r--r--roles/validate-dco-license/defaults/main.yaml9
-rw-r--r--roles/validate-dco-license/tasks/main.yaml25
3 files changed, 46 insertions, 0 deletions
diff --git a/roles/validate-dco-license/README.rst b/roles/validate-dco-license/README.rst
new file mode 100644
index 0000000..2cf9b0b
--- /dev/null
+++ b/roles/validate-dco-license/README.rst
@@ -0,0 +1,12 @@
1Validate 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.
diff --git a/roles/validate-dco-license/defaults/main.yaml b/roles/validate-dco-license/defaults/main.yaml
new file mode 100644
index 0000000..2a6712c
--- /dev/null
+++ b/roles/validate-dco-license/defaults/main.yaml
@@ -0,0 +1,9 @@
1---
2dco_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).
9zuul_work_dir: "{{ zuul.project.src_dir }}"
diff --git a/roles/validate-dco-license/tasks/main.yaml b/roles/validate-dco-license/tasks/main.yaml
new file mode 100644
index 0000000..47228af
--- /dev/null
+++ b/roles/validate-dco-license/tasks/main.yaml
@@ -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