diff --git a/openstack_releases/cmds/validate.py b/openstack_releases/cmds/validate.py index 3b171e2d1c..a7100a6ae9 100644 --- a/openstack_releases/cmds/validate.py +++ b/openstack_releases/cmds/validate.py @@ -432,7 +432,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] @@ -441,6 +441,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, @@ -448,6 +455,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): diff --git a/openstack_releases/deliverable.py b/openstack_releases/deliverable.py index b7e3e56a90..38bb3d7961 100644 --- a/openstack_releases/deliverable.py +++ b/openstack_releases/deliverable.py @@ -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') diff --git a/openstack_releases/tests/test_validate.py b/openstack_releases/tests/test_validate.py index b5a5646960..5035de74bd 100644 --- a/openstack_releases/tests/test_validate.py +++ b/openstack_releases/tests/test_validate.py @@ -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: {}