Check for correct DocImpact tag usage

Enforces Review DocImpact spec.

Could be used later for enforcing other formatting to commit messages
(such as line length, blueprint/bug closes syntax etc.)

Implements: blueprint review-docimpact
Change-Id: I7846f162172a12ba3d0abade088b9301c5a0db49
This commit is contained in:
Joshua Hesketh 2015-11-30 21:40:34 +11:00
parent f22e6cce36
commit f0a1de62f1
4 changed files with 85 additions and 0 deletions

15
jenkins/jobs/git.yaml Normal file
View File

@ -0,0 +1,15 @@
# General jobs relating to git (such as commit messages)
- job-template:
name: 'gate-{name}-commit-message'
node: 'bare-precise || bare-trusty'
builders:
- print-template-name:
template-name: "{template-name}"
- revoke-sudo
- zuul-git-prep
- shell: /usr/local/jenkins/slave_scripts/check-git-commit-message.sh
publishers:
- zuul-swift-upload-console-log

View File

@ -3493,6 +3493,7 @@
- python-kilo-bitrot-jobs
- python-liberty-bitrot-jobs
- openstack-publish-jobs
- gate-{name}-commit-message
- gate-{name}-pylint
- gate-{name}-pip-missing-reqs
- 'gate-{name}-tox-{envlist}':

View File

@ -0,0 +1,65 @@
#!/bin/bash -xe
# Copyright 2015 Rackspace Australia
#
# 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.
# Check the commit message at HEAD for style
CHECK_SUBJECT_LENGTH=${CHECK_SUBJECT_LENGTH:-0}
CHECK_DOCIMPACT_STRING=${CHECK_DOCIMPACT_STRING:-1}
COMMIT=${COMMIT:-HEAD}
function check_subject_length {
# Checks that the subject (first line of the commit message) is less than
# the max-length
# $1 message
# $2 max-length
# TODO(jhesketh) if this is a thing we want
echo "check_subject_length not implemented"
exit 1
}
function check_docimpact_string {
# Checks there is a description following the DocImpact tag as per
# http://specs.openstack.org/openstack/docs-specs/specs/mitaka/review-docimpact.html
# $1 message
# Check if there is a line starting with DocImpact (case-insensitive).
# If there is, then check it's in the correct format (case-sensitive).
echo "$1" | grep -qi "^DocImpact"
if [ $? -eq 0 ]; then
echo "$1" | grep -q "^DocImpact\: .*$"
if [ $? -ne 0 ]; then
echo "DocImpact must have a description following it."
exit 1
fi
fi
}
# Grab the message
message="$(git log --format=%B -n 1 $COMMIT)"
if [ $CHECK_SUBJECT_LENGTH -gt 0 ]; then
check_subject_length "$message" $CHECK_SUBJECT_LENGTH
fi
if [ $CHECK_DOCIMPACT_STRING -gt 0 ]; then
check_docimpact_string "$message"
fi

View File

@ -1776,6 +1776,9 @@ jobs:
- name: gate-tempest-dsvm-ceilometer-mongodb-full
voting: false
- name: gate-nova-commit-message
voting: false
- name: gate-nova-pip-missing-reqs
voting: false
@ -6637,6 +6640,7 @@ projects:
- gate-tempest-dsvm-full-devstack-plugin-ceph-nv
- gate-tempest-dsvm-multinode-full
- gate-compute-api-guide
- gate-nova-commit-message
- gate-nova-python27-constraints
- gate-nova-python34-constraints
- gate-nova-docs-constraints