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

Automatically add --pre when installing collections from git repositories #327

Merged
merged 2 commits into from
Sep 5, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions examples/reqs_v2/requirements.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,13 @@ roles:
name: geerlingguy.mysql
collections:
- name: community-molecule-0.1.0.tar.gz
# Also needed for testing purposes as this should trigger addition of --pre
# argument as this is required due to
# https://github.com/ansible/ansible-lint/issues/3686
# https://github.com/ansible/ansible/issues/79109
- name: https://github.com/ansible-collections/amazon.aws.git
type: git
version: main
- name: https://github.com/ansible-collections/community.aws.git
type: git
version: main
7 changes: 7 additions & 0 deletions src/ansible_compat/runtime.py
Original file line number Diff line number Diff line change
Expand Up @@ -555,6 +555,13 @@ def install_requirements( # noqa: C901
"install",
"-v",
]
for collection in reqs_yaml["collections"]:
if isinstance(collection, dict) and collection.get("type", "") == "git":
_logger.info(
"Adding '--pre' to ansible-galaxy collection install because we detected one collection being sourced from git.",
)
cmd.append("--pre")
break
if offline:
_logger.warning(
"Skipped installing collection dependencies due to running in offline mode.",
Expand Down