Skip to content

Commit

Permalink
Merge pull request #91 from nicoddemus/modernize-workflows
Browse files Browse the repository at this point in the history
Drop Python 3.8 and modernize workflows
  • Loading branch information
nicoddemus authored Dec 12, 2024
2 parents 5f0f046 + 75fa378 commit 65c142a
Show file tree
Hide file tree
Showing 13 changed files with 163 additions and 97 deletions.
8 changes: 8 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
version: 2
updates:
- package-ecosystem: github-actions
directory: /
schedule:
interval: weekly
time: "03:00"
open-pull-requests-limit: 10
51 changes: 51 additions & 0 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
name: deploy

on:
workflow_dispatch:
inputs:
version:
description: 'Release version'
required: true
default: '1.2.3'

jobs:

package:
runs-on: ubuntu-latest
env:
SETUPTOOLS_SCM_PRETEND_VERSION: ${{ github.event.inputs.version }}

steps:
- uses: actions/checkout@v4

- name: Build and Check Package
uses: hynek/[email protected]

deploy:
needs: package
runs-on: ubuntu-latest
environment: deploy
permissions:
id-token: write # For PyPI trusted publishers.
contents: write # For tag.

steps:
- uses: actions/checkout@v4

- name: Download Package
uses: actions/download-artifact@v4
with:
name: Packages
path: dist

- name: Publish package to PyPI
uses: pypa/[email protected]
with:
attestations: true

- name: GitHub Release
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
gh release create v${{ github.event.inputs.version }} --target=${{ github.ref_name }} --title v${{ github.event.inputs.version }}
gh pr merge ${{ github.ref_name }} --merge
42 changes: 0 additions & 42 deletions .github/workflows/publish.yml

This file was deleted.

62 changes: 45 additions & 17 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,30 +2,58 @@ name: test

on:
push:
branches:
- main
- "test-me-*"

pull_request:
workflow_call:
branches:
- "*"


# Cancel running jobs for the same workflow and branch.
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:

package:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Build and Check Package
uses: hynek/[email protected]

test:
needs: [package]
runs-on: ${{ matrix.os }}

strategy:
fail-fast: false
matrix:
python-version:
["3.8", "3.9", "3.10", "3.11", "3.12", "pypy-3.8"]
os: [ubuntu-latest, windows-latest, macos-latest]
os: ["ubuntu-latest", "windows-latest"]
python: ["3.9", "3.10", "3.11", "3.12", "3.13"]

steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip
python -m pip install tox
- name: Test
run: |
tox -e py
- uses: actions/checkout@v4

- name: Download Package
uses: actions/download-artifact@v4
with:
name: Packages
path: dist

- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python }}

- name: Install tox
run: |
python -m pip install --upgrade pip
python -m pip install --upgrade tox
- name: Test
shell: bash
run: |
tox run -e py --installpkg `find dist/*.tar.gz`
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

### Added

