allow deliverable files without any releases
When we initialize a new series, we will have deliverable files without any releases, yet. Ensure the validation, list-changes, and sphinx extension code works in that case. Change-Id: I724c2f77dac8c38e7145c00fc37a27d2078f9e69 Signed-off-by: Doug Hellmann <doug@doughellmann.com>
This commit is contained in:
@@ -195,6 +195,14 @@ def main():
|
|||||||
else:
|
else:
|
||||||
branch = 'stable/' + series
|
branch = 'stable/' + series
|
||||||
|
|
||||||
|
# If there are no releases listed, this is probably a new
|
||||||
|
# deliverable file for initializing a new series. We don't
|
||||||
|
# need to list its changes.
|
||||||
|
if not deliverable_info.get('releases'):
|
||||||
|
header('No releases')
|
||||||
|
print('no releases were found, assuming an initialization file')
|
||||||
|
continue
|
||||||
|
|
||||||
# assume the releases are in order and take the last one
|
# assume the releases are in order and take the last one
|
||||||
new_release = deliverable_info['releases'][-1]
|
new_release = deliverable_info['releases'][-1]
|
||||||
|
|
||||||
|
|||||||
@@ -189,7 +189,7 @@ def validate_releases(deliverable_info, zuul_layout,
|
|||||||
|
|
||||||
prev_version = None
|
prev_version = None
|
||||||
prev_projects = set()
|
prev_projects = set()
|
||||||
for release in deliverable_info['releases']:
|
for release in deliverable_info.get('releases', []):
|
||||||
|
|
||||||
for project in release['projects']:
|
for project in release['projects']:
|
||||||
|
|
||||||
@@ -333,6 +333,8 @@ def validate_new_releases(deliverable_info, filename,
|
|||||||
mk_warning, mk_error):
|
mk_warning, mk_error):
|
||||||
"""Apply validation rules that only apply to the current series.
|
"""Apply validation rules that only apply to the current series.
|
||||||
"""
|
"""
|
||||||
|
if not deliverable_info.get('releases'):
|
||||||
|
return
|
||||||
final_release = deliverable_info['releases'][-1]
|
final_release = deliverable_info['releases'][-1]
|
||||||
deliverable_name = os.path.basename(filename)[:-5] # strip .yaml
|
deliverable_name = os.path.basename(filename)[:-5] # strip .yaml
|
||||||
expected_repos = set(
|
expected_repos = set(
|
||||||
|
|||||||
@@ -197,7 +197,13 @@ class DeliverableDirectiveBase(rst.Directive):
|
|||||||
def _add_deliverables(self, type_tag, deliverables, series, app, result):
|
def _add_deliverables(self, type_tag, deliverables, series, app, result):
|
||||||
source_name = '<' + __name__ + '>'
|
source_name = '<' + __name__ + '>'
|
||||||
|
|
||||||
deliverables = list(deliverables) # expand any generators passed in
|
# expand any generators passed in and filter out deliverables
|
||||||
|
# with no releases
|
||||||
|
deliverables = list(
|
||||||
|
d
|
||||||
|
for d in deliverables
|
||||||
|
if d[1].get('releases')
|
||||||
|
)
|
||||||
if not deliverables:
|
if not deliverables:
|
||||||
# There are no deliverables of this type, and that's OK.
|
# There are no deliverables of this type, and that's OK.
|
||||||
return
|
return
|
||||||
|
|||||||
@@ -603,6 +603,26 @@ class TestValidateReleases(base.BaseTestCase):
|
|||||||
self.assertEqual(0, len(warnings))
|
self.assertEqual(0, len(warnings))
|
||||||
self.assertEqual(1, len(errors))
|
self.assertEqual(1, len(errors))
|
||||||
|
|
||||||
|
def test_no_releases(self):
|
||||||
|
# When we initialize a new series, we won't have any release
|
||||||
|
# data. That's OK.
|
||||||
|
deliverable_info = {
|
||||||
|
'artifact-link-mode': 'none',
|
||||||
|
'releases': []
|
||||||
|
}
|
||||||
|
warnings = []
|
||||||
|
errors = []
|
||||||
|
validate.validate_releases(
|
||||||
|
deliverable_info,
|
||||||
|
{'validate-projects-by-name': {}},
|
||||||
|
'ocata',
|
||||||
|
self.tmpdir,
|
||||||
|
warnings.append,
|
||||||
|
errors.append,
|
||||||
|
)
|
||||||
|
self.assertEqual(0, len(warnings))
|
||||||
|
self.assertEqual(0, len(errors))
|
||||||
|
|
||||||
|
|
||||||
class TestValidateNewReleases(base.BaseTestCase):
|
class TestValidateNewReleases(base.BaseTestCase):
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user