Skip to content

Commit

Permalink
add tox config (#294)
Browse files Browse the repository at this point in the history
* add basic tox config

* Use tox in GitHub CI
  • Loading branch information
jakkdl committed Oct 7, 2022
1 parent 466082c commit e12c12b
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 8 deletions.
16 changes: 8 additions & 8 deletions .github/workflows/ci.yml
@@ -1,3 +1,4 @@
# Uses https://github.com/ymyzk/tox-gh-actions
name: ci

on: [push, pull_request]
Expand All @@ -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]

Expand All @@ -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
11 changes: 11 additions & 0 deletions DEVELOPMENT.md
Expand Up @@ -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`.
Expand Down
1 change: 1 addition & 0 deletions pyproject.toml
Expand Up @@ -47,6 +47,7 @@ Homepage = "https://github.com/PyCQA/flake8-bugbear"

[project.optional-dependencies]
dev = [
"tox",
"coverage",
"hypothesis",
"hypothesmith>=0.2",
Expand Down
22 changes: 22 additions & 0 deletions 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

0 comments on commit e12c12b

Please sign in to comment.