Add std-with-versions stable-branch-type

This adds a new std-with-versions branch type. This is used to control
validation logic when branching to allow the Ironic team to create
intermediary stable branches based on major.minor version numbers in
addition to our normal expected stable/$series branches.

https://specs.openstack.org/openstack/ironic-specs/specs/not-implemented/new-release-model.html

Change-Id: Ic482c77a2c177162ffe37643a455ac1724a658b3
Signed-off-by: Sean McGinnis <sean.mcginnis@gmail.com>
This commit is contained in:
Sean McGinnis 2020-06-02 14:09:17 -05:00
parent 9ae1d5a25a
commit 804e560832
No known key found for this signature in database
GPG Key ID: CE7EE4BFAF8D70C8
4 changed files with 74 additions and 7 deletions

View File

@ -403,6 +403,14 @@ The top level of a deliverable file is a mapping with keys:
associated with the version (as identified by the deliverable
file) will be branched from that version using the name given.
``std-with-versions``
This mode has the same meaning as the ``std`` branch type, with the
addition that version-based branches can be created as well.
These version-based branches are shorter term stable branches that
are named for the major and minor version number (e.g. stable/3.1).
This is primarily used for Ironic releases.
``tagless``
This mode requires stable branch locations to be a mapping between
repository name and an existing commit, specified by the

View File

@ -1512,7 +1512,7 @@ def validate_stable_branches(deliv, context):
location = branch.location
if branch_mode == 'std':
if branch_mode == 'std' or branch_mode == 'std-with-versions':
if not isinstance(location, six.string_types):
context.error(
('branch location for %s is '
@ -1613,11 +1613,22 @@ def validate_stable_branches(deliv, context):
else:
if series != deliv.series:
context.error(
('cycle-based projects must match series names '
'for stable branches. %s should be stable/%s' % (
branch.name, deliv.series))
)
if branch_mode == 'std-with-versions':
# Not a normal stable branch, so it must be a version
# branch (stable/3.1)
expected_version = '.'.join(location.split('.')[0:2])
if series != expected_version:
context.error(
'cycle-based projects must match series names '
'for stable branches, or branch based on version '
'for short term support. %s should be stable/%s '
'or stable/%s' % (
branch.name, deliv.series, expected_version))
else:
context.error(
'cycle-based projects must match series names '
'for stable branches. %s should be stable/%s' % (
branch.name, deliv.series))
def validate_feature_branches(deliv, context):

View File

@ -57,7 +57,7 @@ properties:
"manila-image-elements", "generic" ]
stable-branch-type:
type: "string"
enum: [ "std", "tagless", "upstream", "none" ]
enum: [ "std", "tagless", "upstream", "none", "std-with-versions" ]
cycle-highlights:
type: "array"
items:

View File

@ -2221,6 +2221,54 @@ class TestValidateStableBranches(base.BaseTestCase):
self.assertEqual(0, len(self.ctx.warnings))
self.assertEqual(1, len(self.ctx.errors))
def test_std_with_versions_stable_branch_type(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/99.0
location: 99.0.3
repository-settings:
openstack/release-test: {}
''')
deliv = deliverable.Deliverable(
team='team',
series='ocata',
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_normal_stable_branch_type(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/ocata
location: 99.0.3
repository-settings:
openstack/release-test: {}
''')
deliv = deliverable.Deliverable(
team='team',
series='ocata',
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_tagless_stable_branch_type_bad_location_type(self):
deliverable_data = textwrap.dedent('''
stable-branch-type: tagless