202cce830e
We have a bunch of jobs that are built around the npm role, but for projects using yarn, that can lead to ignoring yarn.lock. For projects with a yarn.lock, we can assume the user wants to use yarn. Make a new js-package-manager role that can detect if that's the case and otherwise use npm. Make an js_build_tool parameter that allows the user to override that auto-detection. Make a whole new suite of jobs that do this behavior, do not have npm in their name, and default to the latest node LTS, version 14. Don't install yarn if we're not going to use yarn. Also allow people who want to use yarn but don't have a yarn.lock to override js_build_tool everywhere we do that logic. Mark the old jobs deprecated. Shift the npm and yarn roles to use the new js-package-manager role with defaults set. Change-Id: I8013228ca05607a69f390a9bb75991fc6543f865
51 lines
1.4 KiB
YAML
51 lines
1.4 KiB
YAML
- name: Check to see if the constraints file exists
|
|
stat:
|
|
path: "{{ tox_constraints_file }}"
|
|
get_checksum: false
|
|
get_mime: false
|
|
get_md5: false
|
|
register: stat_results
|
|
when: tox_constraints_file is defined
|
|
|
|
- name: Fail if constraints file is missing
|
|
when: tox_constraints_file is defined and not stat_results.stat.exists
|
|
fail:
|
|
msg: tox_constraints_file is defined but was not found
|
|
|
|
- name: Record file location
|
|
set_fact:
|
|
tox_constraints_env:
|
|
TOX_CONSTRAINTS_FILE: "{{ tox_constraints_file }}"
|
|
# Backward compatibility, to be removed
|
|
UPPER_CONSTRAINTS_FILE: "{{ tox_constraints_file }}"
|
|
when: tox_constraints_file is defined
|
|
|
|
- name: Check for yarn.lock
|
|
when: js_build_tool is not defined
|
|
stat:
|
|
path: "{{ zuul_work_dir }}/yarn.lock"
|
|
get_checksum: false
|
|
get_mime: false
|
|
get_md5: false
|
|
register: yarn_lock_exists
|
|
|
|
- name: Set js_build_tool fact
|
|
set_fact:
|
|
js_build_tool: '{{ yarn_lock_exists.stat.exists | ternary("yarn", "npm") }}'
|
|
when: js_build_tool is not defined
|
|
|
|
- name: Install yarn dependencies
|
|
command: yarn install
|
|
environment:
|
|
DISPLAY: ':99'
|
|
args:
|
|
chdir: "{{ zuul_work_dir }}"
|
|
when: js_build_tool == 'yarn'
|
|
|
|
- name: Install npm dependencies
|
|
command: npm install --verbose
|
|
environment: "{{ npm_environment|combine(tox_constraints_env|default({})) }}"
|
|
args:
|
|
chdir: "{{ zuul_work_dir }}"
|
|
when: js_build_tool == 'npm'
|