Add a yarn role

Projects using yarn for dependencies can just run yarn commands instead
of npm commands. Add a yarn role that allows a project to do that.

Change-Id: I48a722ca55c88c6330114da3a2c035b1f84f92e1
This commit is contained in:
Monty Taylor 2018-07-27 09:34:22 -04:00
parent 3535aa0e43
commit 98aa9f9bb0
No known key found for this signature in database
GPG Key ID: 7BAE94BC7141A594
4 changed files with 49 additions and 0 deletions

15
roles/yarn/README.rst Normal file
View File

@ -0,0 +1,15 @@
Run yarn command in a source directory. Assumes the appropriate version
of yarn has been installed.
**Role Variables**
.. zuul:rolevar:: yarn_command
Command to run. If it's a standard lifecycle command, it will be run as
``yarn {{ yarn_command }}``. Otherwise it will be run as
``yarn run {{ yarn_command }}``.
.. zuul:rolevar:: zuul_work_dir
:default: {{ zuul.project.src_dir }}
Directory to run yarn in.

View File

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

View File

@ -0,0 +1,24 @@
- name: Require yarn_command variable
fail:
msg: yarn_command is required for this role
when: yarn_command is not defined
- name: Run yarn lifecycle command
when: yarn_command in yarn_lifecycle_phases
command: "yarn {{ yarn_command }} --verbose"
# Need to set DISPLAY to the value that will be set when the virtual
# framebuffer is set up for doing browser tests.
environment:
DISPLAY: ':99'
args:
chdir: "{{ zuul_work_dir }}"
- name: Run yarn custom command
when: yarn_command not in yarn_lifecycle_phases
command: "yarn run {{ yarn_command }} --verbose"
# Need to set DISPLAY to the value that will be set when the virtual
# framebuffer is set up for doing browser tests.
environment:
DISPLAY: ':99'
args:
chdir: "{{ zuul_work_dir }}"

View File

@ -0,0 +1,9 @@
yarn_lifecycle_phases:
- install
- pack
- publish
- restart
- start
- stop
- test
- version