diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 9ac6825..74b712a 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -1,3 +1,4 @@ +# Uses https://github.com/ymyzk/tox-gh-actions name: ci on: [push, pull_request] @@ -8,7 +9,7 @@ jobs: runs-on: ${{ matrix.os }} strategy: matrix: - python-version: ["3.7", "3.8", "3.9", "3.10", '3.11.0-rc - 3.11'] + python-version: ["3.7", "3.8", "3.9", "3.10", "3.11.0-rc - 3.11"] os: [ubuntu-latest] @@ -20,15 +21,14 @@ jobs: with: python-version: ${{ matrix.python-version }} - - name: Update pip, setuptools + wheel + - name: Update pip and setuptools run: | - python -m pip install --upgrade pip setuptools wheel + python -m pip install --upgrade pip setuptools - - name: Install flake8-bugbear w/dev extra install + - name: Install tox and tox-gh-actions run: | - python -m pip install .[dev] + python -m pip install tox tox-gh-actions - - name: Run Unittests + - name: Run tox run: | - coverage run tests/test_bugbear.py - coverage report -m + tox diff --git a/DEVELOPMENT.md b/DEVELOPMENT.md index 32b24c1..3769418 100644 --- a/DEVELOPMENT.md +++ b/DEVELOPMENT.md @@ -50,6 +50,17 @@ flake8-bugbear uses coverage to run standard unittest tests. /path/to/venv/bin/coverage run tests/test_bugbear.py ``` +You can also use [tox](https://tox.wiki/en/latest/index.html) to test with multiple different python versions, emulating what the CI does. + +```console +/path/to/venv/bin/tox +``` +will by default run all tests on python versions 3.7 through 3.11. If you only want to test a specific version you can specify the environment with `-e` + +```console +/path/to/venv/bin/tox -e py38 +``` + ## Running linter We format the code with `black` and `isort`. You can run those using `pre-commit`. diff --git a/pyproject.toml b/pyproject.toml index d31ae92..dcabd39 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -47,6 +47,7 @@ Homepage = "https://github.com/PyCQA/flake8-bugbear" [project.optional-dependencies] dev = [ + "tox", "coverage", "hypothesis", "hypothesmith>=0.2", diff --git a/tox.ini b/tox.ini new file mode 100644 index 0000000..2034dd9 --- /dev/null +++ b/tox.ini @@ -0,0 +1,22 @@ +# The test environment and commands +[tox] +# default environments to run without `-e` +envlist = py37, py38, py39, py310, py311 + +[gh-actions] +python = + 3.7: py37 + 3.8: py38 + 3.9: py39 + 3.10: py310 + "3.11.0-rc - 3.11": py311 + +[testenv:{py37, py38, py39, py310, py311}] +description = Run coverage +deps = + coverage + hypothesis + hypothesmith +commands = + coverage run tests/test_bugbear.py {posargs} + coverage report -m