add collections
This commit is contained in:
@@ -0,0 +1,8 @@
|
||||
# Copyright (c) Ansible Project
|
||||
# GNU General Public License v3.0+ (see LICENSES/GPL-3.0-or-later.txt or https://www.gnu.org/licenses/gpl-3.0.txt)
|
||||
# SPDX-License-Identifier: GPL-3.0-or-later
|
||||
|
||||
azp/posix/1
|
||||
destructive
|
||||
skip/aix
|
||||
skip/freebsd
|
||||
@@ -0,0 +1,9 @@
|
||||
---
|
||||
# Copyright (c) Ansible Project
|
||||
# GNU General Public License v3.0+ (see LICENSES/GPL-3.0-or-later.txt or https://www.gnu.org/licenses/gpl-3.0.txt)
|
||||
# SPDX-License-Identifier: GPL-3.0-or-later
|
||||
|
||||
dependencies:
|
||||
- setup_pkg_mgr
|
||||
- setup_gnutar
|
||||
- setup_remote_tmp_dir
|
||||
@@ -0,0 +1,23 @@
|
||||
---
|
||||
####################################################################
|
||||
# WARNING: These are designed specifically for Ansible tests #
|
||||
# and should not be used as examples of how to write Ansible roles #
|
||||
####################################################################
|
||||
|
||||
# Yarn package manager integration tests
|
||||
# Copyright (c) 2018 David Gunter, <david.gunter@tivix.com>
|
||||
# GNU General Public License v3.0+ (see LICENSES/GPL-3.0-or-later.txt or https://www.gnu.org/licenses/gpl-3.0.txt)
|
||||
# SPDX-License-Identifier: GPL-3.0-or-later
|
||||
|
||||
# ============================================================
|
||||
|
||||
- include: run.yml
|
||||
vars:
|
||||
nodejs_version: '{{ item.node_version }}'
|
||||
nodejs_path: 'node-v{{ nodejs_version }}-{{ ansible_system|lower }}-x{{ ansible_userspace_bits }}'
|
||||
yarn_version: '{{ item.yarn_version }}'
|
||||
with_items:
|
||||
- {node_version: 4.8.0, yarn_version: 1.6.0} # Lowest compatible nodejs version
|
||||
- {node_version: 8.0.0, yarn_version: 1.6.0}
|
||||
when:
|
||||
- not (ansible_os_family == 'Alpine') # TODO
|
||||
@@ -0,0 +1,137 @@
|
||||
---
|
||||
# Copyright (c) Ansible Project
|
||||
# GNU General Public License v3.0+ (see LICENSES/GPL-3.0-or-later.txt or https://www.gnu.org/licenses/gpl-3.0.txt)
|
||||
# SPDX-License-Identifier: GPL-3.0-or-later
|
||||
|
||||
- name: 'Create directory for Node'
|
||||
file:
|
||||
path: /usr/local/lib/nodejs
|
||||
state: directory
|
||||
|
||||
- name: 'Download Nodejs'
|
||||
unarchive:
|
||||
src: 'https://ansible-ci-files.s3.amazonaws.com/test/integration/targets/yarn/{{ nodejs_path }}.tar.gz'
|
||||
dest: '{{ remote_tmp_dir }}'
|
||||
remote_src: yes
|
||||
creates: '{{ remote_tmp_dir }}/{{ nodejs_path }}.tar.gz'
|
||||
|
||||
- name: 'Download Yarn'
|
||||
unarchive:
|
||||
src: 'https://ansible-ci-files.s3.amazonaws.com/test/integration/targets/yarn/yarn-v{{yarn_version}}.tar.gz'
|
||||
dest: '{{ remote_tmp_dir }}'
|
||||
remote_src: yes
|
||||
creates: '{{ remote_tmp_dir }}/yarn-v{{yarn_version}}_pkg.tar.gz'
|
||||
|
||||
- name: 'Copy node to directory created earlier'
|
||||
command: "mv {{ remote_tmp_dir }}/{{ nodejs_path }} /usr/local/lib/nodejs/{{nodejs_path}}"
|
||||
|
||||
# Clean up before running tests
|
||||
- name: Remove any previous Nodejs modules
|
||||
file:
|
||||
path: '{{remote_tmp_dir}}/node_modules'
|
||||
state: absent
|
||||
|
||||
# Set vars for our test harness
|
||||
- vars:
|
||||
#node_bin_path: "/usr/local/lib/nodejs/node-v{{nodejs_version}}/bin"
|
||||
node_bin_path: "/usr/local/lib/nodejs/{{ nodejs_path }}/bin"
|
||||
yarn_bin_path: "{{ remote_tmp_dir }}/yarn-v{{ yarn_version }}/bin"
|
||||
package: 'iconv-lite'
|
||||
environment:
|
||||
PATH: "{{ node_bin_path }}:{{ansible_env.PATH}}"
|
||||
block:
|
||||
|
||||
# Get the version of Yarn and register to a variable
|
||||
- shell: '{{ yarn_bin_path }}/yarn --version'
|
||||
environment:
|
||||
PATH: '{{ node_bin_path }}:{{ ansible_env.PATH }}'
|
||||
register: yarn_version
|
||||
|
||||
- name: 'Create dummy package.json'
|
||||
template:
|
||||
src: package.j2
|
||||
dest: '{{ remote_tmp_dir }}/package.json'
|
||||
|
||||
- name: 'Install all packages.'
|
||||
yarn:
|
||||
path: '{{ remote_tmp_dir }}'
|
||||
executable: '{{ yarn_bin_path }}/yarn'
|
||||
state: present
|
||||
environment:
|
||||
PATH: '{{ node_bin_path }}:{{ ansible_env.PATH }}'
|
||||
|
||||
- name: 'Install the same package from package.json again.'
|
||||
yarn:
|
||||
path: '{{ remote_tmp_dir }}'
|
||||
executable: '{{ yarn_bin_path }}/yarn'
|
||||
name: '{{ package }}'
|
||||
state: present
|
||||
environment:
|
||||
PATH: '{{ node_bin_path }}:{{ ansible_env.PATH }}'
|
||||
register: yarn_install
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- not (yarn_install is changed)
|
||||
|
||||
- name: 'Install all packages in check mode.'
|
||||
yarn:
|
||||
path: '{{ remote_tmp_dir }}'
|
||||
executable: '{{ yarn_bin_path }}/yarn'
|
||||
state: present
|
||||
environment:
|
||||
PATH: '{{ node_bin_path }}:{{ ansible_env.PATH }}'
|
||||
check_mode: true
|
||||
register: yarn_install_check
|
||||
|
||||
- name: verify test yarn global installation in check mode
|
||||
assert:
|
||||
that:
|
||||
- yarn_install_check.err is defined
|
||||
- yarn_install_check.out is defined
|
||||
- yarn_install_check.err is none
|
||||
- yarn_install_check.out is none
|
||||
|
||||
- name: 'Install package with explicit version (older version of package)'
|
||||
yarn:
|
||||
path: '{{ remote_tmp_dir }}'
|
||||
executable: '{{ yarn_bin_path }}/yarn'
|
||||
name: left-pad
|
||||
version: 1.1.0
|
||||
state: present
|
||||
environment:
|
||||
PATH: '{{ node_bin_path }}:{{ ansible_env.PATH }}'
|
||||
register: yarn_install_old_package
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- yarn_install_old_package is changed
|
||||
|
||||
- name: 'Upgrade old package'
|
||||
yarn:
|
||||
path: '{{ remote_tmp_dir }}'
|
||||
executable: '{{ yarn_bin_path }}/yarn'
|
||||
name: left-pad
|
||||
state: latest
|
||||
environment:
|
||||
PATH: '{{ node_bin_path }}:{{ ansible_env.PATH }}'
|
||||
register: yarn_update_old_package
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- yarn_update_old_package is changed
|
||||
|
||||
- name: 'Remove a package'
|
||||
yarn:
|
||||
path: '{{ remote_tmp_dir }}'
|
||||
executable: '{{ yarn_bin_path }}/yarn'
|
||||
name: '{{ package }}'
|
||||
state: absent
|
||||
environment:
|
||||
PATH: '{{ node_bin_path }}:{{ ansible_env.PATH }}'
|
||||
register: yarn_uninstall_package
|
||||
|
||||
- name: 'Assert package removed'
|
||||
assert:
|
||||
that:
|
||||
- yarn_uninstall_package is changed
|
||||
@@ -0,0 +1,14 @@
|
||||
{#
|
||||
Copyright (c) Ansible Project
|
||||
GNU General Public License v3.0+ (see LICENSES/GPL-3.0-or-later.txt or https://www.gnu.org/licenses/gpl-3.0.txt)
|
||||
SPDX-License-Identifier: GPL-3.0-or-later
|
||||
#}
|
||||
{
|
||||
"name": "ansible-yarn-testing",
|
||||
"version": "1.0.0",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"iconv-lite": "^0.4.21",
|
||||
"@types/node": "^12.0.0"
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user