Add Redirection support for unmaintained branches and releases

Change-Id: I6329dd019173dd3eb8d479ef943ae50a619a85c7
This commit is contained in:
Tony Breeds 2024-02-02 14:28:05 +11:00 committed by Dr. Jens Harbott
parent 54d35f1684
commit 9fc7ad3f32
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 release_id = _series_status_data[deliv.series].release_id
if not release_id: if not release_id:
release_id = deliv.series 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: 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 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: 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: if release.is_eol:
target = str(release.version) target = str(release.version)
ref_type = 'tag' ref_type = 'tag'

View File

@ -108,6 +108,10 @@ class TestRedirections(base.BaseTestCase):
series='mitaka', series='mitaka',
name='requirements', name='requirements',
data=yamlutils.loads(textwrap.dedent(''' data=yamlutils.loads(textwrap.dedent('''
branches:
- name: stable/mitaka
location:
openstack/requirements: not_used
releases: releases:
- projects: - projects:
- hash: not_used - hash: not_used
@ -115,6 +119,49 @@ class TestRedirections(base.BaseTestCase):
version: mitaka-eol 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_DATA = series_status.SeriesStatus( SERIES_STATUS_DATA = series_status.SeriesStatus(
@ -234,6 +281,24 @@ class TestRedirections(base.BaseTestCase):
generate_constraints_redirections( generate_constraints_redirections(
deliverables, self.SERIES_STATUS_DATA)) 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): def test_all(self):
deliverables = FakeDeliverables([ deliverables = FakeDeliverables([
self.STABLE_EOL, self.STABLE_EOL,
@ -254,3 +319,5 @@ class TestRedirections(base.BaseTestCase):
self.assertEqual([], self.assertEqual([],
generate_constraints_redirections( generate_constraints_redirections(
deliverables, self.SERIES_STATUS_DATA)) deliverables, self.SERIES_STATUS_DATA))
# FIXME(tonyb): Add testcase for future_releases