|
14 | 14 | # See the License for the specific language governing permissions and |
15 | 15 | # limitations under the License. |
16 | 16 |
|
17 | | -from __future__ import absolute_import |
18 | | - |
19 | 17 | import pathlib |
20 | 18 | import nox |
21 | 19 |
|
22 | 20 | DEFAULT_PYTHON_VERSION = "3.14" |
| 21 | +ALL_PYTHON = ["3.9", "3.10", "3.11", "3.12", "3.13", "3.14"] |
23 | 22 | CURRENT_DIRECTORY = pathlib.Path(__file__).parent.absolute() |
24 | 23 | REPO_ROOT = CURRENT_DIRECTORY.parent.parent |
25 | 24 |
|
|
31 | 30 |
|
32 | 31 | nox.options.sessions = [ |
33 | 32 | "lint", |
| 33 | + "lint_setup_py", |
| 34 | + "unit", |
| 35 | + "mypy", |
| 36 | + "prerelease_deps", |
| 37 | + "core_deps_from_source", |
34 | 38 | "docfx", |
| 39 | + "docs", |
35 | 40 | ] |
36 | 41 |
|
37 | 42 | # Error if a python version is missing |
38 | 43 | nox.options.error_on_missing_interpreters = True |
39 | 44 |
|
40 | 45 | @nox.session(python=DEFAULT_PYTHON_VERSION) |
41 | | -def lint(session): |
| 46 | +def lint_setup_py(session: nox.Session) -> None: |
| 47 | + """Verify that setup.py is valid.""" |
| 48 | + session.install("setuptools") |
| 49 | + session.run("python", "setup.py", "check", "--strict") |
| 50 | + |
| 51 | +@nox.session(python=ALL_PYTHON) |
| 52 | +def unit(session: nox.Session) -> None: |
| 53 | + """Run unit tests.""" |
| 54 | + session.install("pytest", "pytest-cov") |
| 55 | + session.install("-e", ".") |
| 56 | + session.run("pytest", "tests") |
| 57 | + |
| 58 | +@nox.session(python=DEFAULT_PYTHON_VERSION) |
| 59 | +def mypy(session: nox.Session) -> None: |
| 60 | + """Run mypy.""" |
| 61 | + session.install("mypy", "types-PyYAML") |
| 62 | + session.install("-e", ".") |
| 63 | + session.run("mypy", "help", "tests", "noxfile.py", "docfx_helper.py") |
| 64 | + |
| 65 | +@nox.session(python=DEFAULT_PYTHON_VERSION) |
| 66 | +def prerelease_deps(session: nox.Session) -> None: |
| 67 | + """Run unit tests with prerelease dependencies.""" |
| 68 | + # Since we have no dependencies, this is just a normal unit test run |
| 69 | + # but with --pre enabled for any test tools. |
| 70 | + session.install("pytest", "pytest-cov") |
| 71 | + session.install("-e", ".") |
| 72 | + session.run("pytest", "tests") |
| 73 | + |
| 74 | +@nox.session(python=DEFAULT_PYTHON_VERSION) |
| 75 | +def core_deps_from_source(session: nox.Session) -> None: |
| 76 | + """Run unit tests with core dependencies installed from source.""" |
| 77 | + # We don't depend on core, so we just run unit tests. |
| 78 | + session.install("pytest", "pytest-cov") |
| 79 | + session.install("-e", ".") |
| 80 | + session.run("pytest", "tests") |
| 81 | + |
| 82 | +@nox.session(python=DEFAULT_PYTHON_VERSION) |
| 83 | +def lint(session: nox.Session) -> None: |
42 | 84 | """Run linters.""" |
43 | 85 | session.install("ruff") |
44 | 86 | session.run("ruff", "check", ".") |
45 | 87 |
|
46 | 88 | @nox.session(python="3.10") |
47 | | -def docfx(session): |
| 89 | +def docfx(session: nox.Session) -> None: |
48 | 90 | """Build the docfx yaml files for this library.""" |
49 | 91 | session.install("PyYAML", "pypandoc") |
50 | 92 |
|
51 | 93 | # Construct arguments for the helper script |
52 | | - args = [str(CURRENT_DIRECTORY), str(REPO_ROOT)] |
| 94 | + args = [ |
| 95 | + "--current-dir", str(CURRENT_DIRECTORY), |
| 96 | + ] |
53 | 97 | for title, source in DOCS_MAP.items(): |
54 | | - args.extend([title, str(source)]) |
| 98 | + args.extend(["--doc", title, str(source)]) |
55 | 99 |
|
56 | 100 | session.run("python", "docfx_helper.py", *args) |
| 101 | + |
| 102 | +@nox.session(python=DEFAULT_PYTHON_VERSION) |
| 103 | +def docs(session: nox.Session) -> None: |
| 104 | + """No-op session for docs.""" |
| 105 | + session.log("This package does not have Sphinx documentation.") |
0 commit comments