From 9d230819a6c2299d5ea50b8ba32e1197ba1c986d Mon Sep 17 00:00:00 2001
From: Andreas Jaeger <aj@suse.com>
Date: Mon, 9 Oct 2017 21:33:58 +0200
Subject: [PATCH] Use publish-docs for Zuul v3

With Zuul v2, the publishing happens from publish-docs/api-ref.
Let's simplify our scripts and publish with Zuul v3 from publish-docs
directly.

Add new jobs publishlang and publishbuild for Zuul v3 publishing.
Use existing publishlang-api and publishbuild-api for Zuul v2
publishing.

Remove now obsolete comment from doc-tools-check-languages.conf.

Change-Id: I32b29a34c571882cb4d7c542c543ea726e76a0b5
---
 doc-tools-check-languages.conf | 17 +---------
 tools/build-api-quick-start.sh |  2 +-
 tools/build-firstapp-rst.sh    |  4 +--
 tools/build-index.sh           | 12 +++----
 tools/mv-firstapp-trans.sh     | 14 --------
 tox.ini                        | 58 ++++++++++++++++++++--------------
 6 files changed, 43 insertions(+), 64 deletions(-)
 delete mode 100755 tools/mv-firstapp-trans.sh

diff --git a/doc-tools-check-languages.conf b/doc-tools-check-languages.conf
index ad23f03a3..de130c272 100644
--- a/doc-tools-check-languages.conf
+++ b/doc-tools-check-languages.conf
@@ -1,24 +1,9 @@
-
-# IMPORTANT IMPORTANT IMPORTANT IMPORTANT IMPORTANT
-# Note that we publish all files to developer.openstack.org using
-# "tox -e publishlang-api".
-
-# Our script doc-tools-check-languages places guides in the wrong
-# directories, they need to be moved in tox.ini manually to the right
-# place for publishing.
-
-# We publish:
-# The api-quick-start at:
-# http:/developer.openstack.org/LANG/api-guide/quick-start
-
-# directories to be set up
+# Directories to be set up
 declare -A DIRECTORIES=(
 )
 
 # books to be built
 declare -A BOOKS=(
-    # See comment at start of file and update tox.ini as well if you
-    # change anything here.
     ["de"]="api-quick-start firstapp"
     ["id"]="api-quick-start firstapp"
     ["ja"]="api-quick-start"
diff --git a/tools/build-api-quick-start.sh b/tools/build-api-quick-start.sh
index 39623e7ac..ba7881400 100755
--- a/tools/build-api-quick-start.sh
+++ b/tools/build-api-quick-start.sh
@@ -2,4 +2,4 @@
 
 mkdir -p publish-docs
 
-tools/build-rst.sh api-quick-start --target api-ref/api-guide/quick-start
+tools/build-rst.sh api-quick-start --target api-guide/quick-start
diff --git a/tools/build-firstapp-rst.sh b/tools/build-firstapp-rst.sh
index 5e689345b..116743ef3 100755
--- a/tools/build-firstapp-rst.sh
+++ b/tools/build-firstapp-rst.sh
@@ -5,11 +5,11 @@ mkdir -p publish-docs
 # Publish documents to api-ref for developer.openstack.org
 for tag in libcloud shade; do
     tools/build-rst.sh firstapp  \
-        --tag ${tag} --target "api-ref/firstapp-${tag}"
+        --tag ${tag} --target "firstapp-${tag}"
 done
 
 # Draft documents
 for tag in dotnet fog openstacksdk pkgcloud jclouds gophercloud; do
     tools/build-rst.sh firstapp  \
-        --tag ${tag} --target "api-ref/draft/firstapp-${tag}"
+        --tag ${tag} --target "draft/firstapp-${tag}"
 done
diff --git a/tools/build-index.sh b/tools/build-index.sh
index 38efcde36..ffa161671 100755
--- a/tools/build-index.sh
+++ b/tools/build-index.sh
@@ -34,18 +34,14 @@ if [ "$PUBLISH" = "build" ] ; then
     openstack-indexpage publish-docs
 fi
 if [ "$PUBLISH" = "publish" ] ; then
-
-    # Publication happens from publish-docs/api-ref to
-    # developer.openstack.org, so move content around
-    mkdir -p publish-docs/api-ref/
     python tools/www-generator.py --source-directory www/ \
-        --output-directory publish-docs/api-ref/
-    rsync -a www/static/ publish-docs/api-ref/
+        --output-directory publish-docs/
+    rsync -a www/static/ publish-docs/
     # Don't publish this file
-    rm publish-docs/api-ref/www-index.html
+    rm publish-docs/www-index.html
 
     # This marker is needed for infra publishing
     MARKER_TEXT="Project: $ZUUL_PROJECT Ref: $ZUUL_REFNAME Build: $ZUUL_UUID"
-    echo $MARKER_TEXT > publish-docs/api-ref/.root-marker
+    echo $MARKER_TEXT > publish-docs/.root-marker
 
 fi
diff --git a/tools/mv-firstapp-trans.sh b/tools/mv-firstapp-trans.sh
deleted file mode 100755
index 42c264e2b..000000000
--- a/tools/mv-firstapp-trans.sh
+++ /dev/null
@@ -1,14 +0,0 @@
-#!/bin/bash -xe
-
-LANGDIR=$1
-
-if [[ -z "$LANGDIR" ]] ; then
-    echo "usage $0 language"
-    exit 1
-fi
-
-# Move all firstapp files for one language into the api-ref directory
-# since that directory is used for publishing.
-
-mkdir -p publish-docs/api-ref/$LANGDIR/
-mv publish-docs/$LANGDIR/firstapp* publish-docs/api-ref/$LANGDIR/
diff --git a/tox.ini b/tox.ini
index 98dde3243..20459462c 100644
--- a/tox.ini
+++ b/tox.ini
@@ -33,7 +33,7 @@ commands =
   # Build website index
   {toxinidir}/tools/build-index.sh build
 
-[testenv:publishdocs-api]
+[testenv:publishdocs]
 # Prepare documents (without www) so that they can get published on
 # developer.openstack.org with just copying publish-docs/api-ref over.
 commands =
@@ -44,6 +44,22 @@ commands =
   # Build website index
   {toxinidir}/tools/build-index.sh publish
 
+[testenv:publishdocs-api]
+# publishdocs will replace this, leave this in for transition
+whitelist_externals =
+  mkdir
+  mv
+commands =
+  {[testenv:publishdocs]commands}
+  # Now move everything to api-ref directory since that's where
+  # OpenStack CI expects it with this job.
+  # We need to move the content of publish-docs into publish-docs/api-ref.
+  # Tox does not allow us using wildcards here.
+  mkdir .newdir
+  # This renames publish-docs to api-ref
+  mv publish-docs .newdir/api-ref
+  mv .newdir publish-docs
+
 [testenv:checklang]
 whitelist_externals = doc-tools-check-languages
 commands = doc-tools-check-languages doc-tools-check-languages.conf test all
@@ -53,9 +69,9 @@ commands = doc-tools-check-languages doc-tools-check-languages.conf test all
 whitelist_externals = doc-tools-check-languages
 commands = doc-tools-check-languages doc-tools-check-languages.conf test {posargs}
 
-[testenv:publishlang-api]
+[testenv:publishlang]
 # Publish translated documents to developer.openstack.org with just
-# copying publish-docs/api-ref over.
+# copying publish-docs over.
 whitelist_externals =
    doc-tools-check-languages
    mkdir
@@ -67,26 +83,22 @@ commands =
    # multiple times.
    rm -rf publish-docs
    doc-tools-check-languages doc-tools-check-languages.conf publish all
-   # Move directories to proper place, we publish translated
-   # quick-start guides at
-   # developer.openstack.org/LANG/api-guide/quick-start or
-   # developer.openstack.org/draft/LANG/api-guide/quick-start.
-   mkdir -p publish-docs/api-ref
-   mkdir -p publish-docs/api-ref/de/api-guide
-   mkdir -p publish-docs/api-ref/id/api-guide
-   mkdir -p publish-docs/api-ref/ja/api-guide
-   mkdir -p publish-docs/api-ref/ko_KR/api-guide
-   mkdir -p publish-docs/api-ref/tr_TR/api-guide
-   mkdir -p publish-docs/api-ref/zh_CN/api-guide
-   mv publish-docs/de/api-quick-start/ publish-docs/api-ref/de/api-guide/quick-start
-   mv publish-docs/id/api-quick-start/ publish-docs/api-ref/id/api-guide/quick-start
-   mv publish-docs/ja/api-quick-start/ publish-docs/api-ref/ja/api-guide/quick-start
-   mv publish-docs/ko_KR/api-quick-start/ publish-docs/api-ref/ko_KR/api-guide/quick-start
-   mv publish-docs/tr_TR/api-quick-start/ publish-docs/api-ref/tr_TR/api-guide/quick-start
-   mv publish-docs/zh_CN/api-quick-start/ publish-docs/api-ref/zh_CN/api-guide/quick-start
-   {toxinidir}/tools/mv-firstapp-trans.sh de
-   {toxinidir}/tools/mv-firstapp-trans.sh id
-   {toxinidir}/tools/mv-firstapp-trans.sh tr_TR
+
+[testenv:publishlang-api]
+# publishlang will replace this, leave this in for transition
+whitelist_externals =
+  mkdir
+  mv
+commands =
+  {[testenv:publishlang]commands}
+  # Now move everything to api-ref directory since that's where
+  # OpenStack CI expects it with this job.
+  # We need to move the content of publish-docs into publish-docs/api-ref.
+  # Tox does not allow us using wildcards here.
+  mkdir .newdir
+  # This renames publish-docs to api-ref
+  mv publish-docs .newdir/api-ref
+  mv .newdir publish-docs
 
 [testenv:generatepot-rst]
 # Generate POT files for translation, needs {posargs} like: