Skip to content

Commit

Permalink
Show more data for Release
Browse files Browse the repository at this point in the history
Signed-off-by: Mattia Verga <[email protected]>
  • Loading branch information
mattiaverga committed Sep 16, 2023
1 parent 7278db4 commit 7f7dc35
Show file tree
Hide file tree
Showing 11 changed files with 116 additions and 25 deletions.
11 changes: 11 additions & 0 deletions bodhi-client/bodhi/client/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
"""The bodhi CLI client."""

from datetime import datetime
import functools
import logging
import os
Expand Down Expand Up @@ -180,6 +181,8 @@ def _set_logging_debug(
click.option('--branch', help='Git branch name (eg: f20)'),
click.option('--dist-tag', help='Koji dist tag (eg: f20)'),
click.option('--stable-tag', help='Koji stable tag (eg: f20-updates)'),
click.option('--released-on', type=click.DateTime(formats=["%Y-%m-%d"]),
help='Date of first release (eg. 2016-06-14)'),
click.option('--eol', type=click.DateTime(formats=["%Y-%m-%d"]),
help='Release end-of-life date (eg. 2016-06-14)'),
click.option('--testing-tag',
Expand Down Expand Up @@ -1228,6 +1231,7 @@ def create_release(url: str, id_provider: str, client_id: str, debug: bool, **kw
kwargs['composed_by_bodhi'] = True
if kwargs['create_automatic_updates'] is None:
kwargs['create_automatic_updates'] = False
kwargs['released_on'] = kwargs.pop('released_on').date() if kwargs['released_on'] else None
kwargs['eol'] = kwargs.pop('eol').date() if kwargs['eol'] else None
save(client, **kwargs)

Expand All @@ -1246,6 +1250,7 @@ def edit_release(url: str, id_provider: str, client_id: str, debug: bool, **kwar

edited = kwargs.pop('name')

kwargs['released_on'] = kwargs.pop('released_on').date() if kwargs['released_on'] else None
kwargs['eol'] = kwargs.pop('eol').date() if kwargs['eol'] else None

if edited is None:
Expand All @@ -1267,6 +1272,10 @@ def edit_release(url: str, id_provider: str, client_id: str, debug: bool, **kwar
if new_name is not None:
data['name'] = new_name

if (data['state'] == 'pending' and kwargs['state'] == 'current'
and kwargs['released_on'] is None):
kwargs['released_on'] = datetime.now().date()

for k, v in kwargs.items():
if v is not None:
data[k] = v
Expand Down Expand Up @@ -1395,11 +1404,13 @@ def print_release(release: munch.Munch):
click.echo(f" Pending Stable Tag: {release['pending_stable_tag']}")
click.echo(f" Override Tag: {release['override_tag']}")
click.echo(f" State: {release['state']}")
click.echo(f" Beta Status: {release['setting_status']}")
click.echo(f" Email Template: {release['mail_template']}")
click.echo(f" Composed by Bodhi: {release['composed_by_bodhi']}")
click.echo(f" Create Automatic Updates: {release['create_automatic_updates']}")
click.echo(f" Package Manager: {release['package_manager']}")
click.echo(f" Testing Repository: {release['testing_repository']}")
click.echo(f" Released On: {release['released_on']}")
click.echo(f" End of Life: {release['eol']}")


Expand Down
43 changes: 29 additions & 14 deletions bodhi-client/tests/fixtures.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@
'pending_testing_tag': 'epel7-testing-pending', 'stable_tag': 'epel7',
'candidate_tag': 'epel7-testing-candidate',
'package_manager': 'unspecified', 'testing_repository': None,
'eol': None}),
'released_on': None, 'eol': None, 'setting_status': None}),
'date_created': '2018-03-15 17:25:22', 'security': True})})


Expand All @@ -127,7 +127,7 @@
'pending_testing_tag': 'epel7-testing-pending', 'stable_tag': 'epel7',
'candidate_tag': 'epel7-testing-candidate',
'package_manager': 'unspecified', 'testing_repository': None,
'eol': None}),
'released_on': None, 'eol': None, 'setting_status': None}),
'date_created': '2018-03-15 17:25:22', 'security': True}),
Munch({
'release_id': 8, 'content_type': 'rpm',
Expand All @@ -145,7 +145,7 @@
'pending_testing_tag': 'epel7-testing-pending', 'stable_tag': 'epel7',
'candidate_tag': 'epel7-testing-candidate',
'package_manager': 'unspecified', 'testing_repository': None,
'eol': None}),
'released_on': None, 'eol': None, 'setting_status': None}),
'date_created': '2018-03-15 17:25:22', 'security': False})]})


