From 39fed070669258650cdf5d2a4c180399bf256ad6 Mon Sep 17 00:00:00 2001 From: Corey Oordt Date: Sat, 14 Dec 2024 08:37:06 -0600 Subject: [PATCH 1/8] Refactored dependencies config - Changed `project.optional-dependencies` to `dependency-groups` --- pyproject.toml | 2 +- uv.lock | 62 ++++++++++++++++++++++++++++---------------------- 2 files changed, 36 insertions(+), 28 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index d03c79a..cd160db 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -51,7 +51,7 @@ homepage = "https://github.com/callowayproject/bump-my-version" repository = "https://github.com/callowayproject/bump-my-version.git" documentation = "https://callowayproject.github.io/bump-my-version/" -[project.optional-dependencies] +[dependency-groups] dev = [ "git-fame>=1.12.2", "generate-changelog>=0.7.6", diff --git a/uv.lock b/uv.lock index 159b08c..281275a 100644 --- a/uv.lock +++ b/uv.lock @@ -137,7 +137,7 @@ dependencies = [ { name = "wcmatch" }, ] -[package.optional-dependencies] +[package.dev-dependencies] dev = [ { name = "generate-changelog" }, { name = "git-fame" }, @@ -173,35 +173,9 @@ test = [ [package.metadata] requires-dist = [ - { name = "black", marker = "extra == 'docs'" }, { name = "click" }, - { name = "coverage", marker = "extra == 'test'" }, - { name = "freezegun", marker = "extra == 'test'" }, - { name = "generate-changelog", marker = "extra == 'dev'", specifier = ">=0.7.6" }, - { name = "git-fame", marker = "extra == 'dev'", specifier = ">=1.12.2" }, - { name = "markdown-customblocks", marker = "extra == 'docs'" }, - { name = "mdx-truly-sane-lists", marker = "extra == 'docs'" }, - { name = "mkdocs", marker = "extra == 'docs'" }, - { name = "mkdocs-click", marker = "extra == 'docs'" }, - { name = "mkdocs-drawio", marker = "extra == 'docs'" }, - { name = "mkdocs-gen-files", marker = "extra == 'docs'" }, - { name = "mkdocs-git-authors-plugin", marker = "extra == 'docs'" }, - { name = "mkdocs-git-committers-plugin", marker = "extra == 'docs'" }, - { name = "mkdocs-git-revision-date-localized-plugin", marker = "extra == 'docs'", specifier = ">=1.2.6" }, - { name = "mkdocs-include-markdown-plugin", marker = "extra == 'docs'" }, - { name = "mkdocs-literate-nav", marker = "extra == 'docs'" }, - { name = "mkdocs-material", marker = "extra == 'docs'" }, - { name = "mkdocstrings", extras = ["python"], marker = "extra == 'docs'" }, - { name = "pip-tools", marker = "extra == 'dev'" }, - { name = "pre-commit", marker = "extra == 'dev'" }, - { name = "pre-commit", marker = "extra == 'test'" }, { name = "pydantic", specifier = ">=2.0.0" }, { name = "pydantic-settings" }, - { name = "pytest", marker = "extra == 'test'" }, - { name = "pytest-cov", marker = "extra == 'test'" }, - { name = "pytest-mock", marker = "extra == 'test'" }, - { name = "pytest-sugar", marker = "extra == 'test'" }, - { name = "python-frontmatter", marker = "extra == 'docs'" }, { name = "questionary" }, { name = "rich" }, { name = "rich-click" }, @@ -209,6 +183,40 @@ requires-dist = [ { name = "wcmatch", specifier = ">=8.5.1" }, ] +[package.metadata.requires-dev] +dev = [ + { name = "generate-changelog", specifier = ">=0.7.6" }, + { name = "git-fame", specifier = ">=1.12.2" }, + { name = "pip-tools" }, + { name = "pre-commit" }, +] +docs = [ + { name = "black" }, + { name = "markdown-customblocks" }, + { name = "mdx-truly-sane-lists" }, + { name = "mkdocs" }, + { name = "mkdocs-click" }, + { name = "mkdocs-drawio" }, + { name = "mkdocs-gen-files" }, + { name = "mkdocs-git-authors-plugin" }, + { name = "mkdocs-git-committers-plugin" }, + { name = "mkdocs-git-revision-date-localized-plugin", specifier = ">=1.2.6" }, + { name = "mkdocs-include-markdown-plugin" }, + { name = "mkdocs-literate-nav" }, + { name = "mkdocs-material" }, + { name = "mkdocstrings", extras = ["python"] }, + { name = "python-frontmatter" }, +] +test = [ + { name = "coverage" }, + { name = "freezegun" }, + { name = "pre-commit" }, + { name = "pytest" }, + { name = "pytest-cov" }, + { name = "pytest-mock" }, + { name = "pytest-sugar" }, +] + [[package]] name = "certifi" version = "2024.8.30" From 2b7c905c792e1cbe22040a5ba890c4440990f99b Mon Sep 17 00:00:00 2001 From: Corey Oordt Date: Sat, 14 Dec 2024 08:37:24 -0600 Subject: [PATCH 2/8] Refactor warning display with Rich formatting. Replace plain click-based warnings with styled Rich panels for better visibility. This enhances user experience by providing clearer and more visually organized warnings. --- bumpversion/ui.py | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/bumpversion/ui.py b/bumpversion/ui.py index 8b8fa11..55dc191 100644 --- a/bumpversion/ui.py +++ b/bumpversion/ui.py @@ -1,10 +1,14 @@ """Utilities for user interface.""" import logging +import sys import click from click import UsageError, secho from rich.logging import RichHandler +from rich.padding import Padding +from rich.panel import Panel +from rich_click.rich_help_formatter import RichHelpFormatter from bumpversion.indented_logger import IndentedLoggerAdapter @@ -50,4 +54,17 @@ def print_error(msg: str) -> None: def print_warning(msg: str) -> None: """Echo a warning to the console.""" - secho(f"\nWARNING:\n\n{msg}\n", fg="yellow") + formatter = RichHelpFormatter(file=sys.stderr) + config = formatter.config + + formatter.write( + Padding( + Panel( + formatter.highlighter(msg), + border_style="yellow", + title="Warning", + title_align=config.align_errors_panel, + ), + (0, 0, 1, 0), + ) + ) From 86a0a3bdbebbde81e17df687bc4d7303d27d490f Mon Sep 17 00:00:00 2001 From: Corey Oordt Date: Sat, 14 Dec 2024 16:58:05 -0600 Subject: [PATCH 3/8] Fixed GitHub workflows --- .github/actions/release/action.yaml | 9 --------- .github/actions/setup-python-and-git/action.yaml | 12 +++++++----- .github/workflows/docs-final.yml | 11 +++++------ .github/workflows/docs-preview.yml | 11 +++++------ .github/workflows/release.yaml | 2 -- .github/workflows/test.yaml | 6 ++++-- 6 files changed, 21 insertions(+), 30 deletions(-) diff --git a/.github/actions/release/action.yaml b/.github/actions/release/action.yaml index 649bb60..bde34d9 100644 --- a/.github/actions/release/action.yaml +++ b/.github/actions/release/action.yaml @@ -1,15 +1,9 @@ name: Release description: Create a GitHub release and upload the package to PyPI inputs: - pypi-api-token: - description: 'PyPI API token' - required: true tag-name: description: 'The name of the tag for the GitHub release' required: true - github-token: - description: 'GitHub token' - required: true runs: using: "composite" @@ -31,9 +25,6 @@ runs: files: dist/* tag_name: "${{ inputs.tag-name }}" body_path: release-notes.md - token: ${{ inputs.github-token }} - name: Upload package to PyPI uses: pypa/gh-action-pypi-publish@release/v1 - with: - password: ${{ inputs.pypi-api-token }} diff --git a/.github/actions/setup-python-and-git/action.yaml b/.github/actions/setup-python-and-git/action.yaml index 2471ab0..bb288dd 100644 --- a/.github/actions/setup-python-and-git/action.yaml +++ b/.github/actions/setup-python-and-git/action.yaml @@ -4,19 +4,21 @@ inputs: python-version: description: 'Python version to use' required: false - default: '3.11' + default: '3.12' runs: using: 'composite' steps: - - uses: actions/setup-python@v4 + - uses: actions/setup-python@v5 name: Setup Python with: python-version: ${{ inputs.python-version }} - cache: 'pip' # caching pip dependencies - + - name: Install the latest version of uv + uses: astral-sh/setup-uv@v4 + with: + version: "latest" - name: Git check run: | - git config --global user.email "bump-my-version@github.actions" + git config --global user.email "action@github.actions" git config --global user.name "Testing Git" git --version git config --list diff --git a/.github/workflows/docs-final.yml b/.github/workflows/docs-final.yml index 1c60edd..87e24d8 100644 --- a/.github/workflows/docs-final.yml +++ b/.github/workflows/docs-final.yml @@ -19,18 +19,17 @@ jobs: uses: actions/checkout@v4 with: fetch-depth: 0 - token: ${{ secrets.PAT }} - - name: Set up Python 3.10 - uses: actions/setup-python@v5 + - name: Setup Python and Git + uses: ./.github/actions/setup-python-and-git with: - python-version: "3.10" + python-version: '3.12' - name: Install dependencies run: | git pull --all - python -m pip install ".[docs]" + uv sync -p 3.12 --group docs - name: Build and deploy documentation run: | - mkdocs gh-deploy --strict -v + uv run mkdocs gh-deploy --strict diff --git a/.github/workflows/docs-preview.yml b/.github/workflows/docs-preview.yml index f2d30a0..18bbc2d 100644 --- a/.github/workflows/docs-preview.yml +++ b/.github/workflows/docs-preview.yml @@ -24,18 +24,17 @@ jobs: with: fetch-depth: 0 - - name: Set up Python 3.10 - uses: actions/setup-python@v5 + - name: Setup Python and Git + uses: ./.github/actions/setup-python-and-git with: - python-version: "3.10" + python-version: '3.12' - name: Install dependencies - run: | - python -m pip install ".[docs]" + run: uv sync -p 3.12 --group docs - name: Build documentation run: | - mkdocs build --strict -v + uv run mkdocs build --strict - name: Deploy preview uses: rossjrw/pr-preview-action@v1 diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index 6df25b2..47c268c 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -96,5 +96,3 @@ jobs: uses: ./.github/actions/release with: tag-name: ${{ env.TAG_NAME }} - github-token: ${{ secrets.PAT }} - pypi-api-token: ${{ secrets.PYPI_API_TOKEN }} diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index ccbd237..7ca1d00 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -42,8 +42,10 @@ jobs: run: | echo -e '[ui]\nusername = Testing Mercurial' > ~/.hgrc hg --version - - name: Install test dependencies - run: pip install '.[test]' + - name: Install requirements + shell: bash + run: | + uv sync -p 3.12 --group dev - name: Test run: pytest --cov-report=xml - name: Upload coverage to Codecov From 6e2da8d54ad79ed3b46976af57d3721b3e50b370 Mon Sep 17 00:00:00 2001 From: Corey Oordt Date: Sat, 14 Dec 2024 17:02:15 -0600 Subject: [PATCH 4/8] Fixed issue with python install --- .github/workflows/test.yaml | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index 7ca1d00..7c8e044 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -22,22 +22,17 @@ jobs: - ubuntu-latest - windows-latest python-version: - - "3.8" - "3.9" - "3.10" - "3.11" + - "3.12" + - "3.13" runs-on: ${{ matrix.os }} steps: - uses: actions/checkout@v4 - - uses: actions/setup-python@v5 + - uses: ./.github/actions/setup-python-and-git with: python-version: ${{ matrix.python-version }} - - name: Check git is working - run: | - git config --global user.email "bumpversion-test-git@github.actions" - git config --global user.name "Testing Git" - git --version - git config --list - name: Check mercurial is working run: | echo -e '[ui]\nusername = Testing Mercurial' > ~/.hgrc From cbf10f23c33e8d62d4851f11579f93a359553bff Mon Sep 17 00:00:00 2001 From: Corey Oordt Date: Sat, 14 Dec 2024 17:05:09 -0600 Subject: [PATCH 5/8] Fixed installation of test dependencies --- .github/workflows/test.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index 7c8e044..956f8f0 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -40,7 +40,7 @@ jobs: - name: Install requirements shell: bash run: | - uv sync -p 3.12 --group dev + uv sync -p 3.12 --group dev --group test - name: Test run: pytest --cov-report=xml - name: Upload coverage to Codecov From d829276347c5391a9d2233e56e30300b69172d14 Mon Sep 17 00:00:00 2001 From: Corey Oordt Date: Sat, 14 Dec 2024 17:08:49 -0600 Subject: [PATCH 6/8] Fixed more uv run workflows --- .github/workflows/test.yaml | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index 956f8f0..32920cc 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -42,7 +42,7 @@ jobs: run: | uv sync -p 3.12 --group dev --group test - name: Test - run: pytest --cov-report=xml + run: uv run pytest --cov-report=xml - name: Upload coverage to Codecov uses: codecov/codecov-action@v5 with: @@ -60,19 +60,16 @@ jobs: - uses: actions/checkout@v4 with: fetch-depth: 0 - token: ${{ secrets.PAT }} ref: ${{ github.head_ref }} - - uses: actions/setup-python@v5 + - uses: ./.github/actions/setup-python-and-git with: - python-version: '3.11' - cache: 'pip' # caching pip dependencies + python-version: "3.12" - name: Install requirements shell: bash run: | - python -m pip install --disable-pip-version-check --no-python-version-warning build - python -m pip install --disable-pip-version-check --no-python-version-warning -e . + uv sync -p 3.12 --group dev - name: Set dev version shell: bash @@ -80,17 +77,14 @@ jobs: export PR_NUMBER=$(gh pr view --json number -q .number || echo "") echo "PR_NUMBER=$PR_NUMBER" >> $GITHUB_ENV echo "::notice::PR_NUMBER is: ${PR_NUMBER}" - bump-my-version bump dev bumpversion/__init__.py --no-commit --no-tag --no-configured-files -v - env: - GH_TOKEN: ${{ secrets.PAT }} + uv run bump-my-version bump dev bumpversion/__init__.py --no-commit --no-tag --no-configured-files -v - name: Package shell: bash run: | - python -m build + uv build - name: Upload package to Test PyPI uses: pypa/gh-action-pypi-publish@release/v1 with: - password: ${{ secrets.TEST_PYPI_API_TOKEN }} repository-url: https://test.pypi.org/legacy/ From 11c1e42954281dac9febcac80f10d3775fcfcbbc Mon Sep 17 00:00:00 2001 From: Corey Oordt Date: Sat, 14 Dec 2024 17:19:46 -0600 Subject: [PATCH 7/8] Fixed Ruff errors and workflow permissions --- .github/workflows/test.yaml | 2 ++ pyproject.toml | 2 -- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index 32920cc..486557f 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -56,6 +56,8 @@ jobs: release-test-pypi: name: Publish in-dev package to test.pypi.org runs-on: ubuntu-latest + permissions: + id-token: write steps: - uses: actions/checkout@v4 with: diff --git a/pyproject.toml b/pyproject.toml index cd160db..adba278 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -210,8 +210,6 @@ select = [ ignore = [ "ANN002", # missing-type-args "ANN003", # missing-type-kwargs - "ANN101", # missing-type-self - "ANN102", # missing-type-cls "ANN204", # missing-return-type-special-method "ANN401", # any-type "S101", # assert From 183a6f29a8781eb76029f677aa83678a2ed1d505 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Sat, 14 Dec 2024 23:25:05 +0000 Subject: [PATCH 8/8] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- bumpversion/config/models.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bumpversion/config/models.py b/bumpversion/config/models.py index d6ce3ef..52fe228 100644 --- a/bumpversion/config/models.py +++ b/bumpversion/config/models.py @@ -11,7 +11,7 @@ from pydantic_settings import BaseSettings, SettingsConfigDict from bumpversion.ui import get_indented_logger -from bumpversion.versioning.models import VersionComponentSpec # NOQA: TCH001 +from bumpversion.versioning.models import VersionComponentSpec # NOQA: TC001 if TYPE_CHECKING: from bumpversion.scm import SCMInfo