- Confirmed Python 3.13 support. ([#91])
- Confirmed Python 3.12 support. ([#84])
- Added `CHANGELOG.md` file. ([#40])
- Confirmed Python 3.11 support. ([#39])
Expand All @@ -32,6 +33,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Removed

- Dropped Python 3.7 support. ([#84])
- Dropped Python 3.8 support. ([#91])


## [0.1.1] - 2022-03-03
Expand All @@ -55,3 +57,4 @@ Initial release!
[#65]: https://github.com/nicoddemus/pytest-rich/pull/65
[#66]: https://github.com/nicoddemus/pytest-rich/pull/66
[#84]: https://github.com/nicoddemus/pytest-rich/pull/84
[#91]: https://github.com/nicoddemus/pytest-rich/pull/91
37 changes: 37 additions & 0 deletions RELEASING.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
=========================
Releasing pytest-rich
=========================

This document describes the steps to make a new ``pytest-rich`` release.

Version
-------

``master`` should always be green and a potential release candidate. ``pytest-rich`` follows
semantic versioning, so given that the current version is ``X.Y.Z``, to find the next version number
one needs to look at the ``CHANGELOG.rst`` file:

- If there any new feature, then we must make a new **minor** release: next
release will be ``X.Y+1.0``.

- Otherwise it is just a **bug fix** release: ``X.Y.Z+1``.


Steps
-----

To publish a new release ``X.Y.Z``, the steps are as follows:

#. Create a new branch named ``release-X.Y.Z`` from the latest ``main``.

#. Update the ``CHANGELOG.rst`` file with the new release information.

#. Commit and push the branch to ``upstream`` and open a PR.

#. Once the PR is **green** and **approved**, start the ``deploy`` workflow:

.. code-block:: console
gh workflow run deploy.yml -R pytest-dev/pytest-rich --ref release-VERSION --field version=VERSION
The PR will be automatically merged.
1 change: 0 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
requires = [
"setuptools>=42",
"setuptools-scm",
"wheel"
]
build-backend = "setuptools.build_meta"

Expand Down
6 changes: 3 additions & 3 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,19 @@ license = MIT
url = https://github.com/nicoddemus/pytest-rich
description = Leverage rich for richer test session output
long_description = file: README.rst
long_description_content_type = text/x-rst
classifiers =
Development Status :: 4 - Beta
Framework :: Pytest
Intended Audience :: Developers
Topic :: Software Development :: Testing
Programming Language :: Python
Programming Language :: Python :: 3
Programming Language :: Python :: 3.8
Programming Language :: Python :: 3.9
Programming Language :: Python :: 3.10
Programming Language :: Python :: 3.11
Programming Language :: Python :: 3.12
Programming Language :: Python :: 3.13
Programming Language :: Python :: 3 :: Only
Programming Language :: Python :: Implementation :: CPython
Programming Language :: Python :: Implementation :: PyPy
Expand All @@ -31,12 +32,11 @@ package_dir=
=src
packages=find:
py_modules = pytest_rich
python_requires = >=3.7
python_requires = >=3.9
install_requires =
attrs
pytest >= 7.0
rich
typing_extensions; python_version < '3.8'

[options.extras_require]
dev =
Expand Down
3 changes: 1 addition & 2 deletions src/pytest_rich/capture.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
from datetime import datetime
from datetime import timezone
from pathlib import Path
from typing import Tuple

from rich.console import Console

Expand All @@ -28,7 +27,7 @@ def save_terminal_output(console: Console, arg: str) -> None:
save_func(f"{filename}.{filetype}")


def _get_filename_from_arg(arg: str) -> Tuple[str, str]:
def _get_filename_from_arg(arg: str) -> tuple[str, str]:
"""
Get filename from command line argument.
Expand Down
2 changes: 1 addition & 1 deletion src/pytest_rich/header.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import sys
from typing import Iterable
from collections.abc import Iterable
from typing import Union

import pytest
Expand Down
24 changes: 8 additions & 16 deletions src/pytest_rich/terminal.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,9 @@
import sys
import warnings
from collections import defaultdict
from collections.abc import Sequence
from pathlib import Path
from typing import Dict
from typing import List
from typing import Literal
from typing import Optional
from typing import Sequence
from typing import Tuple
from typing import Union

import attr
Expand All @@ -28,11 +25,6 @@
from pytest_rich.header import generate_header_panel
from pytest_rich.traceback import RichExceptionChainRepr

if sys.version_info < (3, 8):
from typing_extensions import Literal
else:
from typing import Literal

HORIZONTAL_PAD = (0, 1, 0, 1)


Expand All @@ -48,11 +40,11 @@ def __attrs_post_init__(self):
self.runtest_progress: Optional[Progress] = None
self.total_items_collected = 0
self.total_items_completed = 0
self.items_per_file: Dict[Path, List[pytest.Item]] = {}
self.status_per_item: Dict[str, RichTerminalReporter.Status] = {}
self.items: Dict[str, pytest.Item] = {}
self.runtest_tasks_per_file: Dict[Path, TaskID] = {}
self.categorized_reports: Dict[str, List[pytest.TestReport]] = defaultdict(list)
self.items_per_file: dict[Path, list[pytest.Item]] = {}
self.status_per_item: dict[str, RichTerminalReporter.Status] = {}
self.items: dict[str, pytest.Item] = {}
self.runtest_tasks_per_file: dict[Path, TaskID] = {}
self.categorized_reports: dict[str, list[pytest.TestReport]] = defaultdict(list)
self.summary: Optional[Live] = None
self.total_duration: float = 0
self.console.record = self.config.getoption("rich_capture") is not None
Expand Down Expand Up @@ -114,7 +106,7 @@ def pytest_deselected(self, items: Sequence[pytest.Item]) -> None: ...
def pytest_plugin_registered(self, plugin) -> None: ...

def pytest_runtest_logstart(
self, nodeid: str, location: Tuple[str, Optional[int], str]
self, nodeid: str, location: tuple[str, Optional[int], str]
) -> None:
if self.runtest_progress is None:
self.runtest_progress = Progress(SpinnerColumn(), "{task.description}")
Expand Down
Loading

0 comments on commit 65c142a

Please sign in to comment.