From 2d2a717f298078a194df953bb5851c426cde7c16 Mon Sep 17 00:00:00 2001 From: Monty Taylor Date: Wed, 6 Sep 2017 13:39:08 -0500 Subject: [PATCH] Ansiblify prepare-infra-docs-for-afs The existing code in branch made a directory for build/{{ branch.tag | dirname }} but then moved things to build/{{ branch.tag | basename }} which produced: html/ html/feature html/zuulv3 Fix that. While we're in there, go ahead and change this into individual ansible tasks. Change-Id: Ib757d1f8bf76012d2d436565913e750c4a5d52a7 --- .../tasks/branch.yaml | 26 +++++++------ .../tasks/main.yaml | 6 ++- .../tasks/stable.yaml | 27 ++++++++------ .../tasks/tagged.yaml | 37 ++++++------------- 4 files changed, 46 insertions(+), 50 deletions(-) diff --git a/roles/prepare-infra-docs-for-afs/tasks/branch.yaml b/roles/prepare-infra-docs-for-afs/tasks/branch.yaml index ff2acc58..b6b8598d 100644 --- a/roles/prepare-infra-docs-for-afs/tasks/branch.yaml +++ b/roles/prepare-infra-docs-for-afs/tasks/branch.yaml @@ -1,12 +1,14 @@ -- name: Process other branch changes - args: - chdir: "{{ zuul_work_dir }}" - # Put other branch changes in dir named after branch under the - # build dir. When Zuul copies these files they will be - # accessible under the developer docs root using the branch name. - # EG: feature/foo or milestone-proposed - shell: | - mv doc/build/html doc/build/tmp - mkdir -p doc/build/html/{{ zuul.branch | dirname }} - mv doc/build/tmp doc/build/html/{{ zuul.branch | basename }} - tags: skip_ansible_lint +# Put other branch changes in dir named after branch under the +# build dir. When Zuul copies these files they will be +# accessible under the developer docs root using the branch name. +# EG: feature/foo or milestone-proposed +- name: Move built html to the side + command: "mv {{ doc_build_dir }}/html {{ doc_build_dir }}/tmp" + +- name: Ensure destination path exists + file: + path: "{{ doc_build_dir }}/html/{{ zuul.branch | dirname }}" + state: directory + +- name: Move html to branch location + command: "mv {{ doc_build_dir }}/tmp {{ doc_build_dir }}/html/{{ zuul.branch }}" diff --git a/roles/prepare-infra-docs-for-afs/tasks/main.yaml b/roles/prepare-infra-docs-for-afs/tasks/main.yaml index 6521505f..7f3adf99 100644 --- a/roles/prepare-infra-docs-for-afs/tasks/main.yaml +++ b/roles/prepare-infra-docs-for-afs/tasks/main.yaml @@ -1,6 +1,10 @@ +- name: Set build dir fact + set_fact: + doc_build_dir: "{{ zuul_work_dir }}/doc/build" + - name: Write marker text copy: - dest: "{{ zuul_work_dir }}/doc/build/html/.root-marker" + dest: "{{ doc_build_dir }}/html/.root-marker" content: "Project: {{ zuul.project.name }} Branch: {{ zuul.branch }} Build: {{ zuul.build }} Revision: {{ zuul.ref }}" - name: Process tagged build diff --git a/roles/prepare-infra-docs-for-afs/tasks/stable.yaml b/roles/prepare-infra-docs-for-afs/tasks/stable.yaml index ee3bdc3d..0d09d9e3 100644 --- a/roles/prepare-infra-docs-for-afs/tasks/stable.yaml +++ b/roles/prepare-infra-docs-for-afs/tasks/stable.yaml @@ -1,12 +1,15 @@ -- name: Process stable branch changes - args: - chdir: "{{ zuul_work_dir }}" - # Put stable release changes in dir named after stable release under the - # build dir. When Zuul copies these files they will be accessible under - # the developer docs root using the stable release name. - shell: | - # Move the docs into a subdir if this is a stable branch build - mv doc/build/html doc/build/tmp - mkdir doc/build/html - mv doc/build/tmp doc/build/html/{{ zuul.branch | replace('stable/', '') }} - tags: skip_ansible_lint +# Put stable release changes in dir named after stable release under the +# build dir. When Zuul copies these files they will be accessible under +# the developer docs root using the stable release name. +- name: Move built html to the side + command: "mv {{ doc_build_dir }}/html {{ doc_build_dir }}/tmp" + +- name: Ensure destination path exists + file: + path: "{{ doc_build_dir }}/html" + state: directory + +- name: Move html to branch location without stable prefix + command: >- + mv {{ doc_build_dir }}/tmp + {{ doc_build_dir }}/html/{{ zuul.branch | replace('stable/', '') }} diff --git a/roles/prepare-infra-docs-for-afs/tasks/tagged.yaml b/roles/prepare-infra-docs-for-afs/tasks/tagged.yaml index c9cfdb6e..ee6da208 100644 --- a/roles/prepare-infra-docs-for-afs/tasks/tagged.yaml +++ b/roles/prepare-infra-docs-for-afs/tasks/tagged.yaml @@ -1,31 +1,18 @@ -- name: Get latest tag for project - args: - chdir: "{{ zuul_work_dir }}" - executable: /bin/bash - # This is a hack to ignore the year.release tags in projects since - # now all projects use semver based versions instead of date based - # versions. The date versions will sort higher even though they - # should not so we just special case it here. - shell: | - git tag | sed -n -e '/^20[0-9]\{2\}\..*$/d' -e '/^[0-9]\+\(\.[0-9]\+\)*$/p' | sort -V | tail -1 - register: latest - tags: skip_ansible_lint - # Put tagged releases in proper location. All tagged builds get copied to # BUILD_DIR/tagname. If this is the latest tagged release the copy of files # at BUILD_DIR remains. When Zuul copies this file the root developer # docs are always the latest release with older tags available under the # root in the tagname dir. +- name: Copy content to the temporary location + copy: + remote_src: true + src: "{{ doc_build_dir }}/html" + dest: "{{ doc_build_dir }}/tmp" -- name: Process tags only builds when the tag is the latest tag - args: - chdir: "{{ zuul_work_dir }}" - # Now publish to / and /$TAG if this is the latest version for projects - # and we are only publishing from the release pipeline, - # or just /$TAG otherwise. - shell: | - # Copy the docs into a subdir if this is a tagged build - mkdir doc/build/{{ zuul.tag }} - cp -R doc/build/html/. doc/build/{{ zuul.tag }} - mv doc/build/{{ zuul.tag }} doc/build/html/{{ zuul.tag }} - tags: skip_ansible_lint +- name: Make destination path + file: + path: "{{ doc_build_dir }}/html/{{ zuul.tag | dirname }}" + state: directory + +- name: Move html to branch location + command: "mv {{ doc_build_dir }}/tmp {{ doc_build_dir }}/html/{{ zuul.tag }}"