Merge "Install yarn if needed in javascript jobs"
This commit is contained in:
commit
5a190a4c03
@ -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
|
||||
|
@ -5,5 +5,6 @@
|
||||
bindep_dir: "{{ zuul_work_dir }}"
|
||||
- test-setup
|
||||
- install-nodejs
|
||||
- install-yarn
|
||||
- revoke-sudo
|
||||
- install-javascript-packages
|
||||
|
@ -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
|
||||
|
8
roles/install-yarn/README.rst
Normal file
8
roles/install-yarn/README.rst
Normal 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.
|
1
roles/install-yarn/defaults/main.yaml
Normal file
1
roles/install-yarn/defaults/main.yaml
Normal file
@ -0,0 +1 @@
|
||||
zuul_work_dir: "{{ zuul.project.src_dir }}"
|
14
roles/install-yarn/tasks/Debian.yaml
Normal file
14
roles/install-yarn/tasks/Debian.yaml
Normal 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
|
8
roles/install-yarn/tasks/RedHat.yaml
Normal file
8
roles/install-yarn/tasks/RedHat.yaml
Normal 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
|
15
roles/install-yarn/tasks/main.yaml
Normal file
15
roles/install-yarn/tasks/main.yaml
Normal 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
|
11
roles/install-yarn/tasks/yarn.yaml
Normal file
11
roles/install-yarn/tasks/yarn.yaml
Normal 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
|
Loading…
Reference in New Issue
Block a user