Merge "tox: empty envlist should behave like tox -e ALL"
This commit is contained in:
commit
8dbd1a79d5
@ -13,9 +13,6 @@ Runs tox for a project
|
||||
``ALL`` runs all test environments while an empty string runs
|
||||
all test environments configured with ``envlist`` in tox.
|
||||
|
||||
Internally this will always be expanded into a comma separated
|
||||
list of test environments to run.
|
||||
|
||||
.. zuul:rolevar:: tox_executable
|
||||
:default: tox
|
||||
|
||||
|
@ -30,11 +30,6 @@ description:
|
||||
requirements:
|
||||
- "python >= 3.5"
|
||||
options:
|
||||
tox_envlist:
|
||||
description:
|
||||
- The tox test environments to act on.
|
||||
required: true
|
||||
type: str
|
||||
tox_show_config:
|
||||
description:
|
||||
- Path to a file containing the output from C(tox --showconfig).
|
||||
@ -59,6 +54,7 @@ except ImportError:
|
||||
|
||||
import pkg_resources as prAPI
|
||||
import os
|
||||
import ast
|
||||
import subprocess
|
||||
import tempfile
|
||||
import traceback
|
||||
@ -256,10 +252,28 @@ def install_siblings(envdir, projects, package_name, constraints):
|
||||
return changed
|
||||
|
||||
|
||||
def get_envlist(tox_config):
|
||||
envlist = []
|
||||
if 'tox' in tox_config.sections():
|
||||
envlist_default = ast.literal_eval(
|
||||
tox_config.get('tox', 'envlist_default'))
|
||||
tox_args = ast.literal_eval(tox_config.get('tox', 'args'))
|
||||
if 'ALL' in tox_args or not envlist_default:
|
||||
for section in tox_config.sections():
|
||||
if section.startswith('testenv'):
|
||||
envlist.append(section.split(':')[1])
|
||||
else:
|
||||
for testenv in envlist_default:
|
||||
envlist.append(testenv)
|
||||
else:
|
||||
for section in tox_config.sections():
|
||||
envlist.append(section.split(':')[1])
|
||||
return envlist
|
||||
|
||||
|
||||
def main():
|
||||
module = AnsibleModule(
|
||||
argument_spec=dict(
|
||||
tox_envlist=dict(required=True, type='str'),
|
||||
tox_show_config=dict(required=True, type='path'),
|
||||
tox_constraints_file=dict(type='str'),
|
||||
project_dir=dict(required=True, type='str'),
|
||||
@ -269,14 +283,12 @@ def main():
|
||||
constraints = module.params.get('tox_constraints_file')
|
||||
project_dir = module.params['project_dir']
|
||||
projects = module.params['projects']
|
||||
tox_envlist = module.params.get('tox_envlist', '')
|
||||
tox_show_config = module.params.get('tox_show_config')
|
||||
|
||||
tox_config = configparser.RawConfigParser()
|
||||
tox_config.read(tox_show_config)
|
||||
|
||||
envlist = {testenv.strip() for testenv
|
||||
in tox_envlist.split(',')}
|
||||
envlist = get_envlist(tox_config)
|
||||
|
||||
if not envlist:
|
||||
module.exit_json(
|
||||
@ -306,7 +318,7 @@ def main():
|
||||
|
||||
changed = False
|
||||
for testenv in envlist:
|
||||
testenv_config = tox_config['testenv:{}'.format(testenv)]
|
||||
testenv_config = tox_config["testenv:{}".format(testenv)]
|
||||
envdir = testenv_config['envdir']
|
||||
envlogdir = testenv_config['envlogdir']
|
||||
try:
|
||||
|
@ -20,49 +20,6 @@
|
||||
UPPER_CONSTRAINTS_FILE: "{{ tox_constraints_file }}"
|
||||
when: tox_constraints_file is defined
|
||||
|
||||
# Tox siblings cannot take 'ALL' and tox_parse_output expects
|
||||
# an envlist to be supplied so always set _tox_envlist equal to
|
||||
# the list of testenvs we're going to run
|
||||
- name: Set _tox_envlist from supplied tox_envlist
|
||||
set_fact:
|
||||
_tox_envlist: "{{ tox_envlist }}"
|
||||
when:
|
||||
- tox_envlist is defined and tox_envlist
|
||||
- tox_envlist != "ALL"
|
||||
|
||||
- name: Get tox default envlist
|
||||
command: "{{ tox_executable }} -l"
|
||||
args:
|
||||
chdir: "{{ zuul_work_dir }}"
|
||||
register: _tox_default_envlist
|
||||
when: tox_envlist is not defined or not tox_envlist
|
||||
|
||||
- name: Set tox envlist fact
|
||||
set_fact:
|
||||
_tox_envlist: "{{ _tox_default_envlist.stdout_lines | join(',') }}"
|
||||
when:
|
||||
- _tox_default_envlist is defined
|
||||
- _tox_default_envlist.stdout_lines is defined
|
||||
|
||||
- name: Get all tox testenvs
|
||||
command: "{{ tox_executable }} -a"
|
||||
args:
|
||||
chdir: "{{ zuul_work_dir }}"
|
||||
register: _tox_all_testenvs
|
||||
when: tox_envlist is defined and tox_envlist == 'ALL'
|
||||
|
||||
- name: Set tox envlist fact
|
||||
set_fact:
|
||||
_tox_envlist: "{{ _tox_all_testenvs.stdout_lines | join(',') }}"
|
||||
when:
|
||||
- _tox_all_testenvs is defined
|
||||
- _tox_all_testenvs.stdout_lines is defined
|
||||
|
||||
- name: Fail if tox_envlist is empty
|
||||
fail:
|
||||
msg: "No envlist configured in zuul or tox.ini"
|
||||
when: _tox_envlist is not defined
|
||||
|
||||
- name: Install tox siblings
|
||||
include_tasks: siblings.yaml
|
||||
when: tox_install_siblings
|
||||
@ -71,7 +28,9 @@
|
||||
debug:
|
||||
msg: >-
|
||||
{{ tox_executable }}
|
||||
-e{{ _tox_envlist }}
|
||||
{% if tox_envlist is defined and tox_envlist %}
|
||||
-e{{ tox_envlist }}
|
||||
{% endif %}
|
||||
{{ tox_extra_args }}
|
||||
|
||||
- block:
|
||||
@ -81,7 +40,9 @@
|
||||
environment: "{{ tox_environment|combine(tox_constraints_env|default({})) }}"
|
||||
command: >-
|
||||
{{ tox_executable }}
|
||||
-e{{ _tox_envlist }}
|
||||
{% if tox_envlist is defined and tox_envlist %}
|
||||
-e{{ tox_envlist }}
|
||||
{% endif %}
|
||||
{{ tox_extra_args }}
|
||||
register: tox_output
|
||||
|
||||
@ -91,7 +52,7 @@
|
||||
- name: Look for output
|
||||
tox_parse_output:
|
||||
tox_output: '{{ tox_output.stdout }}'
|
||||
tox_envlist: '{{ _tox_envlist }}'
|
||||
tox_envlist: '{{ tox_envlist | default("default") }}'
|
||||
workdir: '{{ zuul_work_dir }}'
|
||||
when: tox_inline_comments
|
||||
register: file_comments
|
||||
|
@ -3,7 +3,9 @@
|
||||
command: >-
|
||||
{{ tox_executable }}
|
||||
--notest
|
||||
-e{{ _tox_envlist }}
|
||||
{% if tox_envlist is defined and tox_envlist %}
|
||||
-e{{ tox_envlist }}
|
||||
{% endif %}
|
||||
args:
|
||||
chdir: "{{ zuul_work_dir }}"
|
||||
environment: "{{ tox_environment|combine(tox_constraints_env|default({})) }}"
|
||||
@ -13,17 +15,19 @@
|
||||
tempfile:
|
||||
register: _tox_show_config_tempfile
|
||||
|
||||
# py27, py35..py38 etc are generated on the fly if not
|
||||
# explicitly added to tox.ini, so force tox to generate
|
||||
# the config for the testenvs we're using.
|
||||
- name: Get tox envlist config
|
||||
shell: "{{ tox_executable }} --showconfig -e {{ _tox_envlist }} > {{ _tox_show_config_tempfile.path }}"
|
||||
shell: >-
|
||||
{{ tox_executable }}
|
||||
--showconfig
|
||||
{% if tox_envlist is defined and tox_envlist %}
|
||||
-e{{ tox_envlist }}
|
||||
{% endif %}
|
||||
> {{ _tox_show_config_tempfile.path }}
|
||||
args:
|
||||
chdir: "{{ zuul_work_dir }}"
|
||||
|
||||
- name: Install any sibling python packages
|
||||
tox_install_sibling_packages:
|
||||
tox_envlist: "{{ _tox_envlist }}"
|
||||
tox_show_config: "{{ _tox_show_config_tempfile.path }}"
|
||||
tox_constraints_file: "{{ tox_constraints_file | default(omit) }}"
|
||||
project_dir: "{{ zuul_work_dir }}"
|
||||
|
Loading…
Reference in New Issue
Block a user