Skip to content

Commit 67aef95

Browse files
authored
👷 build: update nox (#69)
* 👷 build: update nox * ci: rm docs building * ci: lock * docs: update docs Signed-off-by: nstarman <nstarman@users.noreply.github.com>
1 parent 872eecd commit 67aef95

20 files changed

Lines changed: 1017 additions & 543 deletions

.github/workflows/cd.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ jobs:
3030
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
3131
with:
3232
fetch-depth: 0
33-
33+
persist-credentials: false
3434
- uses: hynek/build-and-inspect-python-package@efb823f52190ad02594531168b7a2d5790e66516 # v2.14.0
3535

3636
test-publish:

.github/workflows/ci.yml

Lines changed: 22 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -24,18 +24,14 @@ jobs:
2424
runs-on: ubuntu-latest
2525
steps:
2626
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
27-
2827
- name: Install uv
2928
uses: astral-sh/setup-uv@85856786d1ce8acfbcc2f13a5f3fbd6b938f9f41 # v7.1.2
29+
- name: Install
30+
run: uv sync --no-default-groups --group nox --group lint --locked
31+
- name: Lint
32+
run: uv run --frozen nox -s lint
3033

31-
- name: Install the project
32-
run: uv sync --group nox
33-
34-
- uses: pre-commit/action@2c7b3805fd2a0fd8c1884dcaebf91fc102a13ecd # v3.0.1
35-
with:
36-
extra_args: --hook-stage manual --all-files
37-
38-
checks:
34+
tests:
3935
name: Check Python ${{ matrix.python-version }} on ${{ matrix.runs-on }}
4036
runs-on: ${{ matrix.runs-on }}
4137
needs: [format]
@@ -53,10 +49,12 @@ jobs:
5349
with:
5450
python-version: ${{ matrix.python-version }}
5551

56-
- name: Test package
57-
run: >-
58-
uv run --group test pytest -ra --cov --cov-report=xml
59-
--cov-report=term --durations=20
52+
- name: Install
53+
run: uv sync --no-default-groups --group nox --group test --locked
54+
55+
- name: Test
56+
run: |
57+
uv run --frozen nox -s test -- --cov --cov-report=xml --cov-report=term --durations=20
6058
6159
- name: Upload coverage report
6260
uses: codecov/codecov-action@5a1091511ad55cbe89839c7260b706298ca349f7 # v5.5.1
@@ -90,3 +88,14 @@ jobs:
9088
uses: codecov/codecov-action@5a1091511ad55cbe89839c7260b706298ca349f7 # v5.5.1
9189
with:
9290
token: ${{ secrets.CODECOV_TOKEN }}
91+
92+
status:
93+
name: CI Pass
94+
runs-on: ubuntu-latest
95+
needs: [format, tests, check_oldest]
96+
if: always()
97+
steps:
98+
- name: All required jobs passed
99+
uses: re-actors/alls-green@release/v1
100+
with:
101+
jobs: ${{ toJSON(needs) }}

.pre-commit-config.yaml

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -50,19 +50,12 @@ repos:
5050
args: ["--fix", "--show-fixes"]
5151
- id: ruff-format
5252

53-
- repo: https://github.com/pre-commit/mirrors-mypy
54-
rev: "v1.18.2"
55-
hooks:
56-
- id: mypy
57-
files: src
58-
args: []
59-
additional_dependencies:
60-
- pytest
61-
6253
- repo: https://github.com/codespell-project/codespell
6354
rev: "v2.4.1"
6455
hooks:
6556
- id: codespell
57+
args: ["--toml", "pyproject.toml"]
58+
additional_dependencies: ["tomli"]
6659

6760
- repo: https://github.com/shellcheck-py/shellcheck-py
6861
rev: "v0.11.0.1"

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -425,7 +425,7 @@ consideration by the functions in `dataclassish`.
425425
```pycon
426426
>>> from dataclassish import flags
427427
>>> flags.__all__
428-
['FlagConstructionError', 'AbstractFlag', 'NoFlag', 'FilterRepr']
428+
('FlagConstructionError', 'AbstractFlag', 'NoFlag', 'FilterRepr')
429429

430430
```
431431

noxfile.py

Lines changed: 61 additions & 96 deletions
Original file line numberDiff line numberDiff line change
@@ -1,116 +1,81 @@
1-
"""Nox configuration."""
1+
#!/usr/bin/env -S uv run --script # noqa: EXE001
2+
# /// script
3+
# dependencies = ["nox", "nox_uv"]
4+
# ///
5+
"""Nox setup."""
26

3-
import argparse
47
import shutil
58
from pathlib import Path
69

710
import nox
11+
from nox_uv import session
12+
13+
nox.needs_version = ">=2024.3.2"
14+
nox.options.default_venv_backend = "uv"
815

916
DIR = Path(__file__).parent.resolve()
1017

11-
nox.needs_version = ">=2024.3.2"
12-
nox.options.sessions = ["lint", "tests"]
13-
nox.options.default_venv_backend = "uv|virtualenv"
18+
# =============================================================================
19+
# Linting
1420

1521

16-
@nox.session
17-
def lint(session: nox.Session) -> None:
22+
@session(uv_groups=["lint"], reuse_venv=True, default=True)
23+
def lint(s: nox.Session, /) -> None:
1824
"""Run the linter."""
19-
session.install("pre-commit")
20-
session.run(
21-
"pre-commit",
22-
"run",
23-
"--all-files",
24-
"--show-diff-on-failure",
25-
*session.posargs,
26-
)
27-
28-
29-
@nox.session
30-
def pylint(session: nox.Session) -> None:
25+
s.notify("precommit")
26+
s.notify("pylint")
27+
s.notify("mypy")
28+
29+
30+
@session(uv_groups=["lint"], reuse_venv=True)
31+
def precommit(s: nox.Session, /) -> None:
32+
"""Run pre-commit."""
33+
s.run("pre-commit", "run", "--all-files", *s.posargs)
34+
35+
36+
@session(uv_groups=["lint"], reuse_venv=True)
37+
def pylint(s: nox.Session, /) -> None:
3138
"""Run PyLint."""
32-
# This needs to be installed into the package environment, and is slower
33-
# than a pre-commit check
34-
session.install(".", "pylint")
35-
session.run("pylint", "dataclassish", *session.posargs)
39+
s.run("pylint", "dataclassish", *s.posargs)
40+
41+
42+
@session(uv_groups=["lint"], reuse_venv=True)
43+
def mypy(s: nox.Session, /) -> None:
44+
"""Run mypy."""
45+
s.run("mypy", "src/dataclassish", *s.posargs)
46+
47+
48+
# =============================================================================
49+
# Testing
3650

3751

38-
@nox.session
39-
def tests(session: nox.Session) -> None:
52+
@session(uv_groups=["test"], reuse_venv=True, default=True)
53+
def test(s: nox.Session, /) -> None:
4054
"""Run the unit and regular tests."""
41-
session.install(".[test]")
42-
session.run("pytest", *session.posargs)
43-
44-
45-
@nox.session(reuse_venv=True)
46-
def docs(session: nox.Session) -> None:
47-
"""Build the docs. Pass "--serve" to serve. Pass "-b linkcheck" to check links."""
48-
parser = argparse.ArgumentParser()
49-
parser.add_argument("--serve", action="store_true", help="Serve after building")
50-
parser.add_argument(
51-
"-b",
52-
dest="builder",
53-
default="html",
54-
help="Build target (default: html)",
55-
)
56-
args, posargs = parser.parse_known_args(session.posargs)
57-
58-
if args.builder != "html" and args.serve:
59-
session.error("Must not specify non-HTML builder with --serve")
60-
61-
extra_installs = ["sphinx-autobuild"] if args.serve else []
62-
63-
session.install("-e.[docs]", *extra_installs)
64-
session.chdir("docs")
65-
66-
if args.builder == "linkcheck":
67-
session.run(
68-
"sphinx-build",
69-
"-b",
70-
"linkcheck",
71-
".",
72-
"_build/linkcheck",
73-
*posargs,
74-
)
75-
return
76-
77-
shared_args = (
78-
"-n", # nitpicky mode
79-
"-T", # full tracebacks
80-
f"-b={args.builder}",
81-
".",
82-
f"_build/{args.builder}",
83-
*posargs,
84-
)
85-
86-
if args.serve:
87-
session.run("sphinx-autobuild", *shared_args)
88-
else:
89-
session.run("sphinx-build", "--keep-going", *shared_args)
90-
91-
92-
@nox.session
93-
def build_api_docs(session: nox.Session) -> None:
94-
"""Build (regenerate) API docs."""
95-
session.install("sphinx")
96-
session.chdir("docs")
97-
session.run(
98-
"sphinx-apidoc",
99-
"-o",
100-
"api/",
101-
"--module-first",
102-
"--no-toc",
103-
"--force",
104-
"../src/dataclassish",
105-
)
106-
107-
108-
@nox.session
109-
def build(session: nox.Session) -> None:
55+
s.notify("pytest", posargs=s.posargs)
56+
57+
58+
@session(uv_groups=["test"], reuse_venv=True)
59+
def pytest(s: nox.Session, /) -> None:
60+
"""Run the unit and regular tests."""
61+
s.run("pytest", *s.posargs)
62+
63+
64+
# =============================================================================
65+
# Build
66+
67+
68+
@session(uv_groups=["build"])
69+
def build(s: nox.Session, /) -> None:
11070
"""Build an SDist and wheel."""
11171
build_path = DIR.joinpath("build")
11272
if build_path.exists():
11373
shutil.rmtree(build_path)
11474

115-
session.install("build")
116-
session.run("python", "-m", "build")
75+
s.run("python", "-m", "build")
76+
77+
78+
# =============================================================================
79+
80+
if __name__ == "__main__":
81+
nox.main()

pyproject.toml

Lines changed: 55 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -40,49 +40,60 @@ Changelog = "https://github.com/GalacticDynamics/dataclassish/releases"
4040
requires = ["hatchling", "hatch-vcs"]
4141
build-backend = "hatchling.build"
4242

43+
4344
[dependency-groups]
4445
dev = [
4546
"cz-conventional-gitmoji>=0.6.1",
47+
{ "include-group" = "build" },
48+
{ "include-group" = "lint" },
4649
{ "include-group" = "nox" },
4750
{ "include-group" = "test" },
4851
]
49-
nox = ["nox>=2024.10.9"]
52+
nox = [
53+
"nox>=2024.10.9",
54+
"nox-uv>=0.6.3",
55+
]
5056
test = [
5157
"attrs>=25.4.0",
5258
"pytest>=8.4.2",
5359
"pytest-cov>=7.0.0",
5460
"sybil[pytest]>=9.2.0",
5561
]
62+
build = [
63+
"build>=1.3.0",
64+
]
65+
lint = [
66+
"mypy>=1.19.0",
67+
"pre-commit>=4.5.0",
68+
"pylint>=4.0.4",
69+
]
5670

5771
[tool.hatch]
5872
version.source = "vcs"
5973
build.hooks.vcs.version-file = "src/dataclassish/_version.py"
74+
build.hooks.vcs.version-file-template = """\
75+
version: str = {version!r}
76+
version_tuple: tuple[int, int, int] | tuple[int, int, int, str, str]
77+
version_tuple = {version_tuple!r}
78+
"""
6079

6180

62-
[tool.commitizen]
63-
name = "cz_gitmoji"
81+
[tool.codespell]
82+
skip = ["uv.lock"]
6483

6584

66-
[tool.pytest.ini_options]
67-
minversion = "8.0"
68-
addopts = ["-ra", "--showlocals", "--strict-markers", "--strict-config"]
69-
xfail_strict = true
70-
filterwarnings = [
71-
"error",
72-
]
73-
log_cli_level = "INFO"
74-
testpaths = [
75-
"README.md", "src", "tests",
76-
]
85+
[tool.commitizen]
86+
name = "cz_gitmoji"
7787

7888

7989
[tool.coverage]
8090
run.source = ["dataclassish"]
8191
report.exclude_also = [
8292
'\.\.\.',
83-
'if typing.TYPE_CHECKING:',
93+
'if TYPE_CHECKING:',
8494
]
8595

96+
8697
[tool.mypy]
8798
files = ["src"]
8899
python_version = "3.10"
@@ -103,6 +114,35 @@ ignore_missing_imports = true
103114
module = ["plum.*"]
104115

105116

117+
[tool.pylint]
118+
py-version = "3.11"
119+
ignore-paths = [".*/_version.py"]
120+
reports.output-format = "colorized"
121+
similarities.ignore-imports = "yes"
122+
disable = [
123+
"fixme",
124+
"function-redefined", # incompatible with plum-dispatch
125+
"line-too-long", # handled by ruff
126+
"no-member", # handled by mypy
127+
"too-few-public-methods", # Protocols
128+
"too-many-function-args", # incompatible with plum-dispatch
129+
"unused-argument", # handled by ruff
130+
]
131+
132+
133+
[tool.pytest.ini_options]
134+
minversion = "8.0"
135+
addopts = ["-ra", "--showlocals", "--strict-markers", "--strict-config"]
136+
xfail_strict = true
137+
filterwarnings = [
138+
"error",
139+
]
140+
log_cli_level = "INFO"
141+
testpaths = [
142+
"README.md", "src", "tests",
143+
]
144+
145+
106146
[tool.ruff]
107147
src = ["src"]
108148

0 commit comments

Comments
 (0)