tox: allow running default envlist in tox

Change-Id: I49638ab7949804fc967e337fa5ce21d2a3dc9d49
This commit is contained in:
vass 2020-04-22 11:19:22 +02:00
parent 8e472d4137
commit a32119249c
4 changed files with 27 additions and 8 deletions

View File

@ -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

View File

@ -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:

View File

@ -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

View File

@ -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.