From 051504146597c34a25211b379151debb3632df11 Mon Sep 17 00:00:00 2001 From: Albin Vass Date: Mon, 20 Apr 2020 10:01:33 +0200 Subject: [PATCH] Use cached 'tox_executable' in fetch-tox-output Otherwise this role could fail when tox is not installed in PATH. Also updates the default behaviour to only collect the environments configured with 'envlist' in tox.ini and collects all environments if the envlist is set to 'ALL'. Change-Id: I60bcc25cb853d2db3ee767a719b9ac54e421532e --- roles/fetch-tox-output/tasks/main.yaml | 15 +++++++++++---- test-playbooks/python/fetch-tox-output.yaml | 2 ++ test-playbooks/tox/reinstall-tox.yaml | 17 +++++++++++++++++ zuul-tests.d/python-jobs.yaml | 4 ++++ 4 files changed, 34 insertions(+), 4 deletions(-) create mode 100644 test-playbooks/tox/reinstall-tox.yaml diff --git a/roles/fetch-tox-output/tasks/main.yaml b/roles/fetch-tox-output/tasks/main.yaml index c6540cd16..93dc96662 100644 --- a/roles/fetch-tox-output/tasks/main.yaml +++ b/roles/fetch-tox-output/tasks/main.yaml @@ -25,17 +25,24 @@ envlist: "{{ tox_envlist.split(',') }}" when: tox_envlist is defined -- name: Find all environments - command: tox -l +- name: Find all default environments + command: "{{ tox_executable }} -l" args: chdir: "{{ zuul_work_dir }}" register: tox_environments - when: tox_envlist is not defined or tox_envlist|lower == 'all' + when: tox_envlist is not defined + +- name: Find all default environments + command: "{{ tox_executable }} -a" + args: + chdir: "{{ zuul_work_dir }}" + register: tox_environments + when: tox_envlist == 'ALL' - name: Set envlist fact set_fact: envlist: "{{ tox_environments.stdout_lines }}" - when: tox_envlist is not defined or tox_envlist|lower == 'all' + when: tox_envlist is not defined or tox_envlist == 'ALL' - name: Copy tox logs copy: diff --git a/test-playbooks/python/fetch-tox-output.yaml b/test-playbooks/python/fetch-tox-output.yaml index 9812fb185..4e10f5a97 100644 --- a/test-playbooks/python/fetch-tox-output.yaml +++ b/test-playbooks/python/fetch-tox-output.yaml @@ -35,6 +35,8 @@ tasks: - import_role: name: fetch-tox-output + vars: + tox_envlist: "ALL" - block: - name: Undo the log_path fact set by fetch-javascript-output diff --git a/test-playbooks/tox/reinstall-tox.yaml b/test-playbooks/tox/reinstall-tox.yaml new file mode 100644 index 000000000..039125424 --- /dev/null +++ b/test-playbooks/tox/reinstall-tox.yaml @@ -0,0 +1,17 @@ +- hosts: all + name: Remove any pre-installed tox + tasks: + - name: Remove tox package with pip + shell: pip uninstall -y tox + become: true + failed_when: false + - name: Remove tox package with pip3 + shell: pip3 uninstall -y tox + become: true + failed_when: false + - name: Verify tox is not installed + command: "tox --version" + register: result + failed_when: result.rc == 0 + roles: + - ensure-tox diff --git a/zuul-tests.d/python-jobs.yaml b/zuul-tests.d/python-jobs.yaml index 5cf7ee7ae..21a118229 100644 --- a/zuul-tests.d/python-jobs.yaml +++ b/zuul-tests.d/python-jobs.yaml @@ -250,6 +250,10 @@ - roles/ensure-output-dirs/.* - roles/fetch-tox-output/.* - roles/fetch-output/.* + - roles/ensure-tox/.* + - test-playbooks/python/fetch-tox-output.yaml + - test-playbooks/tox/reinstall-tox.yaml + pre-run: test-playbooks/tox/reinstall-tox.yaml run: test-playbooks/python/fetch-tox-output.yaml vars: zuul_use_fetch_output: true