Skip to content

Commit

Permalink
test: use nox for testing
Browse files Browse the repository at this point in the history
  • Loading branch information
martibosch committed Dec 9, 2024
1 parent f8ad65a commit b2b0b47
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 62 deletions.
10 changes: 5 additions & 5 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,11 @@ jobs:
tox
tox-gh
- name: run tests suite
run: tox -vv
env:
TOX_GH_MAJOR_MINOR: ${{ matrix.python-version }}
CONDA_EXE: mamba
- name: setup nox
uses: wntrblm/[email protected]

- name: run nox (tests and build)
run: nox --force-python ${{ matrix.python-version }}

- name: upload coverage reports to Codecov
uses: codecov/codecov-action@v4
Expand Down
33 changes: 33 additions & 0 deletions noxfile.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
"""Nox."""

import nox

PYTHON_VERSIONS = ["3.9", "3.10", "3.11", "3.12", "3.13"]


@nox.session(python=PYTHON_VERSIONS, venv_backend="mamba|micromamba|conda")
def tests(session):
"""Run tests with pytest, and collect coverage."""
session.conda_install("gdal", channel=["conda-forge"])
session.install(".[dev,test]")

session.run(
"pytest",
"-s",
"--cov=pylandstats",
"--cov-append",
"--cov-report=xml",
"--cov-report=term-missing",
"tests",
)


@nox.session(name="build", venv_backend="mamba|micromamba|conda")
def build(session):
"""Build package and documentation."""
session.conda_install("gdal", channel=["conda-forge"])
session.install(".[doc,dev,test]")

session.run("python", "-m", "build")
session.run("sphinx-build", "docs", "docs/_build")
session.run("twine", "check", "dist/*")
61 changes: 4 additions & 57 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ Repository = "https://github.com/martibosch/pylandstats"

[project.optional-dependencies]
test = ["coverage[toml]", "pytest", "pytest-cov", "ruff"]
dev = ["build", "commitizen", "pre-commit", "pip", "toml", "tox", "twine"]
dev = ["build", "commitizen", "nox", "pre-commit", "pip", "toml", "twine"]
doc = ["m2r2", "pydata-sphinx-theme", "sphinx"]

# [tool.setuptools]
Expand Down Expand Up @@ -99,60 +99,7 @@ skip = "*-musllinux_i686"
ignore-words-list = "te"
skip = "CHANGELOG.md"

[tool.tox]
env_list = [
"lint",
"py39",
"py310",
"py311",
"py312",
"py313",
]
requires = [
"tox>=4.19",
]

[tool.tox.gh.python]
"3.13" = ["3.13", "lint"]
"3.12" = ["3.12"]
"3.11" = ["3.11"]
"3.10" = ["3.10"]
"3.9" = ["3.9"]

[tool.tox.env_run_base]
commands = [[
"pytest",
"-s",
"--cov=pylandstats",
"--cov-append",
"--cov-report=xml",
"--cov-report",
"term-missing",
"tests",
]]
conda_deps = [
"gdal>=3.3",
]
extras = [
"test",
]
whitelist_externals = [
"pytest",
]

[tool.tox.env.lint]
commands = [[
["python", "-m", "build"],
["sphinx-build", "docs", "docs/_build"],
["twine", "check", "dist/*"],
]]
extras = [
"dev",
"doc",
"test",
]
whitelist_externals = [
"build",
"sphinx-build",
"twine",
[tool.pytest.ini_options]
addopts = [
"--import-mode=importlib",
]

0 comments on commit b2b0b47

Please sign in to comment.