Add check for ordering of jenkins/jobs/projects.yaml

Example output of test:
$ tools/jenkins-projects-checks.py
Checking section 'OpenStack server projects'
Checking section 'OpenStack client projects'
Checking section 'oslo libraries'
Checking section 'Other OpenStack projects'
  Wrong alphabetical order: tempest, qa-specs
Checking section 'OpenStack API projects'
Checking section 'OpenStack documentation projects'
Checking section 'OpenStack development projects'
Checking section 'OpenStack infrastructure projects'
Checking section 'Stackforge projects'
Found errors in jenkins/jobs/projects.yaml!

This patch fixes the order so that it passes.
It also creates a new job to test this.

Change-Id: I36fd522261363494f07b57e40f0d9b943cf08841
This commit is contained in:
Andreas Jaeger 2014-10-03 19:51:02 +02:00
parent d33cbcb7fd
commit 9836ea5357
5 changed files with 86 additions and 8 deletions

View File

@ -41,6 +41,19 @@
publishers:
- console-log
- job:
name: gate-project-config-jenkins-project
node: 'bare-precise || bare-trusty'
builders:
- revoke-sudo
- gerrit-git-prep
- tox:
envlist: 'jenkins-project'
- zuul_swift_upload_console_log
publishers:
- console-log
# This is a non-standard docs job because it uses SCP instead of FTP
- job:

View File

@ -1168,6 +1168,13 @@
- python-jobs
- pypi-jobs
- project:
name: qa-specs
node: 'bare-precise || bare-trusty'
jobs:
- specs-jobs
- project:
name: requirements
node: 'bare-precise || bare-trusty'
@ -1231,7 +1238,6 @@
- openstack-publish-jobs
- pypi-jobs
- project:
name: tempest
node: 'bare-precise || bare-trusty'
@ -1242,13 +1248,6 @@
- python-jobs
- openstack-publish-jobs
- project:
name: qa-specs
node: 'bare-precise || bare-trusty'
jobs:
- specs-jobs
- project:
name: tempest-lib
node: 'bare-precise || bare-trusty'

View File

@ -0,0 +1,58 @@
#!/usr/bin/python
# Copyright 2014 SUSE Linux Products GmbH
#
# 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.
import sys
def normalize(s):
"Normalize string for comparison."
return s.lower().replace("_", "-")
def check_sections():
"""Check that the projects are in alphabetical order per section."""
# Note that the file has different sections and we need to check
# entries within these sections only
errors = False
last = ""
for line in open('jenkins/jobs/projects.yaml', 'r'):
if line.startswith('# Section:'):
last = ""
section = line[10:].strip()
print("Checking section '%s'" % section)
if ' name: ' in line:
i = line.find(' name: ')
current = line[i + 7:].strip()
if normalize(last) > normalize(current):
print(" Wrong alphabetical order: %(last)s, %(current)s" %
{"last": last, "current": current})
errors = True
last = current
return errors
def check_all():
errors = check_sections()
if errors:
print("Found errors in jenkins/jobs/projects.yaml!")
else:
print("No errors found in jenkins/jobs/projects.yaml!")
return errors
if __name__ == "__main__":
sys.exit(check_all())

View File

@ -43,6 +43,12 @@ commands =
mkdir -p {envdir}/tmp
jenkins-jobs -l debug test -o {envdir}/tmp jenkins/jobs
[testenv:jenkins-project]
basepython = python2.7
deps =
commands =
{toxinidir}/tools/jenkins-projects-checks.py
[testenv:zuul]
basepython = python2.7
deps =

View File

@ -3286,6 +3286,7 @@ projects:
- gate-project-config-pep8
- gate-project-config-bashate
- gate-project-config-irc-access
- gate-project-config-jenkins-project
- gate-project-config-projects-yaml
- gate-infra-puppet-apply-precise
- gate-infra-puppet-apply-centos6
@ -3293,6 +3294,7 @@ projects:
- gate-project-config-layout
- gate-project-config-pep8
- gate-project-config-irc-access
- gate-project-config-jenkins-project
- gate-project-config-projects-yaml
- gate-infra-puppet-apply-precise
- gate-infra-puppet-apply-centos6