Add some check for zuul.d/projects.yaml
Add framework to run checks on zuul.d/projects.yaml. For now it checks that each project has the system-required template and that zuul.d/projects.yaml is sorted. Remove the file tools/zuul-projects_sorted.sh which did a sort test as well. Update list of repos so that they are in the order expected (bash and python string comparison is different). Change-Id: I29e0b7f49ec890f62d6c521e443248ab33cb819a Depends-On: I19dbdebc1c02f0ae6ab6671b4cf3fb3c4382a820
This commit is contained in:
parent
55e93256dc
commit
cff5df5527
83
tools/zuul-projects-checks.py
Executable file
83
tools/zuul-projects-checks.py
Executable file
@ -0,0 +1,83 @@
|
||||
#!/usr/bin/env python
|
||||
|
||||
# Copyright 2017 SUSE Linux 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
|
||||
|
||||
import yaml
|
||||
|
||||
|
||||
projects_yaml = 'zuul.d/projects.yaml'
|
||||
projects = yaml.safe_load(open(projects_yaml))
|
||||
|
||||
|
||||
def check_system_templates():
|
||||
"""Check that each repo has a system-required template."""
|
||||
|
||||
errors = False
|
||||
print("\nChecking for usage of system-required")
|
||||
print("=====================================")
|
||||
for entry in projects:
|
||||
project = entry['project']
|
||||
try:
|
||||
correct = False
|
||||
for template in project['templates']:
|
||||
if template == 'system-required':
|
||||
correct = True
|
||||
if not correct:
|
||||
raise
|
||||
except:
|
||||
print("Project %s has no system-required template" %
|
||||
project['name'])
|
||||
errors = True
|
||||
return errors
|
||||
|
||||
|
||||
def normalize(s):
|
||||
"Normalize string for comparison."
|
||||
return s.lower().replace("_", "-")
|
||||
|
||||
|
||||
def check_projects_sorted():
|
||||
"""Check that the projects are in alphabetical order per section."""
|
||||
|
||||
print("Checking project list for alphabetical order")
|
||||
print("============================================")
|
||||
|
||||
errors = False
|
||||
last = ""
|
||||
for entry in projects:
|
||||
current = entry['project']['name']
|
||||
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_system_templates()
|
||||
errors = check_projects_sorted() or errors
|
||||
|
||||
if errors:
|
||||
print("\nFound errors in zuul.d/projects.yaml!")
|
||||
else:
|
||||
print("\nNo errors found in zuul.d/projects.yaml!")
|
||||
return errors
|
||||
|
||||
if __name__ == "__main__":
|
||||
sys.exit(check_all())
|
@ -1,24 +0,0 @@
|
||||
#!/bin/bash -xe
|
||||
|
||||
# It checks that projects.yaml alphabetized and prints list of projects that
|
||||
# should be sorted.
|
||||
|
||||
export TMPDIR=`/bin/mktemp -d`
|
||||
trap "rm -rf $TMPDIR" EXIT
|
||||
|
||||
pushd $TMPDIR
|
||||
PROJECTS_LIST=$OLDPWD/zuul.d/projects.yaml
|
||||
|
||||
grep name: $PROJECTS_LIST |sed -e 's/^ *name: //' > projects_list
|
||||
|
||||
LC_ALL=C sort --ignore-case projects_list -o projects_list.sorted
|
||||
|
||||
if ! diff projects_list projects_list.sorted > projects_list.diff; then
|
||||
echo "The following projects should be alphabetized: "
|
||||
cat projects_list.diff | grep -e '> '
|
||||
exit 1
|
||||
else
|
||||
echo "Projects alphabetized."
|
||||
fi
|
||||
|
||||
popd
|
4
tox.ini
4
tox.ini
@ -29,8 +29,8 @@ deps =
|
||||
commands =
|
||||
{toxinidir}/tools/run-bashate.sh
|
||||
flake8
|
||||
# Check that zuul.d/projects.yaml list is sorted
|
||||
{toxinidir}/tools/zuul-projects_sorted.sh
|
||||
# Run some policy checks on zuul.d/projects.yaml
|
||||
{toxinidir}/tools/zuul-projects-checks.py
|
||||
# Ansible lint
|
||||
# [ANSIBLE0012] Commands should not change things if nothing needs doing
|
||||
bash -c "find playbooks -type f -regex '.*.ya?ml' -print0 | \
|
||||
|
@ -840,12 +840,6 @@
|
||||
- openstack-tox-pep8
|
||||
- openstack-tox-py27
|
||||
|
||||
- project:
|
||||
name: openstack-infra/logstash-filters
|
||||
templates:
|
||||
- system-required
|
||||
- infra-logstash-filter-jobs
|
||||
|
||||
- project:
|
||||
name: openstack-infra/log_processor
|
||||
templates:
|
||||
@ -854,6 +848,12 @@
|
||||
- publish-openstack-sphinx-docs-infra
|
||||
- publish-to-pypi
|
||||
|
||||
- project:
|
||||
name: openstack-infra/logstash-filters
|
||||
templates:
|
||||
- system-required
|
||||
- infra-logstash-filter-jobs
|
||||
|
||||
- project:
|
||||
name: openstack-infra/lpmqtt
|
||||
templates:
|
||||
@ -1234,7 +1234,7 @@
|
||||
- puppet-beaker-jobs-xenial
|
||||
|
||||
- project:
|
||||
name: openstack-infra/puppet-elasticsearch
|
||||
name: openstack-infra/puppet-elastic_recheck
|
||||
templates:
|
||||
- system-required
|
||||
- infra-puppet-check-jobs
|
||||
@ -1243,7 +1243,7 @@
|
||||
- puppet-beaker-jobs-xenial
|
||||
|
||||
- project:
|
||||
name: openstack-infra/puppet-elastic_recheck
|
||||
name: openstack-infra/puppet-elasticsearch
|
||||
templates:
|
||||
- system-required
|
||||
- infra-puppet-check-jobs
|
||||
@ -1448,6 +1448,15 @@
|
||||
- puppet-beaker-jobs
|
||||
- puppet-beaker-jobs-xenial
|
||||
|
||||
- project:
|
||||
name: openstack-infra/puppet-log_processor
|
||||
templates:
|
||||
- system-required
|
||||
- infra-puppet-check-jobs
|
||||
- infra-puppet-apply-jobs
|
||||
- puppet-beaker-jobs
|
||||
- puppet-beaker-jobs-xenial
|
||||
|
||||
- project:
|
||||
name: openstack-infra/puppet-logrotate
|
||||
templates:
|
||||
@ -1465,15 +1474,6 @@
|
||||
- puppet-beaker-jobs
|
||||
- puppet-beaker-jobs-xenial
|
||||
|
||||
- project:
|
||||
name: openstack-infra/puppet-log_processor
|
||||
templates:
|
||||
- system-required
|
||||
- infra-puppet-check-jobs
|
||||
- infra-puppet-apply-jobs
|
||||
- puppet-beaker-jobs
|
||||
- puppet-beaker-jobs-xenial
|
||||
|
||||
- project:
|
||||
name: openstack-infra/puppet-lpmqtt
|
||||
templates:
|
||||
@ -1558,6 +1558,30 @@
|
||||
- puppet-beaker-jobs
|
||||
- puppet-beaker-jobs-xenial
|
||||
|
||||
- project:
|
||||
name: openstack-infra/puppet-openstack_health
|
||||
templates:
|
||||
- system-required
|
||||
- infra-puppet-check-jobs
|
||||
- infra-puppet-apply-jobs
|
||||
- puppet-beaker-jobs
|
||||
- puppet-beaker-jobs-xenial
|
||||
|
||||
- project:
|
||||
name: openstack-infra/puppet-openstack_infra_spec_helper
|
||||
templates:
|
||||
- system-required
|
||||
check:
|
||||
jobs:
|
||||
- legacy-puppet-openstack-infra-spec-helper-unit-centos-7
|
||||
- legacy-puppet-openstack-infra-spec-helper-unit
|
||||
- legacy-puppet-openstack-infra-spec-helper-unit-ubuntu-trusty
|
||||
gate:
|
||||
jobs:
|
||||
- legacy-puppet-openstack-infra-spec-helper-unit-centos-7
|
||||
- legacy-puppet-openstack-infra-spec-helper-unit
|
||||
- legacy-puppet-openstack-infra-spec-helper-unit-ubuntu-trusty
|
||||
|
||||
- project:
|
||||
name: openstack-infra/puppet-openstackci
|
||||
templates:
|
||||
@ -1585,30 +1609,6 @@
|
||||
- puppet-beaker-jobs
|
||||
- puppet-beaker-jobs-xenial
|
||||
|
||||
- project:
|
||||
name: openstack-infra/puppet-openstack_health
|
||||
templates:
|
||||
- system-required
|
||||
- infra-puppet-check-jobs
|
||||
- infra-puppet-apply-jobs
|
||||
- puppet-beaker-jobs
|
||||
- puppet-beaker-jobs-xenial
|
||||
|
||||
- project:
|
||||
name: openstack-infra/puppet-openstack_infra_spec_helper
|
||||
templates:
|
||||
- system-required
|
||||
check:
|
||||
jobs:
|
||||
- legacy-puppet-openstack-infra-spec-helper-unit-centos-7
|
||||
- legacy-puppet-openstack-infra-spec-helper-unit
|
||||
- legacy-puppet-openstack-infra-spec-helper-unit-ubuntu-trusty
|
||||
gate:
|
||||
jobs:
|
||||
- legacy-puppet-openstack-infra-spec-helper-unit-centos-7
|
||||
- legacy-puppet-openstack-infra-spec-helper-unit
|
||||
- legacy-puppet-openstack-infra-spec-helper-unit-ubuntu-trusty
|
||||
|
||||
- project:
|
||||
name: openstack-infra/puppet-os_client_config
|
||||
templates:
|
||||
@ -19771,6 +19771,18 @@
|
||||
- system-required
|
||||
- puppet-openstack-libraries-jobs
|
||||
|
||||
- project:
|
||||
name: openstack/puppet-openstack_extras
|
||||
templates:
|
||||
- system-required
|
||||
- puppet-openstack-check-jobs
|
||||
- puppet-module-unit-jobs
|
||||
- puppet-beaker-jobs
|
||||
- puppet-beaker-jobs-xenial
|
||||
- puppet-openstack-integration-jobs-all
|
||||
- release-notes-jobs
|
||||
- puppet-release-jobs
|
||||
|
||||
- project:
|
||||
name: openstack/puppet-openstack-guide
|
||||
templates:
|
||||
@ -19791,6 +19803,13 @@
|
||||
vars:
|
||||
update_target: puppet-openstack-constraints
|
||||
|
||||
- project:
|
||||
name: openstack/puppet-openstack_spec_helper
|
||||
templates:
|
||||
- system-required
|
||||
- puppet-openstack-libraries-jobs
|
||||
- release-notes-jobs
|
||||
|
||||
- project:
|
||||
name: openstack/puppet-openstack-specs
|
||||
templates:
|
||||
@ -19815,25 +19834,6 @@
|
||||
- release-notes-jobs
|
||||
- puppet-release-jobs
|
||||
|
||||
- project:
|
||||
name: openstack/puppet-openstack_extras
|
||||
templates:
|
||||
- system-required
|
||||
- puppet-openstack-check-jobs
|
||||
- puppet-module-unit-jobs
|
||||
- puppet-beaker-jobs
|
||||
- puppet-beaker-jobs-xenial
|
||||
- puppet-openstack-integration-jobs-all
|
||||
- release-notes-jobs
|
||||
- puppet-release-jobs
|
||||
|
||||
- project:
|
||||
name: openstack/puppet-openstack_spec_helper
|
||||
templates:
|
||||
- system-required
|
||||
- puppet-openstack-libraries-jobs
|
||||
- release-notes-jobs
|
||||
|
||||
- project:
|
||||
name: openstack/puppet-oslo
|
||||
templates:
|
||||
|
Loading…
x
Reference in New Issue
Block a user