Ctrl K
ComunidadGuías…

tox.ini

Rama main · réplica de lectura del repositorio original.

Archivo original ↗Preguntar a KiBot
# Test matrix for the in-house LFOps plugins.
#
# LFOps plugins fall into two tiers with different runtime environments:
#
#   * Controller plugins (filter, lookup) run on the Ansible controller.
#     The controller requires Python >= 3.10 (ansible-core 2.16/2.17) or
#     >= 3.11 (2.18). These are covered by the `py3XX-ansibleXYZ` envs
#     below and run on standard CI runners via setup-python.
#
#   * Target plugins (modules, module_utils) run on the managed node and
#     must therefore support the oldest managed-node Python we still
#     maintain: Python 3.6 on RHEL 8. CI runners no longer ship Python
#     3.6, so that tier runs inside a RHEL 8 / UBI 8 container, see
#     `[testenv:py36-target]` below. The controller envs run these tests
#     as well, on their newer Python.
#
# ansible-core / controller-Python compatibility (see README.md):
#   2.16: py3.10-3.12   2.17: py3.10-3.12   2.18: py3.11-3.13
# `requires_ansible` in meta/runtime.yml is `>=2.16.0`, so 2.16 is the floor.

[tox]
envlist =
    py310-ansible{216,217}
    py311-ansible{216,217,218}
    py312-ansible{216,217,218}
    py313-ansible{218,latest}
skip_missing_interpreters = true
# this collection is not a Python package, do not build an sdist from the repo root.
no_package = true
# the same for tox 3, which the py36-target env needs (tox 4 does not run on Python 3.6)
skipsdist = true

[testenv]
description = 'Controller-plugin unit tests (filter, lookup)'
deps =
    pytest
    pyyaml
    ansible216: ansible-core~=2.16.0
    ansible217: ansible-core~=2.17.0
    ansible218: ansible-core~=2.18.0
    ansiblelatest: ansible-core
commands =
    # discovers every controller-plugin test under tests/unit; managed-node
    # plugin tests (modules) get their own env, see [testenv:py36-target].
    pytest {posargs:tests/unit}

# Managed-node tier (modules / module_utils). Not in the default envlist. Run
# it inside a RHEL 8 / UBI 8 container, where the system Python is 3.6. tox 4
# no longer runs on Python 3.6, so run tox 3 there:
#
#   podman run --rm -v "$PWD":/src:Z -w /src registry.access.redhat.com/ubi8/ubi \
#     bash -c 'dnf -y install python3 python3-pip && pip3 install "tox<4" && tox -e py36-target'
#
# The tests import the module_utils of ansible-core 2.16, the last series that
# supports Python 3.6 on the managed node, just like the controller ships them
# in production. ansible-core itself needs Python 3.10, so only the package is
# put on PYTHONPATH, without its dependencies. The `Linuxfabrik: Unit Tests`
# workflow runs the same pytest command in that container, without tox, from
# the same hash-pinned requirements files.
[testenv:py36-target]
description = 'Managed-node plugin unit tests (modules) on RHEL 8 Python 3.6'
basepython = python3.6
deps =
    -r .github/unit-tests-py36/requirements.txt
setenv =
    PYTHONPATH = {envtmpdir}/ansible-core
commands_pre =
    pip install --require-hashes --no-deps --ignore-requires-python --target {envtmpdir}/ansible-core --requirement .github/unit-tests-py36-ansible-core/requirements.txt
commands =
    pytest {posargs:tests/unit/plugins/modules tests/unit/plugins/module_utils}