summaryrefslogtreecommitdiffstats
path: root/test/integration/targets/ansible-galaxy-collection-scm/tasks
diff options
context:
space:
mode:
Diffstat (limited to 'test/integration/targets/ansible-galaxy-collection-scm/tasks')
-rw-r--r--test/integration/targets/ansible-galaxy-collection-scm/tasks/download.yml48
-rw-r--r--test/integration/targets/ansible-galaxy-collection-scm/tasks/empty_installed_collections.yml7
-rw-r--r--test/integration/targets/ansible-galaxy-collection-scm/tasks/individual_collection_repo.yml18
-rw-r--r--test/integration/targets/ansible-galaxy-collection-scm/tasks/main.yml61
-rw-r--r--test/integration/targets/ansible-galaxy-collection-scm/tasks/multi_collection_repo_all.yml45
-rw-r--r--test/integration/targets/ansible-galaxy-collection-scm/tasks/multi_collection_repo_individual.yml15
-rw-r--r--test/integration/targets/ansible-galaxy-collection-scm/tasks/reinstalling.yml31
-rw-r--r--test/integration/targets/ansible-galaxy-collection-scm/tasks/requirements.yml103
-rw-r--r--test/integration/targets/ansible-galaxy-collection-scm/tasks/scm_dependency.yml29
-rw-r--r--test/integration/targets/ansible-galaxy-collection-scm/tasks/scm_dependency_deduplication.yml92
-rw-r--r--test/integration/targets/ansible-galaxy-collection-scm/tasks/setup.yml19
-rw-r--r--test/integration/targets/ansible-galaxy-collection-scm/tasks/setup_collection_bad_version.yml47
-rw-r--r--test/integration/targets/ansible-galaxy-collection-scm/tasks/setup_multi_collection_repo.yml70
-rw-r--r--test/integration/targets/ansible-galaxy-collection-scm/tasks/setup_recursive_scm_dependency.yml33
-rw-r--r--test/integration/targets/ansible-galaxy-collection-scm/tasks/test_invalid_version.yml58
-rw-r--r--test/integration/targets/ansible-galaxy-collection-scm/tasks/test_manifest_metadata.yml55
-rw-r--r--test/integration/targets/ansible-galaxy-collection-scm/tasks/test_supported_resolvelib_versions.yml25
17 files changed, 756 insertions, 0 deletions
diff --git a/test/integration/targets/ansible-galaxy-collection-scm/tasks/download.yml b/test/integration/targets/ansible-galaxy-collection-scm/tasks/download.yml
new file mode 100644
index 0000000..6b52bd1
--- /dev/null
+++ b/test/integration/targets/ansible-galaxy-collection-scm/tasks/download.yml
@@ -0,0 +1,48 @@
+- name: create test download dir
+ file:
+ path: '{{ galaxy_dir }}/download'
+ state: directory
+
+- name: download a git repository
+ command: >
+ ansible-galaxy collection download
+ git+https://github.com/ansible-collections/amazon.aws.git,37875c5b4ba5bf3cc43e07edf29f3432fd76def5
+ git+https://github.com/AlanCoding/awx.git#awx_collection,750c22a150d04eef1cb625fd4f83cce57949416c
+ --no-deps
+ args:
+ chdir: '{{ galaxy_dir }}/download'
+ register: download_collection
+
+- name: check that the amazon.aws collection was downloaded
+ stat:
+ path: '{{ galaxy_dir }}/download/collections/amazon-aws-1.0.0.tar.gz'
+ register: download_collection_amazon_actual
+
+- name: check that the awx.awx collection was downloaded
+ stat:
+ path: '{{ galaxy_dir }}/download/collections/awx-awx-0.0.1-devel.tar.gz'
+ register: download_collection_awx_actual
+
+- assert:
+ that:
+ - '"Downloading collection ''amazon.aws:1.0.0'' to" in download_collection.stdout'
+ - '"Downloading collection ''awx.awx:0.0.1-devel'' to" in download_collection.stdout'
+ - download_collection_amazon_actual.stat.exists
+ - download_collection_awx_actual.stat.exists
+
+- name: test the downloaded repository can be installed
+ command: 'ansible-galaxy collection install -r requirements.yml --no-deps'
+ args:
+ chdir: '{{ galaxy_dir }}/download/collections/'
+
+- name: list installed collections
+ command: 'ansible-galaxy collection list'
+ register: installed_collections
+
+- assert:
+ that:
+ - "'amazon.aws' in installed_collections.stdout"
+ - "'awx.awx' in installed_collections.stdout"
+
+- include_tasks: ./empty_installed_collections.yml
+ when: cleanup
diff --git a/test/integration/targets/ansible-galaxy-collection-scm/tasks/empty_installed_collections.yml b/test/integration/targets/ansible-galaxy-collection-scm/tasks/empty_installed_collections.yml
new file mode 100644
index 0000000..241107c
--- /dev/null
+++ b/test/integration/targets/ansible-galaxy-collection-scm/tasks/empty_installed_collections.yml
@@ -0,0 +1,7 @@
+- name: delete installed collections
+ file:
+ state: absent
+ path: "{{ item }}"
+ loop:
+ - "{{ install_path }}"
+ - "{{ alt_install_path }}"
diff --git a/test/integration/targets/ansible-galaxy-collection-scm/tasks/individual_collection_repo.yml b/test/integration/targets/ansible-galaxy-collection-scm/tasks/individual_collection_repo.yml
new file mode 100644
index 0000000..e51c3a9
--- /dev/null
+++ b/test/integration/targets/ansible-galaxy-collection-scm/tasks/individual_collection_repo.yml
@@ -0,0 +1,18 @@
+- name: Clone a git repository
+ git:
+ repo: https://github.com/ansible-collections/amazon.aws.git
+ dest: '{{ scm_path }}/amazon.aws/'
+
+- name: install
+ command: 'ansible-galaxy collection install git+file://{{ scm_path }}/amazon.aws/.git --no-deps'
+
+- name: list installed collections
+ command: 'ansible-galaxy collection list'
+ register: installed_collections
+
+- assert:
+ that:
+ - "'amazon.aws' in installed_collections.stdout"
+
+- include_tasks: ./empty_installed_collections.yml
+ when: cleanup
diff --git a/test/integration/targets/ansible-galaxy-collection-scm/tasks/main.yml b/test/integration/targets/ansible-galaxy-collection-scm/tasks/main.yml
new file mode 100644
index 0000000..dab599b
--- /dev/null
+++ b/test/integration/targets/ansible-galaxy-collection-scm/tasks/main.yml
@@ -0,0 +1,61 @@
+---
+- name: set the temp test directory
+ set_fact:
+ galaxy_dir: "{{ remote_tmp_dir }}/galaxy"
+
+- name: Test installing collections from git repositories
+ environment:
+ ANSIBLE_COLLECTIONS_PATHS: "{{ galaxy_dir }}/collections"
+ vars:
+ cleanup: True
+ galaxy_dir: "{{ galaxy_dir }}"
+ block:
+
+ - include_tasks: ./setup.yml
+ - include_tasks: ./requirements.yml
+ - include_tasks: ./individual_collection_repo.yml
+ - include_tasks: ./setup_multi_collection_repo.yml
+ - include_tasks: ./multi_collection_repo_all.yml
+ - include_tasks: ./scm_dependency.yml
+ vars:
+ cleanup: False
+ - include_tasks: ./reinstalling.yml
+ - include_tasks: ./multi_collection_repo_individual.yml
+ - include_tasks: ./setup_recursive_scm_dependency.yml
+ - include_tasks: ./scm_dependency_deduplication.yml
+ - include_tasks: ./test_supported_resolvelib_versions.yml
+ loop: "{{ supported_resolvelib_versions }}"
+ loop_control:
+ loop_var: resolvelib_version
+ - include_tasks: ./download.yml
+ - include_tasks: ./setup_collection_bad_version.yml
+ - include_tasks: ./test_invalid_version.yml
+ - include_tasks: ./test_manifest_metadata.yml
+
+ always:
+
+ - name: Remove the directories for installing collections and git repositories
+ file:
+ path: '{{ item }}'
+ state: absent
+ loop:
+ - "{{ install_path }}"
+ - "{{ alt_install_path }}"
+ - "{{ scm_path }}"
+
+ - name: remove git
+ package:
+ name: git
+ state: absent
+ when: git_install is changed
+
+ # This gets dragged in as a dependency of git on FreeBSD.
+ # We need to remove it too when done.
+ - name: remove python37 if necessary
+ package:
+ name: python37
+ state: absent
+ when:
+ - git_install is changed
+ - ansible_distribution == 'FreeBSD'
+ - ansible_python.version.major == 2
diff --git a/test/integration/targets/ansible-galaxy-collection-scm/tasks/multi_collection_repo_all.yml b/test/integration/targets/ansible-galaxy-collection-scm/tasks/multi_collection_repo_all.yml
new file mode 100644
index 0000000..f22f984
--- /dev/null
+++ b/test/integration/targets/ansible-galaxy-collection-scm/tasks/multi_collection_repo_all.yml
@@ -0,0 +1,45 @@
+- name: Install all collections by default
+ command: 'ansible-galaxy collection install git+file://{{ test_repo_path }}/.git'
+
+- name: list installed collections
+ command: 'ansible-galaxy collection list'
+ register: installed_collections
+
+- assert:
+ that:
+ - "'ansible_test.collection_1' in installed_collections.stdout"
+ - "'ansible_test.collection_2' in installed_collections.stdout"
+
+- name: install from artifact to another path to compare contents
+ command: 'ansible-galaxy collection install {{ artifact_path }} -p {{ alt_install_path }} --no-deps'
+ vars:
+ artifact_path: "{{ galaxy_dir }}/ansible_test-collection_1-1.0.0.tar.gz"
+
+- name: check if the files and folders in build_ignore were respected
+ stat:
+ path: "{{ install_path }}/ansible_test/collection_1/{{ item }}"
+ register: result
+ loop:
+ - foo.txt
+ - foobar/baz.txt
+ - foobar/qux
+
+- assert:
+ that: result.results | map(attribute='stat') | map(attribute='exists') is not any
+
+- name: check that directory with ignored files exists and is empty
+ stat:
+ path: "{{ install_path }}/ansible_test/collection_1/foobar"
+ register: result
+
+- assert:
+ that: result.stat.exists
+
+- name: test that there are no diff installing from a repo vs artifact
+ command: "diff -ur {{ collection_from_artifact }} {{ collection_from_repo }} -x *.json"
+ vars:
+ collection_from_repo: "{{ install_path }}/ansible_test/collection_1"
+ collection_from_artifact: "{{ alt_install_path }}/ansible_test/collection_1"
+
+- include_tasks: ./empty_installed_collections.yml
+ when: cleanup
diff --git a/test/integration/targets/ansible-galaxy-collection-scm/tasks/multi_collection_repo_individual.yml b/test/integration/targets/ansible-galaxy-collection-scm/tasks/multi_collection_repo_individual.yml
new file mode 100644
index 0000000..a5a2bdf
--- /dev/null
+++ b/test/integration/targets/ansible-galaxy-collection-scm/tasks/multi_collection_repo_individual.yml
@@ -0,0 +1,15 @@
+- name: test installing one collection
+ command: 'ansible-galaxy collection install git+file://{{ test_repo_path }}/.git#collection_2'
+
+- name: list installed collections
+ command: 'ansible-galaxy collection list'
+ register: installed_collections
+
+- assert:
+ that:
+ - "'amazon.aws' not in installed_collections.stdout"
+ - "'ansible_test.collection_1' not in installed_collections.stdout"
+ - "'ansible_test.collection_2' in installed_collections.stdout"
+
+- include_tasks: ./empty_installed_collections.yml
+ when: cleanup
diff --git a/test/integration/targets/ansible-galaxy-collection-scm/tasks/reinstalling.yml b/test/integration/targets/ansible-galaxy-collection-scm/tasks/reinstalling.yml
new file mode 100644
index 0000000..90a70e2
--- /dev/null
+++ b/test/integration/targets/ansible-galaxy-collection-scm/tasks/reinstalling.yml
@@ -0,0 +1,31 @@
+- name: Rerun installing a collection with a dep
+ command: 'ansible-galaxy collection install git+file://{{ test_repo_path }}/.git#/collection_1/'
+ register: installed
+
+- name: SCM collections don't have a concrete artifact version so the collection should always be reinstalled
+ assert:
+ that:
+ - "'Created collection for ansible_test.collection_1' in installed.stdout"
+ - "'Created collection for ansible_test.collection_2' in installed.stdout"
+
+- name: The collection should also be reinstalled when --force flag is used
+ command: 'ansible-galaxy collection install git+file://{{ test_repo_path }}/.git#/collection_1/ --force'
+ register: installed
+
+- assert:
+ that:
+ - "'Created collection for ansible_test.collection_1' in installed.stdout"
+ # The dependency is also an SCM collection, so it should also be reinstalled
+ - "'Created collection for ansible_test.collection_2' in installed.stdout"
+
+- name: The collection should also be reinstalled when --force-with-deps is used
+ command: 'ansible-galaxy collection install git+file://{{ test_repo_path }}/.git#/collection_1/ --force-with-deps'
+ register: installed
+
+- assert:
+ that:
+ - "'Created collection for ansible_test.collection_1' in installed.stdout"
+ - "'Created collection for ansible_test.collection_2' in installed.stdout"
+
+- include_tasks: ./empty_installed_collections.yml
+ when: cleanup
diff --git a/test/integration/targets/ansible-galaxy-collection-scm/tasks/requirements.yml b/test/integration/targets/ansible-galaxy-collection-scm/tasks/requirements.yml
new file mode 100644
index 0000000..10070f1
--- /dev/null
+++ b/test/integration/targets/ansible-galaxy-collection-scm/tasks/requirements.yml
@@ -0,0 +1,103 @@
+- name: make a requirements directory
+ file:
+ state: directory
+ path: '{{ galaxy_dir }}/requirements'
+
+- name: populate requirement templates
+ template:
+ src: "{{ item }}"
+ dest: "{{ galaxy_dir }}/requirements/{{ item }}"
+ loop:
+ - source_only.yml
+ - source_and_name.yml
+ - source_and_name_and_type.yml
+ - name_without_type.yml
+ - git_prefix_name.yml
+ - name_and_type.yml
+
+- name: test source is not a git repo
+ command: 'ansible-galaxy collection install -r source_only.yml'
+ register: result
+ ignore_errors: true
+ args:
+ chdir: '{{ galaxy_dir }}/requirements'
+
+- assert:
+ that:
+ - result.failed
+ - >-
+ "ERROR! Neither the collection requirement entry key 'name',
+ nor 'source' point to a concrete resolvable collection artifact.
+ Also 'name' is not an FQCN. A valid collection name must be in
+ the format <namespace>.<collection>. Please make sure that the
+ namespace and the collection name contain characters from
+ [a-zA-Z0-9_] only." in result.stderr
+
+- name: test source is not a git repo even if name is provided
+ command: 'ansible-galaxy collection install -r source_and_name.yml'
+ register: result
+ ignore_errors: true
+ args:
+ chdir: '{{ galaxy_dir }}/requirements'
+
+- assert:
+ that:
+ - result.failed
+ - >-
+ result.stderr is search("ERROR! Collections requirement 'source'
+ entry should contain a valid Galaxy API URL but it does not:
+ git\+file:///.*/amazon.aws/.git is not an HTTP URL.")
+
+- name: test source is not a git repo even if name and type is provided
+ command: 'ansible-galaxy collection install -r source_and_name_and_type.yml'
+ register: result
+ ignore_errors: true
+ args:
+ chdir: '{{ galaxy_dir }}/requirements'
+
+- assert:
+ that:
+ - result.failed
+ - >-
+ result.stderr is search("ERROR! Failed to clone a Git repository
+ from `file:///.*/.git`.")
+ - >-
+ result.stderr is search("fatal: '/.*/amazon.aws/.git' does not
+ appear to be a git repository")
+
+- name: test using name as a git repo without git+ prefix
+ command: 'ansible-galaxy collection install -r name_without_type.yml --no-deps'
+ register: result
+ ignore_errors: true
+ args:
+ chdir: '{{ galaxy_dir }}/requirements'
+
+- assert:
+ that:
+ - result.failed
+ - '"name must be in the format <namespace>.<collection>" in result.stderr'
+
+- name: Clone a git repository
+ git:
+ repo: https://github.com/ansible-collections/amazon.aws.git
+ dest: '{{ scm_path }}/amazon.aws/'
+
+- name: test using name as a git repo
+ command: 'ansible-galaxy collection install -r git_prefix_name.yml --no-deps'
+ register: result
+ args:
+ chdir: '{{ galaxy_dir }}/requirements'
+
+- name: test using name plus type as a git repo
+ command: 'ansible-galaxy collection install -r name_and_type.yml --force --no-deps'
+ register: result
+ args:
+ chdir: '{{ galaxy_dir }}/requirements'
+
+- name: remove the test repo and requirements dir
+ file:
+ path: '{{ item }}'
+ state: absent
+ loop:
+ - '{{ scm_path }}/amazon.aws/'
+ - '{{ galaxy_dir }}/requirements'
diff --git a/test/integration/targets/ansible-galaxy-collection-scm/tasks/scm_dependency.yml b/test/integration/targets/ansible-galaxy-collection-scm/tasks/scm_dependency.yml
new file mode 100644
index 0000000..5645aec
--- /dev/null
+++ b/test/integration/targets/ansible-galaxy-collection-scm/tasks/scm_dependency.yml
@@ -0,0 +1,29 @@
+- name: test installing one collection that has a SCM dep with --no-deps
+ command: 'ansible-galaxy collection install git+file://{{ test_repo_path }}/.git#/collection_1/ --no-deps'
+
+- name: list installed collections
+ command: 'ansible-galaxy collection list'
+ register: installed_collections
+
+- assert:
+ that:
+ - "'ansible_test.collection_1' in installed_collections.stdout"
+ - "'ansible_test.collection_2' not in installed_collections.stdout"
+
+- name: remove collections to test installing with the dependency
+ include_tasks: ./empty_installed_collections.yml
+
+- name: test installing one collection that has a SCM dep
+ command: 'ansible-galaxy collection install git+file://{{ test_repo_path }}/.git#/collection_1/'
+
+- name: list installed collections
+ command: 'ansible-galaxy collection list'
+ register: installed_collections
+
+- assert:
+ that:
+ - "'ansible_test.collection_1' in installed_collections.stdout"
+ - "'ansible_test.collection_2' in installed_collections.stdout"
+
+- include_tasks: ./empty_installed_collections.yml
+ when: cleanup
diff --git a/test/integration/targets/ansible-galaxy-collection-scm/tasks/scm_dependency_deduplication.yml b/test/integration/targets/ansible-galaxy-collection-scm/tasks/scm_dependency_deduplication.yml
new file mode 100644
index 0000000..f200be1
--- /dev/null
+++ b/test/integration/targets/ansible-galaxy-collection-scm/tasks/scm_dependency_deduplication.yml
@@ -0,0 +1,92 @@
+- name: Install all collections in a repo, one of which has a recursive dependency
+ command: 'ansible-galaxy collection install git+file://{{ scm_path }}/namespace_1/.git'
+ register: command
+
+- assert:
+ that:
+ - command.stdout_lines | length == 12
+ - >-
+ 'Starting galaxy collection install process'
+ in command.stdout_lines
+ - >-
+ 'Starting collection install process'
+ in command.stdout_lines
+ - >-
+ "Installing 'namespace_1.collection_1:1.0.0' to
+ '{{ install_path }}/namespace_1/collection_1'"
+ in command.stdout_lines
+ - >-
+ 'Created collection for namespace_1.collection_1:1.0.0 at
+ {{ install_path }}/namespace_1/collection_1'
+ in command.stdout_lines
+ - >-
+ 'namespace_1.collection_1:1.0.0 was installed successfully'
+ in command.stdout_lines
+ - >-
+ "Installing 'namespace_2.collection_2:1.0.0' to
+ '{{ install_path }}/namespace_2/collection_2'"
+ in command.stdout_lines
+ - >-
+ 'Created collection for namespace_2.collection_2:1.0.0 at
+ {{ install_path }}/namespace_2/collection_2'
+ in command.stdout_lines
+ - >-
+ 'namespace_2.collection_2:1.0.0 was installed successfully'
+ in command.stdout_lines
+
+- name: list installed collections
+ command: 'ansible-galaxy collection list'
+ register: installed_collections
+
+- assert:
+ that:
+ - "'namespace_1.collection_1' in installed_collections.stdout"
+ - "'namespace_2.collection_2' in installed_collections.stdout"
+
+- name: Install a specific collection in a repo with a recursive dependency
+ command: 'ansible-galaxy collection install git+file://{{ scm_path }}/namespace_1/.git#/collection_1/ --force-with-deps'
+ register: command
+
+- assert:
+ that:
+ - command.stdout_lines | length == 12
+ - >-
+ 'Starting galaxy collection install process'
+ in command.stdout_lines
+ - >-
+ 'Starting collection install process'
+ in command.stdout_lines
+ - >-
+ "Installing 'namespace_1.collection_1:1.0.0' to
+ '{{ install_path }}/namespace_1/collection_1'"
+ in command.stdout_lines
+ - >-
+ 'Created collection for namespace_1.collection_1:1.0.0 at
+ {{ install_path }}/namespace_1/collection_1'
+ in command.stdout_lines
+ - >-
+ 'namespace_1.collection_1:1.0.0 was installed successfully'
+ in command.stdout_lines
+ - >-
+ "Installing 'namespace_2.collection_2:1.0.0' to
+ '{{ install_path }}/namespace_2/collection_2'"
+ in command.stdout_lines
+ - >-
+ 'Created collection for namespace_2.collection_2:1.0.0 at
+ {{ install_path }}/namespace_2/collection_2'
+ in command.stdout_lines
+ - >-
+ 'namespace_2.collection_2:1.0.0 was installed successfully'
+ in command.stdout_lines
+
+- name: list installed collections
+ command: 'ansible-galaxy collection list'
+ register: installed_collections
+
+- assert:
+ that:
+ - "'namespace_1.collection_1' in installed_collections.stdout"
+ - "'namespace_2.collection_2' in installed_collections.stdout"
+
+- include_tasks: ./empty_installed_collections.yml
+ when: cleanup
diff --git a/test/integration/targets/ansible-galaxy-collection-scm/tasks/setup.yml b/test/integration/targets/ansible-galaxy-collection-scm/tasks/setup.yml
new file mode 100644
index 0000000..bb882c9
--- /dev/null
+++ b/test/integration/targets/ansible-galaxy-collection-scm/tasks/setup.yml
@@ -0,0 +1,19 @@
+- name: ensure git is installed
+ package:
+ name: git
+ when: ansible_distribution not in ["MacOSX", "Alpine"]
+ register: git_install
+
+- name: set git global user.email if not already set
+ shell: git config --global user.email || git config --global user.email "noreply@example.com"
+
+- name: set git global user.name if not already set
+ shell: git config --global user.name || git config --global user.name "Ansible Test Runner"
+
+- name: Create a directory for installing collections and creating git repositories
+ file:
+ path: '{{ item }}'
+ state: directory
+ loop:
+ - '{{ install_path }}'
+ - '{{ test_repo_path }}'
diff --git a/test/integration/targets/ansible-galaxy-collection-scm/tasks/setup_collection_bad_version.yml b/test/integration/targets/ansible-galaxy-collection-scm/tasks/setup_collection_bad_version.yml
new file mode 100644
index 0000000..0ef406e
--- /dev/null
+++ b/test/integration/targets/ansible-galaxy-collection-scm/tasks/setup_collection_bad_version.yml
@@ -0,0 +1,47 @@
+- name: Initialize a git repo
+ command: 'git init {{ test_error_repo_path }}'
+
+- stat:
+ path: "{{ test_error_repo_path }}"
+
+- name: Add a collection to the repository
+ command: 'ansible-galaxy collection init {{ item }}'
+ args:
+ chdir: '{{ scm_path }}'
+ loop:
+ - error_test.float_version_collection
+ - error_test.not_semantic_version_collection
+ - error_test.list_version_collection
+ - error_test.dict_version_collection
+
+- name: Add an invalid float version to a collection
+ lineinfile:
+ path: '{{ test_error_repo_path }}/float_version_collection/galaxy.yml'
+ regexp: '^version'
+ line: "version: 1.0" # Version is a float, not a string as expected
+
+- name: Add an invalid non-semantic string version a collection
+ lineinfile:
+ path: '{{ test_error_repo_path }}/not_semantic_version_collection/galaxy.yml'
+ regexp: '^version'
+ line: "version: '1.0'" # Version is a string, but not a semantic version as expected
+
+- name: Add an invalid list version to a collection
+ lineinfile:
+ path: '{{ test_error_repo_path }}/list_version_collection/galaxy.yml'
+ regexp: '^version'
+ line: "version: ['1.0.0']" # Version is a list, not a string as expected
+
+- name: Add an invalid version to a collection
+ lineinfile:
+ path: '{{ test_error_repo_path }}/dict_version_collection/galaxy.yml'
+ regexp: '^version'
+ line: "version: {'broken': 'version'}" # Version is a dict, not a string as expected
+
+- name: Commit the changes
+ command: '{{ item }}'
+ args:
+ chdir: '{{ test_error_repo_path }}'
+ loop:
+ - git add ./
+ - git commit -m 'add collections'
diff --git a/test/integration/targets/ansible-galaxy-collection-scm/tasks/setup_multi_collection_repo.yml b/test/integration/targets/ansible-galaxy-collection-scm/tasks/setup_multi_collection_repo.yml
new file mode 100644
index 0000000..e733a84
--- /dev/null
+++ b/test/integration/targets/ansible-galaxy-collection-scm/tasks/setup_multi_collection_repo.yml
@@ -0,0 +1,70 @@
+- name: Initialize a git repo
+ command: 'git init {{ test_repo_path }}'
+
+- stat:
+ path: "{{ test_repo_path }}"
+
+- name: Add a couple collections to the repository
+ command: 'ansible-galaxy collection init {{ item }}'
+ args:
+ chdir: '{{ scm_path }}'
+ loop:
+ - 'ansible_test.collection_1'
+ - 'ansible_test.collection_2'
+
+- name: Preserve the (empty) docs directory for the SCM collection
+ file:
+ path: '{{ test_repo_path }}/{{ item }}/docs/README.md'
+ state: touch
+ loop:
+ - collection_1
+ - collection_2
+
+- name: Preserve the (empty) roles directory for the SCM collection
+ file:
+ path: '{{ test_repo_path }}/{{ item }}/roles/README.md'
+ state: touch
+ loop:
+ - collection_1
+ - collection_2
+
+- name: create extra files and folders to test build_ignore
+ file:
+ path: '{{ test_repo_path }}/collection_1/{{ item.name }}'
+ state: '{{ item.state }}'
+ loop:
+ - name: foo.txt
+ state: touch
+ - name: foobar
+ state: directory
+ - name: foobar/qux
+ state: directory
+ - name: foobar/qux/bar
+ state: touch
+ - name: foobar/baz.txt
+ state: touch
+
+- name: Add collection_2 as a dependency of collection_1
+ lineinfile:
+ path: '{{ test_repo_path }}/collection_1/galaxy.yml'
+ regexp: '^dependencies'
+ line: "dependencies: {'git+file://{{ test_repo_path }}/.git#collection_2/': '*'}"
+
+- name: Ignore a directory and files
+ lineinfile:
+ path: '{{ test_repo_path }}/collection_1/galaxy.yml'
+ regexp: '^build_ignore'
+ line: "build_ignore: ['foo.txt', 'foobar/*']"
+
+- name: Commit the changes
+ command: '{{ item }}'
+ args:
+ chdir: '{{ test_repo_path }}'
+ loop:
+ - git add ./
+ - git commit -m 'add collections'
+
+- name: Build the actual artifact for ansible_test.collection_1 for comparison
+ command: "ansible-galaxy collection build ansible_test/collection_1 --output-path {{ galaxy_dir }}"
+ args:
+ chdir: "{{ scm_path }}"
diff --git a/test/integration/targets/ansible-galaxy-collection-scm/tasks/setup_recursive_scm_dependency.yml b/test/integration/targets/ansible-galaxy-collection-scm/tasks/setup_recursive_scm_dependency.yml
new file mode 100644
index 0000000..dd307d7
--- /dev/null
+++ b/test/integration/targets/ansible-galaxy-collection-scm/tasks/setup_recursive_scm_dependency.yml
@@ -0,0 +1,33 @@
+- name: Initialize git repositories
+ command: 'git init {{ scm_path }}/{{ item }}'
+ loop:
+ - namespace_1
+ - namespace_2
+
+- name: Add a couple collections to the repository
+ command: 'ansible-galaxy collection init {{ item }}'
+ args:
+ chdir: '{{ scm_path }}'
+ loop:
+ - 'namespace_1.collection_1'
+ - 'namespace_2.collection_2'
+
+- name: Add collection_2 as a dependency of collection_1
+ lineinfile:
+ path: '{{ scm_path }}/namespace_1/collection_1/galaxy.yml'
+ regexp: '^dependencies'
+ line: "dependencies: {'git+file://{{ scm_path }}/namespace_2/.git#collection_2/': '*'}"
+
+- name: Add collection_1 as a dependency on collection_2
+ lineinfile:
+ path: '{{ scm_path }}/namespace_2/collection_2/galaxy.yml'
+ regexp: '^dependencies'
+ line: "dependencies: {'git+file://{{ scm_path }}/namespace_1/.git#collection_1/': 'master'}"
+
+- name: Commit the changes
+ shell: git add ./; git commit -m 'add collection'
+ args:
+ chdir: '{{ scm_path }}/{{ item }}'
+ loop:
+ - namespace_1
+ - namespace_2
diff --git a/test/integration/targets/ansible-galaxy-collection-scm/tasks/test_invalid_version.yml b/test/integration/targets/ansible-galaxy-collection-scm/tasks/test_invalid_version.yml
new file mode 100644
index 0000000..1f22bb8
--- /dev/null
+++ b/test/integration/targets/ansible-galaxy-collection-scm/tasks/test_invalid_version.yml
@@ -0,0 +1,58 @@
+- block:
+ - name: test installing a collection with an invalid float version value
+ command: 'ansible-galaxy collection install git+file://{{ test_error_repo_path }}/.git#float_version_collection -vvvvvv'
+ ignore_errors: yes
+ register: invalid_version_result
+
+ - assert:
+ that:
+ - invalid_version_result is failed
+ - msg in invalid_version_result.stderr
+ vars:
+ req: error_test.float_version_collection:1.0
+ ver: "1.0 (<class 'float'>)"
+ msg: "Invalid version found for the collection '{{ req }}': {{ ver }}. A SemVer-compliant version or '*' is required."
+
+ - name: test installing a collection with an invalid non-SemVer string version value
+ command: 'ansible-galaxy collection install git+file://{{ test_error_repo_path }}/.git#not_semantic_version_collection -vvvvvv'
+ ignore_errors: yes
+ register: invalid_version_result
+
+ - assert:
+ that:
+ - invalid_version_result is failed
+ - msg in invalid_version_result.stderr
+ vars:
+ req: error_test.not_semantic_version_collection:1.0
+ ver: "1.0 (<class 'str'>)"
+ msg: "Invalid version found for the collection '{{ req }}': {{ ver }}. A SemVer-compliant version or '*' is required."
+
+ - name: test installing a collection with an invalid list version value
+ command: 'ansible-galaxy collection install git+file://{{ test_error_repo_path }}/.git#list_version_collection -vvvvvv'
+ ignore_errors: yes
+ register: invalid_version_result
+
+ - assert:
+ that:
+ - invalid_version_result is failed
+ - msg in invalid_version_result.stderr
+ vars:
+ req: "error_test.list_version_collection:['1.0.0']"
+ msg: "Invalid version found for the collection '{{ req }}'. A SemVer-compliant version or '*' is required."
+
+ - name: test installing a collection with an invalid dict version value
+ command: 'ansible-galaxy collection install git+file://{{ test_error_repo_path }}/.git#dict_version_collection -vvvvvv'
+ ignore_errors: yes
+ register: invalid_version_result
+
+ - assert:
+ that:
+ - invalid_version_result is failed
+ - msg in invalid_version_result.stderr
+ vars:
+ req: "error_test.dict_version_collection:{'broken': 'version'}"
+ msg: "Invalid version found for the collection '{{ req }}'. A SemVer-compliant version or '*' is required."
+
+ always:
+ - include_tasks: ./empty_installed_collections.yml
+ when: cleanup
diff --git a/test/integration/targets/ansible-galaxy-collection-scm/tasks/test_manifest_metadata.yml b/test/integration/targets/ansible-galaxy-collection-scm/tasks/test_manifest_metadata.yml
new file mode 100644
index 0000000..a01551c
--- /dev/null
+++ b/test/integration/targets/ansible-galaxy-collection-scm/tasks/test_manifest_metadata.yml
@@ -0,0 +1,55 @@
+- name: Test installing a collection from a git repo containing a MANIFEST.json
+ block:
+ - name: Create a temp directory for building the collection
+ file:
+ path: '{{ galaxy_dir }}/scratch'
+ state: directory
+
+ - name: Initialize a collection
+ command: 'ansible-galaxy collection init namespace_3.collection_1'
+ args:
+ chdir: '{{ galaxy_dir }}/scratch'
+
+ - name: Build the collection
+ command: 'ansible-galaxy collection build namespace_3/collection_1'
+ args:
+ chdir: '{{ galaxy_dir }}/scratch'
+
+ - name: Initialize git repository
+ command: 'git init {{ scm_path }}/namespace_3'
+
+ - name: Create the destination for the collection
+ file:
+ path: '{{ scm_path }}/namespace_3/collection_1'
+ state: directory
+
+ - name: Unarchive the collection in the git repo
+ unarchive:
+ dest: '{{ scm_path }}/namespace_3/collection_1'
+ src: '{{ galaxy_dir }}/scratch/namespace_3-collection_1-1.0.0.tar.gz'
+ remote_src: yes
+
+ - name: Commit the changes
+ shell: git add ./; git commit -m 'add collection'
+ args:
+ chdir: '{{ scm_path }}/namespace_3'
+
+ - name: Install the collection in the git repository
+ command: 'ansible-galaxy collection install git+file://{{ scm_path }}/namespace_3/.git'
+ register: result
+
+ - name: Assert the collection was installed successfully
+ assert:
+ that:
+ - '"namespace_3.collection_1:1.0.0 was installed successfully" in result.stdout_lines'
+
+ always:
+ - name: Clean up directories from test
+ file:
+ path: '{{ galaxy_dir }}/scratch'
+ state: absent
+ loop:
+ - '{{ galaxy_dir }}/scratch'
+ - '{{ scm_path }}/namespace_3'
+
+ - include_tasks: ./empty_installed_collections.yml
diff --git a/test/integration/targets/ansible-galaxy-collection-scm/tasks/test_supported_resolvelib_versions.yml b/test/integration/targets/ansible-galaxy-collection-scm/tasks/test_supported_resolvelib_versions.yml
new file mode 100644
index 0000000..029cbb3
--- /dev/null
+++ b/test/integration/targets/ansible-galaxy-collection-scm/tasks/test_supported_resolvelib_versions.yml
@@ -0,0 +1,25 @@
+- vars:
+ venv_cmd: "{{ ansible_python_interpreter ~ ' -m venv' }}"
+ venv_dest: "{{ galaxy_dir }}/test_venv_{{ resolvelib_version }}"
+ block:
+ - name: install another version of resolvelib that is supported by ansible-galaxy
+ pip:
+ name: resolvelib
+ version: "{{ resolvelib_version }}"
+ state: present
+ virtualenv_command: "{{ venv_cmd }}"
+ virtualenv: "{{ venv_dest }}"
+ virtualenv_site_packages: True
+
+ - include_tasks: ./scm_dependency_deduplication.yml
+ args:
+ apply:
+ environment:
+ PATH: "{{ venv_dest }}/bin:{{ ansible_env.PATH }}"
+ ANSIBLE_CONFIG: '{{ galaxy_dir }}/ansible.cfg'
+
+ always:
+ - name: remove test venv
+ file:
+ path: "{{ venv_dest }}"
+ state: absent