From 1743aa7a56af8fbcdf180e4987e9b440c3b4e5e4 Mon Sep 17 00:00:00 2001 From: Zhihan Zhang Date: Mon, 7 Aug 2023 13:46:38 +0200 Subject: [PATCH 1/7] Add run fawltydeps to CI test --- .github/workflows/tests.yaml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/tests.yaml b/.github/workflows/tests.yaml index 3fc433dc..72b1ea8a 100644 --- a/.github/workflows/tests.yaml +++ b/.github/workflows/tests.yaml @@ -1,4 +1,4 @@ -name: Tests +name: Tests on: [workflow_call] @@ -30,3 +30,5 @@ jobs: run: poetry run nox --no-venv --no-install --non-interactive -s tests -- -vv - name: Run integration tests on Python ${{ matrix.python-version }} run: poetry run nox --no-venv --no-install --non-interactive -s integration_tests -- -vv + - name: Run fawltydeps + run: poetry run fawltydeps --code fawltydeps/ --deps pyproject.toml --ignore-unused black codespell colorama hypothesis mypy nox pylint pytest types-setuptools From 1d3a1b44d50d470a67d3f5c61a19f82adc18bcae Mon Sep 17 00:00:00 2001 From: Zhihan Zhang Date: Mon, 7 Aug 2023 13:59:40 +0200 Subject: [PATCH 2/7] Declare setuptools as a dependency of main code --- poetry.lock | 19 ++++++++++++++++++- pyproject.toml | 1 + 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/poetry.lock b/poetry.lock index b942bb67..731b2a7d 100644 --- a/poetry.lock +++ b/poetry.lock @@ -666,6 +666,23 @@ tomli = {version = ">=1.0.0", markers = "python_version < \"3.11\""} [package.extras] testing = ["argcomplete", "hypothesis (>=3.56)", "mock", "nose", "pygments (>=2.7.2)", "requests", "xmlschema"] +[[package]] +name = "setuptools" +version = "68.0.0" +description = "Easily download, build, install, upgrade, and uninstall Python packages" +category = "main" +optional = false +python-versions = ">=3.7" +files = [ + {file = "setuptools-68.0.0-py3-none-any.whl", hash = "sha256:11e52c67415a381d10d6b462ced9cfb97066179f0e871399e006c4ab101fc85f"}, + {file = "setuptools-68.0.0.tar.gz", hash = "sha256:baf1fdb41c6da4cd2eae722e135500da913332ab3f2f5c7d33af9b492acb5235"}, +] + +[package.extras] +docs = ["furo", "jaraco.packaging (>=9)", "jaraco.tidelift (>=1.4)", "pygments-github-lexers (==0.0.5)", "rst.linker (>=1.9)", "sphinx (>=3.5)", "sphinx-favicon", "sphinx-hoverxref (<2)", "sphinx-inline-tabs", "sphinx-lint", "sphinx-notfound-page (==0.8.3)", "sphinx-reredirects", "sphinxcontrib-towncrier"] +testing = ["build[virtualenv]", "filelock (>=3.4.0)", "flake8-2020", "ini2toml[lite] (>=0.9)", "jaraco.envs (>=2.2)", "jaraco.path (>=3.2.0)", "pip (>=19.1)", "pip-run (>=8.8)", "pytest (>=6)", "pytest-black (>=0.3.7)", "pytest-checkdocs (>=2.4)", "pytest-cov", "pytest-enabler (>=1.3)", "pytest-mypy (>=0.9.1)", "pytest-perf", "pytest-ruff", "pytest-timeout", "pytest-xdist", "tomli-w (>=1.0.0)", "virtualenv (>=13.0.0)", "wheel"] +testing-integration = ["build[virtualenv]", "filelock (>=3.4.0)", "jaraco.envs (>=2.2)", "jaraco.path (>=3.2.0)", "pytest", "pytest-enabler", "pytest-xdist", "tomli", "virtualenv (>=13.0.0)", "wheel"] + [[package]] name = "sortedcontainers" version = "2.4.0" @@ -890,4 +907,4 @@ testing = ["flake8 (<5)", "func-timeout", "jaraco.functools", "jaraco.itertools" [metadata] lock-version = "2.0" python-versions = "^3.7.2" -content-hash = "ab919c83f7d121044f7146f185296de56e47f4106c879a1fb76912c98b36406a" +content-hash = "e5ff0b0f1e43d2f9bd977f6454372eb60e626d612e30dc881454c56cbe9cf42d" diff --git a/pyproject.toml b/pyproject.toml index 0cb80193..d50d2fc7 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -43,6 +43,7 @@ pip-requirements-parser = "^32.0.1" pydantic = "^1.10.4" tomli = {version = "^2.0.1", python = "<3.11"} typing-extensions = {version = "^4.4.0", python = "<3.8"} +setuptools = "^68.0.0" [tool.poetry.group.nox] optional = true From 1bc911d0b1da9d11c051898f5b4db287337a94e7 Mon Sep 17 00:00:00 2001 From: Zhihan Zhang Date: Mon, 7 Aug 2023 16:19:37 +0200 Subject: [PATCH 3/7] Add python environment path --- .github/workflows/tests.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/tests.yaml b/.github/workflows/tests.yaml index 72b1ea8a..e9ba683f 100644 --- a/.github/workflows/tests.yaml +++ b/.github/workflows/tests.yaml @@ -31,4 +31,4 @@ jobs: - name: Run integration tests on Python ${{ matrix.python-version }} run: poetry run nox --no-venv --no-install --non-interactive -s integration_tests -- -vv - name: Run fawltydeps - run: poetry run fawltydeps --code fawltydeps/ --deps pyproject.toml --ignore-unused black codespell colorama hypothesis mypy nox pylint pytest types-setuptools + run: poetry run fawltydeps --code fawltydeps/ --deps pyproject.toml --pyenv ~/.cache/pypoetry/virtualenvs --ignore-unused black codespell colorama hypothesis mypy nox pylint pytest types-setuptools From d0e1b94606fb0b1d22c9602dcd9b2288a3e579e3 Mon Sep 17 00:00:00 2001 From: Zhihan Zhang Date: Mon, 7 Aug 2023 16:29:50 +0200 Subject: [PATCH 4/7] Change log level to debug --- .github/workflows/tests.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/tests.yaml b/.github/workflows/tests.yaml index e9ba683f..fa1b6b17 100644 --- a/.github/workflows/tests.yaml +++ b/.github/workflows/tests.yaml @@ -30,5 +30,5 @@ jobs: run: poetry run nox --no-venv --no-install --non-interactive -s tests -- -vv - name: Run integration tests on Python ${{ matrix.python-version }} run: poetry run nox --no-venv --no-install --non-interactive -s integration_tests -- -vv - - name: Run fawltydeps - run: poetry run fawltydeps --code fawltydeps/ --deps pyproject.toml --pyenv ~/.cache/pypoetry/virtualenvs --ignore-unused black codespell colorama hypothesis mypy nox pylint pytest types-setuptools + - name: Run fawltydeps on Python ${{ matrix.python-version }} + run: poetry run fawltydeps --code fawltydeps/ --deps pyproject.toml --pyenv ~/.cache/pypoetry/virtualenvs --ignore-unused black codespell colorama hypothesis mypy nox pylint pytest types-setuptools -vv From d56996c843c0e7ca687a02e9d4fde2e5c7ea3009 Mon Sep 17 00:00:00 2001 From: Zhihan Zhang Date: Tue, 8 Aug 2023 15:37:19 +0200 Subject: [PATCH 5/7] Make it as a nox action --- .github/workflows/tests.yaml | 2 +- noxfile.py | 7 +++++++ pyproject.toml | 17 +++++++++++++++++ 3 files changed, 25 insertions(+), 1 deletion(-) diff --git a/.github/workflows/tests.yaml b/.github/workflows/tests.yaml index fa1b6b17..e5c62d87 100644 --- a/.github/workflows/tests.yaml +++ b/.github/workflows/tests.yaml @@ -31,4 +31,4 @@ jobs: - name: Run integration tests on Python ${{ matrix.python-version }} run: poetry run nox --no-venv --no-install --non-interactive -s integration_tests -- -vv - name: Run fawltydeps on Python ${{ matrix.python-version }} - run: poetry run fawltydeps --code fawltydeps/ --deps pyproject.toml --pyenv ~/.cache/pypoetry/virtualenvs --ignore-unused black codespell colorama hypothesis mypy nox pylint pytest types-setuptools -vv + run: poetry run nox --no-venv --no-install --non-interactive -s self_test -- -vv diff --git a/noxfile.py b/noxfile.py index 72dc7427..54626bd9 100644 --- a/noxfile.py +++ b/noxfile.py @@ -81,6 +81,13 @@ def integration_tests(session): session.run("pytest", "-x", "-m", "integration", "--durations=10", *session.posargs) +@nox.session(python=python_versions) +def self_test(session): + install_groups(session) + venv_path = session.run("poetry", "env", "info", "--path", silent=True).strip() + session.run("fawltydeps", f"--pyenv={venv_path}") + + @nox.session(python=python_versions) def lint(session): install_groups(session, include=["lint"]) diff --git a/pyproject.toml b/pyproject.toml index d50d2fc7..a94d06e2 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -151,3 +151,20 @@ uri-ignore-words-list = "*" [build-system] requires = ["poetry-core"] build-backend = "poetry.core.masonry.api" + +[tool.fawltydeps] +code = ["fawltydeps"] +deps = ["pyproject.toml"] +ignore_unused = [ + # Tools not meant to be imported + "black", + "codespell", + "hypothesis", + "mypy", + "nox", + "pylint", + "pytest", + # Other dependencies that enable functionality in the above tools + "colorama", + "types-setuptools", +] From 7b1424b37717a5f7fcc328167a4f584f0e31a514 Mon Sep 17 00:00:00 2001 From: Zhihan Zhang <32028117+zz1874@users.noreply.github.com> Date: Wed, 9 Aug 2023 17:49:38 +0200 Subject: [PATCH 6/7] Update noxfile.py Co-authored-by: Johan Herland --- noxfile.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/noxfile.py b/noxfile.py index 54626bd9..72973332 100644 --- a/noxfile.py +++ b/noxfile.py @@ -84,7 +84,8 @@ def integration_tests(session): @nox.session(python=python_versions) def self_test(session): install_groups(session) - venv_path = session.run("poetry", "env", "info", "--path", silent=True).strip() + # For --pyenv, use Nox's virtualenv, or fall back to current virtualenv + venv_path = getattr(session.virtualenv, "location", sys.prefix) session.run("fawltydeps", f"--pyenv={venv_path}") From ef7d1f2945c0e1940a6776efc769bfd6c2405b75 Mon Sep 17 00:00:00 2001 From: Zhihan Zhang Date: Wed, 9 Aug 2023 17:50:59 +0200 Subject: [PATCH 7/7] Import sys --- noxfile.py | 1 + 1 file changed, 1 insertion(+) diff --git a/noxfile.py b/noxfile.py index 72973332..7cf22e98 100644 --- a/noxfile.py +++ b/noxfile.py @@ -1,4 +1,5 @@ import hashlib +import sys from pathlib import Path from typing import Iterable