From a9f99dfca96d01a3234ea18e9a98075291c259d5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?El=C5=91d=20Ill=C3=A9s?= Date: Thu, 7 Nov 2024 18:02:27 +0100 Subject: [PATCH] Extend validator to accept .- tags Validator originally checked for -{eol,eom,em,last} tags. Since we are using branch IDs since Antelope, the validator has to accept for example 2023.1-eom, 2023.1-eol and 2023.1-last tags instead of antelope-<..> tags. Change-Id: I584c34a533db25a29206606d81d95ad2daa7779c --- openstack_releases/cmds/validate.py | 10 +-- openstack_releases/tests/test_validate.py | 80 +++++++++++++++++++++++ 2 files changed, 85 insertions(+), 5 deletions(-) diff --git a/openstack_releases/cmds/validate.py b/openstack_releases/cmds/validate.py index dbf809df5e..a5dd83ac2d 100644 --- a/openstack_releases/cmds/validate.py +++ b/openstack_releases/cmds/validate.py @@ -1149,7 +1149,7 @@ def validate_version_numbers(deliv, context): 'EOL tag {} on independent deliverable, branch not validated'.format( release.version)) continue - if release.eol_series != deliv.series: + if release.eol_series != gitutils.get_stable_branch_id(deliv.series): context.error( 'EOL tag {} does not refer to the {} series.'.format( release.version, deliv.series)) @@ -1163,7 +1163,7 @@ def validate_version_numbers(deliv, context): 'EOM tag {} on independent deliverable, branch not validated'.format( release.version)) continue - if release.eom_series != deliv.series: + if release.eom_series != gitutils.get_stable_branch_id(deliv.series): context.error( 'EOM tag {} does not refer to the {} series.'.format( release.version, deliv.series)) @@ -1191,10 +1191,10 @@ def validate_version_numbers(deliv, context): 'LAST tag {} on independent deliverable, branch not validated'.format( release.version)) continue - if release.version != "{}-last".format(deliv.series): + if release.version != "{}-last".format(gitutils.get_stable_branch_id(deliv.series)): context.error( - "LAST tag {} should match branch name (e.g {}-last)".format( - release.version, deliv.series)) + "LAST tag {} should match branch name (e.g {}-last for series {})".format( + release.version, gitutils.get_stable_branch_id(deliv.series), deliv.series)) if not (deliv.series_info.is_em or deliv.series_info.is_eom): context.error( "LAST tag {} aren't allowed on a series ({}) that are not EM or Unmaintained".format( diff --git a/openstack_releases/tests/test_validate.py b/openstack_releases/tests/test_validate.py index f0d4eb43b2..e2e423871f 100644 --- a/openstack_releases/tests/test_validate.py +++ b/openstack_releases/tests/test_validate.py @@ -1186,10 +1186,27 @@ class TestValidateNewReleasesInOpenSeries(base.BaseTestCase): class TestValidateVersionNumbers(base.BaseTestCase): + _series_status_data = yamlutils.loads(textwrap.dedent(''' + - name: antelope + release-id: 2023.1 + status: maintained + initial-release: 2023-03-22 + - name: bobcat + release-id: 2023.2 + status: unmaintained + initial-release: 2023-10-22 + ''')) + def setUp(self): super().setUp() self.ctx = validate.ValidationContext() gitutils.clone_repo(self.ctx.workdir, 'openstack/release-test') + self.series_status = series_status.SeriesStatus( + self._series_status_data) + self.useFixture(fixtures.MockPatch( + 'openstack_releases.deliverable.Deliverable._series_status_data', + self.series_status, + )) @mock.patch('openstack_releases.versionutils.validate_version') def test_invalid_version(self, validate_version): @@ -1289,6 +1306,27 @@ class TestValidateVersionNumbers(base.BaseTestCase): self.assertEqual(0, len(self.ctx.warnings)) self.assertEqual(0, len(self.ctx.errors)) + def test_eol_valid_version_with_release_id(self): + deliv = deliverable.Deliverable( + team='team', + series='antelope', + name='name', + data={ + 'artifact-link-mode': 'none', + 'releases': [ + {'version': '2023.1-eol', + 'projects': [ + {'repo': 'openstack/release-test', + 'hash': 'a26e6a2e8a5e321b2e3517dbb01a7b9a56a8bfd5'}, + ]} + ], + } + ) + validate.validate_version_numbers(deliv, self.ctx) + self.ctx.show_summary() + self.assertEqual(0, len(self.ctx.warnings)) + self.assertEqual(0, len(self.ctx.errors)) + def test_eom_valid_version(self): deliv = deliverable.Deliverable( team='team', @@ -1310,6 +1348,27 @@ class TestValidateVersionNumbers(base.BaseTestCase): self.assertEqual(0, len(self.ctx.warnings)) self.assertEqual(0, len(self.ctx.errors)) + def test_eom_valid_version_with_release_id(self): + deliv = deliverable.Deliverable( + team='team', + series='antelope', + name='name', + data={ + 'artifact-link-mode': 'none', + 'releases': [ + {'version': '2023.1-eom', + 'projects': [ + {'repo': 'openstack/release-test', + 'hash': 'a26e6a2e8a5e321b2e3517dbb01a7b9a56a8bfd5'}, + ]} + ], + } + ) + validate.validate_version_numbers(deliv, self.ctx) + self.ctx.show_summary() + self.assertEqual(0, len(self.ctx.warnings)) + self.assertEqual(0, len(self.ctx.errors)) + def test_em_valid_version(self): deliv = deliverable.Deliverable( team='team', @@ -1331,6 +1390,27 @@ class TestValidateVersionNumbers(base.BaseTestCase): self.assertEqual(0, len(self.ctx.warnings)) self.assertEqual(0, len(self.ctx.errors)) + def test_tempest_last_valid_version_with_release_id(self): + deliv = deliverable.Deliverable( + team='team', + series='bobcat', + name='name', + data={ + 'artifact-link-mode': 'none', + 'releases': [ + {'version': '2023.2-last', + 'projects': [ + {'repo': 'openstack/release-test', + 'hash': 'a26e6a2e8a5e321b2e3517dbb01a7b9a56a8bfd5'}, + ]} + ], + } + ) + validate.validate_version_numbers(deliv, self.ctx) + self.ctx.show_summary() + self.assertEqual(0, len(self.ctx.warnings)) + self.assertEqual(0, len(self.ctx.errors)) + def test_eol_wrong_branch(self): deliv = deliverable.Deliverable( team='team',