Skip to content

Commit

Permalink
Merge pull request #264 from callowayproject/254-color-code-warnings
Browse files Browse the repository at this point in the history
Add better formatting to warnings
  • Loading branch information
coordt authored Dec 14, 2024
2 parents 09b825b + 183a6f2 commit 13353bb
Show file tree
Hide file tree
Showing 10 changed files with 87 additions and 82 deletions.
9 changes: 0 additions & 9 deletions .github/actions/release/action.yaml
Original file line number Diff line number Diff line change
@@ -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"
Expand All @@ -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 }}
12 changes: 7 additions & 5 deletions .github/actions/setup-python-and-git/action.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
11 changes: 5 additions & 6 deletions .github/workflows/docs-final.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
11 changes: 5 additions & 6 deletions .github/workflows/docs-preview.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 0 additions & 2 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}
37 changes: 15 additions & 22 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,30 +22,27 @@ 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 "[email protected]"
git config --global user.name "Testing Git"
git --version
git config --list
- name: Check mercurial is working
run: |
echo -e '[ui]\nusername = Testing Mercurial<[email protected]>' > ~/.hgrc
hg --version
- name: Install test dependencies
run: pip install '.[test]'
- name: Install requirements
shell: bash
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:
Expand All @@ -59,41 +56,37 @@ 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:
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
run: |
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/
2 changes: 1 addition & 1 deletion bumpversion/config/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
19 changes: 18 additions & 1 deletion bumpversion/ui.py
Original file line number Diff line number Diff line change
@@ -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

Expand Down Expand Up @@ -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),
)
)
4 changes: 1 addition & 3 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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
Expand Down
62 changes: 35 additions & 27 deletions uv.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 13353bb

Please sign in to comment.