Skip to content

Commit 0525f08

Browse files
authored
Merge pull request #430 from twisted/nox
2 parents e36a8ca + 5fa7c2d commit 0525f08

File tree

12 files changed

+148
-139
lines changed

12 files changed

+148
-139
lines changed
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
11
[flake8]
22
# Allow for longer test strings. Code is formatted to 88 columns by Black.
33
max-line-length = 99
4+
extend-ignore =
5+
# Conflict between flake8 & black about whitespace in slices.
6+
E203

.github/workflows/ci.yml

Lines changed: 22 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -22,27 +22,25 @@ jobs:
2222
runs-on: ubuntu-latest
2323
python:
2424
- name: CPython 3.9
25-
tox: py39
2625
action: 3.9
2726
task:
2827
- name: Build
29-
tox: build
28+
nox: build
3029

3130
steps:
3231
- uses: actions/checkout@v3
3332

3433
- name: Set up ${{ matrix.python.name }}
35-
uses: actions/setup-python@v3
34+
uses: actions/setup-python@v4
3635
with:
3736
python-version: ${{ matrix.python.action }}
3837

3938
- name: Install dependencies
40-
run: python -m pip install --upgrade pip tox
39+
run: python -m pip install --upgrade pip nox
4140

4241
- uses: twisted/python-info-action@v1
4342

44-
- name: Tox
45-
run: tox -c tox.ini -e ${{ matrix.task.tox }}
43+
- run: nox -e ${{ matrix.task.nox }}
4644

4745
- name: Publish
4846
uses: actions/upload-artifact@v3
@@ -60,29 +58,22 @@ jobs:
6058
matrix:
6159
python:
6260
- name: CPython 3.7
63-
tox: py37
6461
action: 3.7
6562
- name: CPython 3.8
66-
tox: py38
6763
action: 3.8
6864
- name: CPython 3.9
69-
tox: py39
7065
action: 3.9
7166
- name: CPython 3.10
72-
tox: py310
7367
action: '3.10'
7468
- name: CPython 3.11
75-
tox: py311
7669
action: '3.11.0-beta - 3.11'
7770
- name: PyPy 3.7
78-
tox: pypy37
79-
action: pypy-3.7
71+
action: pypy3.7
8072
- name: PyPy 3.8
81-
tox: pypy38
82-
action: pypy-3.8
73+
action: pypy3.8
8374
task:
8475
- name: Test
85-
tox: tests
76+
nox: tests
8677

8778
steps:
8879
- uses: actions/checkout@v3
@@ -94,17 +85,16 @@ jobs:
9485
path: dist/
9586

9687
- name: Set up ${{ matrix.python.name }}
97-
uses: actions/setup-python@v3
88+
uses: actions/setup-python@v4
9889
with:
9990
python-version: ${{ matrix.python.action }}
10091

10192
- name: Install dependencies
102-
run: python -m pip install --upgrade pip tox codecov coverage[toml]
93+
run: python -m pip install --upgrade pip nox codecov coverage[toml]
10394

10495
- uses: twisted/python-info-action@v1
10596

106-
- name: Tox
107-
run: tox -c tox.ini --installpkg dist/*.whl -e ${{ matrix.python.tox }}-tests
97+
- run: nox --python ${{ matrix.python.action }} -e ${{ matrix.task.nox }} -- --use-wheel dist/*.whl
10898

10999
- name: Codecov
110100
run: |
@@ -121,11 +111,10 @@ jobs:
121111
matrix:
122112
python:
123113
- name: CPython 3.9
124-
tox: py39
125114
action: '3.9'
126115
task:
127116
- name: Test
128-
tox: tests
117+
nox: tests
129118

130119
steps:
131120
- uses: actions/checkout@v3
@@ -137,17 +126,16 @@ jobs:
137126
path: dist/
138127

139128
- name: Set up ${{ matrix.python.name }}
140-
uses: actions/setup-python@v3
129+
uses: actions/setup-python@v4
141130
with:
142131
python-version: ${{ matrix.python.action }}
143132

144133
- name: Install dependencies
145-
run: python -m pip install --upgrade pip tox codecov coverage[toml]
134+
run: python -m pip install --upgrade pip nox codecov coverage[toml]
146135

147136
- uses: twisted/python-info-action@v1
148137

149-
- name: Tox
150-
run: tox -c tox.ini --installpkg dist/*.whl -e ${{ matrix.python.tox }}-tests
138+
- run: nox --python ${{ matrix.python.action }} -e ${{ matrix.task.nox }} -- --use-wheel dist/*.whl
151139

152140
- name: Codecov
153141
run: |
@@ -165,17 +153,16 @@ jobs:
165153
# Using second most recent minor release for whatever little
166154
# increase in stability over using the latest minor.
167155
- name: CPython 3.9
168-
tox: py39
169156
python-version: '3.9'
170157
task:
171158
- name: Check Newsfragment
172-
tox: check-newsfragment
159+
nox: check_newsfragment
173160
run-if: ${{ github.head_ref != 'pre-commit-ci-update-config' }}
174161
- name: Check package manifest
175-
tox: check-manifest
162+
nox: check_manifest
176163
run-if: true
177164
- name: Check mypy
178-
tox: typecheck
165+
nox: typecheck
179166
run-if: true
180167

181168
steps:
@@ -190,18 +177,18 @@ jobs:
190177
path: dist/
191178

192179
- name: Set up ${{ matrix.python.name }}
193-
uses: actions/setup-python@v3
180+
uses: actions/setup-python@v4
194181
with:
195182
python-version: ${{ matrix.python.python-version }}
196183

197184
- name: Install dependencies
198-
run: python -m pip install --upgrade pip tox
185+
run: python -m pip install --upgrade pip nox
199186

200187
- uses: twisted/python-info-action@v1
201188

202-
- name: Tox
189+
- run: nox -e ${{ matrix.task.nox }}
203190
if: ${{ matrix.task.run-if }}
204-
run: tox -c tox.ini -e ${{ matrix.task.tox }}
191+
205192

206193
pypi-publish:
207194
# https://github.community/t/is-it-possible-to-require-all-github-actions-tasks-to-pass-without-enumerating-them/117957/4?u=graingert
@@ -222,7 +209,7 @@ jobs:
222209
path: dist/
223210

224211
- name: Set up Python
225-
uses: actions/setup-python@v3
212+
uses: actions/setup-python@v4
226213
with:
227214
python-version: 3.9
228215

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ apidocs/
1818
*.pyproj
1919
.DS_Store
2020
.eggs
21-
.tox/
21+
.nox/
2222
.coverage.*
2323
.vscode
2424
.idea

CONTRIBUTING.rst

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ We recommend the following workflow:
8888
Running the test suite
8989
----------------------
9090

91-
We use the `twisted.trial`_ module and `tox`_ to run tests against all supported
91+
We use the `twisted.trial`_ module and `nox`_ to run tests against all supported
9292
Python versions and operating systems.
9393

9494
The following list contains some ways how to run the test suite:
@@ -109,42 +109,42 @@ The following list contains some ways how to run the test suite:
109109
This will invoke a PDB session. If you press ``c`` it will continue running
110110
the test suite until it runs into an error.
111111

112-
* To run all tests against all supported versions, install tox and use::
112+
* To run all tests against all supported versions, install nox and use::
113113

114-
$ tox
114+
$ nox
115115

116-
You may want to add the ``--skip-missing-interpreters`` option to avoid errors
116+
You may want to add the ``--no-error-on-missing-interpreters`` option to avoid errors
117117
when a specific Python interpreter version couldn't be found.
118118

119119
* To get a complete list of the available targets, run::
120120

121-
$ tox -av
121+
$ nox -l
122122

123123
* To run only a specific test only, use the ``towncrier.test.FILE.CLASS.METHOD`` syntax,
124124
for example::
125125

126-
$ tox -- towncrier.test.test_project.InvocationTests.test_version
126+
$ nox -e tests -- towncrier.test.test_project.InvocationTests.test_version
127127

128128
* To run some quality checks before you create the pull request,
129129
we recommend using this call::
130130

131-
$ tox -e pre-commit,check-manifest,check-newsfragment
131+
$ nox -e pre_commit check_manifest check_newsfragment
132132

133133
* Or enable `pre-commit` as a git hook::
134134

135135
$ pip install pre-commit
136136
$ pre-commit install
137137

138138

139-
**Please note**: If the test suite works in tox, but doesn't by calling
139+
**Please note**: If the test suite works in nox, but doesn't by calling
140140
``trial``, it could be that you've got GPG-signing active for git commits which
141141
fails with our dummy test commits.
142142

143143
.. ### Links
144144
145-
.. _flake8: https://flake8.rtfd.io
145+
.. _flake8: https://flake8.pycqa.org/
146146
.. _GitHub Discussions: https://github.com/twisted/towncrier/discussions
147147
.. _issues: https://github.com/twisted/towncrier/issues
148148
.. _pull request: https://github.com/twisted/towncrier/pulls
149-
.. _tox: https://tox.rtfd.org/
150-
.. _twisted.trial: https://twistedmatrix.com/trac/wiki/TwistedTrial
149+
.. _nox: https://nox.thea.codes/
150+
.. _twisted.trial: https://github.com/twisted/trac-wiki-archive/blob/trunk/TwistedTrial.mediawiki

MANIFEST.in

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,10 @@ include .coveragerc
33
include LICENSE
44
include CODE_OF_CONDUCT.md
55
include pyproject.toml
6-
include tox.ini
7-
include tox_build.sh
8-
include tox_check-release.sh
6+
include noxfile.py
97
include *.yaml
108
include .git-blame-ignore-revs
9+
include .flake8
1110
recursive-include src *.rst
1211

1312
exclude bin

noxfile.py

Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
from __future__ import annotations
2+
3+
import os
4+
5+
import nox
6+
7+
8+
nox.options.sessions = ["pre_commit", "docs", "typecheck", "tests"]
9+
nox.options.reuse_existing_virtualenvs = True
10+
nox.options.error_on_external_run = True
11+
12+
13+
@nox.session
14+
def pre_commit(session: nox.Session) -> None:
15+
session.install("pre-commit")
16+
17+
session.run("pre-commit", "run", "--all-files", "--show-diff-on-failure")
18+
19+
20+
@nox.session(python=["pypy3.7", "pypy3.8", "3.7", "3.8", "3.9", "3.10", "3.11"])
21+
def tests(session: nox.Session) -> None:
22+
session.install("Twisted", "coverage[toml]")
23+
posargs = list(session.posargs)
24+
25+
try:
26+
# Allow `--use-wheel path/to/wheel.whl` to be passed.
27+
i = session.posargs.index("--use-wheel")
28+
session.install(session.posargs[i + 1])
29+
del posargs[i : i + 2]
30+
except ValueError:
31+
session.install(".")
32+
33+
if not posargs:
34+
posargs = ["towncrier"]
35+
36+
session.run("coverage", "run", "--module", "twisted.trial", *posargs)
37+
38+
if os.environ.get("CI") != "true":
39+
session.notify("coverage_report")
40+
else:
41+
session.run("coverage", "combine")
42+
43+
44+
@nox.session
45+
def coverage_report(session: nox.Session) -> None:
46+
session.install("coverage[toml]")
47+
48+
session.run("coverage", "combine")
49+
session.run("coverage", "report")
50+
51+
52+
@nox.session
53+
def check_newsfragment(session: nox.Session) -> None:
54+
session.install(".")
55+
session.run("python", "-m", "towncrier.check", "--compare-with", "origin/trunk")
56+
57+
58+
@nox.session
59+
def check_manifest(session: nox.Session) -> None:
60+
session.install("check-manifest")
61+
session.run("check-manifest")
62+
63+
64+
@nox.session
65+
def typecheck(session: nox.Session) -> None:
66+
session.install(".", "mypy", "types-setuptools")
67+
session.run("mypy", "src")
68+
69+
70+
@nox.session
71+
def docs(session: nox.Session) -> None:
72+
session.install(".[dev]")
73+
74+
session.run(
75+
# fmt: off
76+
"python", "-m", "sphinx",
77+
"-T", "-E",
78+
"-W", "--keep-going",
79+
"-b", "html",
80+
"-d", "docs/_build/doctrees",
81+
"-D", "language=en",
82+
"docs",
83+
"docs/_build/html",
84+
# fmt: on
85+
)
86+
87+
88+
@nox.session
89+
def build(session: nox.Session) -> None:
90+
session.install("build", "check-manifest>=0.44", "twine")
91+
92+
session.run("check-manifest", "--verbose")
93+
# If no argument is passed, build builds an sdist and then a wheel from
94+
# that sdist.
95+
session.run("python", "-m", "build")
96+
97+
session.run("twine", "check", "dist/*")

pyproject.toml

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ exclude = '''
4141
/(
4242
\.eggs # exclude a few common directories in the
4343
| \.git # root of the project
44-
| \.tox
44+
| \.nox
4545
| \.venv
4646
| \.env
4747
| env
@@ -71,6 +71,11 @@ module = 'click_default_group'
7171
# 2022-09-04: This library has no type annotations.
7272
ignore_missing_imports = true
7373

74+
[[tool.mypy.overrides]]
75+
module = 'incremental'
76+
# No released version with type hints.
77+
ignore_missing_imports = true
78+
7479

7580
[build-system]
7681
requires = [
@@ -86,7 +91,7 @@ branch = true
8691
source = ["towncrier"]
8792

8893
[tool.coverage.paths]
89-
source = ["src", ".tox/*/site-packages"]
94+
source = ["src", ".nox/*/site-packages"]
9095

9196
[tool.coverage.report]
9297
show_missing = true

setup.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,5 +61,4 @@
6161
description="Building newsfiles for your project.",
6262
long_description=open("README.rst").read(),
6363
entry_points={"console_scripts": ["towncrier = towncrier._shell:cli"]},
64-
options={"bdist_wheel": {"universal": "1"}},
6564
)

0 commit comments

Comments
 (0)