Skip to content

Commit

Permalink
Misc. refactorings and enhancements
Browse files Browse the repository at this point in the history
  • Loading branch information
jdavcs committed Dec 2, 2024
1 parent 0a6869f commit 912ca26
Show file tree
Hide file tree
Showing 9 changed files with 587 additions and 236 deletions.
514 changes: 279 additions & 235 deletions galaxy_release_util/bootstrap_history.py

Large diffs are not rendered by default.

3 changes: 2 additions & 1 deletion galaxy_release_util/cli/options.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import datetime
import pathlib
from typing import (
Any,
Expand Down Expand Up @@ -41,7 +42,7 @@ def convert(self, value: Any, param: Optional[Parameter], ctx: Optional[Context]
class ClickDate(click.ParamType):
name = "date"

def convert(self, value: Any, param: Optional[Parameter], ctx: Optional[Context]) -> datetime.datetime.date:
def convert(self, value: Any, param: Optional[Parameter], ctx: Optional[Context]) -> datetime.date:
try:
return datetime.datetime.strptime(value, "%Y-%m-%d").date()
except ValueError as e:
Expand Down
1 change: 1 addition & 0 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ include_package_data = True
install_requires =
build
click
python-dateutil
docutils
packaging
PyGithub
Expand Down
115 changes: 115 additions & 0 deletions tests/test_bootstrap_history.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,115 @@
import os
from pathlib import Path

import pytest
from click.testing import CliRunner
from packaging.version import Version

from galaxy_release_util import bootstrap_history
from galaxy_release_util.bootstrap_history import ( # _get_release_date,
_get_next_release_version,
_get_previous_release_version,
_get_release_version_strings,
create_changelog,
)


@pytest.fixture
def release_files_dir():
return Path(".") / "tests" / "test_data"


@pytest.fixture
def release_file(release_files_dir):
with open(release_files_dir / "98.2.rst") as f:
return f.read()


@pytest.fixture
def announcement_file(release_files_dir):
with open(release_files_dir / "98.2_announce.rst") as f:
return f.read()


@pytest.fixture
def user_announcement_file(release_files_dir):
with open(release_files_dir / "98.2_announce_user.rst") as f:
return f.read()


@pytest.fixture
def next_release_announcement_file(release_files_dir):
with open(release_files_dir / "99.0_announce.rst") as f:
return f.read()


@pytest.fixture
def prs_file(release_files_dir):
with open(release_files_dir / "98.2_prs.rst") as f:
return f.read()


def test_get_previous_release_version(monkeypatch):
monkeypatch.setattr(
bootstrap_history, "_get_release_version_strings", lambda x: sorted(["22.01", "22.05", "23.0", "23.1"])
)

assert _get_previous_release_version(None, Version("15.1")) is None
assert _get_previous_release_version(None, Version("22.01")) is None
assert _get_previous_release_version(None, Version("22.05")) == Version("22.01")
assert _get_previous_release_version(None, Version("23.0")) == Version("22.05")
assert _get_previous_release_version(None, Version("23.1")) == Version("23.0")
assert _get_previous_release_version(None, Version("23.2")) == Version("23.1")
assert _get_previous_release_version(None, Version("99.99")) == Version("23.1")


def test_get_next_release_version():
assert _get_next_release_version(Version("25.0")) == Version("25.1")
assert _get_next_release_version(Version("26.1")) == Version("26.2")


def test_get_release_version_strings(monkeypatch):
filenames = [
"15.0.not_rst",
"22.01.rst",
"22.05.rst",
"23.0.rst",
"23.1.rst",
"23.not_a_release.rst",
"not_a_release.23.rst",
]
monkeypatch.setattr(bootstrap_history, "_get_release_documentation_filenames", lambda x: sorted(filenames))
assert _get_release_version_strings(None) == ["22.01", "22.05", "23.0", "23.1"]


def test_create_changelog(
monkeypatch,
release_file,
announcement_file,
user_announcement_file,
prs_file,
next_release_announcement_file,
):
monkeypatch.setattr(
bootstrap_history, "_load_prs", lambda x, y, z: None
) # We don't want to call github's API on test data.
runner = CliRunner()
with runner.isolated_filesystem():
os.makedirs("doc/source/releases")
result = runner.invoke(
create_changelog, ["98.2", "--galaxy-root", ".", "--release-date", "2099-1-15", "--next-version", "99.0"]
) # version 98.2 to be released on January 15, 2099
assert result.exit_code == 0

releases_path = Path("doc") / "source" / "releases"

with open(releases_path / "98.2.rst") as f:
assert f.read() == release_file
with open(releases_path / "98.2_announce.rst") as f:
assert f.read() == announcement_file
with open(releases_path / "98.2_announce_user.rst") as f:
assert f.read() == user_announcement_file
with open(releases_path / "98.2_prs.rst") as f:
assert f.read() == prs_file
with open(releases_path / "99.0_announce.rst") as f:
assert f.read() == next_release_announcement_file
61 changes: 61 additions & 0 deletions tests/test_data/98.2.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@

.. to_doc
98.2
===============================

.. announce_start
Enhancements
-------------------------------

.. major_feature
.. feature
.. enhancement_tag_viz
.. enhancement_tag_datatypes
.. enhancement_tag_tools
.. enhancement_tag_workflows
.. enhancement_tag_ui
.. enhancement_tag_jobs
.. enhancement_tag_admin
.. enhancement
.. small_enhancement
Fixes
-------------------------------

.. major_bug
.. bug_tag_viz
.. bug_tag_datatypes
.. bug_tag_tools
.. bug_tag_workflows
.. bug_tag_ui
.. bug_tag_jobs
.. bug_tag_admin
.. bug
.. include:: 98.2_prs.rst

65 changes: 65 additions & 0 deletions tests/test_data/98.2_announce.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@

===========================================================
98.2 Galaxy Release (January 2099)
===========================================================

.. include:: _header.rst

Highlights
===========================================================

Feature1
--------

Feature description.

Feature2
--------

Feature description.

Feature3
--------

Feature description.

Also check out the `98.2 user release notes <98.2_announce_user.html>`__.
Are you an admin? Check out `some admin relevant PRs <https://github.com/galaxyproject/galaxy/pulls?q=label%3Ahighlight%2Fadmin+milestone%3A98.2+is%3Aclosed+is%3Apr>`__.

Get Galaxy
===========================================================

The code lives at `GitHub <https://github.com/galaxyproject/galaxy>`__ and you should have `Git <https://git-scm.com/>`__ to obtain it.

To get a new Galaxy repository run:
.. code-block:: shell
$ git clone -b release_98.2 https://github.com/galaxyproject/galaxy.git
To update an existing Galaxy repository run:
.. code-block:: shell
$ git fetch origin && git checkout release_98.2 && git pull --ff-only origin release_98.2
See the `community hub <https://galaxyproject.org/develop/source-code/>`__ for additional details on source code locations.


Administration Notes
===========================================================
Add content or drop section.

Configuration Changes
===========================================================
Add content or drop section.

Deprecation Notices
===========================================================
Add content or drop section.

Release Notes
===========================================================

.. include:: 98.2.rst
:start-after: announce_start

.. include:: _thanks.rst
56 changes: 56 additions & 0 deletions tests/test_data/98.2_announce_user.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@

===========================================================
98.2 Galaxy Release (January 2099)
===========================================================

.. include:: _header.rst

Highlights
===========================================================

Feature1
--------

Feature description.

Feature2
--------

Feature description.

Feature3
--------

Feature description.


Visualizations
===========================================================

.. visualizations
Datatypes
===========================================================

.. datatypes
Builtin Tool Updates
===========================================================

.. tools
Release Testing Team
===========================================================

A special thanks to the release testing team for testing many of the new features and reporting many bugs:

<team members go here>

Release Notes
===========================================================

Please see the :doc:`full release notes <98.2_announce>` for more details.

.. include:: 98.2_prs.rst

.. include:: _thanks.rst
2 changes: 2 additions & 0 deletions tests/test_data/98.2_prs.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@

.. github_links
6 changes: 6 additions & 0 deletions tests/test_data/99.0_announce.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@

:orphan:

===========================================================
99.0 Galaxy Release
===========================================================

0 comments on commit 912ca26

Please sign in to comment.