Ensure that gerrit projects have zuul pipelines
Add a layout check to find projects added to gerrit but not zuul, and vice versa. We can ignore gerrit projects with a read-only state since they are not under active development. We can also ignore the z/tempest zuul pipeline since it is a meta-pipeline not tied to a specific project. Change-Id: I1da184ecc0268689081c1795b8ee741b41d80d45
This commit is contained in:
committed by
Andreas Jaeger
parent
365add6fa3
commit
7e427a4ac1
+65
-2
@@ -15,6 +15,7 @@
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
import ConfigParser
|
||||
import copy
|
||||
import os
|
||||
import re
|
||||
@@ -22,8 +23,14 @@ import sys
|
||||
|
||||
import yaml
|
||||
|
||||
layout = yaml.load(open('zuul/layout.yaml'))
|
||||
|
||||
layout_yaml = 'zuul/layout.yaml'
|
||||
layout = yaml.safe_load(open(layout_yaml))
|
||||
|
||||
gerrit_yaml = 'gerrit/projects.yaml'
|
||||
gerrit_config = yaml.safe_load(open(gerrit_yaml))
|
||||
|
||||
gerrit_acl_pattern = 'gerrit/acls/%s.config'
|
||||
|
||||
def check_merge_template():
|
||||
"""Check that each job has a merge-check template."""
|
||||
@@ -108,7 +115,7 @@ def check_jobs():
|
||||
"""Check that jobs have matches"""
|
||||
errors = False
|
||||
|
||||
print("Checking job section regex expressions")
|
||||
print("\nChecking job section regex expressions")
|
||||
print("======================================")
|
||||
|
||||
# The job-list.txt file is created by tools/run-layout.sh and
|
||||
@@ -208,6 +215,61 @@ def check_mixed_noops():
|
||||
return False
|
||||
|
||||
|
||||
def check_gerrit_zuul_projects():
|
||||
'''Check that gerrit projects have zuul pipelines and vice versa'''
|
||||
errors = False
|
||||
|
||||
zuul_projects = [ x['name'] for x in layout['projects'] ]
|
||||
gerrit_projects = [ x['project'] for x in gerrit_config ]
|
||||
|
||||
print("\nChecking for gerrit projects with no zuul pipelines")
|
||||
print("===================================================")
|
||||
|
||||
for gp in gerrit_projects:
|
||||
|
||||
# Check the gerrit config for a different acl file
|
||||
acls = [ x['acl-config'] if 'acl-config' in x else None \
|
||||
for x in gerrit_config if x['project'] == gp ]
|
||||
if len(acls) != 1:
|
||||
errors = True
|
||||
print("Duplicate acl config for %s" % gp)
|
||||
break
|
||||
|
||||
acl_config = acls.pop()
|
||||
if acl_config is None:
|
||||
acl_file = gerrit_acl_pattern % gp
|
||||
else:
|
||||
acl_file = acl_config.replace('/home/gerrit2/acls', 'gerrit/acls')
|
||||
|
||||
config = ConfigParser.ConfigParser()
|
||||
config.read(acl_file)
|
||||
|
||||
try:
|
||||
ignore = config.get('project', 'state') == 'read only'
|
||||
if ignore:
|
||||
continue # Skip inactive projects
|
||||
except ConfigParser.NoSectionError:
|
||||
pass
|
||||
|
||||
if gp not in zuul_projects:
|
||||
print("Project %s is not in %s" % (gp, layout_yaml))
|
||||
errors = True
|
||||
|
||||
print("\nChecking for zuul pipelines with no gerrit project")
|
||||
print("===================================================")
|
||||
|
||||
for zp in zuul_projects:
|
||||
if zp == 'z/tempest':
|
||||
continue # Ignore z/tempest
|
||||
|
||||
if zp not in gerrit_projects:
|
||||
print("Project %s is not in %s" % (zp, gerrit_yaml))
|
||||
errors = True
|
||||
|
||||
return errors
|
||||
|
||||
|
||||
|
||||
def check_all():
|
||||
errors = check_projects_sorted()
|
||||
errors = check_merge_template() or errors
|
||||
@@ -215,6 +277,7 @@ def check_all():
|
||||
errors = check_empty_check() or errors
|
||||
errors = check_empty_gate() or errors
|
||||
errors = check_mixed_noops() or errors
|
||||
errors = check_gerrit_zuul_projects() or errors
|
||||
errors = check_jobs() or errors
|
||||
|
||||
if errors:
|
||||
|
||||
Reference in New Issue
Block a user