Skip to content

Commit

Permalink
Merge pull request #261 from dosaboy/func-tests-support-alt-project-t…
Browse files Browse the repository at this point in the history
…emplates

Respect project templates as defined in charm
  • Loading branch information
dosaboy authored Oct 2, 2024
2 parents 53c8790 + 3795d3e commit 67ff713
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 7 deletions.
40 changes: 34 additions & 6 deletions openstack/tools/func_test_tools/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,19 +19,36 @@ def project_templates(self):
encoding='utf-8') as fd:
yield from yaml.safe_load(fd)

def get_branch_jobs(self, branch):
def get_branch_jobs(self, branch, project_templates):
"""
For a given branch name, find all jobs that need to be run against that
branch.
"""
test_jobs = []
for t in self.project_templates:
t = t['project-template']
if t['name'] == 'charm-functional-jobs':
for jobs in t['check']['jobs']:
for job, info in jobs.items():
if branch in info['branches']:
test_jobs.append(job)

# only look at functional test jobs
if 'functional' not in t['name']:
continue

if t['name'] not in project_templates:
continue

if 'check' not in t or 'jobs' not in t['check']:
continue

for jobs in t['check']['jobs']:
if not isinstance(jobs, dict):
test_jobs.append(jobs)
continue

for job, info in jobs.items():
if t['name'] == 'charm-functional-jobs':
if branch not in info['branches']:
continue

test_jobs.append(job)

return test_jobs

Expand All @@ -45,6 +62,17 @@ def __init__(self):
with open('osci.yaml', encoding='utf-8') as fd:
self._osci_config = yaml.safe_load(fd)

@property
def project_templates(self):
""" Returns all project templates. """
for item in self._osci_config:
if 'project' not in item:
continue

return item['project'].get('templates', [])

return []

@property
def project_check_jobs(self):
""" Generator returning all project check jobs defined. """
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,8 @@ def get_default_jobs():
c = configparser.ConfigParser()
c.read('.gitreview')
branch = c['gerrit']['defaultbranch']
jobs = ZOSCIConfig(path).get_branch_jobs(branch)
osci = OSCIConfig()
jobs = ZOSCIConfig(path).get_branch_jobs(branch, osci.project_templates)
return jobs


Expand Down

0 comments on commit 67ff713

Please sign in to comment.