Make sure -em tag is on last release

We don't want to allow tagging EM if there were no releases. We also
want to make sure the -em tag is on the last official release that was
done.

Change-Id: I7afb3a52cf2ec47d8e0154b51825b500806aa590
Signed-off-by: Sean McGinnis <sean.mcginnis@gmail.com>
This commit is contained in:
Sean McGinnis 2020-03-06 17:08:09 -06:00
parent 4ed0d612f0
commit 05f5aed7fa
No known key found for this signature in database
GPG Key ID: CE7EE4BFAF8D70C8
3 changed files with 131 additions and 2 deletions

View File

@ -430,7 +430,7 @@ def validate_series_eol(deliv, context):
@skip_existing_tags
@applies_to_released
def validate_series_em(deliv, context):
"The EM tag should be applied to the previous release."
"""The EM tag should be applied to the previous release."""
current_release = deliv.releases[-1]
@ -439,6 +439,13 @@ def validate_series_em(deliv, context):
'a series as extended-maintenance')
return
if len(deliv.releases) == 1:
context.error('at least one release will have to been done to '
'mark as extended-maintenance')
print('This deliverable may need to be cleaned up if a '
'release was not actually done for the series.')
return
_require_tag_on_all_repos(
deliv,
current_release,
@ -446,6 +453,23 @@ def validate_series_em(deliv, context):
context,
)
# Make sure we are taking the last release
previous_release = deliv.releases[-2]
for project in deliv.known_repo_names:
current_proj = current_release.project(project)
previous_proj = previous_release.project(project)
if current_proj is None or previous_proj is None:
# Error will be picked up above
continue
current_hash = current_proj.hash
previous_hash = previous_proj.hash
if current_hash != previous_hash:
context.error('EM tag must match the last release, tagging '
'%s, last release %s' %
(current_hash, previous_hash))
@skip_em_eol_tags
def validate_bugtracker(deliv, context):

View File

@ -300,6 +300,11 @@ class Release(object):
def projects(self):
return sorted(self._projects.values())
def project(self, repo):
if repo in self._projects:
return self._projects[repo]
return None
@property
def diff_start(self):
return self._data.get('diff-start')

View File

@ -3258,6 +3258,10 @@ class TestValidateSeriesEM(base.BaseTestCase):
---
team: Release Management
releases:
- version: 1.2.3
projects:
- repo: openstack/automaton
hash: be2885f544637e6ee6139df7dc7bf937925804dd
- version: newton-em
projects:
- repo: openstack/automaton
@ -3277,15 +3281,111 @@ class TestValidateSeriesEM(base.BaseTestCase):
self.assertEqual(0, len(self.ctx.warnings))
self.assertEqual(0, len(self.ctx.errors))
def test_em_no_releases(self):
deliverable_data = yamlutils.loads(textwrap.dedent('''
---
team: Release Management
releases:
- version: newton-em
projects:
- repo: openstack/automaton
hash: be2885f544637e6ee6139df7dc7bf937925804dd
'''))
deliv = deliverable.Deliverable(
None,
'newton',
'test',
deliverable_data,
)
validate.validate_series_em(
deliv,
self.ctx,
)
self.ctx.show_summary()
self.assertEqual(0, len(self.ctx.warnings))
self.assertEqual(1, len(self.ctx.errors))
def test_em_not_matching_last_release(self):
deliverable_data = yamlutils.loads(textwrap.dedent('''
---
team: Release Management
releases:
- version: 1.2.3
projects:
- repo: openstack/automaton
hash: be2885f544637e6ee6139df7dc7bf937925804dd
- version: 1.2.4
projects:
- repo: openstack/automaton
hash: beef85f544637e6ee6139df7dc7bf937925804dd
- version: newton-em
projects:
- repo: openstack/automaton
hash: be2885f544637e6ee6139df7dc7bf937925804dd
repository-settings:
openstack/automaton: {}
'''))
deliv = deliverable.Deliverable(
None,
'newton',
'test',
deliverable_data,
)
validate.validate_series_em(
deliv,
self.ctx,
)
self.ctx.show_summary()
self.assertEqual(0, len(self.ctx.warnings))
self.assertEqual(1, len(self.ctx.errors))
def test_em_matches_last_release(self):
deliverable_data = yamlutils.loads(textwrap.dedent('''
---
team: Release Management
releases:
- version: 1.2.3
projects:
- repo: openstack/automaton
hash: be2885f544637e6ee6139df7dc7bf937925804dd
- version: 1.2.4
projects:
- repo: openstack/automaton
hash: beef85f544637e6ee6139df7dc7bf937925804dd
- version: newton-em
projects:
- repo: openstack/automaton
hash: beef85f544637e6ee6139df7dc7bf937925804dd
repository-settings:
openstack/automaton: {}
'''))
deliv = deliverable.Deliverable(
None,
'newton',
'test',
deliverable_data,
)
validate.validate_series_em(
deliv,
self.ctx,
)
self.ctx.show_summary()
self.assertEqual(0, len(self.ctx.warnings))
self.assertEqual(0, len(self.ctx.errors))
def test_em_missing_repo(self):
deliverable_data = yamlutils.loads(textwrap.dedent('''
---
team: Release Management
releases:
- version: 1.2.3
projects:
- repo: openstack/automaton
hash: be2885f544637e6ee6139df7dc7bf937925804dd
- version: newton-em
projects:
- repo: openstack/automaton
hash: ce2885f544637e6ee6139df7dc7bf937925804dd
hash: be2885f544637e6ee6139df7dc7bf937925804dd
repository-settings:
openstack/automaton: {}
openstack/release-test: {}