Added basic commit checks
Sem-Ver: bugfix
Change-Id: Id5b07d8191c56edd70fcc134d3beaa188ad43bd2
diff --git a/releasenotes/notes/add-commit-msg-checks-6e4a5a0444fb8496.yaml b/releasenotes/notes/add-commit-msg-checks-6e4a5a0444fb8496.yaml
new file mode 100644
index 0000000..4b90452
--- /dev/null
+++ b/releasenotes/notes/add-commit-msg-checks-6e4a5a0444fb8496.yaml
@@ -0,0 +1,4 @@
+---
+features:
+ - Added commit message checks. Starting now, commits must include ``Sem-Ver``
+ tags in the commit message as well as a release note in the ``releasenotes``
diff --git a/zuul.d/jobs.yaml b/zuul.d/jobs.yaml
index f461374..276c297 100644
--- a/zuul.d/jobs.yaml
+++ b/zuul.d/jobs.yaml
@@ -13,6 +13,13 @@
# under the License.
- job:
+ name: ansible-collection-atmosphere-check-commit
+ nodeset:
+ nodes: []
+ run:
+ - zuul.d/playbooks/ansible-collection-atmosphere-check-commit/run.yml
+
+- job:
name: ansible-collection-atmosphere-tox-build
parent: tox
post-run:
diff --git a/zuul.d/playbooks/ansible-collection-atmosphere-check-commit/run.yml b/zuul.d/playbooks/ansible-collection-atmosphere-check-commit/run.yml
new file mode 100644
index 0000000..2e92406
--- /dev/null
+++ b/zuul.d/playbooks/ansible-collection-atmosphere-check-commit/run.yml
@@ -0,0 +1,62 @@
+# Copyright (c) 2022 VEXXHOST, Inc.
+#
+# Licensed under the Apache License, Version 2.0 (the "License"); you may
+# not use this file except in compliance with the License. You may obtain
+# a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+# License for the specific language governing permissions and limitations
+# under the License.
+
+- hosts: localhost
+ gather_facts: false
+ vars:
+ zuul:
+ message: U2VtLVZlcgo=
+ project:
+ canonical_hostname: opendev.org
+ name: vexxhost/ansible-collection-atmosphere
+ ref: refs/changes/92/834092/2
+ tasks:
+ - name: Get the commit for the ref
+ uri:
+ url: "https://{{ zuul.project.canonical_hostname }}/api/v1/repos/{{ zuul.project.name }}/git/refs/{{ zuul.ref | replace('refs/', '') | urlencode }}"
+ return_content: true
+ register: _git_ref
+
+ - name: Get the commit details
+ uri:
+ url: "{{ _git_ref.json[0].object.url }}"
+ return_content: true
+ register: _git_commit
+
+ - block:
+ - name: Run assertions on commit
+ assert:
+ that: "{{ item.that }}"
+ fail_msg: "{{ item.msg }}"
+ loop:
+ - that: "'Sem-Ver' in (zuul.message | b64decode)"
+ msg: "Sem-Ver tag missing from commit message, see: https://docs.openstack.org/pbr/latest/user/features.html#version"
+ - that: "(_git_commit.json.files | selectattr('filename', 'search', 'releasenotes/') | list | length) != 0"
+ msg: "Missing release note in commit message, please create one using `reno`."
+ loop_control:
+ label: "{{ item.that }}"
+ register: _assertions
+
+ always:
+ - name: Generate list of Zuul warnings
+ set_fact:
+ _warnings: "{{ _assertions.results | selectattr('failed', 'equalto', true) | map(attribute='msg') | list }}"
+ - name: Print list of Zuul warnings
+ debug:
+ msg: "{{_warnings }}"
+ - name: Generate a list of Zuul warnings
+ zuul_return:
+ data:
+ zuul:
+ warnings: "{{ _warnings }}"
\ No newline at end of file
diff --git a/zuul.d/project.yaml b/zuul.d/project.yaml
index 682ee36..4c0068d 100644
--- a/zuul.d/project.yaml
+++ b/zuul.d/project.yaml
@@ -15,11 +15,13 @@
- project:
check:
jobs:
+ - ansible-collection-atmosphere-check-commit
- ansible-collection-atmosphere-tox-build
- ansible-collection-atmosphere-tox-molecule-default
- opendev-tox-docs
gate:
jobs:
+ - ansible-collection-atmosphere-check-commit
- ansible-collection-atmosphere-tox-build
- ansible-collection-atmosphere-tox-molecule-default
- opendev-tox-docs