Skip to content
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

Support running ansible-test on collections outside a collection root #60215

Open
geerlingguy opened this issue Aug 7, 2019 · 3 comments

Comments

@geerlingguy
Copy link
Contributor

commented Aug 7, 2019

SUMMARY

When I develop my Ansible Collections, I want to be able to use a typical development workflow:

  1. git clone [my project] [local folder]
  2. cd [local folder]
  3. ansible-test integration (or whatever other command for local testing)

Currently, if I do this I get the following error:

 10:23:35 ~/Dropbox/VMs/collections/geerlingguy.php_roles $ ansible-test
ERROR: The current working directory must be at or below one of:

 - Ansible source: /Users/jgeerling/Downloads/ansible/
 - Ansible collection: {...}/ansible_collections/{namespace}/{collection}/

Current working directory: /Users/jgeerling/Dropbox/VMs/collections/geerlingguy.php_roles

I feel like this presents a pretty significant burden on collection maintainers and contributors, because a very common workflow (especially if I'm not on my main workstation for some reason) is: clone repo, hack on it, run integration tests, commit changes, push to PR.

If I have to create an arbitrary directory structure, then clone into that structure, it's a lot of overhead. Other existing testing tools like molecule (or in other languages, Mocha for Node, PHPUnit or Behat for PHP, etc.) are self-contained and run from within the project directory without issue...

ISSUE TYPE

Feature Idea

COMPONENT NAME

ansible-test

ANSIBLE VERSION
$ ansible --version
ansible 2.9.0.dev0
  config file = /etc/ansible/ansible.cfg
  configured module search path = [u'/Users/jgeerling/.ansible/plugins/modules', u'/usr/share/ansible/plugins/modules']
  ansible python module location = /Users/jgeerling/Downloads/ansible/lib/ansible
  executable location = /Users/jgeerling/Downloads/ansible/bin/ansible
  python version = 2.7.16 (default, Apr 12 2019, 15:32:40) [GCC 4.2.1 Compatible Apple LLVM 10.0.1 (clang-1001.0.46.3)]
CONFIGURATION
ANSIBLE_NOCOWS(/etc/ansible/ansible.cfg) = True
ANSIBLE_PIPELINING(/etc/ansible/ansible.cfg) = True
ANSIBLE_SSH_CONTROL_PATH(/etc/ansible/ansible.cfg) = /tmp/ansible-ssh-%%h-%%p-%%r
DEFAULT_FORKS(/etc/ansible/ansible.cfg) = 20
DEFAULT_HOST_LIST(/etc/ansible/ansible.cfg) = [u'/etc/ansible/hosts']
DEFAULT_ROLES_PATH(/etc/ansible/ansible.cfg) = [u'/Users/jgeerling/Dropbox/VMs/roles']
RETRY_FILES_ENABLED(/etc/ansible/ansible.cfg) = False
OS / ENVIRONMENT

macOS 10.14.5

STEPS TO REPRODUCE
  1. git clone https://github.com/geerlingguy/ansible-collection-php.git ansible-collection-php
  2. cd ansible-collection-php
  3. ansible-test integration
EXPECTED RESULTS

Integration tests, if any, would be run.

ACTUAL RESULTS
$ ansible-test
ERROR: The current working directory must be at or below one of:

 - Ansible source: /Users/jgeerling/Downloads/ansible/
 - Ansible collection: {...}/ansible_collections/{namespace}/{collection}/

Current working directory: /Users/jgeerling/Downloads/ansible-collection-php
@geerlingguy

This comment has been minimized.

Copy link
Contributor Author

commented Aug 7, 2019

If this is also a requirement for running ansible-test in CI, that means everyone who wants to use ansible-test in CI will have to add boilerplate code at the beginning to copy the cloned project into some other directory, adding at minimum one or two extra lines of code to every CI configuration.

@mattclay

This comment has been minimized.

Copy link
Member

commented Aug 8, 2019

This can be made to work. We'll need to update ansible-test to detect a collection that is not in a collection root and copy the files into a temporary directory with the required structure before running the tests.

@mattclay

This comment has been minimized.

Copy link
Member

commented Aug 8, 2019

However, that is only going to work for collections that do not have any dependencies on other collections, since we won't have a containing collection root to get dependencies from.

@mattclay mattclay added feature and removed bug labels Aug 14, 2019

@mattclay mattclay changed the title ansible-test enforces too strict a directory structure Support running ansible-test on collections outside a collection root Aug 14, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
3 participants
You can’t perform that action at this time.