Skip to content

Commit e2ded74

Browse files
Backport PR #34: ci: use nox-uv (#35)
Co-authored-by: Nathaniel Starkman <nstarman@users.noreply.github.com>
1 parent e30dd89 commit e2ded74

4 files changed

Lines changed: 956 additions & 640 deletions

File tree

.github/workflows/ci.yml

Lines changed: 20 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -19,26 +19,22 @@ env:
1919
FORCE_COLOR: 3
2020

2121
jobs:
22-
pre-commit:
22+
format:
2323
name: Format
2424
runs-on: ubuntu-latest
2525
steps:
2626
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
2727
- name: Install uv
2828
uses: astral-sh/setup-uv@85856786d1ce8acfbcc2f13a5f3fbd6b938f9f41 # v6
29-
- name: Install the project
30-
run: uv sync --locked --group test
31-
32-
- uses: pre-commit/action@2c7b3805fd2a0fd8c1884dcaebf91fc102a13ecd # v3.0.1
33-
with:
34-
extra_args: --hook-stage manual --all-files
35-
- name: Run PyLint
36-
run: uv run --frozen nox -s pylint -- --output-format=github
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
3733

38-
checks:
34+
tests:
3935
name: Check Python ${{ matrix.python-version }} on ${{ matrix.runs-on }}
4036
runs-on: ${{ matrix.runs-on }}
41-
needs: [pre-commit]
37+
needs: [format]
4238
strategy:
4339
fail-fast: false
4440
matrix:
@@ -50,9 +46,8 @@ jobs:
5046
- name: Install uv
5147
uses: astral-sh/setup-uv@85856786d1ce8acfbcc2f13a5f3fbd6b938f9f41 # v6
5248
- name: Install the project
53-
run: uv sync --locked --group test
54-
55-
- name: Test package
49+
run: uv sync --no-default-groups --group nox --group test --locked
50+
- name: Test
5651
run: >-
5752
uv run --frozen pytest --cov --cov-report=xml --cov-report=term
5853
--durations=20
@@ -61,3 +56,14 @@ jobs:
6156
uses: codecov/codecov-action@5a1091511ad55cbe89839c7260b706298ca349f7 # v5.5.1
6257
with:
6358
token: ${{ secrets.CODECOV_TOKEN }}
59+
60+
status:
61+
name: CI Pass
62+
runs-on: ubuntu-latest
63+
needs: [format, tests]
64+
if: always()
65+
steps:
66+
- name: All required jobs passed
67+
uses: re-actors/alls-green@release/v1
68+
with:
69+
jobs: ${{ toJSON(needs) }}

noxfile.py

Lines changed: 44 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,52 +1,66 @@
1-
"""Nox configuration."""
1+
"""Nox setup."""
22

33
import shutil
44
from pathlib import Path
55

66
import nox
7-
8-
DIR = Path(__file__).parent.resolve()
7+
from nox_uv import session
98

109
nox.needs_version = ">=2024.3.2"
11-
nox.options.sessions = ["lint", "pylint", "tests"]
1210
nox.options.default_venv_backend = "uv"
1311

12+
DIR = Path(__file__).parent.resolve()
13+
14+
# =============================================================================
15+
# Linting
1416

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

45+
# =============================================================================
46+
# Testing
3647

37-
@nox.session
38-
def tests(session: nox.Session) -> None:
48+
49+
@session(uv_groups=["test"], reuse_venv=True)
50+
def pytest(s: nox.Session, /) -> None:
3951
"""Run the unit and regular tests."""
40-
session.install(".[test]")
41-
session.run("pytest", *session.posargs)
52+
s.run("pytest", *s.posargs)
53+
54+
55+
# =============================================================================
56+
# Build
4257

4358

44-
@nox.session
45-
def build(session: nox.Session) -> None:
59+
@session(uv_groups=["build"])
60+
def build(s: nox.Session, /) -> None:
4661
"""Build an SDist and wheel."""
4762
build_path = DIR.joinpath("build")
4863
if build_path.exists():
4964
shutil.rmtree(build_path)
5065

51-
session.install("build")
52-
session.run("python", "-m", "build")
66+
s.run("python", "-m", "build")

pyproject.toml

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,21 @@
3838
"ipykernel>=6.29.5",
3939
"pre-commit>=4.0.1",
4040
"uv>=0.6.4",
41+
{ include-group = "build" },
4142
{ include-group = "test" },
4243
]
44+
build = [
45+
"build>=1.3.0",
46+
]
47+
lint = [
48+
"mypy>=1.19.0",
49+
"pre-commit>=4.2.0",
50+
"pylint>=3.3.9",
51+
]
52+
nox = [
53+
"nox>=2025.5.1",
54+
"nox-uv>=0.6.3",
55+
]
4356
test = [
4457
"optional_dependencies >= 0.3",
4558
"pytest >=6",
@@ -137,3 +150,7 @@
137150
py-version = "3.9"
138151
reports.output-format = "colorized"
139152
similarities.ignore-imports = "yes"
153+
154+
155+
[tool.codespell]
156+
skip = "uv.lock"

0 commit comments

Comments
 (0)