-
Notifications
You must be signed in to change notification settings - Fork 667
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
Automatically install current collection #2998
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As already stated on IRC, I have a hard time justifying this functionality in the Molecule. I would much rather document how to set up a collection development environment and then let molecule run ansible from within the collection where it can automatically use the content without installing it.
src/molecule/dependency/base.py
Outdated
""" | ||
Execute ``cmd`` and returns None. | ||
|
||
:return: None | ||
""" | ||
if os.path.isfile("galaxy.yml"): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This check is too naive to be effective. For example, we have our molecule scenarios stored under tests/integration/molecule
, which means that we run Molecule from the tests/integration
collection subfolder where galaxy.yml file will never be found.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I will address this because molecule already looks for repository root location as is used in config file lookup, so we should be able to re-use repo-root path and avoid depending on cwd.
src/molecule/dependency/base.py
Outdated
dist = Path(self._config.scenario.ephemeral_directory) / "dist" | ||
dist.mkdir(parents=True, exist_ok=True) | ||
result = util.run_command( | ||
f"ansible-galaxy collection build -v -f --output-path {dist}", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Again, this build command is too naive because it assumes that we are running molecule from the collection root. And there is another problem: users might need to some something else before they build the collection artifact. Because ansible-galaxy collection build
command is really primitive, there is usually quite a few steps we need to perform before we get to building (or we risk packaging together things like virtual environments, coverage reports - and the are huge BTW, etc.).
If run inside a collection repository dependency step will first build and install the current collection. This avoids failure to run test scenarios unless user already installed the collection. Fixes: #2997
This will address an issue I am currently encountering where trying to get Molecule to pick up an existing collection is difficult but also causes any other collections on my development machine to be overwritten by the ansibile-galaxy command. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This would be a wonderful improvement to my current development cycle.
""" | ||
Execute ``cmd`` and returns None. | ||
|
||
:return: None | ||
""" | ||
workdir = util.find_vcs_root(self._config.project_directory) | ||
collection_marker = os.path.join(workdir, "galaxy.yml") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What if galaxy.yml
doesn't live at the root of the current VCS?
I think there first needs to be some consensus (and documentation) on where the |
Closing in favour of #3077 which is reusing ansible-lint prerun code. |
If run inside a collection repository dependency step will first
build and install the current collection. This avoids failure to
run test scenarios unless user already installed the collection.
Fixes: #2997