mirror of https://github.com/ansible/ansible.git
Always allow "no-other-choice" pre-release dependencies when resolving collection dependency tree
PR #81606.
Prior to this patch, when `--pre` CLI flag was not passed, the
dependency resolver would treat concrete collection dependency
candidates (Git repositories, subdirs, tarball URLs, or local dirs or
files etc) as not meeting the requirements.
This patch makes it so pre-releases in any concrete artifact
references, and the ones being specifically pinned dependencies or
user requests, met anywhere in the dependency tree, are allowed
unconditionally.
This is achieved by moving the pre-release check from
`is_satisfied_by()` to the `find_matches()` hook, following the
Pip's example.
As a bonus, this change also fixes the situation when a collection
pre-releases weren't considered if it didn't have any stable releases.
This now works even if `--pre` wasn't requested explicitly.
Finally, this patch partially reverts commit
6f4b4c345b
, except for the tests. And it
also improves the `--pre` hint warning to explain that it mostly
affects Galaxy/Automation Hub-hosted collection releases.
Ref #73416
Ref #79112
Fixes #79168
Fixes #80048
Resolves #81605
Co-authored-by: Sloane Hertel <19572925+s-hertel@users.noreply.github.com>
pull/81738/head
parent
4b7705b07a
commit
7662a05085
@ -0,0 +1,16 @@
|
||||
---
|
||||
|
||||
bugfixes:
|
||||
- >-
|
||||
ansible-galaxy - started allowing the use of pre-releases
|
||||
for dependencies on any level of the dependency tree that
|
||||
specifically demand exact pre-release versions of
|
||||
collections and not version ranges.
|
||||
(https://github.com/ansible/ansible/pull/81606)
|
||||
- >-
|
||||
ansible-galaxy - started allowing the use of pre-releases
|
||||
for collections that do not have any stable versions
|
||||
published.
|
||||
(https://github.com/ansible/ansible/pull/81606)
|
||||
|
||||
...
|
@ -0,0 +1,79 @@
|
||||
---
|
||||
|
||||
- name: >-
|
||||
test that the dependency resolver chooses pre-releases if they are pinned
|
||||
environment:
|
||||
ANSIBLE_COLLECTIONS_PATH: '{{ galaxy_dir }}'
|
||||
ANSIBLE_CONFIG: '{{ galaxy_dir }}/ansible.cfg'
|
||||
block:
|
||||
- name: reset installation directory
|
||||
file:
|
||||
state: "{{ item }}"
|
||||
path: "{{ galaxy_dir }}/ansible_collections"
|
||||
loop:
|
||||
- absent
|
||||
- directory
|
||||
|
||||
- name: >-
|
||||
install collections with pre-release versions in the dependency tree
|
||||
command: >-
|
||||
ansible-galaxy collection install
|
||||
meta_ns_with_transitive_wildcard_dep.meta_name_with_transitive_wildcard_dep
|
||||
rc_meta_ns_with_transitive_dev_dep.rc_meta_name_with_transitive_dev_dep:=2.4.5-rc5
|
||||
{{ galaxy_verbosity }}
|
||||
register: prioritize_direct_req
|
||||
- assert:
|
||||
that:
|
||||
- >-
|
||||
"rc_meta_ns_with_transitive_dev_dep.rc_meta_name_with_transitive_dev_dep:2.4.5-rc5 was installed successfully"
|
||||
in prioritize_direct_req.stdout
|
||||
- >-
|
||||
"meta_ns_with_transitive_wildcard_dep.meta_name_with_transitive_wildcard_dep:4.5.6 was installed successfully"
|
||||
in prioritize_direct_req.stdout
|
||||
- >-
|
||||
"ns_with_dev_dep.name_with_dev_dep:6.7.8 was installed successfully"
|
||||
in prioritize_direct_req.stdout
|
||||
- >-
|
||||
"ns_with_wildcard_dep.name_with_wildcard_dep:5.6.7-beta.3 was installed successfully"
|
||||
in prioritize_direct_req.stdout
|
||||
- >-
|
||||
"dev_and_stables_ns.dev_and_stables_name:1.2.3-dev0 was installed successfully"
|
||||
in prioritize_direct_req.stdout
|
||||
|
||||
- name: cleanup
|
||||
file:
|
||||
state: "{{ item }}"
|
||||
path: "{{ galaxy_dir }}/ansible_collections"
|
||||
loop:
|
||||
- absent
|
||||
- directory
|
||||
|
||||
- name: >-
|
||||
install collection that only has pre-release versions published
|
||||
to the index
|
||||
command: >-
|
||||
ansible-galaxy collection install
|
||||
rc_meta_ns_with_transitive_dev_dep.rc_meta_name_with_transitive_dev_dep:*
|
||||
{{ galaxy_verbosity }}
|
||||
register: select_pre_release_if_no_stable
|
||||
- assert:
|
||||
that:
|
||||
- >-
|
||||
"rc_meta_ns_with_transitive_dev_dep.rc_meta_name_with_transitive_dev_dep:2.4.5-rc5 was installed successfully"
|
||||
in select_pre_release_if_no_stable.stdout
|
||||
- >-
|
||||
"ns_with_dev_dep.name_with_dev_dep:6.7.8 was installed successfully"
|
||||
in select_pre_release_if_no_stable.stdout
|
||||
- >-
|
||||
"dev_and_stables_ns.dev_and_stables_name:1.2.3-dev0 was installed successfully"
|
||||
in select_pre_release_if_no_stable.stdout
|
||||
always:
|
||||
- name: cleanup
|
||||
file:
|
||||
state: "{{ item }}"
|
||||
path: "{{ galaxy_dir }}/ansible_collections"
|
||||
loop:
|
||||
- absent
|
||||
- directory
|
||||
|
||||
...
|
@ -0,0 +1,77 @@
|
||||
- environment:
|
||||
ANSIBLE_CONFIG: '{{ galaxy_dir }}/ansible.cfg'
|
||||
vars:
|
||||
scm_path: "{{ galaxy_dir }}/scms"
|
||||
metadata:
|
||||
collection1: |-
|
||||
name: collection1
|
||||
version: "1.0.0"
|
||||
dependencies:
|
||||
test_prereleases.collection2: '*'
|
||||
collection2: |
|
||||
name: collection2
|
||||
version: "1.0.0-dev0"
|
||||
dependencies: {}
|
||||
namespace_boilerplate: |-
|
||||
namespace: test_prereleases
|
||||
readme: README.md
|
||||
authors:
|
||||
- "ansible-core"
|
||||
description: test prerelease priority with virtual collections
|
||||
license:
|
||||
- GPL-2.0-or-later
|
||||
license_file: ''
|
||||
tags: []
|
||||
repository: https://github.com/ansible/ansible
|
||||
documentation: https://github.com/ansible/ansible
|
||||
homepage: https://github.com/ansible/ansible
|
||||
issues: https://github.com/ansible/ansible
|
||||
build_ignore: []
|
||||
block:
|
||||
- name: Initialize git repository
|
||||
command: 'git init {{ scm_path }}/test_prereleases'
|
||||
|
||||
- name: Configure commiter for the repo
|
||||
shell: git config user.email ansible-test@ansible.com && git config user.name ansible-test
|
||||
args:
|
||||
chdir: "{{ scm_path }}/test_prereleases"
|
||||
|
||||
- name: Add collections to the repo
|
||||
file:
|
||||
path: "{{ scm_path }}/test_prereleases/{{ item }}"
|
||||
state: directory
|
||||
loop:
|
||||
- collection1
|
||||
- collection2
|
||||
|
||||
- name: Add collection metadata
|
||||
copy:
|
||||
dest: "{{ scm_path }}/test_prereleases/{{ item }}/galaxy.yml"
|
||||
content: "{{ metadata[item] + '\n' + metadata['namespace_boilerplate'] }}"
|
||||
loop:
|
||||
- collection1
|
||||
- collection2
|
||||
|
||||
- name: Save the changes
|
||||
shell: git add . && git commit -m "Add collections to test installing a git repo directly takes priority over indirect Galaxy dep"
|
||||
args:
|
||||
chdir: '{{ scm_path }}/test_prereleases'
|
||||
|
||||
- name: Validate the dependency also exists on Galaxy before test
|
||||
command: "ansible-galaxy collection install test_prereleases.collection2"
|
||||
register: prereq
|
||||
failed_when: '"test_prereleases.collection2:1.0.0 was installed successfully" not in prereq.stdout'
|
||||
|
||||
- name: Install collections from source
|
||||
command: "ansible-galaxy collection install git+file://{{ scm_path }}/test_prereleases"
|
||||
register: prioritize_direct_req
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- '"test_prereleases.collection2:1.0.0-dev0 was installed successfully" in prioritize_direct_req.stdout'
|
||||
|
||||
always:
|
||||
- name: Clean up test repos
|
||||
file:
|
||||
path: "{{ scm_path }}"
|
||||
state: absent
|
Loading…
Reference in New Issue