Skip to content

Commit 0653a9b

Browse files
authored
ci: refactor nox (#29)
* ci: refactor nox * ci: rm pypy * ci: twiddle settings Signed-off-by: nstarman <[email protected]>
1 parent 3ae8885 commit 0653a9b

File tree

5 files changed

+222
-74
lines changed

5 files changed

+222
-74
lines changed

.github/workflows/cd.yml

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,13 +25,12 @@ jobs:
2525
runs-on: ubuntu-latest
2626
permissions:
2727
contents: read
28+
env:
29+
PYO3_USE_ABI3_FORWARD_COMPATIBILITY: "1"
2830

2931
steps:
3032
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
31-
with:
32-
fetch-depth: 0
33-
34-
- uses: hynek/build-and-inspect-python-package@c52c3a4710070b50470d903818a7b25115dcd076 # v2.13.0
33+
- uses: hynek/build-and-inspect-python-package@efb823f52190ad02594531168b7a2d5790e66516 # v2.14.0
3534

3635
test-publish:
3736
needs: [dist]

.github/workflows/ci.yml

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,10 @@ jobs:
2727
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
2828
- name: Install uv
2929
uses: astral-sh/setup-uv@557e51de59eb14aaaba2ed9621916900a91d50c6 # v6.6.1
30-
- uses: pre-commit/action@2c7b3805fd2a0fd8c1884dcaebf91fc102a13ecd # v3.0.1
31-
- name: Run PyLint
32-
run: uv run --group nox nox -s pylint -- --output-format=github
30+
- name: Install
31+
run: uv sync --group nox --group lint --locked
32+
- name: Lint
33+
run: uv run --frozen nox -s lint
3334

3435
tests:
3536
name: Check Python ${{ matrix.python-version }} on ${{ matrix.runs-on }}
@@ -41,10 +42,6 @@ jobs:
4142
python-version: ["3.9", "3.13"]
4243
runs-on: [ubuntu-latest, macos-latest, windows-latest]
4344

44-
include:
45-
- python-version: pypy-3.10
46-
runs-on: ubuntu-latest
47-
4845
steps:
4946
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
5047

@@ -53,10 +50,12 @@ jobs:
5350
with:
5451
python-version: ${{ matrix.python-version }}
5552

56-
- name: Test package
57-
run: >-
58-
uv run --group test pytest --cov --cov-report=xml --cov-report=term
59-
--durations=20
53+
- name: Install
54+
run: uv sync --no-default-groups --group nox --group test --locked
55+
56+
- name: Test
57+
run: |
58+
uv run --frozen nox -s pytest -- --cov --cov-report=xml --cov-report=term --durations=20
6059
6160
- name: Upload coverage report
6261
uses: codecov/codecov-action@5a1091511ad55cbe89839c7260b706298ca349f7 # v5.5.1

noxfile.py

Lines changed: 28 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -1,94 +1,65 @@
1-
"""Nox configuration."""
2-
# pylint: disable=import-error
1+
"""Nox setup."""
32

43
import shutil
54
from pathlib import Path
65

76
import nox
7+
from nox_uv import session
88

99
nox.needs_version = ">=2024.3.2"
10-
nox.options.sessions = [
11-
# Linting
12-
"lint",
13-
"precommit",
14-
"pylint",
15-
# Testing
16-
"tests",
17-
]
1810
nox.options.default_venv_backend = "uv"
1911

20-
2112
DIR = Path(__file__).parent.resolve()
2213

2314
# =============================================================================
2415
# Linting
2516

2617

27-
@nox.session(venv_backend="uv")
28-
def lint(session: nox.Session, /) -> None:
18+
@session(uv_groups=["lint"], reuse_venv=True)
19+
def lint(s: nox.Session, /) -> None:
2920
"""Run the linter."""
30-
precommit(session) # reuse pre-commit session
31-
pylint(session) # reuse pylint session
21+
precommit(s) # reuse pre-commit session
22+
pylint(s) # reuse pylint session
23+
mypy(s) # reuse mypy session
3224

3325

34-
@nox.session(venv_backend="uv")
35-
def precommit(session: nox.Session, /) -> None:
26+
@session(uv_groups=["lint"], reuse_venv=True)
27+
def precommit(s: nox.Session, /) -> None:
3628
"""Run pre-commit."""
37-
session.run_install(
38-
"uv",
39-
"sync",
40-
"--group=lint",
41-
f"--python={session.virtualenv.location}",
42-
env={"UV_PROJECT_ENVIRONMENT": session.virtualenv.location},
43-
)
44-
session.run("pre-commit", "run", "--all-files", *session.posargs)
45-
46-
47-
@nox.session(venv_backend="uv")
48-
def pylint(session: nox.Session, /) -> None:
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:
4934
"""Run PyLint."""
50-
session.run_install(
51-
"uv",
52-
"sync",
53-
"--group=lint",
54-
f"--python={session.virtualenv.location}",
55-
env={"UV_PROJECT_ENVIRONMENT": session.virtualenv.location},
56-
)
57-
session.run("pylint", "zeroth", *session.posargs)
35+
s.run("pylint", "zeroth", *s.posargs)
36+
37+
38+
@session(uv_groups=["lint"], reuse_venv=True)
39+
def mypy(s: nox.Session, /) -> None:
40+
"""Run mypy."""
41+
s.run("mypy", "src/zeroth", *s.posargs)
5842

5943

6044
# =============================================================================
6145
# Testing
6246

6347

64-
@nox.session(venv_backend="uv")
65-
def tests(session: nox.Session, /) -> None:
48+
@session(uv_groups=["test"], reuse_venv=True)
49+
def pytest(s: nox.Session, /) -> None:
6650
"""Run the unit and regular tests."""
67-
session.run_install(
68-
"uv",
69-
"sync",
70-
"--group=test",
71-
f"--python={session.virtualenv.location}",
72-
env={"UV_PROJECT_ENVIRONMENT": session.virtualenv.location},
73-
)
74-
session.run("pytest", *session.posargs)
51+
s.run("pytest", *s.posargs)
7552

7653

7754
# =============================================================================
55+
# Build
7856

7957

80-
@nox.session(venv_backend="uv")
81-
def build(session: nox.Session, /) -> None:
58+
@session(uv_groups=["build"])
59+
def build(s: nox.Session, /) -> None:
8260
"""Build an SDist and wheel."""
8361
build_path = DIR.joinpath("build")
8462
if build_path.exists():
8563
shutil.rmtree(build_path)
8664

87-
session.run_install(
88-
"uv",
89-
"sync",
90-
"--group=build",
91-
f"--python={session.virtualenv.location}",
92-
env={"UV_PROJECT_ENVIRONMENT": session.virtualenv.location},
93-
)
94-
session.run("python", "-m", "build")
65+
s.run("python", "-m", "build")

pyproject.toml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,10 +59,14 @@ docs = [
5959
"sphinx-copybutton>=0.5.2",
6060
]
6161
lint = [
62+
"mypy>=1.19.0",
6263
"pre-commit>=4.1.0",
6364
"pylint>=3.3.8",
6465
]
65-
nox = ["nox>=2024.10.9"]
66+
nox = [
67+
"nox>=2024.10.9",
68+
"nox-uv>=0.6.3",
69+
]
6670
test = [
6771
"numpy>=2.0.2",
6872
"optional_dependencies>=0.3",

0 commit comments

Comments
 (0)