Merge "check stable branch name against current series"

This commit is contained in:
Jenkins 2017-02-25 18:32:38 +00:00 committed by Gerrit Code Review
commit f7667c14c2
2 changed files with 46 additions and 8 deletions

View File

@ -471,7 +471,8 @@ def validate_branch_prefixes(deliverable_info, mk_waring, mk_error):
branch['name'], _VALID_BRANCH_PREFIXES)) branch['name'], _VALID_BRANCH_PREFIXES))
def validate_stable_branches(deliverable_info, mk_warning, mk_error): def validate_stable_branches(deliverable_info, series_name,
mk_warning, mk_error):
"Apply the rules for stable branches." "Apply the rules for stable branches."
if ('launchpad' in deliverable_info and if ('launchpad' in deliverable_info and
deliverable_info['launchpad'] in _NO_STABLE_BRANCH_CHECK): deliverable_info['launchpad'] in _NO_STABLE_BRANCH_CHECK):
@ -502,12 +503,20 @@ def validate_stable_branches(deliverable_info, mk_warning, mk_error):
'list of releases for this deliverable' % ( 'list of releases for this deliverable' % (
branch['location'], branch['name'])) branch['location'], branch['name']))
) )
if series not in known_series: if series_name == '_independent':
mk_error( if series not in known_series:
('stable branches must be named for known series ' mk_error(
'but %s was not found in %s' % ( ('stable branches must be named for known series '
branch['name'], known_series)) 'but %s was not found in %s' % (
) branch['name'], known_series))
)
else:
if series != series_name:
mk_error(
('cycle-based projects must match series names '
'for stable branches. %s should be stable/%s' % (
branch['name'], series_name))
)
def validate_feature_branches(deliverable_info, workdir, mk_warning, mk_error): def validate_feature_branches(deliverable_info, workdir, mk_warning, mk_error):
@ -692,6 +701,7 @@ def main():
) )
validate_stable_branches( validate_stable_branches(
deliverable_info, deliverable_info,
series_name,
mk_warning, mk_warning,
mk_error, mk_error,
) )

View File

@ -1035,6 +1035,7 @@ class TestValidateStableBranches(base.BaseTestCase):
deliverable_info = yaml.safe_load(deliverable_data) deliverable_info = yaml.safe_load(deliverable_data)
validate.validate_stable_branches( validate.validate_stable_branches(
deliverable_info, deliverable_info,
'ocata',
warnings.append, warnings.append,
errors.append, errors.append,
) )
@ -1057,13 +1058,14 @@ class TestValidateStableBranches(base.BaseTestCase):
deliverable_info = yaml.safe_load(deliverable_data) deliverable_info = yaml.safe_load(deliverable_data)
validate.validate_stable_branches( validate.validate_stable_branches(
deliverable_info, deliverable_info,
'ocata',
warnings.append, warnings.append,
errors.append, errors.append,
) )
self.assertEqual(0, len(warnings)) self.assertEqual(0, len(warnings))
self.assertEqual(1, len(errors)) self.assertEqual(1, len(errors))
def test_unknown_series(self): def test_unknown_series_cycle(self):
deliverable_data = textwrap.dedent(''' deliverable_data = textwrap.dedent('''
releases: releases:
- version: 1.5.0 - version: 1.5.0
@ -1079,6 +1081,31 @@ class TestValidateStableBranches(base.BaseTestCase):
deliverable_info = yaml.safe_load(deliverable_data) deliverable_info = yaml.safe_load(deliverable_data)
validate.validate_stable_branches( validate.validate_stable_branches(
deliverable_info, deliverable_info,
'ocata',
warnings.append,
errors.append,
)
print(warnings, errors)
self.assertEqual(0, len(warnings))
self.assertEqual(1, len(errors))
def test_unknown_series_independent(self):
deliverable_data = textwrap.dedent('''
releases:
- version: 1.5.0
projects:
- repo: openstack/automaton
hash: be2885f544637e6ee6139df7dc7bf937925804dd
branches:
- name: stable/abc
location: 1.5.0
''')
warnings = []
errors = []
deliverable_info = yaml.safe_load(deliverable_data)
validate.validate_stable_branches(
deliverable_info,
'_independent',
warnings.append, warnings.append,
errors.append, errors.append,
) )
@ -1103,6 +1130,7 @@ class TestValidateStableBranches(base.BaseTestCase):
deliverable_info = yaml.safe_load(deliverable_data) deliverable_info = yaml.safe_load(deliverable_data)
validate.validate_stable_branches( validate.validate_stable_branches(
deliverable_info, deliverable_info,
'_independent',
warnings.append, warnings.append,
errors.append, errors.append,
) )