Merge "Add Redirection support for unmaintained branches and releases"

This commit is contained in:
Zuul 2024-02-23 15:08:21 +00:00 committed by Gerrit Code Review
commit 79b8bd5a55
2 changed files with 89 additions and 4 deletions

View File

@ -30,14 +30,32 @@ def generate_constraints_redirections(_deliverables, _series_status_data,
release_id = _series_status_data[deliv.series].release_id
if not release_id:
release_id = deliv.series
# Unless there is a specific stable branch
# Unless there is a stable or unmaintained branch
# Look at all branches We can't rely the ordering in the deliverable
# file
for branch in deliv.branches:
if branch.name == 'stable/%s' % (release_id):
# Set the target when the branch is 'stable/'
# but ONLY If the target would otherwise be the master branch
if target == 'master' and branch.name == 'stable/%s' % (release_id):
target = branch.name
# An open unmaintained branch should become the target in
# preference over a master or stable branch
elif branch.name == 'unmaintained/%s' % (release_id):
target = branch.name
break
# Or we have a ${series}-eol tag
# After looking at all the branches we now look for ${series}-eom
# or a ${series}-eol tag
for release in deliv.releases:
# an EOM release is a probable target.
if release.is_eom:
# Select the EOM tag instad of a master or stable branch.
# however if there is an unmaintained branch that's the
# expected target until the series is marked EOL
if target == 'master' or target == 'stable/%s' % (release_id):
target = str(release.version)
ref_type = 'tag'
# If a series is marked as EOL then we that tag is the correct
# destination, no options
if release.is_eol:
target = str(release.version)
ref_type = 'tag'

View File

@ -108,6 +108,10 @@ class TestRedirections(base.BaseTestCase):
series='mitaka',
name='requirements',
data=yamlutils.loads(textwrap.dedent('''
branches:
- name: stable/mitaka
location:
openstack/requirements: not_used
releases:
- projects:
- hash: not_used
@ -115,6 +119,49 @@ class TestRedirections(base.BaseTestCase):
version: mitaka-eol
'''))
)
# Deliverable that looks like a closed (unmaintained) stable series
STABLE_EOM_EOL = deliverable.Deliverable(
team='requirements',
series='mitaka',
name='requirements',
data=yamlutils.loads(textwrap.dedent('''
branches:
- name: stable/mitaka
location:
openstack/requirements: not_used
- name: unmaintained/mitaka
location: mitaka-eom
releases:
- projects:
- hash: not_used
repo: openstack/requirements
version: mitaka-eom
- projects:
- hash: also_not_used
repo: openstack/requirements
version: mitaka-eol
'''))
)
# Deliverable that looks like a closed (unmaintained) stable series, but with
# an open 'unmaintained' branch
STABLE_EOM_UNMAINTAINED = deliverable.Deliverable(
team='requirements',
series='mitaka',
name='requirements',
data=yamlutils.loads(textwrap.dedent('''
branches:
- name: stable/mitaka
location:
openstack/requirements: not_used
- name: unmaintained/mitaka
location: mitaka-eom
releases:
- projects:
- hash: not_used
repo: openstack/requirements
version: mitaka-eom
'''))
)
# Series status data
SERIES_STATUS_DATA = series_status.SeriesStatus(
@ -234,6 +281,24 @@ class TestRedirections(base.BaseTestCase):
generate_constraints_redirections(
deliverables, self.SERIES_STATUS_DATA))
def test_stable_eom(self):
deliverables = FakeDeliverables([
self.STABLE_EOM_EOL,
])
self.assertEqual([dict(code=301, src='mitaka', ref_type='tag',
dst='mitaka-eol')],
generate_constraints_redirections(
deliverables, self.SERIES_STATUS_DATA))
def test_stable_eom_unmaintained(self):
deliverables = FakeDeliverables([
self.STABLE_EOM_UNMAINTAINED,
])
self.assertEqual([dict(code=301, src='mitaka', ref_type='branch',
dst='unmaintained/mitaka')],
generate_constraints_redirections(
deliverables, self.SERIES_STATUS_DATA))
def test_all(self):
deliverables = FakeDeliverables([
self.STABLE_EOL,
@ -254,3 +319,5 @@ class TestRedirections(base.BaseTestCase):
self.assertEqual([],
generate_constraints_redirections(
deliverables, self.SERIES_STATUS_DATA))
# FIXME(tonyb): Add testcase for future_releases