mirror of
https://github.com/beetbox/beets.git
synced 2025-12-06 08:39:17 +01:00
Test rst to md conversion
This commit is contained in:
parent
13e83cdce3
commit
7b9625bc86
3 changed files with 91 additions and 10 deletions
6
.github/workflows/ci.yaml
vendored
6
.github/workflows/ci.yaml
vendored
|
|
@ -29,12 +29,12 @@ jobs:
|
||||||
python-version: ${{ matrix.python-version }}
|
python-version: ${{ matrix.python-version }}
|
||||||
cache: poetry
|
cache: poetry
|
||||||
|
|
||||||
- name: Install PyGobject dependencies on Ubuntu
|
- name: Install PyGobject and release script dependencies on Ubuntu
|
||||||
if: matrix.platform == 'ubuntu-latest'
|
if: matrix.platform == 'ubuntu-latest'
|
||||||
run: |
|
run: |
|
||||||
sudo apt update
|
sudo apt update
|
||||||
sudo apt install ffmpeg gobject-introspection libgirepository1.0-dev
|
sudo apt install ffmpeg gobject-introspection libgirepository1.0-dev pandoc
|
||||||
poetry install --extras=replaygain --extras=reflink
|
poetry install --with=release --extras=replaygain --extras=reflink
|
||||||
|
|
||||||
- name: Install Python dependencies
|
- name: Install Python dependencies
|
||||||
run: poetry install --only=main,test --extras=autobpm
|
run: poetry install --only=main,test --extras=autobpm
|
||||||
|
|
|
||||||
|
|
@ -119,13 +119,15 @@ def rst2md(text: str) -> str:
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
def changelog_as_markdown() -> str:
|
def get_changelog_contents() -> str | None:
|
||||||
|
if m := RST_LATEST_CHANGES.search(CHANGELOG.read_text()):
|
||||||
|
return m.group(1)
|
||||||
|
|
||||||
|
return None
|
||||||
|
|
||||||
|
|
||||||
|
def changelog_as_markdown(rst: str) -> str:
|
||||||
"""Get the latest changelog entry as hacked up Markdown."""
|
"""Get the latest changelog entry as hacked up Markdown."""
|
||||||
contents = CHANGELOG.read_text()
|
|
||||||
|
|
||||||
m = RST_LATEST_CHANGES.search(contents)
|
|
||||||
rst = m.group(1) if m else ""
|
|
||||||
|
|
||||||
for pattern, repl in RST_REPLACEMENTS:
|
for pattern, repl in RST_REPLACEMENTS:
|
||||||
rst = re.sub(pattern, repl, rst, flags=re.M)
|
rst = re.sub(pattern, repl, rst, flags=re.M)
|
||||||
|
|
||||||
|
|
@ -155,7 +157,8 @@ def bump(version: Version) -> None:
|
||||||
@cli.command()
|
@cli.command()
|
||||||
def changelog():
|
def changelog():
|
||||||
"""Get the most recent version's changelog as Markdown."""
|
"""Get the most recent version's changelog as Markdown."""
|
||||||
print(changelog_as_markdown())
|
if changelog := get_changelog_contents():
|
||||||
|
print(changelog_as_markdown(changelog))
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
|
|
|
||||||
78
test/test_release.py
Normal file
78
test/test_release.py
Normal file
|
|
@ -0,0 +1,78 @@
|
||||||
|
"""Tests for the release utils."""
|
||||||
|
|
||||||
|
import os
|
||||||
|
import shutil
|
||||||
|
import sys
|
||||||
|
|
||||||
|
import pytest
|
||||||
|
|
||||||
|
from extra.release import changelog_as_markdown
|
||||||
|
|
||||||
|
pytestmark = pytest.mark.skipif(
|
||||||
|
not (
|
||||||
|
(os.environ.get("GITHUB_ACTIONS") == "true" and sys.platform != "win32")
|
||||||
|
or bool(shutil.which("pandoc"))
|
||||||
|
),
|
||||||
|
reason="pandoc isn't available",
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.fixture
|
||||||
|
def rst_changelog():
|
||||||
|
return """New features:
|
||||||
|
|
||||||
|
* :doc:`/plugins/substitute`: Some substitute
|
||||||
|
multi-line change.
|
||||||
|
:bug:`5467`
|
||||||
|
* :ref:`list-cmd` Update.
|
||||||
|
|
||||||
|
Bug fixes:
|
||||||
|
|
||||||
|
* Some fix that refers to an issue.
|
||||||
|
:bug:`5467`
|
||||||
|
* Some fix that mentions user :user:`username`.
|
||||||
|
|
||||||
|
Empty section:
|
||||||
|
|
||||||
|
Other changes:
|
||||||
|
|
||||||
|
* Changed `bitesize` label to `good first issue`. Our `contribute`_ page is now
|
||||||
|
automatically populated with these issues. :bug:`4855`
|
||||||
|
|
||||||
|
.. _contribute: https://github.com/beetbox/beets/contribute
|
||||||
|
|
||||||
|
2.1.0 (November 22, 2024)
|
||||||
|
-------------------------
|
||||||
|
|
||||||
|
Bug fixes:
|
||||||
|
|
||||||
|
* Fixed something."""
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.fixture
|
||||||
|
def md_changelog():
|
||||||
|
return r"""### New features
|
||||||
|
|
||||||
|
- Command **`list`**: Update.
|
||||||
|
- Plugin **`substitute`**: Some substitute multi-line change. :bug: (\#5467)
|
||||||
|
|
||||||
|
### Bug fixes
|
||||||
|
|
||||||
|
- Some fix that mentions user @username.
|
||||||
|
- Some fix that refers to an issue. :bug: (\#5467)
|
||||||
|
|
||||||
|
### Other changes
|
||||||
|
|
||||||
|
|
||||||
|
# 2.1.0 (November 22, 2024)
|
||||||
|
- Changed `bitesize` label to `good first issue`. Our [contribute](https://github.com/beetbox/beets/contribute) page is now automatically populated with these issues. :bug: (\#4855)
|
||||||
|
|
||||||
|
### Bug fixes
|
||||||
|
|
||||||
|
- Fixed something.""" # noqa: E501
|
||||||
|
|
||||||
|
|
||||||
|
def test_convert_rst_to_md(rst_changelog, md_changelog):
|
||||||
|
actual = changelog_as_markdown(rst_changelog)
|
||||||
|
|
||||||
|
assert actual == md_changelog
|
||||||
Loading…
Reference in a new issue