From b8c06fc18f7db8905b7414c7629aedbd5c20a21c Mon Sep 17 00:00:00 2001 From: JensDiemer Date: Fri, 28 Nov 2025 22:49:08 +0100 Subject: [PATCH] Use nox --- .github/workflows/tests.yml | 16 +++++++--- README.md | 2 ++ noxfile.py | 45 ++++++++++++++++++++++++++++ pyproject.toml | 4 +-- uv.lock | 59 +++++++++++++++++++++++++++++++++++++ 5 files changed, 120 insertions(+), 6 deletions(-) create mode 100644 noxfile.py diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index b99dde8..831dd88 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -1,6 +1,8 @@ name: tests +permissions: + contents: read on: push: @@ -12,12 +14,18 @@ on: jobs: test: - name: 'Python ${{ matrix.python-version }}' + name: 'Python ${{ matrix.python-version }} Django ${{ matrix.django-version }}' runs-on: ubuntu-latest strategy: fail-fast: false matrix: - python-version: ['3.13', '3.12', '3.11'] + python-version: ['3.14', '3.13', '3.12', '3.11'] + django-version: ['5.2', '5.1', '4.2'] + exclude: + - python-version: '3.14' + django-version: '5.1' + - python-version: '3.14' + django-version: '4.2' steps: - name: Checkout run: | @@ -51,12 +59,12 @@ jobs: run: | ./manage.py pip_audit - - name: 'Python ${{ matrix.python-version }}' + - name: 'Python ${{ matrix.python-version }} Django ${{ matrix.django-version }}' env: PYTHONUNBUFFERED: 1 PYTHONWARNINGS: always run: | - ./manage.py test + ./manage.py nox -e "tests-${{ matrix.python-version }}(django='${{ matrix.django-version }}')" - name: 'Upload coverage report' uses: codecov/codecov-action@v5 diff --git a/README.md b/README.md index bef2781..c012bca 100644 --- a/README.md +++ b/README.md @@ -170,6 +170,8 @@ To make a new release, do this: [comment]: <> (✂✂✂ auto generated history start ✂✂✂) * [**dev**](https://github.com/jedie/PyInventory/compare/v0.23.0...main) + * 2025-11-28 - Use nox + * 2025-11-28 - Update README.md * 2025-11-28 - Add logo * [v0.23.0](https://github.com/jedie/PyInventory/compare/v0.22.1...v0.23.0) * 2025-11-25 - Enhance 'Change category for selected items' and add tests for it diff --git a/noxfile.py b/noxfile.py new file mode 100644 index 0000000..64aabeb --- /dev/null +++ b/noxfile.py @@ -0,0 +1,45 @@ +# +# https://github.com/wntrblm/nox/ +# Documentation: https://nox.thea.codes/ +# +import nox +from nox.sessions import Session + + +PYTHON_VERSIONS = ('3.14', '3.13', '3.12', '3.11') +DJANGO_VERSIONS = ('5.2', '5.1', '4.2') + +# Python 3.14 needs Django 5.2+ +EXCLUDED_COMBINATIONS = [ + ('3.14', '5.1'), + ('3.14', '4.2'), +] + + +@nox.session( + python=PYTHON_VERSIONS, + venv_backend='uv', + download_python='auto', +) +@nox.parametrize('django', DJANGO_VERSIONS) +def tests(session: Session, django: str): + if (session.python, django) in EXCLUDED_COMBINATIONS: + session.skip('Python 3.14 needs Django 5.2+') + + session.install('uv') + session.run( + 'uv', + 'sync', + '--all-extras', + '--python', + session.python, + env={'UV_PROJECT_ENVIRONMENT': session.virtualenv.location}, + ) + session.run( + 'uv', + 'pip', + 'install', + f'django>={django},<={django}.999', + env={'UV_PROJECT_ENVIRONMENT': session.virtualenv.location}, + ) + session.run('python', '-m', 'coverage', 'run', '--context', f'py{session.python}-django{django}') diff --git a/pyproject.toml b/pyproject.toml index 50edbb6..6761159 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -46,7 +46,7 @@ dev = [ "hatchling", # https://github.com/pypa/hatch/tree/master/backend "playwright", # https://github.com/microsoft/playwright-python "tblib", # https://github.com/ionelmc/python-tblib - # TODO: "nox", # https://github.com/wntrblm/nox + "nox", # https://github.com/wntrblm/nox "coverage", # https://github.com/nedbat/coveragepy "ruff", # https://github.com/astral-sh/ruff "codespell", # https://github.com/codespell-project/codespell @@ -97,7 +97,6 @@ version_module_name = "inventory" # Used by "update-readme-history" pre-commit h [tool.cli_base.pip_audit] -requirements=["requirements.dev.txt"] strict=true require_hashes=true ignore-vuln=[] @@ -169,6 +168,7 @@ applied_migrations = [ "b3e0624", # 2025-05-01T00:07:45+02:00 "46497a1", # 2025-09-05T08:45:19+02:00 "38082ef", # 2025-10-16T10:28:32+02:00 + "95a3003", # 2025-11-28T22:00:56+01:00 ] [manageprojects.cookiecutter_context.cookiecutter] diff --git a/uv.lock b/uv.lock index bc15f20..39ec67b 100644 --- a/uv.lock +++ b/uv.lock @@ -2,6 +2,15 @@ version = 1 revision = 3 requires-python = ">=3.11" +[[package]] +name = "argcomplete" +version = "3.6.3" +source = { registry = "https://pypi.org/simple" } +sdist = { url = "https://files.pythonhosted.org/packages/38/61/0b9ae6399dd4a58d8c1b1dc5a27d6f2808023d0b5dd3104bb99f45a33ff6/argcomplete-3.6.3.tar.gz", hash = "sha256:62e8ed4fd6a45864acc8235409461b72c9a28ee785a2011cc5eb78318786c89c", size = 73754, upload-time = "2025-10-20T03:33:34.741Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/74/f5/9373290775639cb67a2fce7f629a1c240dce9f12fe927bc32b2736e16dfc/argcomplete-3.6.3-py3-none-any.whl", hash = "sha256:f5007b3a600ccac5d25bbce33089211dfd49eab4a7718da3f10e3082525a92ce", size = 43846, upload-time = "2025-10-20T03:33:33.021Z" }, +] + [[package]] name = "arrow" version = "1.4.0" @@ -24,6 +33,15 @@ wheels = [ { url = "https://files.pythonhosted.org/packages/91/be/317c2c55b8bbec407257d45f5c8d1b6867abc76d12043f2d3d58c538a4ea/asgiref-3.11.0-py3-none-any.whl", hash = "sha256:1db9021efadb0d9512ce8ffaf72fcef601c7b73a8807a1bb2ef143dc6b14846d", size = 24096, upload-time = "2025-11-19T15:32:19.004Z" }, ] +[[package]] +name = "attrs" +version = "25.4.0" +source = { registry = "https://pypi.org/simple" } +sdist = { url = "https://files.pythonhosted.org/packages/6b/5c/685e6633917e101e5dcb62b9dd76946cbb57c26e133bae9e0cd36033c0a9/attrs-25.4.0.tar.gz", hash = "sha256:16d5969b87f0859ef33a48b35d55ac1be6e42ae49d5e853b597db70c35c57e11", size = 934251, upload-time = "2025-10-06T13:54:44.725Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/3a/2a/7cc015f5b9f5db42b7d48157e23356022889fc354a2813c15934b7cb5c0e/attrs-25.4.0-py3-none-any.whl", hash = "sha256:adcf7e2a1fb3b36ac48d97835bb6d8ade15b8dcce26aba8bf1d14847b57a3373", size = 67615, upload-time = "2025-10-06T13:54:43.17Z" }, +] + [[package]] name = "backports-tarfile" version = "1.2.0" @@ -530,6 +548,18 @@ wheels = [ { url = "https://files.pythonhosted.org/packages/07/6c/aa3f2f849e01cb6a001cd8554a88d4c77c5c1a31c95bdf1cf9301e6d9ef4/defusedxml-0.7.1-py2.py3-none-any.whl", hash = "sha256:a352e7e428770286cc899e2542b6cdaedb2b4953ff269a210103ec58f6198a61", size = 25604, upload-time = "2021-03-08T10:59:24.45Z" }, ] +[[package]] +name = "dependency-groups" +version = "1.3.1" +source = { registry = "https://pypi.org/simple" } +dependencies = [ + { name = "packaging" }, +] +sdist = { url = "https://files.pythonhosted.org/packages/62/55/f054de99871e7beb81935dea8a10b90cd5ce42122b1c3081d5282fdb3621/dependency_groups-1.3.1.tar.gz", hash = "sha256:78078301090517fd938c19f64a53ce98c32834dfe0dee6b88004a569a6adfefd", size = 10093, upload-time = "2025-05-02T00:34:29.452Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/99/c7/d1ec24fb280caa5a79b6b950db565dab30210a66259d17d5bb2b3a9f878d/dependency_groups-1.3.1-py3-none-any.whl", hash = "sha256:51aeaa0dfad72430fcfb7bcdbefbd75f3792e5919563077f30bc0d73f4493030", size = 8664, upload-time = "2025-05-02T00:34:27.085Z" }, +] + [[package]] name = "diff-match-patch" version = "20241021" @@ -846,6 +876,15 @@ wheels = [ { url = "https://files.pythonhosted.org/packages/0d/a5/48cb7efb8b4718b1a4c0c331e3364a3a33f614ff0d6afd2b93ee883d3c47/hatchling-1.28.0-py3-none-any.whl", hash = "sha256:dc48722b68b3f4bbfa3ff618ca07cdea6750e7d03481289ffa8be1521d18a961", size = 76075, upload-time = "2025-11-27T00:31:12.544Z" }, ] +[[package]] +name = "humanize" +version = "4.14.0" +source = { registry = "https://pypi.org/simple" } +sdist = { url = "https://files.pythonhosted.org/packages/b6/43/50033d25ad96a7f3845f40999b4778f753c3901a11808a584fed7c00d9f5/humanize-4.14.0.tar.gz", hash = "sha256:2fa092705ea640d605c435b1ca82b2866a1b601cdf96f076d70b79a855eba90d", size = 82939, upload-time = "2025-10-15T13:04:51.214Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/c3/5b/9512c5fb6c8218332b530f13500c6ff5f3ce3342f35e0dd7be9ac3856fd3/humanize-4.14.0-py3-none-any.whl", hash = "sha256:d57701248d040ad456092820e6fde56c930f17749956ac47f4f655c0c547bfff", size = 132092, upload-time = "2025-10-15T13:04:49.404Z" }, +] + [[package]] name = "icdiff" version = "2.0.7" @@ -1446,6 +1485,24 @@ wheels = [ { url = "https://files.pythonhosted.org/packages/d2/1d/1b658dbd2b9fa9c4c9f32accbfc0205d532c8c6194dc0f2a4c0428e7128a/nodeenv-1.9.1-py2.py3-none-any.whl", hash = "sha256:ba11c9782d29c27c70ffbdda2d7415098754709be8a7056d79a737cd901155c9", size = 22314, upload-time = "2024-06-04T18:44:08.352Z" }, ] +[[package]] +name = "nox" +version = "2025.11.12" +source = { registry = "https://pypi.org/simple" } +dependencies = [ + { name = "argcomplete" }, + { name = "attrs" }, + { name = "colorlog" }, + { name = "dependency-groups" }, + { name = "humanize" }, + { name = "packaging" }, + { name = "virtualenv" }, +] +sdist = { url = "https://files.pythonhosted.org/packages/b4/a8/e169497599266d176832e2232c08557ffba97eef87bf8a18f9f918e0c6aa/nox-2025.11.12.tar.gz", hash = "sha256:3d317f9e61f49d6bde39cf2f59695bb4e1722960457eee3ae19dacfe03c07259", size = 4030561, upload-time = "2025-11-12T18:39:03.319Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/b9/34/434c594e0125a16b05a7bedaea33e63c90abbfbe47e5729a735a8a8a90ea/nox-2025.11.12-py3-none-any.whl", hash = "sha256:707171f9f63bc685da9d00edd8c2ceec8405b8e38b5fb4e46114a860070ef0ff", size = 74447, upload-time = "2025-11-12T18:39:01.575Z" }, +] + [[package]] name = "packageurl-python" version = "0.17.6" @@ -1754,6 +1811,7 @@ dev = [ { name = "manage-django-project" }, { name = "model-bakery" }, { name = "mypy" }, + { name = "nox" }, { name = "pip-audit" }, { name = "playwright" }, { name = "pre-commit" }, @@ -1799,6 +1857,7 @@ dev = [ { name = "manage-django-project", specifier = ">=0.11.0" }, { name = "model-bakery" }, { name = "mypy" }, + { name = "nox" }, { name = "pip-audit" }, { name = "playwright" }, { name = "pre-commit" },