Update project-config validation
Zuul v2 is gone so we should validate the Zuul v3 configuration instead. Change-Id: Ia19b13d00f5f2e12c4d7ab99a0b110aaaa868376
This commit is contained in:
parent
552e917215
commit
19ee6e2b47
@ -39,7 +39,7 @@ def main():
|
|||||||
)
|
)
|
||||||
args = parser.parse_args()
|
args = parser.parse_args()
|
||||||
|
|
||||||
zuul_layout = project_config.get_zuul_layout_data()
|
zuul_projects = project_config.get_zuul_projects_data()
|
||||||
|
|
||||||
error_count = 0
|
error_count = 0
|
||||||
|
|
||||||
@ -52,7 +52,7 @@ def main():
|
|||||||
if repo in _BLACKLIST:
|
if repo in _BLACKLIST:
|
||||||
continue
|
continue
|
||||||
pe = project_config.require_check_requirements_for_repo(
|
pe = project_config.require_check_requirements_for_repo(
|
||||||
zuul_layout, repo)
|
zuul_projects, repo)
|
||||||
for e in pe:
|
for e in pe:
|
||||||
print(e)
|
print(e)
|
||||||
error_count += 1
|
error_count += 1
|
||||||
|
@ -17,17 +17,12 @@ import requests
|
|||||||
import yaml
|
import yaml
|
||||||
|
|
||||||
|
|
||||||
ZUUL_LAYOUT_URL = 'http://git.openstack.org/cgit/openstack-infra/project-config/plain/zuul/layout.yaml' # noqa
|
ZUUL_PROJECTS_URL = 'https://git.openstack.org/cgit/openstack-infra/project-config/plain/zuul.d/projects.yaml' # noqa
|
||||||
ZUUL_LAYOUT_FILENAME = 'openstack-infra/project-config/zuul/layout.yaml'
|
ZUUL_PROJECTS_FILENAME = 'openstack-infra/project-config/zuul.d/projects.yaml'
|
||||||
|
|
||||||
# We use this key to modify the data structure read from the zuul
|
|
||||||
# layout file. We don't control what are valid keys there, so make it
|
|
||||||
# easy to change the key we use, just in case.
|
|
||||||
_VALIDATE_KEY = 'validate-projects-by-name'
|
|
||||||
|
|
||||||
|
|
||||||
def get_zuul_layout_data(url=ZUUL_LAYOUT_URL):
|
def get_zuul_projects_data(url=ZUUL_PROJECTS_URL):
|
||||||
"""Return the parsed data structure for the zuul/layout.yaml file.
|
"""Return the parsed data structure for the zuul.d/projects.yaml file.
|
||||||
|
|
||||||
:param url: Optional URL to the location of the file. Defaults to
|
:param url: Optional URL to the location of the file. Defaults to
|
||||||
the most current version in the public git repository.
|
the most current version in the public git repository.
|
||||||
@ -37,14 +32,14 @@ def get_zuul_layout_data(url=ZUUL_LAYOUT_URL):
|
|||||||
raw = yaml.safe_load(r.text)
|
raw = yaml.safe_load(r.text)
|
||||||
# Add a mapping from repo name to repo settings, since that is how
|
# Add a mapping from repo name to repo settings, since that is how
|
||||||
# we access this most often.
|
# we access this most often.
|
||||||
raw[_VALIDATE_KEY] = {
|
projects = {
|
||||||
p['name']: p
|
p['project']['name']: p['project']
|
||||||
for p in raw['projects']
|
for p in raw
|
||||||
}
|
}
|
||||||
return raw
|
return projects
|
||||||
|
|
||||||
|
|
||||||
def require_check_requirements_for_repo(zuul_layout, repo):
|
def require_check_requirements_for_repo(zuul_projects, repo):
|
||||||
"""Check the repository for the jobs related to requirements.
|
"""Check the repository for the jobs related to requirements.
|
||||||
|
|
||||||
Returns a list of error messages.
|
Returns a list of error messages.
|
||||||
@ -52,22 +47,19 @@ def require_check_requirements_for_repo(zuul_layout, repo):
|
|||||||
"""
|
"""
|
||||||
errors = []
|
errors = []
|
||||||
|
|
||||||
if repo not in zuul_layout[_VALIDATE_KEY]:
|
if repo not in zuul_projects:
|
||||||
errors.append(
|
errors.append(
|
||||||
('did not find %s in %s' % (repo, ZUUL_LAYOUT_FILENAME),
|
('did not find %s in %s' % (repo, ZUUL_PROJECTS_FILENAME),
|
||||||
True)
|
True)
|
||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
p = zuul_layout[_VALIDATE_KEY][repo]
|
p = zuul_projects[repo]
|
||||||
templates = [
|
templates = p.get('templates', [])
|
||||||
t['name']
|
|
||||||
for t in p.get('template', [])
|
|
||||||
]
|
|
||||||
# NOTE(dhellmann): We don't mess around looking for individual
|
# NOTE(dhellmann): We don't mess around looking for individual
|
||||||
# jobs, because we want projects to use the templates.
|
# jobs, because we want projects to use the templates.
|
||||||
if 'check-requirements' not in templates:
|
if 'check-requirements' not in templates:
|
||||||
errors.append(
|
errors.append(
|
||||||
'%s no check-requirements job specified for %s'
|
'%s no check-requirements job specified for %s'
|
||||||
% (ZUUL_LAYOUT_FILENAME, repo)
|
% (ZUUL_PROJECTS_FILENAME, repo)
|
||||||
)
|
)
|
||||||
return errors
|
return errors
|
||||||
|
Loading…
x
Reference in New Issue
Block a user