From 85159bc42fbbe14b694c8400525bec1b4a65cd29 Mon Sep 17 00:00:00 2001 From: Paul Belanger Date: Fri, 1 Sep 2017 14:07:22 -0400 Subject: [PATCH] Refactor run-docs role to use tox role We can leverate tox role from tox-docs for running out python setup.py build_sphinx command. This just leaves 'run-docs' role with openstack specific rename logic. The next patch in the series will refactor this another fitting name. Change-Id: Ic45541089391cea1d0b787a48be002d645cd28ea Signed-off-by: Paul Belanger --- playbooks/openstack-doc-build/post.yaml | 3 ++ playbooks/tox/docs.yaml | 4 -- roles/prepare-docs-for-afs/defaults/main.yaml | 2 + .../tasks/main.yaml | 44 ++----------------- roles/run-docs/defaults/main.yaml | 8 ---- zuul.yaml | 6 ++- 6 files changed, 13 insertions(+), 54 deletions(-) create mode 100644 playbooks/openstack-doc-build/post.yaml delete mode 100644 playbooks/tox/docs.yaml create mode 100644 roles/prepare-docs-for-afs/defaults/main.yaml rename roles/{run-docs => prepare-docs-for-afs}/tasks/main.yaml (63%) delete mode 100644 roles/run-docs/defaults/main.yaml diff --git a/playbooks/openstack-doc-build/post.yaml b/playbooks/openstack-doc-build/post.yaml new file mode 100644 index 00000000..61a111e9 --- /dev/null +++ b/playbooks/openstack-doc-build/post.yaml @@ -0,0 +1,3 @@ +- hosts: all + roles: + - prepare-docs-for-afs diff --git a/playbooks/tox/docs.yaml b/playbooks/tox/docs.yaml deleted file mode 100644 index c800ec34..00000000 --- a/playbooks/tox/docs.yaml +++ /dev/null @@ -1,4 +0,0 @@ -- hosts: all - roles: - - role: run-docs - envlist: venv diff --git a/roles/prepare-docs-for-afs/defaults/main.yaml b/roles/prepare-docs-for-afs/defaults/main.yaml new file mode 100644 index 00000000..a0afa22c --- /dev/null +++ b/roles/prepare-docs-for-afs/defaults/main.yaml @@ -0,0 +1,2 @@ +--- +zuul_work_dir: "src/{{ zuul.project.canonical_name }}" diff --git a/roles/run-docs/tasks/main.yaml b/roles/prepare-docs-for-afs/tasks/main.yaml similarity index 63% rename from roles/run-docs/tasks/main.yaml rename to roles/prepare-docs-for-afs/tasks/main.yaml index 87b7d8fe..e18c33be 100644 --- a/roles/run-docs/tasks/main.yaml +++ b/roles/prepare-docs-for-afs/tasks/main.yaml @@ -1,47 +1,10 @@ -- name: Require tox_envlist variable - {{ tox_envlist }} - fail: - 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) }}" - -# NOTE(pabelanger): This needs to be refactored to use our tox role in -# zuul-jobs. But right now, this is very openstack specific. -- name: Execute run-docs.sh. +- name: Process built docs to prepare for AFS publication args: - chdir: "{{ zuul_work_dir | default(omit) }}" + chdir: "{{ zuul_work_dir }}" executable: /bin/bash - environment: "{{ my_tox_environment }}" shell: | set -ex - # If a bundle file is present, call tox with the jenkins version of - # the test environment so it is used. Otherwise, use the normal - # (non-bundle) test environment. Also, run pbr freeze on the - # resulting environment at the end so that we have a record of exactly - # what packages we ended up testing. - # - - venv={{ tox_envlist }} tags_handling=${2:both} - - mkdir -p doc/build - export HUDSON_PUBLISH_DOCS=1 - # The "python setup.py build_sphinx" is intentionally executed instead of - # "tox -edocs", because it's the standard python project build interface - # specified in OpenStack Project Testing Interface: - # http://governance.openstack.org/reference/project-testing-interface.html - tox -e$venv -- python setup.py build_sphinx - result=$? - - [ -e .tox/$venv/bin/pbr ] && freezecmd=pbr || freezecmd=pip - - echo "Begin pbr freeze output from test virtualenv:" - echo "======================================================================" - .tox/${venv}/bin/${freezecmd} freeze - echo "======================================================================" - MARKER_TEXT="Project: $ZUUL_PROJECT Ref: $ZUUL_REFNAME Build: $ZUUL_UUID Revision: $ZUUL_NEWREV" echo $MARKER_TEXT > doc/build/html/.root-marker @@ -78,7 +41,7 @@ elif echo $ZUUL_REFNAME | grep stable/ >/dev/null ; then # Put stable release changes in dir named after stable release under the # build dir. When Jenkins copies these files they will be accessible under - # the developer docs root using the stable release's name. + # the developer docs root using the stable release name. BRANCH=$(echo $ZUUL_REFNAME | sed 's/stable.//') if [ ! -z $BRANCH ] ; then # Move the docs into a subdir if this is a stable branch build @@ -97,4 +60,3 @@ mkdir -p doc/build/html/$TOP mv doc/build/tmp doc/build/html/$BRANCH fi - exit $result diff --git a/roles/run-docs/defaults/main.yaml b/roles/run-docs/defaults/main.yaml deleted file mode 100644 index cb70ca0a..00000000 --- a/roles/run-docs/defaults/main.yaml +++ /dev/null @@ -1,8 +0,0 @@ ---- -tox_environment: {} -tox_environment_defaults: {} -tox_envlist: venv -tox_executable: tox -tox_extra_args: -vv - -zuul_work_dir: "src/{{ zuul.project.canonical_name }}" diff --git a/zuul.yaml b/zuul.yaml index aa114d6d..85d7ca47 100644 --- a/zuul.yaml +++ b/zuul.yaml @@ -6,12 +6,16 @@ - job: name: openstack-doc-build parent: tox-docs - run: playbooks/tox/docs + post-run: playbooks/openstack-doc-build/post required-projects: - name: openstack/requirements + roles: + - zuul: openstack-infra/zuul-jobs vars: tox_environment: UPPER_CONSTRAINTS_FILE: "{{ ansible_user_dir }}/src/git.openstack.org/openstack/requirements/upper-constraints.txt" + tox_envlist: venv + tox_extra_args: -vv python setup.py build_sphinx - job: name: tox-py35-on-zuul