From ab5ac24829f88dc795df256d7ad00c707e0f2987 Mon Sep 17 00:00:00 2001 From: Arthur Pastel Date: Tue, 14 Nov 2023 14:10:35 +0100 Subject: [PATCH 1/7] chore: add codspeed badge to the readme --- README.md | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index be3d3b3..2712dac 100644 --- a/README.md +++ b/README.md @@ -2,11 +2,10 @@

pytest-codspeed

[![CI](https://github.com/CodSpeedHQ/pytest-codspeed/actions/workflows/ci.yml/badge.svg)](https://github.com/CodSpeedHQ/pytest-codspeed/actions/workflows/ci.yml) - -Package version - -python-3.7-3.8-3.9-3.10-3.11-3.12 +[![PyPi Version](https://img.shields.io/pypi/v/pytest-codspeed?color=%2334D058&label=pypi)](https://pypi.org/project/pytest-codspeed) +![Python Version](https://img.shields.io/badge/python-3.7%20|%203.8%20|%203.9%20|%203.10%20|%203.11%20|%203.12-informational.svg) [![Discord](https://img.shields.io/badge/chat%20on-discord-7289da.svg)](https://discord.com/invite/MxpaCfKSqF) +[![CodSpeed Badge](https://img.shields.io/endpoint?url=https://codspeed.io/badge.json)](https://codspeed.io/CodSpeedHQ/pytest-codspeed) Pytest plugin to create CodSpeed benchmarks From 367ef470149485a8267e491f14a6c413d2821b03 Mon Sep 17 00:00:00 2001 From: Adrien Cacciaguerra Date: Fri, 1 Dec 2023 16:52:19 +0100 Subject: [PATCH 2/7] chore: update action version in README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 2712dac..32ec187 100644 --- a/README.md +++ b/README.md @@ -107,7 +107,7 @@ jobs: - name: Install dependencies run: pip install -r requirements.txt - name: Run benchmarks - uses: CodSpeedHQ/action@v1 + uses: CodSpeedHQ/action@v2 with: token: ${{ secrets.CODSPEED_TOKEN }} run: pytest tests/ --codspeed From 56e6211d1904b690d5800fcc22210c05f1f243b9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Edgar=20Ram=C3=ADrez=20Mondrag=C3=B3n?= <16805946+edgarrmondragon@users.noreply.github.com> Date: Tue, 13 Feb 2024 09:37:47 -0600 Subject: [PATCH 3/7] fix: loosen runtime requirements (#21) * fix: Loosen runtime requirements * Bump `setup-python` * Loosen `setuptools` requirement * chore: update setuptools requirements * fixup! chore: update setuptools requirements * fixup! chore: update setuptools requirements --------- Co-authored-by: Arthur Pastel --- .github/workflows/ci.yml | 11 ++++++----- .github/workflows/codspeed.yml | 2 +- pyproject.toml | 8 +++++--- 3 files changed, 12 insertions(+), 9 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 356b979..25b11c8 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -4,6 +4,7 @@ on: branches: [master] pull_request: branches: [master] + workflow_dispatch: concurrency: group: ${{ github.ref }} @@ -13,9 +14,9 @@ jobs: static-analysis: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v4 - name: Set up Python 3.11 - uses: actions/setup-python@v2 + uses: actions/setup-python@v5 with: python-version: "3.11" - uses: pre-commit/action@v3.0.0 @@ -37,12 +38,12 @@ jobs: - "3.9" - "3.10" - "3.11" - - "3.12.0-beta.1" + - "3.12" steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v4 - name: "Set up Python ${{ matrix.python-version }}" - uses: actions/setup-python@v2 + uses: actions/setup-python@v5 with: python-version: "${{ matrix.python-version }}" - if: matrix.config == 'valgrind' || matrix.config == 'pytest-benchmark' diff --git a/.github/workflows/codspeed.yml b/.github/workflows/codspeed.yml index a633d95..b13938d 100644 --- a/.github/workflows/codspeed.yml +++ b/.github/workflows/codspeed.yml @@ -14,7 +14,7 @@ jobs: - name: Set up Python 3.12 uses: actions/setup-python@v2 with: - python-version: "3.12.0-beta.3" + python-version: "3.12" - name: Install local version of pytest-codspeed run: pip install . - name: Run benchmarks diff --git a/pyproject.toml b/pyproject.toml index 2411b8b..8f56f9e 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -35,10 +35,12 @@ classifiers = [ "Typing :: Typed", ] dependencies = [ - "cffi ~= 1.15.1", + "cffi >= 1.15.1", + # cffi doesn't automatically install setuptools with python 3.12+ + # cf https://github.com/python-cffi/cffi/releases/tag/v1.16.0 + "setuptools; python_full_version >= '3.12.0'", "pytest>=3.8", - "filelock ~= 3.12.2", - "setuptools ~= 67.8.0; python_full_version >= '3.12.0b1'", # FIXME: remove when cffi supports directly python 3.12 + "filelock >= 3.12.2", ] [project.optional-dependencies] From 061699b38f9527336aa118cd50467583f39c6646 Mon Sep 17 00:00:00 2001 From: Arthur Pastel Date: Mon, 18 Mar 2024 19:05:09 -0400 Subject: [PATCH 4/7] feat: support pytest 8.1.1 --- .github/workflows/ci.yml | 12 +++++++++--- src/pytest_codspeed/plugin.py | 12 ++++++++---- tests/test_pytest_plugin.py | 2 +- 3 files changed, 18 insertions(+), 8 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 25b11c8..0b10086 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -33,12 +33,18 @@ jobs: - pytest-benchmark - valgrind python-version: - - "3.7" - "3.8" - "3.9" - "3.10" - "3.11" - "3.12" + pytest-version: + - ">=8.1.1" + include: + - config: pytest-benchmark + python-version: "3.7" + pytest-version: "<8.1.1" + steps: - uses: actions/checkout@v4 @@ -49,8 +55,8 @@ jobs: - if: matrix.config == 'valgrind' || matrix.config == 'pytest-benchmark' name: Install valgrind run: sudo apt-get install valgrind -y - - name: Install dependencies - run: pip install .[dev,compat] + - name: Install dependencies with pytest${{ matrix.pytest-version }} + run: pip install .[dev,compat] "pytest${{ matrix.pytest-version }}" - if: matrix.config != 'pytest-benchmark' name: Uninstall pytest-benchmark run: pip uninstall -y pytest-benchmark diff --git a/src/pytest_codspeed/plugin.py b/src/pytest_codspeed/plugin.py index 13d8e97..559066f 100644 --- a/src/pytest_codspeed/plugin.py +++ b/src/pytest_codspeed/plugin.py @@ -28,6 +28,7 @@ IS_PYTEST_BENCHMARK_INSTALLED = pkgutil.find_loader("pytest_benchmark") is not None SUPPORTS_PERF_TRAMPOLINE = sys.version_info >= (3, 12) +BEFORE_PYTEST_8_1_1 = pytest.version_tuple < (8, 1, 1) @pytest.hookimpl(trylast=True) @@ -95,15 +96,18 @@ def pytest_plugin_registered(plugin, manager: "pytest.PytestPluginManager"): codspeed_plugin: CodSpeedPlugin = manager.get_plugin(PLUGIN_NAME) if codspeed_plugin.is_codspeed_enabled: codspeed_benchmark_fixtures = plugin.getfixturedefs( - "codspeed_benchmark", "" + "codspeed_benchmark", + fixture_manager.session.nodeid + if BEFORE_PYTEST_8_1_1 + else fixture_manager.session, ) assert codspeed_benchmark_fixtures is not None + # Archive the pytest-benchmark fixture fixture_manager._arg2fixturedefs[ "__benchmark" ] = fixture_manager._arg2fixturedefs["benchmark"] - fixture_manager._arg2fixturedefs["benchmark"] = list( - codspeed_benchmark_fixtures - ) + # Replace the pytest-benchmark fixture with the codspeed one + fixture_manager._arg2fixturedefs["benchmark"] = codspeed_benchmark_fixtures @pytest.hookimpl(trylast=True) diff --git a/tests/test_pytest_plugin.py b/tests/test_pytest_plugin.py index ce83032..2997f08 100644 --- a/tests/test_pytest_plugin.py +++ b/tests/test_pytest_plugin.py @@ -142,7 +142,7 @@ class TestGroup: def setup_method(self): print(); print("Setup called") - def teardown(self): + def teardown_method(self): print(); print("Teardown called") @pytest.mark.benchmark From e75634be2d9c976393f70a6c5bb3b482da7d813b Mon Sep 17 00:00:00 2001 From: Arthur Pastel Date: Tue, 19 Mar 2024 17:39:24 -0400 Subject: [PATCH 5/7] chore: switch from black to ruff format --- .pre-commit-config.yaml | 9 +++------ pyproject.toml | 3 ++- src/pytest_codspeed/plugin.py | 6 +++--- 3 files changed, 8 insertions(+), 10 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 0f71438..953997a 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -8,15 +8,12 @@ repos: - id: end-of-file-fixer - id: check-yaml - id: check-added-large-files - - repo: https://github.com/psf/black - rev: 22.3.0 - hooks: - - id: black - repo: https://github.com/pre-commit/mirrors-mypy rev: v1.3.0 hooks: - id: mypy - - repo: https://github.com/charliermarsh/ruff-pre-commit - rev: v0.0.275 + - repo: https://github.com/astral-sh/ruff-pre-commit + rev: v0.3.3 hooks: - id: ruff + - id: ruff-format diff --git a/pyproject.toml b/pyproject.toml index 8f56f9e..9032d69 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -44,7 +44,7 @@ dependencies = [ ] [project.optional-dependencies] -lint = ["black ~= 23.3.0", "isort ~=5.12.0", "mypy ~= 1.3.0", "ruff ~= 0.0.275"] +lint = ["mypy ~= 1.3.0", "ruff ~= 0.3.3"] compat = ["pytest-benchmark ~= 4.0.0", "pytest-xdist ~= 2.0.0"] test = ["pytest ~= 7.0", "pytest-cov ~= 4.0.0"] @@ -73,6 +73,7 @@ python_version = "3.12" [tool.ruff] line-length = 88 +[tool.ruff.lint] select = ["E", "F", "I", "C"] [tool.isort] diff --git a/src/pytest_codspeed/plugin.py b/src/pytest_codspeed/plugin.py index 559066f..24dc656 100644 --- a/src/pytest_codspeed/plugin.py +++ b/src/pytest_codspeed/plugin.py @@ -103,9 +103,9 @@ def pytest_plugin_registered(plugin, manager: "pytest.PytestPluginManager"): ) assert codspeed_benchmark_fixtures is not None # Archive the pytest-benchmark fixture - fixture_manager._arg2fixturedefs[ - "__benchmark" - ] = fixture_manager._arg2fixturedefs["benchmark"] + fixture_manager._arg2fixturedefs["__benchmark"] = ( + fixture_manager._arg2fixturedefs["benchmark"] + ) # Replace the pytest-benchmark fixture with the codspeed one fixture_manager._arg2fixturedefs["benchmark"] = codspeed_benchmark_fixtures From 0d1fdceed60e44941c8cab41fe09b84ddc443b87 Mon Sep 17 00:00:00 2001 From: Arthur Pastel Date: Tue, 19 Mar 2024 17:44:41 -0400 Subject: [PATCH 6/7] chore: add all-checks job to CI workflow --- .github/workflows/ci.yml | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 0b10086..8d13451 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -45,7 +45,6 @@ jobs: python-version: "3.7" pytest-version: "<8.1.1" - steps: - uses: actions/checkout@v4 - name: "Set up Python ${{ matrix.python-version }}" @@ -62,3 +61,11 @@ jobs: run: pip uninstall -y pytest-benchmark - name: Run tests run: pytest -vs + + all-checks: + runs-on: ubuntu-latest + steps: + - run: echo "All CI checks passed." + needs: + - static-analysis + - tests From 7546a2fd6f812c3201f85842fa2e733bcb689535 Mon Sep 17 00:00:00 2001 From: Arthur Pastel Date: Tue, 19 Mar 2024 17:59:08 -0400 Subject: [PATCH 7/7] =?UTF-8?q?Release=20v2.2.1=20=F0=9F=9A=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/pytest_codspeed/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pytest_codspeed/__init__.py b/src/pytest_codspeed/__init__.py index fda8a71..dcc0ac0 100644 --- a/src/pytest_codspeed/__init__.py +++ b/src/pytest_codspeed/__init__.py @@ -1,4 +1,4 @@ -__version__ = "2.2.0" +__version__ = "2.2.1" from .plugin import BenchmarkFixture