implicitly set type to tempest-plugin based on the name

When the name looks like the repo contains a tempest plugin, set the
type accordingly.

Change-Id: I2e40f85a2c0047825ef07080cb491bacb86e8409
Signed-off-by: Doug Hellmann <doug@doughellmann.com>
This commit is contained in:
Doug Hellmann 2018-02-06 14:22:21 -05:00
parent 84dce327eb
commit 6c3be826ad
2 changed files with 90 additions and 12 deletions

View File

@ -693,7 +693,7 @@ def validate_releases(deliverable_info, zuul_projects,
mk_error(msg)
def validate_new_releases(deliverable_info, filename,
def validate_new_releases(deliverable_info, deliverable_name,
team_data,
mk_warning, mk_error):
@ -702,7 +702,6 @@ def validate_new_releases(deliverable_info, filename,
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(
r.name
for r in governance.get_repositories(
@ -741,7 +740,17 @@ def validate_branch_prefixes(deliverable_info, mk_waring, mk_error):
branch['name'], _VALID_BRANCH_PREFIXES))
def validate_stable_branches(deliverable_info, workdir,
def _guess_deliverable_type(deliverable_name, deliverable_info):
if 'tempest-plugin' in deliverable_name:
return 'tempest-plugin'
if 'type' in deliverable_info:
return deliverable_info['type']
return 'other'
def validate_stable_branches(deliverable_info,
deliverable_name,
workdir,
series_name,
mk_warning, mk_error):
"Apply the rules for stable branches."
@ -751,7 +760,8 @@ def validate_stable_branches(deliverable_info, workdir,
branches = deliverable_info.get('branches', [])
if deliverable_info.get('type', 'other') == 'tempest-plugin' and branches:
d_type = _guess_deliverable_type(deliverable_name, deliverable_info)
if d_type == 'tempest-plugin' and branches:
mk_error('Tempest plugins do not support branching.')
return
@ -857,11 +867,15 @@ def validate_stable_branches(deliverable_info, workdir,
)
def validate_feature_branches(deliverable_info, workdir, mk_warning, mk_error):
def validate_feature_branches(deliverable_info,
deliverable_name,
workdir,
mk_warning, mk_error):
"Apply the rules for feature branches."
branches = deliverable_info.get('branches', [])
if deliverable_info.get('type', 'other') == 'tempest-plugin' and branches:
d_type = _guess_deliverable_type(deliverable_name, deliverable_info)
if d_type == 'tempest-plugin' and branches:
mk_error('Tempest plugins do not support branching.')
return
@ -901,7 +915,10 @@ def validate_feature_branches(deliverable_info, workdir, mk_warning, mk_error):
_require_gitreview(workdir, repo, mk_error)
def validate_driverfixes_branches(deliverable_info, workdir, mk_warning, mk_error):
def validate_driverfixes_branches(deliverable_info,
deliverable_name,
workdir,
mk_warning, mk_error):
"Apply the rules for driverfixes branches."
known_series = sorted(list(
d for d in os.listdir('deliverables')
@ -909,7 +926,8 @@ def validate_driverfixes_branches(deliverable_info, workdir, mk_warning, mk_erro
))
branches = deliverable_info.get('branches', [])
if deliverable_info.get('type', 'other') == 'tempest-plugin' and branches:
d_type = _guess_deliverable_type(deliverable_name, deliverable_info)
if d_type == 'tempest-plugin' and branches:
mk_error('Tempest plugins do not support branching.')
return
@ -1032,6 +1050,7 @@ def main():
series_name = os.path.basename(
os.path.dirname(filename)
)
deliverable_name = os.path.basename(filename)[:-5] # strip .yaml
if series_name in _CLOSED_SERIES:
continue
@ -1074,7 +1093,7 @@ def main():
if series_name == defaults.RELEASE:
validate_new_releases(
deliverable_info,
filename,
deliverable_name,
team_data,
mk_warning,
mk_error,
@ -1099,6 +1118,7 @@ def main():
)
validate_stable_branches(
deliverable_info,
deliverable_name,
workdir,
series_name,
mk_warning,
@ -1106,12 +1126,14 @@ def main():
)
validate_feature_branches(
deliverable_info,
deliverable_name,
workdir,
mk_warning,
mk_error,
)
validate_driverfixes_branches(
deliverable_info,
deliverable_name,
workdir,
mk_warning,
mk_error,

View File

@ -1215,7 +1215,7 @@ class TestValidateNewReleases(base.BaseTestCase):
errors = []
validate.validate_new_releases(
deliverable_info,
'release-test.yaml',
'release-test',
self.team_data,
warnings.append,
errors.append,
@ -1242,7 +1242,7 @@ class TestValidateNewReleases(base.BaseTestCase):
errors = []
validate.validate_new_releases(
deliverable_info,
'release-test.yaml',
'release-test',
self.team_data,
warnings.append,
errors.append,
@ -1263,11 +1263,12 @@ class TestValidateNewReleases(base.BaseTestCase):
errors = []
validate.validate_new_releases(
deliverable_info,
'release-test.yaml',
'release-test',
self.team_data,
warnings.append,
errors.append,
)
print(warnings, errors)
self.assertEqual(1, len(warnings))
self.assertEqual(0, len(errors))
@ -1331,6 +1332,7 @@ class TestValidateStableBranches(base.BaseTestCase):
deliverable_info = yamlutils.loads(deliverable_data)
validate.validate_stable_branches(
deliverable_info,
'name',
self.tmpdir,
'ocata',
warnings.append,
@ -1355,6 +1357,7 @@ class TestValidateStableBranches(base.BaseTestCase):
deliverable_info = yamlutils.loads(deliverable_data)
validate.validate_stable_branches(
deliverable_info,
'name',
self.tmpdir,
'ocata',
warnings.append,
@ -1379,6 +1382,7 @@ class TestValidateStableBranches(base.BaseTestCase):
deliverable_info = yamlutils.loads(deliverable_data)
validate.validate_stable_branches(
deliverable_info,
'name',
self.tmpdir,
'ocata',
warnings.append,
@ -1403,6 +1407,7 @@ class TestValidateStableBranches(base.BaseTestCase):
deliverable_info = yamlutils.loads(deliverable_data)
validate.validate_stable_branches(
deliverable_info,
'name',
self.tmpdir,
'ocata',
warnings.append,
@ -1428,6 +1433,7 @@ class TestValidateStableBranches(base.BaseTestCase):
deliverable_info = yamlutils.loads(deliverable_data)
validate.validate_stable_branches(
deliverable_info,
'name',
self.tmpdir,
'_independent',
warnings.append,
@ -1456,6 +1462,7 @@ class TestValidateStableBranches(base.BaseTestCase):
deliverable_info = yamlutils.loads(deliverable_data)
validate.validate_stable_branches(
deliverable_info,
'name',
self.tmpdir,
'_independent',
warnings.append,
@ -1482,6 +1489,7 @@ class TestValidateStableBranches(base.BaseTestCase):
deliverable_info = yamlutils.loads(deliverable_data)
validate.validate_stable_branches(
deliverable_info,
'name',
self.tmpdir,
'ocata',
warnings.append,
@ -1507,6 +1515,7 @@ class TestValidateStableBranches(base.BaseTestCase):
deliverable_info = yamlutils.loads(deliverable_data)
validate.validate_stable_branches(
deliverable_info,
'name',
self.tmpdir,
'ocata',
warnings.append,
@ -1532,6 +1541,7 @@ class TestValidateStableBranches(base.BaseTestCase):
deliverable_info = yamlutils.loads(deliverable_data)
validate.validate_stable_branches(
deliverable_info,
'name',
self.tmpdir,
'ocata',
warnings.append,
@ -1558,6 +1568,7 @@ class TestValidateStableBranches(base.BaseTestCase):
deliverable_info = yamlutils.loads(deliverable_data)
validate.validate_stable_branches(
deliverable_info,
'name',
self.tmpdir,
'ocata',
warnings.append,
@ -1584,6 +1595,7 @@ class TestValidateStableBranches(base.BaseTestCase):
deliverable_info = yamlutils.loads(deliverable_data)
validate.validate_stable_branches(
deliverable_info,
'name',
self.tmpdir,
'ocata',
warnings.append,
@ -1610,6 +1622,7 @@ class TestValidateStableBranches(base.BaseTestCase):
deliverable_info = yamlutils.loads(deliverable_data)
validate.validate_stable_branches(
deliverable_info,
'name',
self.tmpdir,
'ocata',
warnings.append,
@ -1642,6 +1655,7 @@ class TestValidateFeatureBranches(base.BaseTestCase):
deliverable_info = yamlutils.loads(deliverable_data)
validate.validate_feature_branches(
deliverable_info,
'name',
self.tmpdir,
warnings.append,
errors.append,
@ -1667,6 +1681,7 @@ class TestValidateFeatureBranches(base.BaseTestCase):
deliverable_info = yamlutils.loads(deliverable_data)
validate.validate_feature_branches(
deliverable_info,
'name',
self.tmpdir,
warnings.append,
errors.append,
@ -1692,6 +1707,7 @@ class TestValidateFeatureBranches(base.BaseTestCase):
deliverable_info = yamlutils.loads(deliverable_data)
validate.validate_feature_branches(
deliverable_info,
'name',
self.tmpdir,
warnings.append,
errors.append,
@ -1717,6 +1733,7 @@ class TestValidateFeatureBranches(base.BaseTestCase):
deliverable_info = yamlutils.loads(deliverable_data)
validate.validate_feature_branches(
deliverable_info,
'name',
self.tmpdir,
warnings.append,
errors.append,
@ -1742,6 +1759,7 @@ class TestValidateFeatureBranches(base.BaseTestCase):
deliverable_info = yamlutils.loads(deliverable_data)
validate.validate_feature_branches(
deliverable_info,
'name',
self.tmpdir,
warnings.append,
errors.append,
@ -1768,6 +1786,7 @@ class TestValidateFeatureBranches(base.BaseTestCase):
deliverable_info = yamlutils.loads(deliverable_data)
validate.validate_feature_branches(
deliverable_info,
'name',
self.tmpdir,
warnings.append,
errors.append,
@ -1801,6 +1820,7 @@ class TestValidateDriverfixesBranches(base.BaseTestCase):
deliverable_info = yamlutils.loads(deliverable_data)
validate.validate_driverfixes_branches(
deliverable_info,
'name',
self.tmpdir,
warnings.append,
errors.append,
@ -1825,6 +1845,7 @@ class TestValidateDriverfixesBranches(base.BaseTestCase):
deliverable_info = yamlutils.loads(deliverable_data)
validate.validate_driverfixes_branches(
deliverable_info,
'name',
self.tmpdir,
warnings.append,
errors.append,
@ -1850,6 +1871,7 @@ class TestValidateDriverfixesBranches(base.BaseTestCase):
deliverable_info = yamlutils.loads(deliverable_data)
validate.validate_driverfixes_branches(
deliverable_info,
'name',
self.tmpdir,
warnings.append,
errors.append,
@ -1875,6 +1897,7 @@ class TestValidateDriverfixesBranches(base.BaseTestCase):
deliverable_info = yamlutils.loads(deliverable_data)
validate.validate_driverfixes_branches(
deliverable_info,
'name',
self.tmpdir,
warnings.append,
errors.append,
@ -1900,6 +1923,7 @@ class TestValidateDriverfixesBranches(base.BaseTestCase):
deliverable_info = yamlutils.loads(deliverable_data)
validate.validate_driverfixes_branches(
deliverable_info,
'name',
self.tmpdir,
warnings.append,
errors.append,
@ -1925,6 +1949,7 @@ class TestValidateDriverfixesBranches(base.BaseTestCase):
deliverable_info = yamlutils.loads(deliverable_data)
validate.validate_driverfixes_branches(
deliverable_info,
'name',
self.tmpdir,
warnings.append,
errors.append,
@ -1951,6 +1976,7 @@ class TestValidateDriverfixesBranches(base.BaseTestCase):
deliverable_info = yamlutils.loads(deliverable_data)
validate.validate_driverfixes_branches(
deliverable_info,
'name',
self.tmpdir,
warnings.append,
errors.append,
@ -2260,3 +2286,33 @@ class TestValidateSeriesFirst(base.BaseTestCase):
print(warnings, errors)
self.assertEqual(0, len(warnings))
self.assertEqual(0, len(errors))
class TestGuessDeliverableType(base.BaseTestCase):
def test_explicit(self):
self.assertEqual(
'the-type',
validate._guess_deliverable_type(
'name',
{'type': 'the-type'},
),
)
def test_implicit_tempest_plugin(self):
self.assertEqual(
'tempest-plugin',
validate._guess_deliverable_type(
'foo-tempest-plugin',
{},
),
)
def test_default_other(self):
self.assertEqual(
'other',
validate._guess_deliverable_type(
'name',
{},
),
)