diff --git a/.github/workflows/coverage.yml b/.github/workflows/coverage.yml index ab393048a..4c177878f 100644 --- a/.github/workflows/coverage.yml +++ b/.github/workflows/coverage.yml @@ -11,10 +11,10 @@ jobs: - name: Set up Python ${{ matrix.python-version }} uses: actions/setup-python@v5 with: - python-version: 3.11 - - name: Install dependencies - run: pip install nox + python-version: 3.13 + - name: Install uv + uses: astral-sh/setup-uv@v6 - name: Test with nox - run: nox -e coverage + run: uv run --group nox nox -e coverage - name: Upload coverage to Codecov uses: codecov/codecov-action@v4 diff --git a/.github/workflows/matchers/pytest.json b/.github/workflows/matchers/pytest.json deleted file mode 100644 index 3e5d8d5b8..000000000 --- a/.github/workflows/matchers/pytest.json +++ /dev/null @@ -1,18 +0,0 @@ -{ - "problemMatcher": [ - { - "owner": "python", - "pattern": [ - { - "regexp": "^\\s*File\\s\\\"(.*)\\\",\\sline\\s(\\d+),\\sin\\s(.*)$", - "file": 1, - "line": 2 - }, - { - "regexp": "^\\s*raise\\s(.*)\\(\\'(.*)\\'\\)$", - "message": 2 - } - ] - } - ] -} diff --git a/.github/workflows/nox.yml b/.github/workflows/nox.yml index 499b48c4e..f021d3b2c 100644 --- a/.github/workflows/nox.yml +++ b/.github/workflows/nox.yml @@ -12,7 +12,7 @@ jobs: fail-fast: false matrix: platform: [ubuntu-latest, macos-latest, windows-latest] - python-version: ["3.9", "3.10", "3.11", "3.12"] + python-version: ["3.9", "3.10", "3.11", "3.12", "3.13"] steps: - uses: actions/checkout@v4 @@ -20,11 +20,9 @@ jobs: uses: actions/setup-python@v5 with: python-version: ${{ matrix.python-version }} - - name: Register Python problem matcher - run: echo "::add-matcher::.github/workflows/matchers/pytest.json" - - name: Install dependencies - run: pip install nox pytest-github-actions-annotate-failures + - name: Install uv + uses: astral-sh/setup-uv@v6 - name: Test with nox using minimal dependencies - run: nox -e "pytest-${{ matrix.python-version }}(all_deps=False)" + run: uv run --group nox nox -e "pytest_min_deps-${{ matrix.python-version }}" - name: Test with nox with all dependencies - run: nox -e "pytest-${{ matrix.python-version }}(all_deps=True)" + run: uv run --group nox nox -e "pytest_all_deps-${{ matrix.python-version }}" diff --git a/.github/workflows/typeguard.yml b/.github/workflows/typeguard.yml index a95ac4f2f..3689442b3 100644 --- a/.github/workflows/typeguard.yml +++ b/.github/workflows/typeguard.yml @@ -12,8 +12,8 @@ jobs: - name: Set up Python ${{ matrix.python-version }} uses: actions/setup-python@v5 with: - python-version: "3.11" - - name: Install dependencies - run: pip install nox + python-version: "3.13" + - name: Install uv + uses: astral-sh/setup-uv@v6 - name: Test with nox - run: nox -e pytest_typeguard + run: uv run --group nox nox -e pytest_typeguard diff --git a/README.md b/README.md index c7b2fcad6..dcfd4ff8f 100644 --- a/README.md +++ b/README.md @@ -160,12 +160,12 @@ jupyter labextension install @pyviz/jupyterlab_pyviz ## :wrench: Development -Clone the repository and run `pip install -e ".[notebook,testing,other]"` to add a link to the cloned repo into your Python path: +Clone the repository and run `pip install -e ".[notebook,test,other]"` to add a link to the cloned repo into your Python path: ```bash git clone git@github.com:python-adaptive/adaptive.git cd adaptive -pip install -e ".[notebook,testing,other]" +pip install -e ".[notebook,test,other]" ``` We recommend using a Conda environment or a virtualenv for package management during Adaptive development. diff --git a/noxfile.py b/noxfile.py index 55544435c..6a6114bb3 100644 --- a/noxfile.py +++ b/noxfile.py @@ -1,31 +1,45 @@ """Nox configuration file.""" +import os + import nox +nox.options.default_venv_backend = "uv" + +python = ["3.9", "3.10", "3.11", "3.12", "3.13"] +num_cpus = os.cpu_count() or 1 +xdist = ("-n", "auto") if num_cpus > 2 else () + + +@nox.session(python=python) +def pytest_min_deps(session: nox.Session) -> None: + """Run pytest with no optional dependencies.""" + session.install(".[test]") + session.run("coverage", "erase") + session.run("pytest", *xdist) + -@nox.session(python=["3.9", "3.10", "3.11", "3.12"]) -@nox.parametrize("all_deps", [True, False]) -def pytest(session: nox.Session, all_deps: bool) -> None: - """Run pytest with optional dependencies.""" - session.install(".[testing,other]" if all_deps else ".[testing]") +@nox.session(python=python) +def pytest_all_deps(session: nox.Session) -> None: + """Run pytest with "other" optional dependencies.""" + session.install(".[test,other]") session.run("coverage", "erase") - session.run("pytest") + session.run("pytest", *xdist) -@nox.session(python="3.11") +@nox.session(python="3.13") def pytest_typeguard(session: nox.Session) -> None: """Run pytest with typeguard.""" - session.install(".[testing,other]") + session.install(".[test,other]") session.run("coverage", "erase") - session.run("pytest", "--typeguard-packages=adaptive") + session.run("pytest", "--typeguard-packages=adaptive", *xdist) -@nox.session(python="3.11") +@nox.session(python="3.13") def coverage(session: nox.Session) -> None: """Generate coverage report.""" - session.install("coverage") - session.install(".[testing,other]") - session.run("pytest") + session.install(".[test,other]") + session.run("pytest", *xdist) session.run("coverage", "report") session.run("coverage", "xml") diff --git a/pyproject.toml b/pyproject.toml index 8dbe2c89a..5e59cad3b 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -47,15 +47,18 @@ notebook = [ "matplotlib", "plotly", ] -testing = [ +test = [ "flaky", "pytest", "pytest-cov", "pytest-randomly", "pytest-timeout", + "pytest-xdist", "pre_commit", "typeguard", + "coverage", ] +dev = ["adaptive[test,nox,notebook,other]"] [project.urls] homepage = "https://adaptive.readthedocs.io/" @@ -66,6 +69,12 @@ repository = "https://github.com/python-adaptive/adaptive" content-type = "text/markdown" file = "README.md" +[dependency-groups] +nox = [ + "nox", + "pytest-github-actions-annotate-failures", +] + [tool.setuptools.packages.find] include = ["adaptive.*", "adaptive"]