Skip to content
Open
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
19 changes: 16 additions & 3 deletions .github/workflows/test_tox.yml
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,18 @@ jobs:
posargs: 'rolldice -v && exit 1 || exit 0'
pytest: false

test_external_clib:
uses: ./.github/workflows/tox.yml
with:
envs: |
- linux: libraries-clibrary
libraries:
apt:
- libffcall-dev
- linux: libraries-clibrary
conda_packages: libffcall
- linux: libraries-clibrary

test_venv:
uses: ./.github/workflows/tox.yml
with:
Expand All @@ -124,10 +136,11 @@ jobs:
test_conda:
uses: ./.github/workflows/tox.yml
with:
conda_packages: requests
envs: |
- linux: py312-conda
- macos: py311-conda
- windows: py310-conda
- linux: py312
- macos: py311
- windows: py310

test_setenv:
uses: ./.github/workflows/tox.yml
Expand Down
37 changes: 18 additions & 19 deletions .github/workflows/tox.yml

Large diffs are not rendered by default.

17 changes: 10 additions & 7 deletions docs/source/tox.rst
Original file line number Diff line number Diff line change
Expand Up @@ -230,15 +230,18 @@ To use the token set the ``CODECOV_TOKEN`` environment variable or pass it as a
To use oidc you need to give the job the ``id-token: write`` permission, we recommend you set this on the job level not the workflow level, and set ``coverage: codecov-oidc``.


conda
^^^^^
conda_packages
^^^^^^^^^^^^^^

If populated, will set up a conda environment and install the requested packages from ``conda-forge``.

Whether to test within a conda environment using ``tox-conda``. Options
are ``'auto'`` (default), ``'true'`` and ``'false'``.
Remember to use ``allowlist_externals`` in your Tox configuration if using non-Python Conda packages.

conda_channels
^^^^^^^^^^^^^^

If ``'auto'``, conda will be used if the tox environment names contains
“conda”. For example, ``'auto'`` would enable conda for tox environments
named ``py39-conda``, ``conda-test`` or even ``py38-secondary``.
Conda channel(s) to use with ``conda_packages`` (defaults to ``conda-forge``).
If multiple, separate with spaces.

setenv
^^^^^^
Expand Down
27 changes: 11 additions & 16 deletions tools/tox_matrix.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
import json
import os
import re
import warnings
from copy import copy

import click
Expand All @@ -26,7 +25,8 @@
@click.option("--pytest", default="true")
@click.option("--pytest-results-summary", default="false")
@click.option("--coverage", default="")
@click.option("--conda", default="auto")
@click.option("--conda-packages")
@click.option("--conda-channels", default="conda-forge")
@click.option("--setenv", default="")
@click.option("--display", default="false")
@click.option("--cache-path", default="")
Expand All @@ -49,7 +49,8 @@ def load_tox_targets(
pytest,
pytest_results_summary,
coverage,
conda,
conda_packages,
conda_channels,
setenv,
display,
cache_path,
Expand Down Expand Up @@ -106,7 +107,8 @@ def load_tox_targets(
"pytest": pytest,
"pytest-results-summary": pytest_results_summary,
"coverage": coverage,
"conda": conda,
"conda_packages": conda_packages,
"conda_channels": json.dumps(conda_channels.split()),
"setenv": setenv,
"display": display,
"cache-path": cache_path,
Expand Down Expand Up @@ -165,6 +167,7 @@ def get_matrix_item(env, global_libraries, global_string_parameters, runs_on, de
"libraries_brew_cask": None,
"libraries_apt": None,
"libraries_choco": None,
"conda-packages": None,
"cache-path": None,
"cache-key": None,
"cache-restore-keys": None,
Expand Down Expand Up @@ -212,6 +215,10 @@ def get_matrix_item(env, global_libraries, global_string_parameters, runs_on, de
if item["pytest-results-summary"] == "true":
item["pytest_flag"] += rf"--junitxml ${{GITHUB_WORKSPACE}}{sep}results.xml "

env_conda_channels = env.get("conda-channels")
if isinstance(env_conda_channels, str) and len(env_conda_channels.strip()) == 0:
item["conda-channels"] = json.dumps(env_conda_channels.split())

# set libraries
env_libraries = env.get("libraries")
if isinstance(env_libraries, str) and len(env_libraries.strip()) == 0:
Expand All @@ -220,23 +227,11 @@ def get_matrix_item(env, global_libraries, global_string_parameters, runs_on, de
for manager in ["brew", "brew_cask", "apt", "choco"]:
item[f"libraries_{manager}"] = " ".join(libraries.get(manager, []))

if item["conda"]:
warnings.warn("`conda` parameter is deprecated")

# set "auto" conda value
if item["conda"] == "auto":
item["conda"] = "true" if "conda" in item["toxenv"] else "false"

# inject toxdeps for conda
if item["conda"] == "true" and "tox-conda" not in item["toxdeps"].lower():
item["toxdeps"] = ("tox-conda " + item["toxdeps"]).strip()

# make timeout-minutes a number
item["timeout-minutes"] = int(item["timeout-minutes"])

# verify values
assert item["pytest"] in {"true", "false"}
assert item["conda"] in {"true", "false"}
assert item["display"] in {"true", "false"}

return item
Expand Down
11 changes: 3 additions & 8 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
envlist =
pep8
py3{10,11,12}
py3{10,11,12}-inputs-{linux,macos,windows,conda,con_da}
py3{10,11,12}-inputs-{linux,macos,windows}
default_python
py{,py}3{10,13}-python_version
libraries
Expand Down Expand Up @@ -37,9 +37,6 @@ commands =
linux: python -c "import platform; assert platform.system() == 'Linux'"
macos: python -c "import platform; assert platform.system() == 'Darwin'"
windows: python -c "import platform; assert platform.system() == 'Windows'"
# Check is conda is being used
!conda-!con_da: python -c "import os, sys; assert not os.path.exists(os.path.join(sys.prefix, 'conda-meta', 'history'))"
conda,con_da: python -c "import os, sys; assert {posargs} os.path.exists(os.path.join(sys.prefix, 'conda-meta', 'history'))"
# Run a command that should only succeed is the library is installed
libraries: {posargs}
# Verify that setenv is working
Expand All @@ -53,26 +50,24 @@ commands =
# Verify that freethreaded builds are using freethreaded interpreter
py313t: python -c "import sys; assert 'free-threading' in sys.version"
covcheck: coverage run --parallel-mode -m pytest --pyargs test_package {posargs}
clibrary: python -c "from ctypes.util import find_library; lib = find_library('libffcall'); print(lib); assert lib"

[testenv:pep8]
description = verify pep8
deps = ruff
commands = ruff check .

[testenv:py3{10-16}{,-conda,-tmpdir,-tmpdir_warning}]
[testenv:py3{10-16}{,-tmpdir,-tmpdir_warning}]
description = run pytest
skip_install = false
dependency_groups =
test
covcheck
conda_deps = pytest
changedir =
tmpdir,tmpdir_warning: .tmp/{envname}
setenv =
tmpdir: COVERAGE_FILE={toxinidir}/.coverage
commands =
conda: python -c "import os, sys; assert os.path.exists(os.path.join(sys.prefix, 'conda-meta', 'history'))"
conda: micromamba list
pytest --pyargs test_package {posargs}

[testenv:build_docs]
Expand Down
Loading