Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use tox to run flake8/black/mypy #60

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 3 additions & 15 deletions .github/workflows/python-build-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
37 changes: 31 additions & 6 deletions tox.ini
Original file line number Diff line number Diff line change
@@ -1,13 +1,38 @@
[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
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}

[gh-actions]
python =
3.7: py37
3.8: py38
3.9: py39
3.10: py310
3.11: py311, lint, format, type