diff --git a/roles/fetch-tox-output/README.rst b/roles/fetch-tox-output/README.rst index a20fb1f4d..27d08ee2a 100644 --- a/roles/fetch-tox-output/README.rst +++ b/roles/fetch-tox-output/README.rst @@ -5,7 +5,9 @@ Collect log output from a tox build .. zuul:rolevar:: tox_envlist :default: venv - Which tox environment to fetch log output from. + Comma separated string with test environmens to fetch log output from. + ``ALL`` fetches all environments while an empty string fetches all test + environments configured with ``envlist`` in tox. .. zuul:rolevar:: tox_executable :default: tox diff --git a/roles/fetch-tox-output/tasks/main.yaml b/roles/fetch-tox-output/tasks/main.yaml index 93dc96662..9d58a7c51 100644 --- a/roles/fetch-tox-output/tasks/main.yaml +++ b/roles/fetch-tox-output/tasks/main.yaml @@ -23,26 +23,31 @@ - name: Set envlist fact set_fact: envlist: "{{ tox_envlist.split(',') }}" - when: tox_envlist is defined + when: tox_envlist is defined and tox_envlist != 'ALL' and tox_envlist - name: Find all default environments command: "{{ tox_executable }} -l" args: chdir: "{{ zuul_work_dir }}" register: tox_environments - when: tox_envlist is not defined + when: tox_envlist is not defined or + not tox_envlist - name: Find all default environments command: "{{ tox_executable }} -a" args: chdir: "{{ zuul_work_dir }}" register: tox_environments - when: tox_envlist == 'ALL' + when: + - tox_envlist is defined + - tox_envlist == 'ALL' - name: Set envlist fact set_fact: envlist: "{{ tox_environments.stdout_lines }}" - when: tox_envlist is not defined or tox_envlist == 'ALL' + when: tox_envlist is not defined or + not tox_envlist or + tox_envlist == 'ALL' - name: Copy tox logs copy: diff --git a/roles/tox/README.rst b/roles/tox/README.rst index e770a3507..89cb3a499 100644 --- a/roles/tox/README.rst +++ b/roles/tox/README.rst @@ -9,7 +9,9 @@ Runs tox for a project .. zuul:rolevar:: tox_envlist :default: venv - Which tox environment to run. + Comma separated string with test environments tox should run. + ``ALL`` runs all test environments while an empty string runs + all test environments configured with ``envlist`` in tox. .. zuul:rolevar:: tox_executable :default: tox diff --git a/roles/tox/tasks/main.yaml b/roles/tox/tasks/main.yaml index c498d8f11..9af1068f7 100644 --- a/roles/tox/tasks/main.yaml +++ b/roles/tox/tasks/main.yaml @@ -31,13 +31,23 @@ - name: Emit tox command debug: - msg: "Running tox: {{ tox_executable }} -e{{ tox_envlist }} {{ tox_extra_args }}" + msg: >- + {{ tox_executable }} + {% if tox_envlist is defined and tox_envlist %} + -e{{ tox_envlist }} + {% endif %} + {{ tox_extra_args }} - name: Run tox args: chdir: "{{ zuul_work_dir }}" environment: "{{ tox_environment|combine(tox_constraints_env|default({})) }}" - command: "{{ tox_executable }} -e{{ tox_envlist }} {{ tox_extra_args }}" + command: >- + {{ tox_executable }} + {% if tox_envlist is defined and tox_envlist %} + -e{{ tox_envlist }} + {% endif %} + {{ tox_extra_args }} # Note: This intentionally ignores errors to give us the chance to look # for file comments in the stdout. In case of an error this will be returned # in a later task.