zuul-jobs/roles/fetch-javascript-output/tasks/main.yaml
Monty Taylor 89f68c5ca0
Fetch built web content in javascript jobs
If a javascript job produces web content that should be deployed (such
as zuul-web or storyboard-webclient) we should collect that in the post
step of the job and put it into the html/ directory.

While in there, add a bunch of get_*: false entries for the stat calls.
Calculating the md5 and whatnot is expensive, and we should really
always set them to false unless we're *using* the hash values.

Change-Id: I9b96656aa5f225e4b069a78442cf0159cadc9009
2017-12-16 20:07:02 -06:00

121 lines
2.8 KiB
YAML

- name: Set log path for multiple nodes
set_fact:
log_path: "{{ zuul.executor.log_root }}/{{ inventory_hostname }}/npm"
when: groups['all'] | length > 1
- name: Set log path for single node
set_fact:
log_path: "{{ zuul.executor.log_root }}/npm"
when: log_path is not defined
- name: Ensure local tox dir
file:
path: "{{ log_path }}"
state: directory
delegate_to: localhost
- name: Check for yarn.lock
stat:
path: "{{ zuul_work_dir }}/yarn.lock"
get_checksum: false
get_mime: false
get_md5: false
register: yarn_lock
- name: Check for shrinkwrap
stat:
path: "{{ zuul_work_dir }}/npm-shrinkwrap.json"
get_checksum: false
get_mime: false
get_md5: false
when: not yarn_lock.stat.exists
register: shrinkwrap
- name: Run npm prune because of https://github.com/npm/npm/issues/6298
when:
- not yarn_lock.stat.exists
- not shrinkwrap.stat.exists
command: npm prune
environment:
DISPLAY: ':99'
args:
chdir: "{{ zuul_work_dir }}"
- name: Run npm shrinkwrap
when:
- not yarn_lock.stat.exists
- not shrinkwrap.stat.exists
command: npm shrinkwrap
environment:
DISPLAY: ':99'
args:
chdir: "{{ zuul_work_dir }}"
- name: Check for reports
stat:
path: "{{ zuul_work_dir }}/reports"
get_checksum: false
get_mime: false
get_md5: false
register: reports_stat
- name: Collect npm reports
synchronize:
dest: "{{ log_path }}"
mode: pull
src: "{{ zuul_work_dir }}/reports"
verify_host: true
when: reports_stat.stat.exists
- name: Check for karma.subunit files
stat:
path: "{{ zuul_work_dir }}/karma.subunit"
get_checksum: false
get_mime: false
get_md5: false
register: karma_stat
- name: Collect karma subunit files
synchronize:
dest: "{{ log_path }}"
mode: pull
src: "{{ zuul_work_dir }}/karma.subunit"
verify_host: true
when: karma_stat.stat.exists
- name: Check again for shrinkwrap
when: not yarn_lock.stat.exists
stat:
path: "{{ zuul_work_dir }}/npm-shrinkwrap.json"
get_checksum: false
get_mime: false
get_md5: false
register: shrinkwrap_final
- name: Collect shrinkwrap file
synchronize:
dest: "{{ log_path }}"
mode: pull
src: "{{ zuul_work_dir }}/npm-shrinkwrap.json"
verify_host: true
when:
- not yarn_lock.stat.exists
- shrinkwrap_final.stat.exists
- name: Check for built output
stat:
path: "{{ zuul_work_dir }}/{{ javascript_content_dir }}"
get_checksum: false
get_mime: false
get_md5: false
register: javascript_output
- name: Collect javascript output
synchronize:
src: "{{ zuul_work_dir }}/{{ javascript_content_dir }}/"
dest: "{{ log_path }}/html/"
mode: pull
copy_links: true
verify_host: true
when: javascript_output.stat.exists