-
Notifications
You must be signed in to change notification settings - Fork 23.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ansible-test does not work with collections installed by galaxy inside a git repository #68499
Comments
Files identified in the description: If these files are incorrect, please update the |
I'm currently dealing with this issue as well. Not sure if it's related to #63032 - is |
I think @sivel mentioned on IRC that he cannot reproduce it. I still get this, though. And I don't have |
Ok, I think I see what the problem is. I installed the collection in a place which is part of a git repository higher up. The problem is that ansible-test first tries to find a Git repository containing the collection, and only if that fails uses the I was able to fix the problem as follows: diff --git a/test/lib/ansible_test/_internal/data.py b/test/lib/ansible_test/_internal/data.py
index 6f8cbf45ca..fefe8fcd9c 100644
--- a/test/lib/ansible_test/_internal/data.py
+++ b/test/lib/ansible_test/_internal/data.py
@@ -121,7 +121,7 @@ class DataContext:
layout_provider = find_path_provider(LayoutProvider, layout_providers, root, walk)
try:
- source_provider = find_path_provider(SourceProvider, source_providers, root, walk)
+ source_provider = find_path_provider(SourceProvider, source_providers, root, walk, True)
except ProviderNotFoundForPath:
source_provider = UnversionedSource(layout_provider.root)
diff --git a/test/lib/ansible_test/_internal/provider/__init__.py b/test/lib/ansible_test/_internal/provider/__init__.py
index 6e034b536b..0404f91e17 100644
--- a/test/lib/ansible_test/_internal/provider/__init__.py
+++ b/test/lib/ansible_test/_internal/provider/__init__.py
@@ -29,6 +29,7 @@ def find_path_provider(provider_type, # type: t.Type[TPathProvider],
provider_classes, # type: t.List[t.Type[TPathProvider]]
path, # type: str
walk, # type: bool
+ check_paths=False,
): # type: (...) -> TPathProvider
"""Return the first found path provider of the given type for the given path."""
sequences = sorted(set(pc.sequence for pc in provider_classes if pc.sequence > 0))
@@ -40,7 +41,12 @@ def find_path_provider(provider_type, # type: t.Type[TPathProvider],
while True:
for provider_class in tier_classes:
if provider_class.is_content_root(candidate_path):
- return provider_class(candidate_path)
+ provider = provider_class(candidate_path)
+ if check_paths:
+ if path in provider.get_paths(path):
+ return provider
+ else:
+ return provider
if not walk:
break I.e. only select source providers which actually find the path to the collection. @mattclay would a change like this be OK? |
This patch breaks some other cases (like change detection), since resolved_by_pr #69341 |
Any workaround for this? |
It took me quite awhile to realize I'm facing the same issue. In my scenario, my home directory ( Is there a recommended workaround? @felixfontein - Any reason why you closed the PR with the fix? |
There's not an easy apparent solution to this one that we can think of, so instead of continuing to punt this as a "maybe someday", we're just going to close it. If someone comes up with a more robust approach to detect and account for the issue in ansible-test, feel free to reopen or propose a change. |
SUMMARY
For example in
ansible.netcommon
installed withansible-galaxy collection install ansible.netcommon
:That collection has both unit and integration tests, and some plugins and modules.
For source collections checked out with git, ansible-test works.
ISSUE TYPE
COMPONENT NAME
ansible-test
ANSIBLE VERSION
The text was updated successfully, but these errors were encountered: