-
Notifications
You must be signed in to change notification settings - Fork 122
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This greatly simplifies (and makes more idiomatic) both our local tests and CI.
- Loading branch information
Showing
13 changed files
with
166 additions
and
140 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,6 @@ | ||
[flake8] | ||
# Allow for longer test strings. Code is formatted to 88 columns by Black. | ||
max-line-length = 99 | ||
extend-ignore = | ||
# Conflict between flake8 & black about whitespace in slices. | ||
E203 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -18,7 +18,7 @@ apidocs/ | |
*.pyproj | ||
.DS_Store | ||
.eggs | ||
.tox/ | ||
.nox/ | ||
.coverage.* | ||
.vscode | ||
.idea | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,97 @@ | ||
from __future__ import annotations | ||
|
||
import os | ||
|
||
import nox | ||
|
||
|
||
nox.options.sessions = ["pre_commit", "docs", "typecheck", "tests"] | ||
nox.options.reuse_existing_virtualenvs = True | ||
nox.options.error_on_external_run = True | ||
|
||
|
||
@nox.session | ||
def pre_commit(session: nox.Session) -> None: | ||
session.install("pre-commit") | ||
|
||
session.run("pre-commit", "run", "--all-files", "--show-diff-on-failure") | ||
|
||
|
||
@nox.session(python=["pypy3.7", "pypy3.8", "3.7", "3.8", "3.9", "3.10", "3.11"]) | ||
def tests(session: nox.Session) -> None: | ||
session.install("Twisted", "coverage[toml]") | ||
posargs = list(session.posargs) | ||
|
||
try: | ||
# Allow `--use-wheel path/to/wheel.whl` to be passed. | ||
i = session.posargs.index("--use-wheel") | ||
session.install(session.posargs[i + 1]) | ||
del posargs[i : i + 2] | ||
except ValueError: | ||
session.install(".") | ||
|
||
if not posargs: | ||
posargs = ["towncrier"] | ||
|
||
session.run("coverage", "run", "--module", "twisted.trial", *posargs) | ||
|
||
if os.environ.get("CI") != "true": | ||
session.notify("coverage_report") | ||
else: | ||
session.run("coverage", "combine") | ||
|
||
|
||
@nox.session | ||
def coverage_report(session: nox.Session) -> None: | ||
session.install("coverage[toml]") | ||
|
||
session.run("coverage", "combine") | ||
session.run("coverage", "report") | ||
|
||
|
||
@nox.session | ||
def check_newsfragment(session: nox.Session) -> None: | ||
session.install(".") | ||
session.run("python", "-m", "towncrier.check", "--compare-with", "origin/trunk") | ||
|
||
|
||
@nox.session | ||
def check_manifest(session: nox.Session) -> None: | ||
session.install("check-manifest") | ||
session.run("check-manifest") | ||
|
||
|
||
@nox.session | ||
def typecheck(session: nox.Session) -> None: | ||
session.install(".", "mypy", "types-setuptools") | ||
session.run("mypy", "src") | ||
|
||
|
||
@nox.session | ||
def docs(session: nox.Session) -> None: | ||
session.install(".[dev]") | ||
|
||
session.run( | ||
# fmt: off | ||
"python", "-m", "sphinx", | ||
"-T", "-E", | ||
"-W", "--keep-going", | ||
"-b", "html", | ||
"-d", "docs/_build/doctrees", | ||
"-D", "language=en", | ||
"docs", | ||
"docs/_build/html", | ||
# fmt: on | ||
) | ||
|
||
|
||
@nox.session | ||
def build(session: nox.Session) -> None: | ||
session.install("build", "check-manifest>=0.44", "twine") | ||
|
||
session.run("check-manifest", "--verbose") | ||
# If no argument is passed, build builds an sdist and then a wheel from | ||
# that sdist. | ||
session.run("python", "-m", "build") | ||
|
||
session.run("twine", "check", "dist/*") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.