Expand Down Expand Up @@ -279,7 +279,9 @@
'version': '25',
'package_manager': 'unspecified',
'testing_repository': None,
'eol': None},
'released_on': None,
'eol': None,
'setting_status': None},
'request': None,
'require_bugs': False,
'require_testcases': False,
Expand Down Expand Up @@ -387,7 +389,9 @@
'version': '25',
'package_manager': 'unspecified',
'testing_repository': None,
'eol': None},
'released_on': None,
'eol': None,
'setting_status': None},
'request': None,
'require_bugs': False,
'require_testcases': False,
Expand Down Expand Up @@ -456,7 +460,9 @@
'version': '25',
'package_manager': 'unspecified',
'testing_repository': None,
'eol': None},
'released_on': None,
'eol': None,
'setting_status': None},
'request': None,
'require_bugs': False,
'require_testcases': False,
Expand Down Expand Up @@ -766,7 +772,8 @@
'override_tag': 'epel7-override', 'branch': 'epel7', 'id_prefix': 'FEDORA-EPEL',
'pending_testing_tag': 'epel7-testing-pending', 'stable_tag': 'epel7',
'candidate_tag': 'epel7-testing-candidate', 'package_manager': 'unspecified',
'testing_repository': None, 'eol': None}), 'date_stable': '2016-10-21 13:23:01',
'testing_repository': None, 'released_on': None, 'eol': None,
'setting_status': None}), 'date_stable': '2016-10-21 13:23:01',
'content_type': 'rpm'})

SINGLE_UPDATE_MUNCH = Munch({
Expand Down Expand Up @@ -824,7 +831,8 @@
'override_tag': 'epel7-override', 'branch': 'epel7', 'id_prefix': 'FEDORA-EPEL',
'pending_testing_tag': 'epel7-testing-pending', 'stable_tag': 'epel7',
'candidate_tag': 'epel7-testing-candidate', 'package_manager': 'unspecified',
'testing_repository': None, 'eol': None}), 'date_stable': '2016-10-21 13:23:01',
'testing_repository': None, 'released_on': None, 'eol': None,
'setting_status': None}), 'date_stable': '2016-10-21 13:23:01',
'content_type': 'rpm'})})


Expand All @@ -838,7 +846,8 @@
'branch': 'f25', 'id_prefix': 'FEDORA',
'pending_testing_tag': 'f25-updates-testing-pending',
'stable_tag': 'f25-updates', 'candidate_tag': 'f25-updates-candidate',
'package_manager': 'unspecified', 'testing_repository': None, 'eol': None})],
'package_manager': 'unspecified', 'testing_repository': None, 'released_on': None,
'eol': None, 'setting_status': None})],
'page': 1})


Expand Down Expand Up @@ -906,7 +915,7 @@
'pending_testing_tag': 'f27-updates-testing-pending', 'stable_tag': 'f27-updates',
'candidate_tag': 'f27-updates-candidate', 'mail_template': 'fedora_errata_template',
'create_automatic_updates': False, 'package_manager': 'unspecified',
'testing_repository': None, 'eol': None})
'testing_repository': None, 'released_on': None, 'eol': None, 'setting_status': None})


EXPECTED_RELEASE_OUTPUT = """Saved release:
Expand All @@ -924,11 +933,13 @@
Pending Stable Tag: f27-updates-pending
Override Tag: f27-override
State: pending
Beta Status: None
Email Template: fedora_errata_template
Composed by Bodhi: True
Create Automatic Updates: False
Package Manager: unspecified
Testing Repository: None
Released On: None
End of Life: None
"""

Expand All @@ -941,7 +952,8 @@
'pending_testing_tag': 'f26-updates-testing-pending',
'candidate_tag': 'f26-updates-candidate', 'stable_tag': 'f26-updates',
'override_tag': 'f26-override', 'composed_by_bodhi': True,
'package_manager': 'unspecified', 'testing_repository': None, 'eol': None,
'package_manager': 'unspecified', 'testing_repository': None, 'released_on': None,
'eol': None, 'setting_status': None,
})

EXAMPLE_CURRENT_RELEASE_MUNCH = Munch({
Expand All @@ -953,7 +965,8 @@
'pending_testing_tag': 'f28-updates-testing-pending',
'candidate_tag': 'f28-updates-candidate', 'stable_tag': 'f28-updates',
'override_tag': 'f28-override', 'composed_by_bodhi': True,
'package_manager': 'unspecified', 'testing_repository': None, 'eol': None,
'package_manager': 'unspecified', 'testing_repository': None, 'released_on': None,
'eol': None, 'setting_status': None,
})

