From 1eafcaabbb055160b31e3fefa916072af79779c1 Mon Sep 17 00:00:00 2001 From: Kenneth Giusti Date: Tue, 10 Oct 2017 11:02:55 -0400 Subject: [PATCH] Parameterize the test-setup role The patch will allow jobs to set environment variables and pass command line arguments to the test-setup.sh script defined by a project. This can be used to customize the setup based on the particular job being run. Change-Id: I11e1ab15fd2bf3c734544121d9b4040b99ee63da --- roles/test-setup/README.rst | 12 ++++++++++++ roles/test-setup/defaults/main.yaml | 4 ++++ roles/test-setup/tasks/main.yaml | 3 ++- 3 files changed, 18 insertions(+), 1 deletion(-) diff --git a/roles/test-setup/README.rst b/roles/test-setup/README.rst index 570e662b2..90fe4e459 100644 --- a/roles/test-setup/README.rst +++ b/roles/test-setup/README.rst @@ -8,3 +8,15 @@ be run. This allows projects to specify test-setup steps (such as creating or initializing a database) in a form that can be easily run by both an automated testing system and developers. + +**Role Variables** + +.. zuul:rolevar:: test_setup_environment + + Environment variables to pass in to the test-setup script. + +.. zuul:rolevar:: test_setup_args + + String of optional command line options passed to + the test-setup script. + diff --git a/roles/test-setup/defaults/main.yaml b/roles/test-setup/defaults/main.yaml index a0afa22c5..71630b024 100644 --- a/roles/test-setup/defaults/main.yaml +++ b/roles/test-setup/defaults/main.yaml @@ -1,2 +1,6 @@ --- +test_setup_args: "" +test_setup_environment: {} + zuul_work_dir: "src/{{ zuul.project.canonical_name }}" + diff --git a/roles/test-setup/tasks/main.yaml b/roles/test-setup/tasks/main.yaml index 8d67789f0..4977dfe60 100644 --- a/roles/test-setup/tasks/main.yaml +++ b/roles/test-setup/tasks/main.yaml @@ -4,7 +4,8 @@ register: p - name: Run tools/test-setup.sh - command: tools/test-setup.sh + command: tools/test-setup.sh {{ test_setup_args }} + environment: "{{ test_setup_environment }}" args: chdir: "{{ zuul_work_dir }}" when: