Merge "fetch-javascript-tarball: introduce zuul_use_fetch_output"

This commit is contained in:
Zuul 2020-02-17 16:42:44 +00:00 committed by Gerrit Code Review
commit fa6e25f730
5 changed files with 74 additions and 14 deletions

View File

@ -6,3 +6,11 @@ Fetch a Javascript tarball back to be published.
:default: {{ zuul.project.src_dir }}
Directory to run npm in.
.. 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 +1,3 @@
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) }}"

View File

@ -1,14 +1,15 @@
- name: Rename tarball for uploading
shell: |
mkdir -p dist
cp *.tgz dist/{{ zuul.project.short_name }}-{{ project_ver }}.tar.gz
cp *.tgz dist/{{ zuul.project.short_name }}-latest.tar.gz
mkdir -p {{ zuul_output_dir }}/artifacts
cp *.tgz {{ zuul_output_dir }}/artifacts/{{ zuul.project.short_name }}-{{ project_ver }}.tar.gz
cp *.tgz {{ zuul_output_dir }}/artifacts/{{ zuul.project.short_name }}-latest.tar.gz
args:
chdir: "{{ zuul_work_dir }}"
tags:
# Ignore ANSIBLE0007: No need to use file module instead of mkdir
- skip_ansible_lint
- block:
- name: Ensure artifacts directory exists
file:
path: "{{ zuul.executor.work_root }}/artifacts"
@ -19,5 +20,6 @@
synchronize:
dest: "{{ zuul.executor.work_root }}/artifacts/"
mode: pull
src: "{{ zuul_work_dir }}/dist/"
src: "{{ zuul_output_dir }}/artifacts/"
verify_host: true
when: not zuul_use_fetch_output

View File

@ -0,0 +1,26 @@
- hosts: all
pre_tasks:
- name: Create fake tarball
shell: |
mkdir -p {{ zuul.project.src_dir }}
tar czf {{ zuul.project.src_dir }}/dist.tgz /etc/os-release
tasks:
- import_role:
name: fetch-javascript-tarball
vars:
project_ver: master
- 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/zuul-jobs-latest.tar.gz"
register: _test_artifact
failed_when: not _test_artifact.stat.exists
- name: Check for artifact on the executor
stat:
path: "{{ zuul.executor.work_root }}/artifacts/zuul-jobs-latest.tar.gz"
delegate_to: localhost
register: _executor_artifact
failed_when: not _executor_artifact.stat.exists

View File

@ -7,6 +7,26 @@
vars:
role_name: install-nodejs
- job:
name: zuul-jobs-test-fetch-javascript-tarball
description: Test the fetch-javascript-tarball
files:
- roles/fetch-javascript-tarball/.*
- roles/fetch-output/.*
run: test-playbooks/javascripts/fetch-javascript-tarball.yaml
vars:
zuul_use_fetch_output: true
- job:
name: zuul-jobs-test-fetch-javascript-tarball-synchronize
description: Test the fetch-javascript-tarball without fetch-output
files:
- roles/fetch-javascript-tarball/.*
run: test-playbooks/javascripts/fetch-javascript-tarball.yaml
vars:
zuul_use_fetch_output: false
# -* AUTOGENERATED *-
# The following project section is autogenerated by
# tox -e update-test-platforms
@ -16,5 +36,7 @@
check:
jobs: &id001
- zuul-jobs-test-install-nodejs
- zuul-jobs-test-fetch-javascript-tarball
- zuul-jobs-test-fetch-javascript-tarball-synchronize
gate:
jobs: *id001