diff --git a/roles/fetch-translation-output/README.rst b/roles/fetch-translation-output/README.rst index aa6e4205d..18b615b69 100644 --- a/roles/fetch-translation-output/README.rst +++ b/roles/fetch-translation-output/README.rst @@ -1 +1,11 @@ Collect output from a translation build + +**Role Variables** + +.. 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. diff --git a/roles/fetch-translation-output/defaults/main.yaml b/roles/fetch-translation-output/defaults/main.yaml index 8c052310a..0ed152a3b 100644 --- a/roles/fetch-translation-output/defaults/main.yaml +++ b/roles/fetch-translation-output/defaults/main.yaml @@ -1,3 +1,5 @@ --- zuul_executor_dest: "{{ zuul.executor.work_root }}/artifacts" translation_output_src: "src/{{ zuul.project.canonical_name }}/translation-source/" +zuul_output_dir: "{{ ansible_user_dir }}/zuul-output" +zuul_use_fetch_output: "{{ zuul_site_use_fetch_output|default(false) }}" diff --git a/roles/fetch-translation-output/tasks/main.yaml b/roles/fetch-translation-output/tasks/main.yaml index db065f4cc..67358c6f1 100644 --- a/roles/fetch-translation-output/tasks/main.yaml +++ b/roles/fetch-translation-output/tasks/main.yaml @@ -3,12 +3,22 @@ path: "{{ translation_output_src }}" register: translation_files -- name: Collect translation source files - synchronize: - dest: "{{ zuul_executor_dest }}" - mode: pull - src: "{{ translation_output_src }}" - verify_host: true - owner: no - group: no +- block: + - name: Collect translation source files + synchronize: + dest: "{{ zuul_executor_dest }}" + mode: pull + src: "{{ translation_output_src }}" + verify_host: true + owner: no + group: no + when: not zuul_use_fetch_output + + - name: Copy translation source files + copy: + dest: "{{ zuul_output_dir }}/artifacts" + src: "{{ translation_output_src }}" + mode: 0755 + remote_src: true + when: zuul_use_fetch_output when: translation_files.stat.exists diff --git a/test-playbooks/general/fetch-translation-output.yaml b/test-playbooks/general/fetch-translation-output.yaml new file mode 100644 index 000000000..100bd914c --- /dev/null +++ b/test-playbooks/general/fetch-translation-output.yaml @@ -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 translation + shell: | + mkdir -p src/{{ zuul.project.canonical_name }}/translation-source/ + echo Hello > src/{{ zuul.project.canonical_name }}/translation-source/test + + tasks: + - import_role: + name: fetch-translation-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/artifacts/test" + 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.work_root }}/artifacts/test" + delegate_to: localhost + register: _executor_artifact + failed_when: not _executor_artifact.stat.exists diff --git a/zuul-tests.d/general-roles-jobs.yaml b/zuul-tests.d/general-roles-jobs.yaml index bdf030e9c..4ff06ac15 100644 --- a/zuul-tests.d/general-roles-jobs.yaml +++ b/zuul-tests.d/general-roles-jobs.yaml @@ -695,6 +695,26 @@ - test-playbooks/stage-output.yaml - roles/stage-output/.* +- job: + name: zuul-jobs-test-fetch-translation-output + description: Test the fetch-translation-output + files: + - roles/ensure-output-dirs/.* + - roles/fetch-translation-output/.* + - roles/fetch-output/.* + run: test-playbooks/general/fetch-translation-output.yaml + vars: + zuul_use_fetch_output: true + +- job: + name: zuul-jobs-test-fetch-translation-output-synchronize + description: Test the fetch-translation-output + files: + - roles/fetch-translation-output/.* + run: test-playbooks/general/fetch-translation-output.yaml + vars: + zuul_use_fetch_output: false + # -* AUTOGENERATED *- # The following project section is autogenerated by # tox -e update-test-platforms @@ -750,6 +770,8 @@ - zuul-jobs-test-ensure-zookeeper - zuul-jobs-test-update-json-file - zuul-jobs-test-stage-output + - zuul-jobs-test-fetch-translation-output + - zuul-jobs-test-fetch-translation-output-synchronize gate: jobs: &id001 - zuul-jobs-test-add-authorized-keys @@ -796,5 +818,7 @@ - zuul-jobs-test-ensure-zookeeper - zuul-jobs-test-update-json-file - zuul-jobs-test-stage-output + - zuul-jobs-test-fetch-translation-output + - zuul-jobs-test-fetch-translation-output-synchronize periodic-weekly: jobs: *id001