Create tox_environment_defaults variable for tox based jobs

Expose the ability for tox jobs to define a default set of
environmental variables to pass to the tox role.  We also do a few new
things.

Check to see if tox_environment and tox_environment_defaults are
defined, if so combined tox_environment_defaults with
tox_environment creating a new my_tox_environment variable.
Variables defined in tox_environment take priority when we combine
variables.

Change-Id: Ic4a5644e79ca7000cbdaee40467619a6832c8332
Signed-off-by: Paul Belanger <pabelanger@redhat.com>
This commit is contained in:
Paul Belanger 2017-07-24 12:06:16 -04:00
parent 4ba5f093d7
commit 9c60767c9f
No known key found for this signature in database
GPG Key ID: 611A80832067AF38
3 changed files with 14 additions and 3 deletions

View File

@ -1,3 +1,5 @@
---
tox_envlist: venv
zuul_work_dir: "src/{{ zuul.project.canonical_name }}"
tox_environment: {}
tox_environment_defaults: {}

View File

@ -3,11 +3,15 @@
msg: "tox_envlist is required for this role"
when: tox_envlist is not defined
- name: Create my_tox_environment variable
set_fact:
my_tox_environment: "{{ tox_environment_defaults | combine(tox_environment) }}"
- name: Run tox
args:
chdir: "{{ zuul_work_dir }}"
executable: /bin/bash
environment: "{{ tox_environment | default(omit) }}"
environment: "{{ my_tox_environment }}"
shell: |
# If a bundle file is present, call tox with the jenkins version of
# the test environment so it is used. Otherwise, use the normal

View File

@ -44,19 +44,24 @@
This performs basic host and general project setup tasks common
to all tox unit test jobs.
Responds to three variables:
Responds to these variables:
tox_envlist
work against specified environments (ALL selects all)
tox_environment
list of environmental variables to pass to bash shell
list of user defined environmental variables to pass to bash shell
tox_command_line
an optional command line
run: playbooks/tox/run
pre-run: playbooks/tox/pre
post-run: playbooks/tox/post
vars:
tox_environment_defaults:
NOSE_WITH_HTML_OUTPUT: 1
NOSE_HTML_OUT_FILE: nose_results.html
NOSE_WITH_XUNIT: 1
- job:
name: tox-py27