Fix validator for std-with-versions
For projects that has branch type 'std-with-versions' (like ironic, because they cut bugfix/<MAJOR>.<MINOR> bugfix branches) the new stable branch name style (like stable/2023.1) does not pass validator. This patch extends the validator to accept these branch names, too. Change-Id: If597684b1a4ea741707ee786e8e01e9e8f3d2cb4
This commit is contained in:
parent
d5c2a25b05
commit
27c4dcced7
|
@ -1522,6 +1522,14 @@ def validate_branch_prefixes(deliv, context):
|
||||||
branch.name, _VALID_BRANCH_PREFIXES))
|
branch.name, _VALID_BRANCH_PREFIXES))
|
||||||
|
|
||||||
|
|
||||||
|
def _is_branch_with_release_id(branch_name):
|
||||||
|
"Check if stable branch name matches the new format, like stable/2023.1."
|
||||||
|
|
||||||
|
prefix, branch_id = branch_name.split('/')
|
||||||
|
return (prefix == 'stable' and
|
||||||
|
re.search(r'^[0-9]{4}.[1-2]{1}$', branch_id, re.I) is not None)
|
||||||
|
|
||||||
|
|
||||||
def validate_stable_branches(deliv, context):
|
def validate_stable_branches(deliv, context):
|
||||||
"Apply the rules for stable branches."
|
"Apply the rules for stable branches."
|
||||||
|
|
||||||
|
@ -1679,18 +1687,21 @@ def validate_stable_branches(deliv, context):
|
||||||
if series != deliv.series:
|
if series != deliv.series:
|
||||||
if branch_mode == 'std-with-versions':
|
if branch_mode == 'std-with-versions':
|
||||||
# Not a normal stable branch, so it must be a versioned
|
# Not a normal stable branch, so it must be a versioned
|
||||||
# bugfix branch (bugfix/3.1)
|
# bugfix branch (bugfix/3.1) or the new format of stable
|
||||||
|
# branches (for example: stable/2023.1)
|
||||||
expected_version = '.'.join(location.split('.')[0:2])
|
expected_version = '.'.join(location.split('.')[0:2])
|
||||||
if series != expected_version:
|
if (series != expected_version and
|
||||||
|
not _is_branch_with_release_id(branch.name)):
|
||||||
context.error(
|
context.error(
|
||||||
'cycle-based projects must match series names '
|
'cycle-based projects must match series names '
|
||||||
'for stable branches, or branch based on version '
|
'for stable branches, or branch based on version '
|
||||||
'for short term support. %s should be stable/%s '
|
'for short term support. %s should be stable/%s '
|
||||||
'or bugfix/%s' % (
|
'or stable/<year>.<release_number> (for example: '
|
||||||
|
'stable/2023.1) or bugfix/%s' % (
|
||||||
branch.name, deliv.series, expected_version))
|
branch.name, deliv.series, expected_version))
|
||||||
elif branch_mode == 'std':
|
elif branch_mode == 'std':
|
||||||
# Looking for SLURP naming (e.g: 2023.1)
|
# Looking for SLURP naming (e.g: 2023.1)
|
||||||
if re.search(r'^[0-9]{4}.[1]{1}$', series, re.I) is None:
|
if not _is_branch_with_release_id(branch.name):
|
||||||
context.error(
|
context.error(
|
||||||
'cycle-based projects must match series names '
|
'cycle-based projects must match series names '
|
||||||
'for stable branches. %s should be stable/%s '
|
'for stable branches. %s should be stable/%s '
|
||||||
|
|
|
@ -2024,7 +2024,7 @@ class TestValidateStableBranches(base.BaseTestCase):
|
||||||
self.assertEqual(0, len(self.ctx.warnings))
|
self.assertEqual(0, len(self.ctx.warnings))
|
||||||
self.assertEqual(1, len(self.ctx.errors))
|
self.assertEqual(1, len(self.ctx.errors))
|
||||||
|
|
||||||
def test_stable_branch_slurp_formatted_name(self):
|
def test_std_branch_type_with_release_id(self):
|
||||||
deliverable_data = textwrap.dedent('''
|
deliverable_data = textwrap.dedent('''
|
||||||
releases:
|
releases:
|
||||||
- version: 99.0.3
|
- version: 99.0.3
|
||||||
|
@ -2032,7 +2032,31 @@ class TestValidateStableBranches(base.BaseTestCase):
|
||||||
- repo: openstack/release-test
|
- repo: openstack/release-test
|
||||||
hash: 0cd17d1ee3b9284d36b2a0d370b49a6f0bbb9660
|
hash: 0cd17d1ee3b9284d36b2a0d370b49a6f0bbb9660
|
||||||
branches:
|
branches:
|
||||||
- name: stable/2023.1
|
- name: stable/2022.2
|
||||||
|
location: 99.0.3
|
||||||
|
repository-settings:
|
||||||
|
openstack/release-test: {}
|
||||||
|
''')
|
||||||
|
deliv = deliverable.Deliverable(
|
||||||
|
team='team',
|
||||||
|
series='antelope',
|
||||||
|
name='release-test',
|
||||||
|
data=yamlutils.loads(deliverable_data),
|
||||||
|
)
|
||||||
|
validate.validate_stable_branches(deliv, self.ctx)
|
||||||
|
self.assertEqual(0, len(self.ctx.warnings))
|
||||||
|
self.assertEqual(0, len(self.ctx.errors))
|
||||||
|
|
||||||
|
def test_std_with_versions_branch_type_with_release_id(self):
|
||||||
|
deliverable_data = textwrap.dedent('''
|
||||||
|
stable-branch-type: std-with-versions
|
||||||
|
releases:
|
||||||
|
- version: 99.0.3
|
||||||
|
projects:
|
||||||
|
- repo: openstack/release-test
|
||||||
|
hash: 0cd17d1ee3b9284d36b2a0d370b49a6f0bbb9660
|
||||||
|
branches:
|
||||||
|
- name: stable/2022.2
|
||||||
location: 99.0.3
|
location: 99.0.3
|
||||||
repository-settings:
|
repository-settings:
|
||||||
openstack/release-test: {}
|
openstack/release-test: {}
|
||||||
|
|
Loading…
Reference in New Issue