From 6a6ed821bc0ac368dc7939c8d14f02034de457d2 Mon Sep 17 00:00:00 2001 From: Iuri de Silvio Date: Sat, 24 Feb 2024 11:31:27 +0100 Subject: [PATCH 1/4] Replace poetry with uv --- .github/workflows/python-publish.yml | 1 - .gitignore | 1 + pyproject.toml | 36 +++++++++++++--------------- requirements-test.txt | 23 ++++++++++++++++++ requirements.txt | 3 +++ tests/test_plugin.py | 2 ++ tox.ini | 11 ++++++--- 7 files changed, 54 insertions(+), 23 deletions(-) create mode 100644 requirements-test.txt create mode 100644 requirements.txt diff --git a/.github/workflows/python-publish.yml b/.github/workflows/python-publish.yml index bf100e0..182bab3 100644 --- a/.github/workflows/python-publish.yml +++ b/.github/workflows/python-publish.yml @@ -26,5 +26,4 @@ jobs: - name: Build and publish to pypi uses: JRubics/poetry-publish@v1.15 with: - plugins: poetry_dynamic_versioning[plugin] pypi_token: ${{ secrets.PYPI_API_TOKEN }} diff --git a/.gitignore b/.gitignore index 1c439c7..d691af3 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,6 @@ __pycache__/ .tox/ +*.egg-info/ .coverage coverage*.xml diff --git a/pyproject.toml b/pyproject.toml index 0712e1d..eb951ec 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,29 +1,30 @@ -[tool.poetry] +[project] name = "pytest-ruff" -version = "0.0.0" description = "pytest plugin to check ruff requirements." -authors = ["Iuri de Silvio "] +authors = [{"name" = "Iuri de Silvio", "email" = "iurisilvio@gmail.com"}] readme = "README.md" classifiers = [ "Development Status :: 4 - Beta", "Intended Audience :: Developers", "Operating System :: OS Independent", "Framework :: Pytest", "Programming Language :: Python :: 3", "Programming Language :: Python :: 3 :: Only", "Topic :: Software Development :: Libraries :: Python Modules"] +dynamic = ["version"] +dependencies = [ + "ruff>=0.0.242" +] -[tool.poetry.urls] +[project.urls] Homepage = "https://github.com/businho/pytest-ruff" [build-system] -requires = ["poetry-core>=1.0.0", "poetry-dynamic-versioning"] -build-backend = "poetry_dynamic_versioning.backend" +requires = ["setuptools", "setuptools_scm"] +build-backend = "setuptools.build_meta" -[tool.poetry.dependencies] -python = "^3.8" -ruff = ">=0.0.242" +[project.optional-dependencies] +test = [ + "pytest>=7.2.0", + "pytest-mock>=3.10.0", + "pytest-cov>=4.1.0", +] -[tool.poetry.group.dev.dependencies] -pytest = "^7.2.0" -pytest-mock = "^3.10.0" -pytest-cov = "^4.1.0" - -[tool.poetry-dynamic-versioning] -enable = true +[project.entry-points.pytest11] +ruff = "pytest_ruff" [tool.pytest.ini_options] addopts = "--capture=no" @@ -31,9 +32,6 @@ addopts = "--capture=no" [tool.ruff] line-length = 88 -[tool.poetry.plugins] -pytest11 = { ruff = "pytest_ruff" } - [tool.coverage.run] branch = true diff --git a/requirements-test.txt b/requirements-test.txt new file mode 100644 index 0000000..47a0ffa --- /dev/null +++ b/requirements-test.txt @@ -0,0 +1,23 @@ +# This file was autogenerated by uv via the following command: +# uv pip compile pyproject.toml --extra test +coverage==7.4.3 + # via pytest-cov +exceptiongroup==1.2.0 + # via pytest +iniconfig==2.0.0 + # via pytest +packaging==23.2 + # via pytest +pluggy==1.4.0 + # via pytest +pytest==8.0.1 + # via + # pytest-cov + # pytest-mock +pytest-cov==4.1.0 +pytest-mock==3.12.0 +ruff==0.2.2 +tomli==2.0.1 + # via + # coverage + # pytest diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 0000000..af29ab2 --- /dev/null +++ b/requirements.txt @@ -0,0 +1,3 @@ +# This file was autogenerated by uv via the following command: +# uv pip compile pyproject.toml +ruff==0.2.2 diff --git a/tests/test_plugin.py b/tests/test_plugin.py index bf0bc10..11c762c 100644 --- a/tests/test_plugin.py +++ b/tests/test_plugin.py @@ -44,6 +44,7 @@ def test_pytest_ruff(): stdout=subprocess.PIPE, stderr=subprocess.PIPE, ).communicate() + assert err == b"" out_utf8 = out.decode("utf-8") assert "`os` imported but unused" in out_utf8 @@ -76,4 +77,5 @@ def test_pytest_ruff_noformat(): stdout=subprocess.PIPE, stderr=subprocess.PIPE, ).communicate() + assert err == b"" assert "File would be reformatted" not in out.decode("utf-8") diff --git a/tox.ini b/tox.ini index f16d762..191b0ca 100644 --- a/tox.ini +++ b/tox.ini @@ -3,11 +3,16 @@ isolated_build = true envlist = py{38,39,310,311,312},lint [testenv] -allowlist_externals = poetry +allowlist_externals = + pip + pytest + uv commands = - poetry install --no-root --with dev + pip install uv + uv pip install -r requirements-test.txt + uv pip install -e . # Disable ruff plugin to generate better coverage results - poetry run pytest -p no:ruff -vvv --cov --cov-append --cov-report term --cov-report xml {posargs} + pytest -vvv -p no:ruff -vvv --cov --cov-append --cov-report term --cov-report xml {posargs} [testenv:lint] description = lint source code From 6efcabd90f9cadf4950f4c15ff72c39b028bfaa2 Mon Sep 17 00:00:00 2001 From: Iuri de Silvio Date: Sat, 24 Feb 2024 11:54:15 +0100 Subject: [PATCH 2/4] Publish --- .github/workflows/python-package.yml | 4 ++-- .github/workflows/python-publish.yml | 33 ++++++++++++---------------- .gitignore | 1 - 3 files changed, 16 insertions(+), 22 deletions(-) diff --git a/.github/workflows/python-package.yml b/.github/workflows/python-package.yml index 1fe7cf5..88e9456 100644 --- a/.github/workflows/python-package.yml +++ b/.github/workflows/python-package.yml @@ -22,8 +22,8 @@ jobs: python-version: ${{ matrix.python-version }} - name: Install dependencies run: | - python -m pip install --upgrade pip - python -m pip install poetry tox tox-gh-actions + python -m pip install uv + python -m uv pip install tox tox-gh-actions - name: Cache tox environments id: cache-tox uses: actions/cache@v3 diff --git a/.github/workflows/python-publish.yml b/.github/workflows/python-publish.yml index 182bab3..aa4f6bd 100644 --- a/.github/workflows/python-publish.yml +++ b/.github/workflows/python-publish.yml @@ -1,29 +1,24 @@ name: Upload Python Package on: - release: - types: [published] - -permissions: - contents: read + pull_request: + push: + branches: + - "*" + tags: + - "v*" jobs: - deploy: - + test-pypi-publish: runs-on: ubuntu-latest - + environment: + name: pypi + url: https://pypi.org/p/pytest-ruff + permissions: + id-token: write # IMPORTANT: this permission is mandatory for trusted publishing steps: - uses: actions/checkout@v3 - name: Set up Python uses: actions/setup-python@v3 - with: - python-version: '3.x' - - name: Install Poetry - uses: snok/install-poetry@v1 - - name: Install dependencies - run: | - poetry install - - name: Build and publish to pypi - uses: JRubics/poetry-publish@v1.15 - with: - pypi_token: ${{ secrets.PYPI_API_TOKEN }} + - name: Publish package distributions to PyPI + uses: pypa/gh-action-pypi-publish@release/v1 diff --git a/.gitignore b/.gitignore index d691af3..92431ec 100644 --- a/.gitignore +++ b/.gitignore @@ -4,4 +4,3 @@ __pycache__/ .coverage coverage*.xml -poetry.lock From f592629813913c515f6287e5e128306983eddef1 Mon Sep 17 00:00:00 2001 From: Iuri de Silvio Date: Wed, 28 Feb 2024 23:37:50 +0100 Subject: [PATCH 3/4] venv --- tox.ini | 1 + 1 file changed, 1 insertion(+) diff --git a/tox.ini b/tox.ini index 191b0ca..6e622a7 100644 --- a/tox.ini +++ b/tox.ini @@ -9,6 +9,7 @@ allowlist_externals = uv commands = pip install uv + uv venv uv pip install -r requirements-test.txt uv pip install -e . # Disable ruff plugin to generate better coverage results From 2f122d36dcfb80a09054f86735ba7dcec888eb3a Mon Sep 17 00:00:00 2001 From: Iuri de Silvio Date: Wed, 28 Feb 2024 23:39:46 +0100 Subject: [PATCH 4/4] venv --- .github/workflows/python-package.yml | 5 +++-- tox.ini | 2 -- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/.github/workflows/python-package.yml b/.github/workflows/python-package.yml index 88e9456..a929ab7 100644 --- a/.github/workflows/python-package.yml +++ b/.github/workflows/python-package.yml @@ -22,8 +22,9 @@ jobs: python-version: ${{ matrix.python-version }} - name: Install dependencies run: | - python -m pip install uv - python -m uv pip install tox tox-gh-actions + pip install uv + uv venv + uv pip install tox tox-gh-actions - name: Cache tox environments id: cache-tox uses: actions/cache@v3 diff --git a/tox.ini b/tox.ini index 6e622a7..6c2d91a 100644 --- a/tox.ini +++ b/tox.ini @@ -8,8 +8,6 @@ allowlist_externals = pytest uv commands = - pip install uv - uv venv uv pip install -r requirements-test.txt uv pip install -e . # Disable ruff plugin to generate better coverage results