From 6f43acde4198220549e24cc816342501bd7d5598 Mon Sep 17 00:00:00 2001
From: Ian Wienand <iwienand@redhat.com>
Date: Thu, 15 Oct 2020 14:12:37 +1100
Subject: [PATCH] fetch-sphinx-tarball: don't run merge-output-to-logs

The merge-output-to-logs role is not doing anything in this test.  As
described inline, this merges files in
zuul.executor.work_root/<docs,artifacts> into the
zuul.executor.log_root directory so they are available in change
results.

Since this job doesn't publish anything there, this role is unused.

merge-output-to-logs currently can't run because it tries to run shell
scripts on the executor.  Thus we can remove this unused role and
restore the job.

Change-Id: I1afc905aa8d9c420bed316e99760ad7ad1d838ce
---
 roles/fetch-sphinx-output/README.rst          | 15 ++++++++---
 roles/fetch-sphinx-tarball/README.rst         | 14 ++++++++---
 .../python/fetch-sphinx-tarball.yaml          | 17 +------------
 zuul-tests.d/python-jobs.yaml                 | 25 +++++++++----------
 4 files changed, 34 insertions(+), 37 deletions(-)

diff --git a/roles/fetch-sphinx-output/README.rst b/roles/fetch-sphinx-output/README.rst
index 0c854aada..1cc09a0b8 100644
--- a/roles/fetch-sphinx-output/README.rst
+++ b/roles/fetch-sphinx-output/README.rst
@@ -35,10 +35,17 @@ to the log root of the executor.
 
    The location of the main working directory of the job.
 
+
 .. zuul:rolevar:: zuul_use_fetch_output
    :default: false
 
-   Whether to synchronize files to the executor work dir, or to copy them
-   on the test instance.
-   When set to false, the role synchronizes the file to the executor.
-   When set to true, the job needs to use the fetch-output role later.
+   Whether to synchronize files to the executor work dir, or to only
+   copy them on the test instance.
+
+   When set to ``False``, the default, the role synchronizes the
+   tarball archives and extracted documentation files to the executor
+   ``log_root``.
+
+   When set to ``True``, the content is copied locally to
+   ``{{  ansible_user_dir }}/zuul-output/logs/``.  The ``fetch-output`` role
+   needs to be run to copy this output to the executor ``log_root``.
diff --git a/roles/fetch-sphinx-tarball/README.rst b/roles/fetch-sphinx-tarball/README.rst
index 0895ec894..5fd6b4059 100644
--- a/roles/fetch-sphinx-tarball/README.rst
+++ b/roles/fetch-sphinx-tarball/README.rst
@@ -27,7 +27,13 @@ archive into the log root for viewing.
 .. zuul:rolevar:: zuul_use_fetch_output
    :default: false
 
-   Whether to synchronize files to the executor work dir, or to copy them
-   on the test instance.
-   When set to false, the role synchronizes the file to the executor.
-   When set to true, the job needs to use the fetch-output role later.
+   Whether to synchronize files to the executor work dir, or to only
+   copy them on the test instance.
+
+   When set to ``False``, the default, the role synchronizes the
+   tarball archives and extracted documentation files to the executor
+   ``log_root``.
+
+   When set to ``True``, the content is copied locally to
+   ``{{  ansible_user_dir }}/zuul-output/logs/``.  The ``fetch-output`` role
+   needs to be run to copy this output to the executor ``log_root``.
diff --git a/test-playbooks/python/fetch-sphinx-tarball.yaml b/test-playbooks/python/fetch-sphinx-tarball.yaml
index 6e290b624..e5292c9d5 100644
--- a/test-playbooks/python/fetch-sphinx-tarball.yaml
+++ b/test-playbooks/python/fetch-sphinx-tarball.yaml
@@ -32,7 +32,7 @@
     #  The generated .tar.gz files are copied into
     #  {{ ansible_user_dir }}/zuul-output/logs/ and extracted into
     #  zuul-output/logs/<docs|pdf> on the host.  They need to be brought back
-    #  to the executor using fetch-output/merge-output-to-logs
+    #  to the executor using fetch-output
     - import_role:
         name: fetch-sphinx-tarball
 
@@ -43,21 +43,6 @@
         name: fetch-output
       when: zuul_use_fetch_output
 
-    # This moves <docs|artifacts> in zuul.executor.work_root into
-    # zuul.executor.log_root so they are published when operating in a
-    # change context.
-    #
-    # For example, in the release pipeline, jobs might build artifacts
-    # like sdist/wheels, copy them to the executor and upload them and
-    # do not need to publish those actual artifacts in the logs.  Thus
-    # when triggered from a tag/periodic job this job won't copy
-    # anything.  However, when triggered from a change, this *will*
-    # copy the docs/artifacts into the logs so they can be browsed
-    # from the change result.
-    - import_role:
-        name: merge-output-to-logs
-      when: zuul_use_fetch_output
-
   post_tasks:
     - name: Check for artifact on the test instance
       stat:
diff --git a/zuul-tests.d/python-jobs.yaml b/zuul-tests.d/python-jobs.yaml
index 1aaa18cbc..d82512d48 100644
--- a/zuul-tests.d/python-jobs.yaml
+++ b/zuul-tests.d/python-jobs.yaml
@@ -455,19 +455,16 @@
     vars:
       zuul_use_fetch_output: false
 
-# Disabled because "Move artifacts and docs to logs dir" task would
-# fail with "Executing local code is prohibited" during testing
-# - job:
-#     name: zuul-jobs-test-fetch-sphinx-tarball-with-zuul-output
-#     description: Test the fetch-sphinx-tarball
-#     files:
-#       - roles/ensure-output-dirs/.*
-#       - roles/fetch-sphinx-tarball/.*
-#       - roles/fetch-output/.*
-#     run: test-playbooks/python/fetch-sphinx-tarball.yaml
-#     voting: false
-#     vars:
-#       zuul_use_fetch_output: true
+- job:
+    name: zuul-jobs-test-fetch-sphinx-tarball-with-zuul-output
+    description: Test the fetch-sphinx-tarball
+    files:
+      - roles/ensure-output-dirs/.*
+      - roles/fetch-sphinx-tarball/.*
+      - roles/fetch-output/.*
+    run: test-playbooks/python/fetch-sphinx-tarball.yaml
+    vars:
+      zuul_use_fetch_output: true
 
 - job:
     name: zuul-jobs-test-fetch-sphinx-tarball-synchronize
@@ -522,6 +519,7 @@
         - zuul-jobs-test-fetch-subunit-output-synchronize
         - zuul-jobs-test-fetch-sphinx-output
         - zuul-jobs-test-fetch-sphinx-output-synchronize
+        - zuul-jobs-test-fetch-sphinx-tarball-with-zuul-output
         - zuul-jobs-test-fetch-sphinx-tarball-synchronize
     gate:
       jobs: &id001
@@ -563,6 +561,7 @@
         - zuul-jobs-test-fetch-subunit-output-synchronize
         - zuul-jobs-test-fetch-sphinx-output
         - zuul-jobs-test-fetch-sphinx-output-synchronize
+        - zuul-jobs-test-fetch-sphinx-tarball-with-zuul-output
         - zuul-jobs-test-fetch-sphinx-tarball-synchronize
     periodic-weekly:
       jobs: *id001