EXAMPLE_PENDING_RELEASE_MUNCH = Munch({
Expand All @@ -965,7 +978,8 @@
'pending_testing_tag': 'f29-updates-testing-pending',
'candidate_tag': 'f29-updates-candidate', 'stable_tag': 'f29-updates',
'override_tag': 'f29-override', 'composed_by_bodhi': True,
'package_manager': 'unspecified', 'testing_repository': None, 'eol': None,
'package_manager': 'unspecified', 'testing_repository': None, 'released_on': None,
'eol': None, 'setting_status': None,
})

EXAMPLE_FROZEN_RELEASE_MUNCH = Munch({
Expand All @@ -977,7 +991,8 @@
'pending_testing_tag': 'f30-updates-testing-pending',
'candidate_tag': 'f30-updates-candidate', 'stable_tag': 'f30-updates',
'override_tag': 'f30-override', 'composed_by_bodhi': True,
'package_manager': 'unspecified', 'testing_repository': None, 'eol': None,
'package_manager': 'unspecified', 'testing_repository': None, 'released_on': None,
'eol': None, 'setting_status': None,
})

EXAMPLE_RELEASE_MUNCH_NO_ARCHIVED = Munch({
Expand Down
19 changes: 13 additions & 6 deletions bodhi-client/tests/test_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -2089,7 +2089,7 @@ def test_url_flag(self, mocked_client_class):
mocked_client_class.send_request.assert_called_once_with(
'releases/', verb='POST', auth=True,
data={'dist_tag': None, 'csrf_token': 'a_csrf_token', 'staging': False,
'eol': None, 'name': 'F27',
'released_on': None, 'eol': None, 'name': 'F27',
'testing_tag': None, 'pending_stable_tag': None, 'long_name': None, 'state': None,
'version': None, 'override_tag': None, 'branch': None, 'id_prefix': None,
'pending_testing_tag': None, 'pending_signing_tag': None, 'stable_tag': None,
Expand Down Expand Up @@ -2150,7 +2150,8 @@ def test_url_flag(self, mocked_client_class):
'stable_tag': 'f27-updates', 'candidate_tag': 'f27-updates-candidate',
'mail_template': 'fedora_errata_template', 'composed_by_bodhi': True,
'create_automatic_updates': False, 'package_manager': 'unspecified',
'testing_repository': None, 'eol': None})
'testing_repository': None, 'released_on': None, 'eol': None,
'setting_status': None})

def test_new_name_flag(self, mocked_client_class):
"""
Expand Down Expand Up @@ -2183,7 +2184,8 @@ def test_new_name_flag(self, mocked_client_class):
'stable_tag': 'f27-updates', 'candidate_tag': 'f27-updates-candidate',
'mail_template': 'fedora_errata_template', 'composed_by_bodhi': True,
'create_automatic_updates': False, 'package_manager': 'unspecified',
'testing_repository': None, 'eol': None})
'testing_repository': None, 'released_on': None, 'eol': None,
'setting_status': None})

def test_edit_no_name_provided(self, mocked_client_class):
"""
Expand Down Expand Up @@ -2247,7 +2249,8 @@ def test_edit_mail_template(self, mocked_client_class):
'stable_tag': 'f27-updates', 'candidate_tag': 'f27-updates-candidate',
'mail_template': 'edited_fedora_errata_template', 'composed_by_bodhi': True,
'create_automatic_updates': False, 'package_manager': 'unspecified',
'testing_repository': None, 'eol': None})
'testing_repository': None, 'released_on': None, 'eol': None,
'setting_status': None})

def test_edit_not_composed_by_bodhi_flag(self, mocked_client_class):
"""
Expand Down Expand Up @@ -2279,7 +2282,8 @@ def test_edit_not_composed_by_bodhi_flag(self, mocked_client_class):
'stable_tag': 'f27-updates', 'candidate_tag': 'f27-updates-candidate',
'mail_template': 'fedora_errata_template',
'composed_by_bodhi': False, 'package_manager': 'unspecified',
'testing_repository': None, 'eol': None, 'create_automatic_updates': False})
'testing_repository': None, 'released_on': None, 'eol': None,
'setting_status': None, 'create_automatic_updates': False})

def test_edit_create_automatic_updates_flag(self, mocked_client_class):
"""
Expand Down Expand Up @@ -2312,7 +2316,8 @@ def test_edit_create_automatic_updates_flag(self, mocked_client_class):
'stable_tag': 'f27-updates', 'candidate_tag': 'f27-updates-candidate',
'mail_template': 'fedora_errata_template',
'composed_by_bodhi': True, 'create_automatic_updates': True,
'package_manager': 'unspecified', 'testing_repository': None, 'eol': None})
'package_manager': 'unspecified', 'testing_repository': None,
'released_on': None, 'eol': None, 'setting_status': None})

def test_edit_eol(self, mocked_client_class):
"""
Expand Down Expand Up @@ -2354,6 +2359,8 @@ def test_edit_eol(self, mocked_client_class):
"mail_template": "fedora_errata_template",
"create_automatic_updates": False,
"package_manager": "unspecified",
"released_on": None,
"setting_status": None,
"testing_repository": None,
"eol": date(2021, 6, 14),
"edited": "F27",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
# Copyright (c) 2023 Mattia Verga
#
# This file is part of Bodhi.
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
"""
Add released_on to release.
Revision ID: f660455231d4
Revises: e3988e00b338
Create Date: 2023-09-06 15:33:36.185933
"""
from alembic import op
import sqlalchemy as sa


# revision identifiers, used by Alembic.
revision = 'f660455231d4'
down_revision = 'e3988e00b338'


def upgrade():
"""Add the released_on column."""
op.add_column(
'releases',
sa.Column('released_on', sa.Date, nullable=True),
)


def downgrade():
"""Drop the released_on column."""
op.drop_column('releases', 'released_on')
3 changes: 3 additions & 0 deletions bodhi-server/bodhi/server/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -837,11 +837,13 @@ class Release(Base):
the values defined in :class:`PackageManager`.
testing_repository (str): The name of repository where updates are placed for
testing before being pushed to the main repository.
released_on (str): Date of first release in a datetime.date() format '2020-05-17'.
eol (str): End-of-life of the release in a datetime.date() format '2020-05-17'.
"""

__tablename__ = 'releases'
__exclude_columns__ = ('id', 'builds', 'composes')
__include_extras__ = ('setting_status', )
__get_by__ = ('name', 'long_name', 'dist_tag')

name = Column(Unicode(10), unique=True, nullable=False)
Expand All @@ -868,6 +870,7 @@ class Release(Base):

package_manager = Column(PackageManager.db_type(), default=PackageManager.unspecified)
testing_repository = Column(UnicodeText, nullable=True)
released_on = Column(Date, nullable=True)
eol = Column(Date, nullable=True)

# One-to-many relationships
Expand Down
2 changes: 2 additions & 0 deletions bodhi-server/bodhi/server/services/releases.py
Original file line number Diff line number Diff line change
Expand Up @@ -330,6 +330,8 @@ def query_releases_json(request):
if state is not None:
query = query.filter(Release.state == ReleaseState.from_string(state))

query = query.order_by(Release.name.asc())

# We can't use ``query.count()`` here because it is naive with respect to
# all the joins that we're doing above.
count_query = query.set_label_style(LABEL_STYLE_TABLENAME_PLUS_COL).statement\
Expand Down
2 changes: 2 additions & 0 deletions bodhi-server/bodhi/server/templates/release.html
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,12 @@ <h3 class="fw-bold m-0"><a href="${request.route_url('releases')}">Releases</a>
'Pending Stable Tag': 'pending_stable_tag',\
'Override Tag': 'override_tag',\
'Email Template': 'mail_template',\
'Prerelease status': 'setting_status',\
'Composed by Bodhi': 'composed_by_bodhi',\
'Create Automatic Updates': 'create_automatic_updates',\
'Package Manager': 'package_manager',\
'Testing Repository': 'testing_repository',\
'Released on': 'released_on',\
'End of Life': 'eol'}.items():
<tr class="d-flex">
<td class="col-6">${property}</td>
Expand Down
1 change: 1 addition & 0 deletions devel/ci/integration/tests/test_bodhi.py
Original file line number Diff line number Diff line change
Expand Up @@ -1057,6 +1057,7 @@ def test_get_compose_json(bodhi_container, db_container):
" create_automatic_updates, "
" package_manager, "
" testing_repository, "
" released_on, "
" eol "
"FROM releases "
"WHERE id = %s "
Expand Down
Loading

0 comments on commit 7f7dc35

Please sign in to comment.