Merge "Install yarn if needed in javascript jobs"

This commit is contained in:
Zuul 2017-12-15 17:11:54 +00:00 committed by Gerrit Code Review
commit 5a190a4c03
9 changed files with 76 additions and 0 deletions

View File

@ -5,6 +5,7 @@
bindep_dir: "{{ zuul_work_dir }}"
- test-setup
- install-nodejs
- install-yarn
# nodejs-test-dependencies requires sudo,
# so we cannot inherit pre.yaml from javascript-base.
- nodejs-test-dependencies

View File

@ -5,5 +5,6 @@
bindep_dir: "{{ zuul_work_dir }}"
- test-setup
- install-nodejs
- install-yarn
- revoke-sudo
- install-javascript-packages

View File

@ -1,6 +1,23 @@
- name: Check for yarn.lock file
stat:
path: "{{ zuul_work_dir }}/yarn.lock"
get_checksum: false
get_mime: false
get_md5: false
register: yarn_lock
- name: Install yarn dependencies
command: yarn install
environment:
DISPLAY: ':99'
args:
chdir: "{{ zuul_work_dir }}"
when: yarn_lock.stat.exists
- name: Install npm dependencies
command: npm install --verbose
environment:
DISPLAY: ':99'
args:
chdir: "{{ zuul_work_dir }}"
when: not yarn_lock.stat.exists

View File

@ -0,0 +1,8 @@
Install yarn from yarnpkg repos
**Role Variables**
.. zuul:rolevar:: zuul_work_dir
:default: {{ zuul.project.src_dir }}
The directory to work in.

View File

@ -0,0 +1 @@
zuul_work_dir: "{{ zuul.project.src_dir }}"

View File

@ -0,0 +1,14 @@
- name: Add yarnpkg repository key
apt_key:
url: https://dl.yarnpkg.com/debian/pubkey.gpg
become: yes
- name: Add yarnpkg apt source repository
apt_repository:
repo: "deb https://dl.yarnpkg.com/debian/ stable main"
state: present
update_cache: yes
become: yes
- name: Install yarn
include: yarn.yaml

View File

@ -0,0 +1,8 @@
- name: Add yarnpkg repo file
get_url:
url: https://dl.yarnpkg.com/rpm/yarn.repo
dest: /etc/yum.repos.d/yarn.repo
become: yes
- name: Install yarn
include: yarn.yaml

View File

@ -0,0 +1,15 @@
- name: Check for yarn.lock file
stat:
path: "{{ zuul_work_dir }}/yarn.lock"
get_checksum: false
get_mime: false
get_md5: false
register: yarn_lock
- name: Install yarn if needed
include: "{{ item }}"
with_first_found:
- "{{ ansible_distribution }}.yaml"
- "{{ ansible_os_family }}.yaml"
when:
- yarn_lock.stat.exists

View File

@ -0,0 +1,11 @@
- name: Install yarn from yarnpkg.com
package:
name: yarn
state: latest
become: yes
tags:
# Ignore ANSIBLE0010: We really want latest version
- skip_ansible_lint
- name: Output yarn version
command: yarn --version