From e3b1bff111771db994550a3913e6b43cbe822259 Mon Sep 17 00:00:00 2001 From: Bruno Oliveira Date: Thu, 12 Dec 2024 19:44:13 -0300 Subject: [PATCH] Drop Python 3.8 and modernize workflows * Drop Python 3.8 EOL support. * Modernize workflows to be consistent with the other workflows/good practices used in other `pytest-dev` repositories. --- .github/dependabot.yml | 8 +++++ .github/workflows/deploy.yml | 51 ++++++++++++++++++++++++++++ .github/workflows/publish.yml | 42 ------------------------ .github/workflows/test.yml | 62 +++++++++++++++++++++++++---------- CHANGELOG.md | 3 ++ RELEASING.rst | 37 +++++++++++++++++++++ pyproject.toml | 1 - setup.cfg | 5 ++- src/pytest_rich/terminal.py | 7 +--- src/pytest_rich/traceback.py | 10 ++---- tox.ini | 2 +- 11 files changed, 150 insertions(+), 78 deletions(-) create mode 100644 .github/dependabot.yml create mode 100644 .github/workflows/deploy.yml delete mode 100644 .github/workflows/publish.yml create mode 100644 RELEASING.rst diff --git a/.github/dependabot.yml b/.github/dependabot.yml new file mode 100644 index 0000000..2f48d86 --- /dev/null +++ b/.github/dependabot.yml @@ -0,0 +1,8 @@ +version: 2 +updates: +- package-ecosystem: github-actions + directory: / + schedule: + interval: weekly + time: "03:00" + open-pull-requests-limit: 10 diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml new file mode 100644 index 0000000..f37f529 --- /dev/null +++ b/.github/workflows/deploy.yml @@ -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/build-and-inspect-python-package@v2.10 + + 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/gh-action-pypi-publish@v1.12.2 + 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 diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml deleted file mode 100644 index 12be247..0000000 --- a/.github/workflows/publish.yml +++ /dev/null @@ -1,42 +0,0 @@ -name: publish - -on: - push: - tags: - - "v*" - -jobs: - test: - uses: ./.github/workflows/test.yml - deploy: - runs-on: ubuntu-latest - needs: [test] - steps: - - uses: actions/checkout@v4 - - name: Set up Python - uses: actions/setup-python@v5 - with: - python-version: "3.x" - - name: Get pip cache dir - id: pip-cache - run: | - echo "::set-output name=dir::$(pip cache dir)" - - uses: actions/cache@v2 - name: Configure pip caching - with: - path: ${{ steps.pip-cache.outputs.dir }} - key: ${{ runner.os }}-publish-pip-${{ hashFiles('**/setup.cfg') }} - restore-keys: | - - ${{ runner.os }}-publish-pip- - - name: Install dependencies - run: | - python -m pip install --upgrade pip - python -m pip install --upgrade build - - name: Build package - run: | - python -m build - - name: Publish package to PyPI - uses: pypa/gh-action-pypi-publish@master - with: - user: __token__ - password: ${{ secrets.PYPI_TOKEN }} diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 0611121..f3f2244 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -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/build-and-inspect-python-package@v2.10 + 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` diff --git a/CHANGELOG.md b/CHANGELOG.md index b9de23f..b11a94d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -21,6 +21,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Added +- Confirmed Python 3.13 support. ([#XX]) - Confirmed Python 3.12 support. ([#84]) - Added `CHANGELOG.md` file. ([#40]) - Confirmed Python 3.11 support. ([#39]) @@ -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. ([#XX]) ## [0.1.1] - 2022-03-03 @@ -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 +[#XX]: https://github.com/nicoddemus/pytest-rich/pull/XX diff --git a/RELEASING.rst b/RELEASING.rst new file mode 100644 index 0000000..3d7b583 --- /dev/null +++ b/RELEASING.rst @@ -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. diff --git a/pyproject.toml b/pyproject.toml index ab6c843..b3e70ed 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -2,7 +2,6 @@ requires = [ "setuptools>=42", "setuptools-scm", - "wheel" ] build-backend = "setuptools.build_meta" diff --git a/setup.cfg b/setup.cfg index b84d26c..45a3fd7 100644 --- a/setup.cfg +++ b/setup.cfg @@ -15,11 +15,11 @@ classifiers = 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 @@ -31,12 +31,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 = diff --git a/src/pytest_rich/terminal.py b/src/pytest_rich/terminal.py index d4fe6ca..aeb2e2c 100644 --- a/src/pytest_rich/terminal.py +++ b/src/pytest_rich/terminal.py @@ -1,9 +1,9 @@ -import sys import warnings from collections import defaultdict 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 @@ -28,11 +28,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) diff --git a/src/pytest_rich/traceback.py b/src/pytest_rich/traceback.py index 6aaa822..05f0160 100644 --- a/src/pytest_rich/traceback.py +++ b/src/pytest_rich/traceback.py @@ -1,5 +1,4 @@ import ast -import sys from typing import Dict from typing import Optional from typing import Sequence @@ -152,14 +151,9 @@ def get_funcname(lineno: int, filename: str) -> str: tree = ast.parse(code) for node in ast.walk(tree): if isinstance(node, ast.FunctionDef): - # TODO: Remove this if statement once 3.7 support is dropped - if sys.version_info < (3, 8): - if node.lineno <= lineno < node.lineno + node.body[0].lineno: + if node.end_lineno is not None: + if node.lineno <= lineno <= node.end_lineno: return node.name - else: - if node.end_lineno is not None: - if node.lineno <= lineno <= node.end_lineno: - return node.name return "???" def get_args(reprfuncargs: ReprFuncArgs) -> Text: diff --git a/tox.ini b/tox.ini index 2244635..3db8987 100644 --- a/tox.ini +++ b/tox.ini @@ -1,7 +1,7 @@ # For more information about tox, see https://tox.readthedocs.io/en/latest/ [tox] envlist = - py{37,38,39,310,311,312,py38} + py{39,310,311,312,313} isolated_build = true [testenv]