Combine tox-siblings and tox roles
There is a bunch of duplicate logic between tox and tox-siblings, the tox-siblings logic is already protected with a flag - and having them be split already led to not doing the right thing with constraints files in siblings when we did it right in tox itself. Combine them into one role. This means the siblings code will run as part of run instead of as part of pre- but that's how things have worked for years anyway until siblings was introduced - and is also the behavior is the siblings flag is false -so it's more consistent overall. Leave a no-op tox-siblings role so that we can gracefully remove the use of tox-siblings from castellan, python-openstacksdk, shade and tacker. Change-Id: Id61ae52d48b28cfc2221cb556a1c1f7c6dfd60dd
This commit is contained in:
parent
43943c5bb0
commit
d7cba9d7d5
@ -1,5 +1,3 @@
|
||||
- hosts: all
|
||||
roles:
|
||||
- ensure-tox
|
||||
- role: tox-siblings
|
||||
when: tox_install_siblings
|
||||
|
@ -1,29 +0,0 @@
|
||||
Installs python packages from other Zuul repos into a tox environment.
|
||||
|
||||
**Role Variables**
|
||||
|
||||
.. zuul:rolevar:: zuul_workdir
|
||||
:default: {{ zuul.project.src_dir }}
|
||||
|
||||
Directory to run tox in.
|
||||
|
||||
.. zuul:rolevar:: tox_envlist
|
||||
:default: venv
|
||||
|
||||
Which tox environment to run. Defaults to 'venv'.
|
||||
|
||||
.. zuul:rolevar:: tox_executable
|
||||
:default: tox
|
||||
|
||||
Location of the tox executable. Defaults to 'tox'.
|
||||
|
||||
.. zuul:rolevar:: tox_constraints_file
|
||||
|
||||
Path to a pip constraints file. Will be provided to pip via '-c'
|
||||
argument for any sibling package installations.
|
||||
|
||||
.. zuul:rolevar:: tox_install_siblings
|
||||
:default: true
|
||||
|
||||
Flag controlling whether to attempt to install python packages from any
|
||||
other source code repos zuul has checked out. Defaults to True.
|
@ -1,6 +0,0 @@
|
||||
---
|
||||
tox_envlist: venv
|
||||
tox_executable: tox
|
||||
tox_install_siblings: true
|
||||
|
||||
zuul_work_dir: "{{ zuul.project.src_dir }}"
|
@ -1,3 +1,3 @@
|
||||
- name: Install tox siblings
|
||||
include: siblings.yaml
|
||||
when: tox_install_siblings
|
||||
- name: Emit warning message
|
||||
debug:
|
||||
msg: tox-siblings is no longer needed and should be removed
|
||||
|
@ -1,38 +0,0 @@
|
||||
- name: Require tox_envlist variable
|
||||
fail:
|
||||
msg: tox_envlist is required for this role
|
||||
when: tox_envlist is not defined
|
||||
|
||||
- name: Check to see if the constraints file exists
|
||||
stat:
|
||||
path: "{{ tox_constraints_file }}"
|
||||
get_checksum: false
|
||||
get_mime: false
|
||||
get_md5: false
|
||||
register: stat_results
|
||||
when: tox_constraints_file is defined
|
||||
|
||||
- name: Fail if constraints file is missing
|
||||
when: tox_constraints_file is defined and not stat_results.stat.exists
|
||||
fail:
|
||||
msg: tox_constraints_file is defined but was not found
|
||||
|
||||
- name: Record file location
|
||||
set_fact:
|
||||
tox_constraints_env:
|
||||
UPPER_CONSTRAINTS_FILE: "{{ tox_constraints_file }}"
|
||||
when: tox_constraints_file is defined
|
||||
|
||||
- name: Run tox without tests
|
||||
command: "{{ tox_executable }} --notest -e{{ tox_envlist }}"
|
||||
args:
|
||||
chdir: "{{ zuul_work_dir }}"
|
||||
environment: "{{ tox_environment|combine(tox_constraints_env|default({})) }}"
|
||||
|
||||
# TODO(mordred) handle tox_envlist being a list
|
||||
- name: Install any sibling python packages
|
||||
tox_install_sibling_packages:
|
||||
tox_envlist: "{{ tox_envlist }}"
|
||||
tox_constraints_file: "{{ tox_constraints_file | default(omit) }}"
|
||||
project_dir: "{{ zuul_work_dir }}"
|
||||
projects: "{{ zuul.projects | selectattr('required') | list }}"
|
@ -26,6 +26,12 @@ Runs tox for a project
|
||||
Path to a pip constraints file. Will be provided to tox via
|
||||
UPPER_CONSTRAINTS_FILE environment variable if it exists.
|
||||
|
||||
.. zuul:rolevar:: tox_install_siblings
|
||||
:default: true
|
||||
|
||||
Flag controlling whether to attempt to install python packages from any
|
||||
other source code repos zuul has checked out. Defaults to True.
|
||||
|
||||
.. zuul:rolevar:: zuul_work_dir
|
||||
:default: {{ zuul.project.src_dir }}
|
||||
|
||||
|
@ -3,5 +3,6 @@ tox_environment: {}
|
||||
tox_envlist: venv
|
||||
tox_executable: tox
|
||||
tox_extra_args: -vv
|
||||
tox_install_siblings: true
|
||||
|
||||
zuul_work_dir: "{{ zuul.project.src_dir }}"
|
||||
|
@ -5,18 +5,27 @@
|
||||
|
||||
- name: Check to see if the constraints file exists
|
||||
stat:
|
||||
path: "{{ tox_constraints_file|default('missing') }}"
|
||||
path: "{{ tox_constraints_file }}"
|
||||
get_checksum: false
|
||||
get_mime: false
|
||||
get_md5: false
|
||||
register: stat_results
|
||||
when: tox_constraints_file is defined
|
||||
|
||||
- name: Fail if constraints file is missing
|
||||
when: tox_constraints_file is defined and not stat_results.stat.exists
|
||||
fail:
|
||||
msg: tox_constraints_file is defined but was not found
|
||||
|
||||
- name: Record file location
|
||||
set_fact:
|
||||
tox_constraints_env:
|
||||
UPPER_CONSTRAINTS_FILE: "{{ tox_constraints_file }}"
|
||||
when: not stat_results|skipped and stat_results.stat.exists
|
||||
when: tox_constraints_file is defined
|
||||
|
||||
- name: Install tox siblings
|
||||
include: siblings.yaml
|
||||
when: tox_install_siblings
|
||||
|
||||
- name: Emit tox command
|
||||
debug:
|
||||
|
13
roles/tox/tasks/siblings.yaml
Normal file
13
roles/tox/tasks/siblings.yaml
Normal file
@ -0,0 +1,13 @@
|
||||
- name: Run tox without tests
|
||||
command: "{{ tox_executable }} --notest -e{{ tox_envlist }}"
|
||||
args:
|
||||
chdir: "{{ zuul_work_dir }}"
|
||||
environment: "{{ tox_environment|combine(tox_constraints_env|default({})) }}"
|
||||
|
||||
# TODO(mordred) handle tox_envlist being a list
|
||||
- name: Install any sibling python packages
|
||||
tox_install_sibling_packages:
|
||||
tox_envlist: "{{ tox_envlist }}"
|
||||
tox_constraints_file: "{{ tox_constraints_file | default(omit) }}"
|
||||
project_dir: "{{ zuul_work_dir }}"
|
||||
projects: "{{ zuul.projects | selectattr('required') | list }}"
|
Loading…
Reference in New Issue
Block a user