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
5 changes: 4 additions & 1 deletion .github/workflows/cd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,16 @@ jobs:
runs-on: ubuntu-latest
permissions:
contents: read
env:
PYO3_USE_ABI3_FORWARD_COMPATIBILITY: "1"

steps:
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
with:
fetch-depth: 0
persist-credentials: false

- uses: hynek/build-and-inspect-python-package@c52c3a4710070b50470d903818a7b25115dcd076 # v2.13.0
- uses: hynek/build-and-inspect-python-package@efb823f52190ad02594531168b7a2d5790e66516 # v2.14.0

test-publish:
needs: [dist]
Expand Down
47 changes: 28 additions & 19 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,46 +20,55 @@ env:
FORCE_COLOR: 3

jobs:
pre-commit:
format:
name: Format
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
- uses: actions/setup-python@e797f83bcb11b83ae66e0230d6156d7c80228e7c # v6.0.0
with:
python-version: "3.x"
# - uses: pre-commit/action@v3.0.1
# with:
# extra_args: --hook-stage manual --all-files
- name: Run PyLint
run: pipx run nox -s pylint -- --output-format=github
- name: Install uv
uses: astral-sh/setup-uv@85856786d1ce8acfbcc2f13a5f3fbd6b938f9f41 # v7.1.2
- 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:
python-version: ["3.8", "3.13"]
python-version: ["3.9", "3.13"]
runs-on: [ubuntu-latest, windows-latest, macos-latest]

steps:
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
- uses: actions/setup-python@e797f83bcb11b83ae66e0230d6156d7c80228e7c # v6.0.0

- name: Install uv
uses: astral-sh/setup-uv@85856786d1ce8acfbcc2f13a5f3fbd6b938f9f41 # v7.1.2
with:
python-version: ${{ matrix.python-version }}
allow-prereleases: true

- name: Install package
run: python -m pip install .[test]
- name: Install
run: uv sync --no-default-groups --group nox --group test --locked

- name: Test package
run: >-
python -m pytest -ra --cov --cov-report=xml --cov-report=term
--durations=20
run: |
uv run --frozen nox -s test -- --cov --cov-report=xml --cov-report=term --durations=20

- name: Upload coverage report
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) }}
2 changes: 2 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,8 @@ repos:
rev: "v2.4.1"
hooks:
- id: codespell
args: ["--toml", "pyproject.toml"]
additional_dependencies: ["tomli"]

- repo: local
hooks:
Expand Down
72 changes: 42 additions & 30 deletions noxfile.py
Original file line number Diff line number Diff line change
@@ -1,52 +1,64 @@
"""Nox configuration."""
"""Nox setup."""

import shutil
from pathlib import Path

import nox
from nox_uv import session

nox.needs_version = ">=2024.3.2"
nox.options.default_venv_backend = "uv"

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

nox.needs_version = ">=2024.3.2"
nox.options.sessions = ["lint", "pylint", "tests"]
nox.options.default_venv_backend = "uv|virtualenv"
# =============================================================================
# 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")


@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", "plotting_backends", *session.posargs)
s.run("pylint", "plotting_backends", *s.posargs)


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


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


@session(uv_groups=["test"], reuse_venv=True)
def pytest(s: nox.Session, /) -> None:
"""Run the unit and regular tests."""
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")
72 changes: 49 additions & 23 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ authors = [
description = "Plotting dispatch backends"
readme = "README.md"
license.file = "LICENSE"
requires-python = ">=3.8"
requires-python = ">=3.9"
classifiers = [
"Development Status :: 1 - Planning",
"Intended Audience :: Science/Research",
Expand All @@ -22,7 +22,6 @@ classifiers = [
"Programming Language :: Python",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3 :: Only",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
Expand All @@ -34,36 +33,51 @@ classifiers = [
dynamic = ["version"]
dependencies = []

[project.optional-dependencies]
test = [
"pytest >=6",
"pytest-cov >=3",
"sybil != 7.1.0",
]
dev = [
"plotting_backends[test]",
]

[project.urls]
Homepage = "https://github.com/GalacticDynamics/plotting_backends"
"Bug Tracker" = "https://github.com/GalacticDynamics/plotting_backends/issues"
Changelog = "https://github.com/GalacticDynamics/plotting_backends/releases"


[dependency-groups]
dev = [
"cz-conventional-gitmoji>=0.6.1",
"ipykernel>=6.29.5",
{ include-group = "build" },
{ include-group = "lint" },
{ include-group = "nox" },
{ include-group = "test" },
]
build = [
"build>=1.3.0",
]
lint = [
"mypy>=1.19.0",
"pre-commit>=3.5.0",
"pylint>=3.3.9",
]
nox = [
"nox>=2025.11.12",
"nox-uv>=0.6.3",
]
test = [
"pytest>=8.4.1",
"pytest-cov>=6.2.1",
"sybil[pytest]>=9.1.0",
]


[tool.hatch]
version.source = "vcs"
build.hooks.vcs.version-file = "src/plotting_backends/_version.py"


[tool.pytest.ini_options]
minversion = "8.0"
addopts = ["-ra", "--showlocals", "--strict-markers", "--strict-config"]
xfail_strict = true
filterwarnings = [
"error",
]
log_cli_level = "INFO"
testpaths = ["tests/", "src/"]
[tool.codespell]
skip = ["uv.lock"]


[tool.commitizen]
name = "cz_gitmoji"


[tool.coverage]
Expand All @@ -76,8 +90,9 @@ report.exclude_also = [
'if typing.TYPE_CHECKING:',
]


[tool.mypy]
python_version = "3.8"
python_version = "3.9"

disallow_incomplete_defs = true
disallow_untyped_defs = true
Expand All @@ -100,6 +115,17 @@ module = "plotting_backends.*"
disable_error_code = ["name-defined"] # <- jaxtyping


[tool.pytest.ini_options]
minversion = "8.0"
addopts = ["-ra", "--showlocals", "--strict-markers", "--strict-config"]
xfail_strict = true
filterwarnings = [
"error",
]
log_cli_level = "INFO"
testpaths = ["tests/", "src/"]


[tool.ruff]

[tool.ruff.lint]
Expand All @@ -118,7 +144,7 @@ ignore = [


[tool.pylint]
py-version = "3.8"
py-version = "3.9"
ignore-paths = [".*/_version.py"]
reports.output-format = "colorized"
similarities.ignore-imports = "yes"
Expand Down
Loading