From e535848cf88db1fcb3d4b5fe54024157aace7ea0 Mon Sep 17 00:00:00 2001 From: Jason McLaren Date: Mon, 20 Mar 2023 16:36:17 -0700 Subject: [PATCH 1/4] Use tox to run flake8/black/mypy --- .github/workflows/python-build-test.yml | 18 +++---------- tox.ini | 34 ++++++++++++++++++++----- 2 files changed, 31 insertions(+), 21 deletions(-) diff --git a/.github/workflows/python-build-test.yml b/.github/workflows/python-build-test.yml index 1064db3..1dae4f6 100644 --- a/.github/workflows/python-build-test.yml +++ b/.github/workflows/python-build-test.yml @@ -18,23 +18,11 @@ jobs: - name: Set up Python ${{ matrix.python-version }} uses: actions/setup-python@v4 - with: python-version: ${{ matrix.python-version }} - name: Install dependencies run: | python -m pip install --upgrade pip - pip install flake8 pytest mypy black - if [ -f requirements.txt ]; then pip install -r requirements.txt; fi - - name: Lint with flake8 - run: | - flake8 src/pyprojroot tests - - name: MyPy (type) checking - run: | - mypy --strict src/pyprojroot - - name: Format with black - run: | - black --check --diff src/pyprojroot tests - - name: Test with pytest - run: | - PYTHONPATH=src pytest + pip install tox tox-gh-actions + - name: Run all tests with tox + run: tox diff --git a/tox.ini b/tox.ini index da1f29b..f3b4e48 100644 --- a/tox.ini +++ b/tox.ini @@ -1,13 +1,35 @@ [tox] -env_list = - py{37,38,39,310,311} +env_list = lint, format, type, py{37,38,39,310,311} minversion = 4.4.7 [testenv] description = run the tests with pytest package = wheel wheel_build_env = .pkg -deps = - pytest>=6.2.5 -commands = - pytest {tty:--color=yes} {posargs} +deps = pytest>=6.2.5 +commands = pytest {tty:--color=yes} {posargs} + +[testenv:lint] +description = run flake8 +skip_install = true +deps = flake8~=3.8.4 +commands = flake8 {posargs:src/pyprojroot tests} + +[testenv:format] +description = run black +deps = black~=19.3b0 +skip_install = true +commands = black --check --diff src/pyprojroot tests + +[testenv:type] +description = run type checks +deps = mypy~=0.720 +commands = mypy --strict {posargs:src/pyprojroot} + +[gh-actions] +python = + 3.7: py37 + 3.8: py38 + 3.9: py39 + 3.10: py310 + 3.11: py311 From 668b03d8ca205ced298978d33aca719a8585e80b Mon Sep 17 00:00:00 2001 From: Jason McLaren Date: Mon, 20 Mar 2023 16:47:35 -0700 Subject: [PATCH 2/4] Try adding basepython to get gh actions to run other envs --- tox.ini | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/tox.ini b/tox.ini index f3b4e48..d9d47f4 100644 --- a/tox.ini +++ b/tox.ini @@ -7,6 +7,15 @@ description = run the tests with pytest package = wheel wheel_build_env = .pkg deps = pytest>=6.2.5 +basepython = + py37: python3.7 + py38: python3.8 + py39: python3.9 + py310: python3.10 + py311: python3.11 + lint: python3.11 + format: python3.11 + type: python3.11 commands = pytest {tty:--color=yes} {posargs} [testenv:lint] From c5c785325a74da69f05f73b6f4b7b6177c57dfc4 Mon Sep 17 00:00:00 2001 From: Jason McLaren Date: Mon, 20 Mar 2023 18:35:22 -0700 Subject: [PATCH 3/4] Put lint/format/type in the github-actions map --- pyproject.toml | 1 + tox.ini | 7 +------ 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index 1189c5c..75678c7 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -30,6 +30,7 @@ dev = [ "flake8~=3.8.4", "twine~=4.0.2", "build~=0.10.0", + "tox~=4.4.7" ] test = [ "pytest>=6.2.5", diff --git a/tox.ini b/tox.ini index d9d47f4..ad37d3d 100644 --- a/tox.ini +++ b/tox.ini @@ -8,11 +8,6 @@ package = wheel wheel_build_env = .pkg deps = pytest>=6.2.5 basepython = - py37: python3.7 - py38: python3.8 - py39: python3.9 - py310: python3.10 - py311: python3.11 lint: python3.11 format: python3.11 type: python3.11 @@ -41,4 +36,4 @@ python = 3.8: py38 3.9: py39 3.10: py310 - 3.11: py311 + 3.11: py311, lint, format, type From b99d8573f7e97b8e153bf997105ce53895e406e7 Mon Sep 17 00:00:00 2001 From: Jason McLaren Date: Mon, 20 Mar 2023 18:39:46 -0700 Subject: [PATCH 4/4] Try putting basepython in the individual environments --- tox.ini | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/tox.ini b/tox.ini index ad37d3d..6452cbd 100644 --- a/tox.ini +++ b/tox.ini @@ -7,26 +7,25 @@ description = run the tests with pytest package = wheel wheel_build_env = .pkg deps = pytest>=6.2.5 -basepython = - lint: python3.11 - format: python3.11 - type: python3.11 commands = pytest {tty:--color=yes} {posargs} [testenv:lint] description = run flake8 skip_install = true +basepython = python3.11 deps = flake8~=3.8.4 commands = flake8 {posargs:src/pyprojroot tests} [testenv:format] description = run black +basepython = python3.11 deps = black~=19.3b0 skip_install = true commands = black --check --diff src/pyprojroot tests [testenv:type] description = run type checks +basepython = python3.11 deps = mypy~=0.720 commands = mypy --strict {posargs:src/pyprojroot}