use deliverable model objects to validate feature branches
Change-Id: I2ba56e28d5849bdea033165be091cfc0340da1d6 Signed-off-by: Doug Hellmann <doug@doughellmann.com>
This commit is contained in:
@@ -963,51 +963,51 @@ def validate_stable_branches(deliv, workdir, series_name, messages):
|
||||
)
|
||||
|
||||
|
||||
def validate_feature_branches(deliverable_info,
|
||||
deliverable_name,
|
||||
workdir,
|
||||
messages):
|
||||
def validate_feature_branches(deliv, workdir, messages):
|
||||
"Apply the rules for feature branches."
|
||||
header('Validate Feature Branches')
|
||||
branches = deliverable_info.get('branches', [])
|
||||
|
||||
d_type = _guess_deliverable_type(deliverable_name, deliverable_info)
|
||||
if d_type == 'tempest-plugin' and branches:
|
||||
if deliv.type == 'tempest-plugin' and deliv.branches:
|
||||
messages.error('Tempest plugins do not support branching.')
|
||||
return
|
||||
|
||||
for branch in branches:
|
||||
for branch in deliv.branches:
|
||||
try:
|
||||
prefix, series = branch['name'].split('/')
|
||||
prefix, series = branch.name.split('/')
|
||||
except ValueError:
|
||||
messages.error(
|
||||
('feature branch name expected to be feature/name '
|
||||
'but got %s') % (branch['name'],))
|
||||
'but got %s') % (branch.name,))
|
||||
continue
|
||||
if prefix != 'feature':
|
||||
LOG.debug('{} is not a feature branch, skipping'.format(
|
||||
branch.name))
|
||||
continue
|
||||
location = branch['location']
|
||||
|
||||
location = branch.location
|
||||
|
||||
if not isinstance(location, dict):
|
||||
messages.error(
|
||||
('branch location for %s is '
|
||||
'expected to be a mapping but got a %s' % (
|
||||
branch['name'], type(location)))
|
||||
branch.name, type(location)))
|
||||
)
|
||||
# The other rules aren't going to be testable, so skip them.
|
||||
continue
|
||||
|
||||
for repo, loc in sorted(location.items()):
|
||||
if not is_a_hash(loc):
|
||||
messages.error(
|
||||
('feature branches should be created from commits by SHA '
|
||||
'but location %s for branch %s of %s does not look '
|
||||
'like a SHA' % (
|
||||
(loc, repo, branch['name'])))
|
||||
(loc, repo, branch.name)))
|
||||
)
|
||||
if not gitutils.commit_exists(workdir, repo, loc):
|
||||
messages.error(
|
||||
('feature branches should be created from merged commits '
|
||||
'but location %s for branch %s of %s does not exist' % (
|
||||
(loc, repo, branch['name'])))
|
||||
(loc, repo, branch.name)))
|
||||
)
|
||||
|
||||
|
||||
@@ -1336,8 +1336,7 @@ def main():
|
||||
messages,
|
||||
)
|
||||
validate_feature_branches(
|
||||
deliv._data,
|
||||
deliv.name,
|
||||
deliv,
|
||||
workdir,
|
||||
messages,
|
||||
)
|
||||
|
||||
@@ -1851,10 +1851,14 @@ class TestValidateFeatureBranches(base.BaseTestCase):
|
||||
- name: feature/abc
|
||||
location: 0.0.3
|
||||
''')
|
||||
deliverable_info = yamlutils.loads(deliverable_data)
|
||||
deliv = deliverable.Deliverable(
|
||||
team='team',
|
||||
series='ocata',
|
||||
name='release-test',
|
||||
data=yamlutils.loads(deliverable_data),
|
||||
)
|
||||
validate.validate_feature_branches(
|
||||
deliverable_info,
|
||||
'name',
|
||||
deliv,
|
||||
self.tmpdir,
|
||||
self.msg,
|
||||
)
|
||||
@@ -1874,10 +1878,14 @@ class TestValidateFeatureBranches(base.BaseTestCase):
|
||||
location:
|
||||
openstack/release-test: 0.0.3
|
||||
''')
|
||||
deliverable_info = yamlutils.loads(deliverable_data)
|
||||
deliv = deliverable.Deliverable(
|
||||
team='team',
|
||||
series='ocata',
|
||||
name='release-test',
|
||||
data=yamlutils.loads(deliverable_data),
|
||||
)
|
||||
validate.validate_feature_branches(
|
||||
deliverable_info,
|
||||
'name',
|
||||
deliv,
|
||||
self.tmpdir,
|
||||
self.msg,
|
||||
)
|
||||
@@ -1897,10 +1905,14 @@ class TestValidateFeatureBranches(base.BaseTestCase):
|
||||
location:
|
||||
openstack/release-test: 0cd17d1ee3b9284d36b2a0d370b49a6f0bbb9660
|
||||
''')
|
||||
deliverable_info = yamlutils.loads(deliverable_data)
|
||||
deliv = deliverable.Deliverable(
|
||||
team='team',
|
||||
series='ocata',
|
||||
name='release-test',
|
||||
data=yamlutils.loads(deliverable_data),
|
||||
)
|
||||
validate.validate_feature_branches(
|
||||
deliverable_info,
|
||||
'name',
|
||||
deliv,
|
||||
self.tmpdir,
|
||||
self.msg,
|
||||
)
|
||||
@@ -1920,10 +1932,14 @@ class TestValidateFeatureBranches(base.BaseTestCase):
|
||||
location:
|
||||
openstack/release-test: 0cd17d1ee3b9284d36b2a0d370b49a6f0bbb9660
|
||||
''')
|
||||
deliverable_info = yamlutils.loads(deliverable_data)
|
||||
deliv = deliverable.Deliverable(
|
||||
team='team',
|
||||
series='ocata',
|
||||
name='release-test',
|
||||
data=yamlutils.loads(deliverable_data),
|
||||
)
|
||||
validate.validate_feature_branches(
|
||||
deliverable_info,
|
||||
'name',
|
||||
deliv,
|
||||
self.tmpdir,
|
||||
self.msg,
|
||||
)
|
||||
@@ -1943,10 +1959,14 @@ class TestValidateFeatureBranches(base.BaseTestCase):
|
||||
location:
|
||||
openstack/release-test: de2885f544637e6ee6139df7dc7bf937925804dd
|
||||
''')
|
||||
deliverable_info = yamlutils.loads(deliverable_data)
|
||||
deliv = deliverable.Deliverable(
|
||||
team='team',
|
||||
series='ocata',
|
||||
name='release-test',
|
||||
data=yamlutils.loads(deliverable_data),
|
||||
)
|
||||
validate.validate_feature_branches(
|
||||
deliverable_info,
|
||||
'name',
|
||||
deliv,
|
||||
self.tmpdir,
|
||||
self.msg,
|
||||
)
|
||||
@@ -1967,10 +1987,14 @@ class TestValidateFeatureBranches(base.BaseTestCase):
|
||||
location:
|
||||
openstack/release-test: 0cd17d1ee3b9284d36b2a0d370b49a6f0bbb9660
|
||||
''')
|
||||
deliverable_info = yamlutils.loads(deliverable_data)
|
||||
deliv = deliverable.Deliverable(
|
||||
team='team',
|
||||
series='ocata',
|
||||
name='release-test',
|
||||
data=yamlutils.loads(deliverable_data),
|
||||
)
|
||||
validate.validate_feature_branches(
|
||||
deliverable_info,
|
||||
'name',
|
||||
deliv,
|
||||
self.tmpdir,
|
||||
self.msg,
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user