Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 5 additions & 10 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,10 @@ jobs:
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
- name: Install uv
uses: astral-sh/setup-uv@85856786d1ce8acfbcc2f13a5f3fbd6b938f9f41 # v6
- name: Install the project
run: uv sync --locked --group test

- uses: pre-commit/action@2c7b3805fd2a0fd8c1884dcaebf91fc102a13ecd # v3.0.1
with:
extra_args: --hook-stage manual --all-files
- name: Run PyLint
run: uv run --frozen nox -s pylint -- --output-format=github
- name: Install
run: uv sync --locked --group lint
Comment thread
nstarman marked this conversation as resolved.
Outdated
- name: Lint
run: uv run --frozen nox -s lint

checks:
name: Check Python ${{ matrix.python-version }} on ${{ matrix.runs-on }}
Expand All @@ -51,8 +47,7 @@ jobs:
uses: astral-sh/setup-uv@85856786d1ce8acfbcc2f13a5f3fbd6b938f9f41 # v6
- name: Install the project
run: uv sync --locked --group test

- name: Test package
- name: Test
run: >-
uv run --frozen pytest --cov --cov-report=xml --cov-report=term
--durations=20
Expand Down
73 changes: 43 additions & 30 deletions noxfile.py
Original file line number Diff line number Diff line change
@@ -1,52 +1,65 @@
"""Nox configuration."""
"""Nox setup."""

import shutil
from pathlib import Path

import nox

DIR = Path(__file__).parent.resolve()
from nox_uv import session

nox.needs_version = ">=2024.3.2"
nox.options.sessions = ["lint", "pylint", "tests"]
nox.options.default_venv_backend = "uv"
Comment thread
nstarman marked this conversation as resolved.

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

# =============================================================================
# Linting

@nox.session
def lint(session: nox.Session) -> None:

@session(uv_groups=["lint"], reuse_venv=True)
def lint(s: nox.Session, /) -> None:
"""Run the linter."""
session.install("pre-commit")
session.run(
"pre-commit",
"run",
"--all-files",
"--show-diff-on-failure",
*session.posargs,
)


@nox.session
def pylint(session: nox.Session) -> None:
precommit(s) # reuse pre-commit session
pylint(s) # reuse pylint session
Comment thread
nstarman marked this conversation as resolved.
Outdated


@session(uv_groups=["lint"], reuse_venv=True)
def precommit(s: nox.Session, /) -> None:
"""Run pre-commit."""
s.run("pre-commit", "run", "--all-files", *s.posargs)


@session(uv_groups=["lint"], reuse_venv=True)
def pylint(s: nox.Session, /) -> None:
"""Run PyLint."""
# This needs to be installed into the package environment, and is slower
# than a pre-commit check
session.install(".", "pylint>=3.2")
session.run("pylint", "is_annotated", *session.posargs)
s.install(".", "pylint>=3.2")
s.run("pylint", "is_annotated", *s.posargs)


@session(uv_groups=["lint"], reuse_venv=True)
def mypy(s: nox.Session, /) -> None:
"""Run mypy."""
s.run("mypy", "src/is_annotated", *s.posargs)


# =============================================================================
# Testing

@nox.session
def tests(session: nox.Session) -> None:

@session(uv_groups=["test"], reuse_venv=True)
def pytest(s: nox.Session, /) -> None:
"""Run the unit and regular tests."""
session.install(".[test]")
session.run("pytest", *session.posargs)
s.run("pytest", *s.posargs)


# =============================================================================
# Build


@nox.session
def build(session: nox.Session) -> None:
@session(uv_groups=["build"])
def build(s: nox.Session, /) -> None:
"""Build an SDist and wheel."""
build_path = DIR.joinpath("build")
if build_path.exists():
shutil.rmtree(build_path)

Comment thread
nstarman marked this conversation as resolved.
session.install("build")
session.run("python", "-m", "build")
s.run("python", "-m", "build")
6 changes: 6 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,12 @@
"uv>=0.6.4",
{ include-group = "test" },
]
lint = [
Comment thread
nstarman marked this conversation as resolved.
"pylint>=3.3.9",
]
nox = [
Comment thread
nstarman marked this conversation as resolved.
"nox-uv>=0.6.3",
]
test = [
"optional_dependencies >= 0.3",
"pytest >=6",
Expand Down
Loading
Loading