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:
Doug Hellmann 2016-12-01 15:03:17 -05:00
parent 26b6265ef2
commit d775c650e7
4 changed files with 38 additions and 2 deletions

View File

@ -195,6 +195,14 @@ def main():
else:
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
new_release = deliverable_info['releases'][-1]

View File

@ -189,7 +189,7 @@ def validate_releases(deliverable_info, zuul_layout,
prev_version = None
prev_projects = set()
for release in deliverable_info['releases']:
for release in deliverable_info.get('releases', []):
for project in release['projects']:
@ -333,6 +333,8 @@ def validate_new_releases(deliverable_info, filename,
mk_warning, mk_error):
"""Apply validation rules that only apply to the current series.
"""
if not deliverable_info.get('releases'):
return
final_release = deliverable_info['releases'][-1]
deliverable_name = os.path.basename(filename)[:-5] # strip .yaml
expected_repos = set(

View File

@ -197,7 +197,13 @@ class DeliverableDirectiveBase(rst.Directive):
def _add_deliverables(self, type_tag, deliverables, series, app, result):
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:
# There are no deliverables of this type, and that's OK.
return

View File

@ -603,6 +603,26 @@ class TestValidateReleases(base.BaseTestCase):
self.assertEqual(0, len(warnings))
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):