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/2
|
||||
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,32 @@
|
||||
---
|
||||
####################################################################
|
||||
# WARNING: These are designed specifically for Ansible tests #
|
||||
# and should not be used as examples of how to write Ansible roles #
|
||||
####################################################################
|
||||
|
||||
# test code for the npm module
|
||||
# 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
|
||||
|
||||
# -------------------------------------------------------------
|
||||
# Setup steps
|
||||
|
||||
- when:
|
||||
- not (ansible_os_family == 'Alpine') # TODO
|
||||
block:
|
||||
|
||||
# expand remote path
|
||||
- command: 'echo {{ remote_tmp_dir }}'
|
||||
register: echo
|
||||
- set_fact:
|
||||
remote_dir: '{{ echo.stdout }}'
|
||||
|
||||
- include_tasks: run.yml
|
||||
vars:
|
||||
nodejs_version: '{{ item }}'
|
||||
nodejs_path: 'node-v{{ nodejs_version }}-{{ ansible_system|lower }}-x{{ ansible_userspace_bits }}'
|
||||
with_items:
|
||||
- 7.10.1 # provides npm 4.2.0 (last npm < 5 released)
|
||||
- 8.0.0 # provides npm 5.0.0
|
||||
- 8.2.0 # provides npm 5.3.0 (output change with this version)
|
||||
@@ -0,0 +1,68 @@
|
||||
---
|
||||
# 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: 'Remove any node modules'
|
||||
file:
|
||||
path: '{{ remote_dir }}/node_modules'
|
||||
state: absent
|
||||
|
||||
- vars:
|
||||
# sample: node-v8.2.0-linux-x64.tar.xz
|
||||
node_path: '{{ remote_dir }}/{{ nodejs_path }}/bin'
|
||||
package: 'ncp'
|
||||
block:
|
||||
- shell: npm --version
|
||||
environment:
|
||||
PATH: '{{ node_path }}:{{ ansible_env.PATH }}'
|
||||
register: npm_version
|
||||
|
||||
- debug:
|
||||
var: npm_version.stdout
|
||||
|
||||
- name: 'Install simple package with no_bin_links disabled'
|
||||
npm:
|
||||
path: '{{ remote_dir }}'
|
||||
executable: '{{ node_path }}/npm'
|
||||
state: present
|
||||
name: '{{ package }}'
|
||||
no_bin_links: false
|
||||
environment:
|
||||
PATH: '{{ node_path }}:{{ ansible_env.PATH }}'
|
||||
register: npm_install_no_bin_links_disabled
|
||||
|
||||
- name: 'Make sure .bin folder has been created'
|
||||
stat:
|
||||
path: "{{ remote_dir }}/node_modules/.bin"
|
||||
register: npm_dotbin_folder_disabled
|
||||
|
||||
- name: 'Remove any node modules'
|
||||
file:
|
||||
path: '{{ remote_dir }}/node_modules'
|
||||
state: absent
|
||||
|
||||
- name: 'Install simple package with no_bin_links enabled'
|
||||
npm:
|
||||
path: '{{ remote_dir }}'
|
||||
executable: '{{ node_path }}/npm'
|
||||
state: present
|
||||
name: '{{ package }}'
|
||||
no_bin_links: true
|
||||
environment:
|
||||
PATH: '{{ node_path }}:{{ ansible_env.PATH }}'
|
||||
register: npm_install_no_bin_links_enabled
|
||||
|
||||
- name: 'Make sure .bin folder has not been created'
|
||||
stat:
|
||||
path: "{{ remote_dir }}/node_modules/.bin"
|
||||
register: npm_dotbin_folder_enabled
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- npm_install_no_bin_links_disabled is success
|
||||
- npm_install_no_bin_links_disabled is changed
|
||||
- npm_install_no_bin_links_enabled is success
|
||||
- npm_install_no_bin_links_enabled is changed
|
||||
- npm_dotbin_folder_disabled.stat.exists
|
||||
- not npm_dotbin_folder_enabled.stat.exists
|
||||
@@ -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
|
||||
|
||||
- include_tasks: setup.yml
|
||||
- include_tasks: test.yml
|
||||
- include_tasks: no_bin_links.yml
|
||||
@@ -0,0 +1,11 @@
|
||||
---
|
||||
# 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: 'Download NPM'
|
||||
unarchive:
|
||||
src: 'https://ansible-ci-files.s3.amazonaws.com/test/integration/targets/npm/{{ nodejs_path }}.tar.gz'
|
||||
dest: '{{ remote_tmp_dir }}'
|
||||
remote_src: yes
|
||||
creates: '{{ remote_tmp_dir }}/{{ nodejs_path }}.tar.gz'
|
||||
@@ -0,0 +1,74 @@
|
||||
---
|
||||
# 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: 'Remove any node modules'
|
||||
file:
|
||||
path: '{{ remote_dir }}/node_modules'
|
||||
state: absent
|
||||
|
||||
- vars:
|
||||
# sample: node-v8.2.0-linux-x64.tar.xz
|
||||
node_path: '{{ remote_dir }}/{{ nodejs_path }}/bin'
|
||||
package: 'iconv-lite'
|
||||
block:
|
||||
- shell: npm --version
|
||||
environment:
|
||||
PATH: '{{ node_path }}:{{ ansible_env.PATH }}'
|
||||
register: npm_version
|
||||
|
||||
- debug:
|
||||
var: npm_version.stdout
|
||||
|
||||
- name: 'Install simple package without dependency'
|
||||
npm:
|
||||
path: '{{ remote_dir }}'
|
||||
executable: '{{ node_path }}/npm'
|
||||
state: present
|
||||
name: '{{ package }}'
|
||||
environment:
|
||||
PATH: '{{ node_path }}:{{ ansible_env.PATH }}'
|
||||
register: npm_install
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- npm_install is success
|
||||
- npm_install is changed
|
||||
|
||||
- name: 'Reinstall simple package without dependency'
|
||||
npm:
|
||||
path: '{{ remote_dir }}'
|
||||
executable: '{{ node_path }}/npm'
|
||||
state: present
|
||||
name: '{{ package }}'
|
||||
environment:
|
||||
PATH: '{{ node_path }}:{{ ansible_env.PATH }}'
|
||||
register: npm_reinstall
|
||||
|
||||
- name: Check there is no change
|
||||
assert:
|
||||
that:
|
||||
- npm_reinstall is success
|
||||
- not (npm_reinstall is changed)
|
||||
|
||||
- name: 'Manually delete package'
|
||||
file:
|
||||
path: '{{ remote_dir }}/node_modules/{{ package }}'
|
||||
state: absent
|
||||
|
||||
- name: 'reinstall simple package'
|
||||
npm:
|
||||
path: '{{ remote_dir }}'
|
||||
executable: '{{ node_path }}/npm'
|
||||
state: present
|
||||
name: '{{ package }}'
|
||||
environment:
|
||||
PATH: '{{ node_path }}:{{ ansible_env.PATH }}'
|
||||
register: npm_fix_install
|
||||
|
||||
- name: Check result is changed and successful
|
||||
assert:
|
||||
that:
|
||||
- npm_fix_install is success
|
||||
- npm_fix_install is changed
|
||||
Reference in New Issue
Block a user