From 3d449a07dfd4c3a29befc5a9bd00d10dd486cc9c Mon Sep 17 00:00:00 2001 From: Jeremy Stanley Date: Mon, 30 Aug 2021 15:32:51 +0000 Subject: [PATCH] Add tox_config_file rolevar to tox In some situations, projects may not keep a tox.ini in the root directory of their repository, or may even have multiple tox configuration files. Allow the location and name of the config to be overridden explicitly through the use of a new rolevar. Change-Id: I1927142e6d9fa75e96902ae001c8ca98d69c7443 --- roles/tox/README.rst | 6 ++++++ roles/tox/tasks/main.yaml | 6 ++++++ roles/tox/tasks/siblings.yaml | 6 ++++++ 3 files changed, 18 insertions(+) diff --git a/roles/tox/README.rst b/roles/tox/README.rst index 4ed87391b..fe157eda3 100644 --- a/roles/tox/README.rst +++ b/roles/tox/README.rst @@ -37,6 +37,12 @@ corresponding Zuul sibling projects and runs tox tests as follows: Location of the tox executable. +.. zuul:rolevar:: tox_config_file + + Path to a tox configuration file, or directory containing a + ``tox.ini`` file. Will be provided to tox via its ``-c`` + command-line option if set. + .. zuul:rolevar:: tox_extra_args :default: -vv diff --git a/roles/tox/tasks/main.yaml b/roles/tox/tasks/main.yaml index b0e79f748..2cf8143ec 100644 --- a/roles/tox/tasks/main.yaml +++ b/roles/tox/tasks/main.yaml @@ -28,6 +28,9 @@ debug: msg: >- {{ tox_executable }} + {% if tox_config_file is defined and tox_config_file %} + -c{{ tox_config_file }} + {% endif %} {% if tox_envlist is defined and tox_envlist %} -e{{ tox_envlist }} {% endif %} @@ -40,6 +43,9 @@ environment: "{{ tox_environment|combine(tox_constraints_env|default({})) }}" command: >- {{ tox_executable }} + {% if tox_config_file is defined and tox_config_file %} + -c{{ tox_config_file }} + {% endif %} {% if tox_envlist is defined and tox_envlist %} -e{{ tox_envlist }} {% endif %} diff --git a/roles/tox/tasks/siblings.yaml b/roles/tox/tasks/siblings.yaml index c060d2974..a838f2e59 100644 --- a/roles/tox/tasks/siblings.yaml +++ b/roles/tox/tasks/siblings.yaml @@ -2,6 +2,9 @@ - name: Run tox without tests command: >- {{ tox_executable }} + {% if tox_config_file is defined and tox_config_file %} + -c{{ tox_config_file }} + {% endif %} --notest {% if tox_envlist is defined and tox_envlist %} -e{{ tox_envlist }} @@ -18,6 +21,9 @@ - name: Get tox envlist config shell: >- {{ tox_executable }} + {% if tox_config_file is defined and tox_config_file %} + -c{{ tox_config_file }} + {% endif %} --showconfig {% if tox_envlist is defined and tox_envlist %} -e{{ tox_envlist }}