From 9c60767c9fb728d79d75d859106a02b194266a75 Mon Sep 17 00:00:00 2001 From: Paul Belanger Date: Mon, 24 Jul 2017 12:06:16 -0400 Subject: [PATCH] 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 --- roles/tox/defaults/main.yaml | 2 ++ roles/tox/tasks/main.yaml | 6 +++++- zuul.yaml | 9 +++++++-- 3 files changed, 14 insertions(+), 3 deletions(-) diff --git a/roles/tox/defaults/main.yaml b/roles/tox/defaults/main.yaml index 7a8e44269..775a25d65 100644 --- a/roles/tox/defaults/main.yaml +++ b/roles/tox/defaults/main.yaml @@ -1,3 +1,5 @@ --- tox_envlist: venv zuul_work_dir: "src/{{ zuul.project.canonical_name }}" +tox_environment: {} +tox_environment_defaults: {} diff --git a/roles/tox/tasks/main.yaml b/roles/tox/tasks/main.yaml index 77b59e06c..22c799999 100644 --- a/roles/tox/tasks/main.yaml +++ b/roles/tox/tasks/main.yaml @@ -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 diff --git a/zuul.yaml b/zuul.yaml index 2bcd46515..33f8218da 100644 --- a/zuul.yaml +++ b/zuul.yaml @@ -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