From 7513629be76c02d00f3fd6b4c1a51254d0ad4d52 Mon Sep 17 00:00:00 2001
From: Andreas Jaeger <aj@suse.com>
Date: Wed, 10 Jul 2019 19:01:12 +0200
Subject: [PATCH] Skip test-setup.sh in pep8 jobs

pep8 jobs should not require database setup, etc, so we can skip
running test-setup.sh to save time.

Also, address comments from https://review.opendev.org/670120 and
use a block to not run the stat if can we will skip using the file.

Change-Id: Ia140b331ae1502fcf1f685faa6dace117d77d35d
---
 roles/test-setup/tasks/main.yaml | 27 ++++++++++++++-------------
 zuul.d/python-jobs.yaml          |  1 +
 2 files changed, 15 insertions(+), 13 deletions(-)

diff --git a/roles/test-setup/tasks/main.yaml b/roles/test-setup/tasks/main.yaml
index 85fc0e92e..a1a059d91 100644
--- a/roles/test-setup/tasks/main.yaml
+++ b/roles/test-setup/tasks/main.yaml
@@ -1,14 +1,15 @@
-- name: "Check if project's tools/test-setup.sh exists"
-  stat:
-    path: "{{ zuul_work_dir }}/tools/test-setup.sh"
-  register: p
+- when: not test_setup_skip
+  block:
+    - name: "Check if project's tools/test-setup.sh exists"
+      stat:
+        path: "{{ zuul_work_dir }}/tools/test-setup.sh"
+      register: p
 
-- name: Run tools/test-setup.sh
-  command: tools/test-setup.sh {{ test_setup_args }}
-  environment: "{{ test_setup_environment }}"
-  args:
-    chdir: "{{ zuul_work_dir }}"
-  when:
-    - p.stat.exists
-    - p.stat.executable
-    - not test_setup_skip
+    - name: Run tools/test-setup.sh
+      command: tools/test-setup.sh {{ test_setup_args }}
+      environment: "{{ test_setup_environment }}"
+      args:
+        chdir: "{{ zuul_work_dir }}"
+      when:
+        - p.stat.exists
+        - p.stat.executable
diff --git a/zuul.d/python-jobs.yaml b/zuul.d/python-jobs.yaml
index 2087bc04f..c3fd68dbc 100644
--- a/zuul.d/python-jobs.yaml
+++ b/zuul.d/python-jobs.yaml
@@ -147,6 +147,7 @@
       Uses tox with the ``pep8`` environment.
     vars:
       tox_envlist: pep8
+      test_setup_skip: true
 
 - job:
     name: tox-cover