Extend validator to accept <year>.<id>-<state> tags

Validator originally checked for <series>-{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
This commit is contained in:
Előd Illés 2024-11-07 18:02:27 +01:00
parent e5510db163
commit a9f99dfca9
2 changed files with 85 additions and 5 deletions

View File

@ -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(

View File

@ -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',