Skip to content

Commit 3747224

Browse files
authored
Switch from Tox to Nox (#347)
* Switch from Tox to Nox * only typeguard in Python 3.10 * fix PY_VERSION * only run once * fix cov * no need to install again * rename tox.ini -> setup.cfg * add .nox * use tool:pytest * move configuration to pyproject.toml * fix syntax * fix bool * fix list * add .ini_options
1 parent 36d20f4 commit 3747224

File tree

6 files changed

+74
-75
lines changed

6 files changed

+74
-75
lines changed

.github/workflows/coverage.yml

+3-3
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@ jobs:
1313
with:
1414
python-version: 3.7
1515
- name: Install dependencies
16-
run: pip install tox codecov
17-
- name: Test with tox
18-
run: tox -e py37-alldeps,report
16+
run: pip install nox codecov
17+
- name: Test with nox
18+
run: nox -e coverage
1919
- name: Upload test coverage
2020
run: codecov -t ${{ secrets.CODECOV_TOKEN }} -f .coverage.xml
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: tox
1+
name: nox
22

33
on:
44
pull_request:
@@ -12,26 +12,24 @@ jobs:
1212
fail-fast: false
1313
matrix:
1414
platform: [ubuntu-latest, macos-latest, windows-latest]
15-
python-version: [3.7, 3.8, 3.9]
15+
python-version: ["3.7", "3.8", "3.9", "3.10"]
1616

1717
steps:
1818
- uses: actions/checkout@v1
1919
- name: Set up Python ${{ matrix.python-version }}
2020
uses: actions/setup-python@v2
2121
with:
2222
python-version: ${{ matrix.python-version }}
23-
- name: Set Python version for tox
24-
run: echo "PY_VERSION=$(echo py${version//./})" >> $GITHUB_ENV
23+
- name: Set Python version for nox
24+
run: echo "PY_VERSION=$(echo ${version})" >> $GITHUB_ENV
2525
shell: bash
2626
env:
2727
version: ${{ matrix.python-version }}
2828
- name: Register Python problem matcher
2929
run: echo "::add-matcher::.github/workflows/matchers/pytest.json"
3030
- name: Install dependencies
31-
run: pip install tox pytest-github-actions-annotate-failures
32-
- name: Test with tox using minimal dependencies
33-
run: tox -e ${{ env.PY_VERSION }}-mindeps
34-
- name: Clean
35-
run: tox -e clean
36-
- name: Test with tox with all dependencies
37-
run: tox -e ${{ env.PY_VERSION }}-alldeps
31+
run: pip install nox pytest-github-actions-annotate-failures
32+
- name: Test with nox using minimal dependencies
33+
run: nox -e "pytest-${{ env.PY_VERSION }}(all_deps=False)"
34+
- name: Test with nox with all dependencies
35+
run: nox -e "pytest-${{ env.PY_VERSION }}(all_deps=True)"

noxfile.py

+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
import nox
2+
3+
4+
@nox.session(python=["3.7", "3.8", "3.9", "3.10"])
5+
@nox.parametrize("all_deps", [True, False])
6+
def pytest(session, all_deps):
7+
if all_deps:
8+
session.install(".[testing,other]")
9+
else:
10+
session.install(".[testing]")
11+
12+
session.run("coverage", "erase")
13+
14+
if session.python == "3.10":
15+
session.run("pytest", "--typeguard-packages=adaptive")
16+
else:
17+
session.run("pytest")
18+
19+
20+
@nox.session(python="3.7")
21+
def coverage(session):
22+
session.install("coverage")
23+
session.install(".[testing,other]")
24+
session.run("pytest")
25+
26+
session.run("coverage", "report")
27+
session.run("coverage", "xml")

pyproject.toml

+29
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,32 @@ requires = [
44
"setuptools_scm >= 2.0.0, <3"
55
]
66
build-backend = "setuptools.build_meta"
7+
8+
[tool.pytest.ini_options]
9+
testpaths = ["adaptive"]
10+
addopts = "--durations=5 --cov --cov-append --cov-fail-under=70 -vvv --cov-report="
11+
norecursedirs = ["docs"]
12+
13+
[tool.coverage.paths]
14+
source = [
15+
"adaptive",
16+
".nox/py*/lib/python*/site-packages",
17+
]
18+
19+
[tool.coverage.run]
20+
branch = true
21+
parallel = true
22+
source = ["adaptive"]
23+
24+
[tool.coverage.report]
25+
show_missing = true
26+
precision = 2
27+
28+
[tool.coverage.xml]
29+
output = ".coverage.xml"
30+
31+
[tool.isort]
32+
profile = "black"
33+
34+
[tool.mypy]
35+
ignore_missing_imports = true

setup.cfg

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
[flake8]
2+
max-line-length = 100
3+
ignore = E501, W503, E203, E266, E741
4+
max-complexity = 18
5+
select = B, C, E, F, W, T4, B9
6+
exclude = .git, .tox, __pycache__, dist, .nox

tox.ini

-61
This file was deleted.

0 commit comments

Comments
 (0)