Merge "fetch-sphinx-output: introduce zuul_use_fetch_output"

This commit is contained in:
Zuul 2020-05-13 18:59:10 +00:00 committed by Gerrit Code Review
commit d17cc7b522
5 changed files with 75 additions and 0 deletions

View File

@ -34,3 +34,11 @@ to the log root of the executor.
:default: {{ zuul.project.src_dir }}
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.

View File

@ -1,6 +1,8 @@
---
zuul_executor_dest: "{{ zuul.executor.log_root }}"
zuul_work_dir: "{{ zuul.project.src_dir }}"
zuul_output_dir: "{{ ansible_user_dir }}/zuul-output"
zuul_use_fetch_output: "{{ zuul_site_use_fetch_output|default(false) }}"
sphinx_build_dir: doc/build
sphinx_output_suffix: ""
sphinx_output_src: "{{ zuul_work_dir }}/{{ sphinx_build_dir }}/html{{ sphinx_output_suffix }}"

View File

@ -4,6 +4,14 @@
mode: pull
src: "{{ sphinx_output_src }}"
verify_host: true
when: not zuul_use_fetch_output
- name: Copy sphinx build html
copy:
dest: "{{ zuul_output_dir }}/logs/"
src: "{{ sphinx_output_src }}"
remote_src: true
when: zuul_use_fetch_output
- name: Return artifact to Zuul
zuul_return:

View File

@ -0,0 +1,33 @@
- hosts: all
pre_tasks:
# Run ensure-output-dirs now as it is not performed speculatively
- import_role:
name: ensure-output-dirs
- name: Create fake sphinx output
shell: |
mkdir -p {{ zuul.project.src_dir }}/doc/build/html
echo "<body>Hello</body>" > {{ zuul.project.src_dir }}/doc/build/html/index.html
tasks:
- import_role:
name: fetch-sphinx-output
- import_role:
name: fetch-output
when: zuul_use_fetch_output
post_tasks:
- name: Check for artifact on the test instance
stat:
path: "{{ ansible_user_dir }}/zuul-output/logs/html/index.html"
register: _test_artifact
failed_when: not _test_artifact.stat.exists
when: zuul_use_fetch_output
- name: Check for artifact on the executor
stat:
path: "{{ zuul.executor.log_root }}/html/index.html"
delegate_to: localhost
register: _executor_artifact
failed_when: not _executor_artifact.stat.exists

View File

@ -458,6 +458,26 @@
vars:
zuul_use_fetch_output: false
- job:
name: zuul-jobs-test-fetch-sphinx-output
description: Test the fetch-sphinx-output
files:
- roles/ensure-output-dirs/.*
- roles/fetch-sphinx-output/.*
- roles/fetch-output/.*
run: test-playbooks/python/fetch-sphinx-output.yaml
vars:
zuul_use_fetch_output: true
- job:
name: zuul-jobs-test-fetch-sphinx-output-synchronize
description: Test the fetch-sphinx-output
files:
- roles/fetch-sphinx-output/.*
run: test-playbooks/python/fetch-sphinx-output.yaml
vars:
zuul_use_fetch_output: false
- project:
check:
jobs:
@ -503,6 +523,8 @@
- zuul-jobs-test-fetch-tox-output-synchronize
- zuul-jobs-test-fetch-subunit-output
- zuul-jobs-test-fetch-subunit-output-synchronize
- zuul-jobs-test-fetch-sphinx-output
- zuul-jobs-test-fetch-sphinx-output-synchronize
gate:
jobs:
- zuul-jobs-test-ensure-pip-centos-7
@ -544,3 +566,5 @@
- zuul-jobs-test-fetch-tox-output-synchronize
- zuul-jobs-test-fetch-subunit-output
- zuul-jobs-test-fetch-subunit-output-synchronize
- zuul-jobs-test-fetch-sphinx-output
- zuul-jobs-test-fetch-sphinx-output-synchronize