replace validate_releases with validate_release_branch_membership

The last checks being done by validate_releases are all related to
ensuring that one release in a series is on a commit that comes after
another commit in the same series' branch. Rename the function to
reflect that.

Change-Id: I05161eb6244da0fbd0e973d046c34ee93f8fcfa0
Signed-off-by: Doug Hellmann <doug@doughellmann.com>
This commit is contained in:
Doug Hellmann 2018-02-21 20:06:09 -05:00
parent 44516f0a4d
commit f013d5b5cc
2 changed files with 145 additions and 76 deletions

View File

@ -772,22 +772,24 @@ def validate_new_releases_at_end(deliv, workdir, messages):
messages.error(msg)
def validate_releases(deliv, zuul_projects,
workdir,
messages):
"""Apply validation rules to the 'releases' list for the deliverable.
"""
header('Validate Releases')
def validate_release_branch_membership(deliv, workdir, messages):
"Commits being tagged need to be on the right branch."
header('Validate Release Branch Membership')
if deliv.is_independent:
messages.warning('skipping descendant test for '
'independent project, verify '
'branch manually')
return
prev_version = None
for release in deliv.releases:
LOG.info('checking {}'.format(release.version))
for project in release.projects:
LOG.info('{} SHA {}'.format(project.repo.name, project.hash))
if not gitutils.safe_clone_repo(workdir, project.repo.name,
project.hash, messages):
continue
@ -802,12 +804,6 @@ def validate_releases(deliv, zuul_projects,
LOG.info('Found new version {} for {}'.format(
release.version, project.repo))
if deliv.is_independent:
messages.warning('skipping descendant test for '
'independent project, verify '
'branch manually')
else:
# If this is the first version in the series,
# check that the commit is actually on the
# targeted branch.
@ -1367,12 +1363,7 @@ def main():
validate_existing_tags(deliv, workdir, messages)
validate_version_numbers(deliv, workdir, messages)
validate_new_releases_at_end(deliv, workdir, messages)
validate_releases(
deliv,
zuul_projects,
workdir,
messages,
)
validate_release_branch_membership(deliv, workdir, messages)
validate_tarball_base(deliv, workdir, messages)
# Some rules only apply to the most current release.
if deliv.series == defaults.RELEASE:

View File

@ -477,6 +477,27 @@ class TestValidateReleaseSHAExists(base.BaseTestCase):
self.assertEqual(0, len(self.msg.warnings))
self.assertEqual(1, len(self.msg.errors))
def test_no_releases(self):
# When we initialize a new series, we won't have any release
# data. That's OK.
deliv = deliverable.Deliverable(
team='team',
series='ocata',
name='name',
data={
'artifact-link-mode': 'none',
'releases': []
}
)
validate.validate_release_sha_exists(
deliv,
self.tmpdir,
self.msg,
)
self.msg.show_summary()
self.assertEqual(0, len(self.msg.warnings))
self.assertEqual(0, len(self.msg.errors))
class TestValidateExistingTags(base.BaseTestCase):
@ -538,11 +559,32 @@ class TestValidateExistingTags(base.BaseTestCase):
self.assertEqual(0, len(self.msg.warnings))
self.assertEqual(1, len(self.msg.errors))
def test_no_releases(self):
# When we initialize a new series, we won't have any release
# data. That's OK.
deliv = deliverable.Deliverable(
team='team',
series='ocata',
name='name',
data={
'artifact-link-mode': 'none',
'releases': []
}
)
validate.validate_existing_tags(
deliv,
self.tmpdir,
self.msg,
)
self.msg.show_summary()
self.assertEqual(0, len(self.msg.warnings))
self.assertEqual(0, len(self.msg.errors))
class TestValidateReleases(base.BaseTestCase):
class TestValidateReleaseBranchMembership(base.BaseTestCase):
def setUp(self):
super(TestValidateReleases, self).setUp()
super().setUp()
self.tmpdir = self.useFixture(fixtures.TempDir()).path
gitutils.clone_repo(self.tmpdir, 'openstack/release-test')
self.msg = validate.MessageCollector()
@ -565,9 +607,8 @@ class TestValidateReleases(base.BaseTestCase):
],
}
)
validate.validate_releases(
validate.validate_release_branch_membership(
deliv,
{'validate-projects-by-name': {}},
self.tmpdir,
self.msg,
)
@ -599,9 +640,8 @@ class TestValidateReleases(base.BaseTestCase):
],
}
)
validate.validate_releases(
validate.validate_release_branch_membership(
deliv,
{'validate-projects-by-name': {}},
self.tmpdir,
self.msg,
)
@ -627,9 +667,8 @@ class TestValidateReleases(base.BaseTestCase):
],
}
)
validate.validate_releases(
validate.validate_release_branch_membership(
deliv,
{'validate-projects-by-name': {}},
self.tmpdir,
self.msg,
)
@ -653,9 +692,8 @@ class TestValidateReleases(base.BaseTestCase):
],
}
)
validate.validate_releases(
validate.validate_release_branch_membership(
deliv,
{'validate-projects-by-name': {}},
self.tmpdir,
self.msg,
)
@ -688,9 +726,8 @@ class TestValidateReleases(base.BaseTestCase):
],
}
)
validate.validate_releases(
validate.validate_release_branch_membership(
deliv,
{'validate-projects-by-name': {}},
self.tmpdir,
self.msg,
)
@ -710,9 +747,8 @@ class TestValidateReleases(base.BaseTestCase):
'releases': []
}
)
validate.validate_releases(
validate.validate_release_branch_membership(
deliv,
{'validate-projects-by-name': {}},
self.tmpdir,
self.msg,
)
@ -729,6 +765,27 @@ class TestValidateNewReleasesAtEnd(base.BaseTestCase):
gitutils.clone_repo(self.tmpdir, 'openstack/release-test')
self.msg = validate.MessageCollector()
def test_no_releases(self):
# When we initialize a new series, we won't have any release
# data. That's OK.
deliv = deliverable.Deliverable(
team='team',
series='ocata',
name='name',
data={
'artifact-link-mode': 'none',
'releases': []
}
)
validate.validate_new_releases_at_end(
deliv,
self.tmpdir,
self.msg,
)
self.msg.show_summary()
self.assertEqual(0, len(self.msg.warnings))
self.assertEqual(0, len(self.msg.errors))
def test_not_at_end(self):
deliv = deliverable.Deliverable(
team='team',
@ -802,11 +859,32 @@ class TestValidateVersionNumbers(base.BaseTestCase):
self.assertEqual(0, len(self.msg.warnings))
self.assertEqual(1, len(self.msg.errors))
def test_no_releases(self):
# When we initialize a new series, we won't have any release
# data. That's OK.
deliv = deliverable.Deliverable(
team='team',
series='ocata',
name='name',
data={
'artifact-link-mode': 'none',
'releases': []
}
)
validate.validate_version_numbers(
deliv,
self.tmpdir,
self.msg,
)
self.msg.show_summary()
self.assertEqual(0, len(self.msg.warnings))
self.assertEqual(0, len(self.msg.errors))
class TestGetReleaseType(base.BaseTestCase):
def setUp(self):
super(TestGetReleaseType, self).setUp()
super().setUp()
self.tmpdir = self.useFixture(fixtures.TempDir()).path
self.msg = validate.MessageCollector()