Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
34 changes: 20 additions & 14 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,26 +19,22 @@ env:
FORCE_COLOR: 3

jobs:
pre-commit:
format:
name: Format
runs-on: ubuntu-latest
steps:
- 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 --no-default-groups --group nox --group lint --locked
- name: Lint
run: uv run --frozen nox -s lint

checks:
tests:
name: Check Python ${{ matrix.python-version }} on ${{ matrix.runs-on }}
runs-on: ${{ matrix.runs-on }}
needs: [pre-commit]
needs: [format]
strategy:
fail-fast: false
matrix:
Expand All @@ -50,9 +46,8 @@ jobs:
- name: Install uv
uses: astral-sh/setup-uv@85856786d1ce8acfbcc2f13a5f3fbd6b938f9f41 # v6
- name: Install the project
run: uv sync --locked --group test

- name: Test package
run: uv sync --no-default-groups --group nox --group test --locked
- name: Test
run: >-
uv run --frozen pytest --cov --cov-report=xml --cov-report=term
--durations=20
Expand All @@ -61,3 +56,14 @@ jobs:
uses: codecov/codecov-action@5a1091511ad55cbe89839c7260b706298ca349f7 # v5.5.1
with:
token: ${{ secrets.CODECOV_TOKEN }}

status:
name: CI Pass
runs-on: ubuntu-latest
needs: [format, tests]
if: always()
steps:
- name: All required jobs passed
uses: re-actors/alls-green@release/v1
with:
jobs: ${{ toJSON(needs) }}
74 changes: 44 additions & 30 deletions noxfile.py
Original file line number Diff line number Diff line change
@@ -1,52 +1,66 @@
"""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"

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:
s.notify("precommit")
s.notify("pylint")
s.notify("mypy")


@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)

session.install("build")
session.run("python", "-m", "build")
s.run("python", "-m", "build")
17 changes: 17 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,21 @@
"ipykernel>=6.29.5",
"pre-commit>=4.0.1",
"uv>=0.6.4",
{ include-group = "build" },
{ include-group = "test" },
]
build = [
"build>=1.3.0",
]
lint = [
"mypy>=1.19.0",
"pre-commit>=4.2.0",
"pylint>=3.3.9",
]
nox = [
"nox>=2025.5.1",
"nox-uv>=0.6.3",
]
test = [
"optional_dependencies >= 0.3",
"pytest >=6",
Expand Down Expand Up @@ -137,3 +150,7 @@
py-version = "3.9"
reports.output-format = "colorized"
similarities.ignore-imports = "yes"


[tool.codespell]
skip = "uv.lock"
Loading