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

Add cpanm option --with-recommends #9555

Open
wants to merge 7 commits into
base: main
Choose a base branch
from

Conversation

ZephOne
Copy link

@ZephOne ZephOne commented Jan 8, 2025

Fix #9554

SUMMARY

Fixes #9554

This PR aims to add the use of the option --with-recommands to cpanm module

minor_changes:
  - cpanm - enable usage of option --with-recommands (https://github.com/ansible-collections/community.general/issues/9554).
ISSUE TYPE
  • Feature Pull Request
COMPONENT NAME

cpanm

@ZephOne ZephOne force-pushed the add-cpanm-options-with-recommands branch from 93a6439 to ed02509 Compare January 8, 2025 15:29
@ansibullbot
Copy link
Collaborator

@ansibullbot ansibullbot added feature This issue/PR relates to a feature request module module needs_revision This PR fails CI tests or a maintainer has requested a review/revision of the PR new_contributor Help guide this first time contributor plugins plugin (any type) labels Jan 8, 2025
@russoz
Copy link
Collaborator

russoz commented Jan 8, 2025

Hi @ZephOne please update the main branch, then rebase your PR branch with it to fix the Alpine tests

@felixfontein felixfontein added check-before-release PR will be looked at again shortly before release and merged if possible. backport-10 Automatically create a backport for the stable-10 branch labels Jan 8, 2025
Copy link
Collaborator

@felixfontein felixfontein left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for your contribution!

You don't need to rebase BTW, adding another commit also resolves the CI problems.

plugins/modules/cpanm.py Outdated Show resolved Hide resolved
plugins/modules/cpanm.py Outdated Show resolved Hide resolved
@ZephOne ZephOne force-pushed the add-cpanm-options-with-recommands branch from ed02509 to 0b4ccb4 Compare January 8, 2025 20:50
@ZephOne
Copy link
Author

ZephOne commented Jan 8, 2025

Hi, thanks for your quick answer.
Yet I rebased.
I've written a bad commit message for the second commit that include your suggestion (they were good suggests). I assume that you would fixup that last commit, if you want me to do it on my branch, let me know.

@ansibullbot ansibullbot removed the needs_revision This PR fails CI tests or a maintainer has requested a review/revision of the PR label Jan 8, 2025
Copy link
Collaborator

@russoz russoz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hi @ZephOne thanks for your contribution!

The spelling needs fixing.

That being said, a couple of general comments:

  • since you are doing --with-recommends, I would suggest you expand that and make the exact same thing for --with-suggests, which seem to be a distinct categorie of dependencies for cpanm.
  • quoting from cpanm docs:

    There's also --without-recommend and --without-suggests to override the default decision made earlier in PERL_CPANM_OPT. I made a suggestion that allows both forms to be selected by the user - docs will need an update for that as well.

plugins/modules/cpanm.py Outdated Show resolved Hide resolved
plugins/modules/cpanm.py Outdated Show resolved Hide resolved
plugins/modules/cpanm.py Outdated Show resolved Hide resolved
plugins/modules/cpanm.py Outdated Show resolved Hide resolved
plugins/modules/cpanm.py Outdated Show resolved Hide resolved
@ZephOne ZephOne changed the title Add cpanm option --with-recommands Add cpanm option --with-recommends Jan 10, 2025
@ZephOne ZephOne force-pushed the add-cpanm-options-with-recommands branch from e8736fe to 818cfbf Compare January 10, 2025 13:38
@ansibullbot

This comment was marked as outdated.

@ansibullbot ansibullbot added ci_verified Push fixes to PR branch to re-run CI needs_revision This PR fails CI tests or a maintainer has requested a review/revision of the PR labels Jan 10, 2025
@ZephOne ZephOne force-pushed the add-cpanm-options-with-recommands branch from 818cfbf to 94206b0 Compare January 10, 2025 14:33
@ansibullbot ansibullbot removed ci_verified Push fixes to PR branch to re-run CI needs_revision This PR fails CI tests or a maintainer has requested a review/revision of the PR labels Jan 10, 2025
Comment on lines 61 to 64
- Installs dependencies declared as recommends per META spec.
- When these dependencies fail to install, cpanm continues the installation, since they are just recommendation.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should be telling the user about the 3 options they have. Maybe something like:

Suggested change
- Installs dependencies declared as recommends per META spec.
- When these dependencies fail to install, cpanm continues the installation, since they are just recommendation.
- If V(true), installs dependencies declared as recommends per META spec.
- If V(false), it ensures the dependencies declared as recommends are not installed, overriding any decision made earlier in E(PERL_CPANM_OPT).
- If parameter is not set, C(cpanm) will use its existing defaults.
- When these dependencies fail to install, cpanm continues the installation, since they are just recommendation.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep, I agree. Explicit is better. I'll just use your suggestion.
By the way what's the keyword for the doc about those doc functions : V(true), V(false), C(cpanm) and E(PERL_CPANM_OPT) ?

Copy link
Author

@ZephOne ZephOne Jan 11, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@russoz
Copy link
Collaborator

russoz commented Jan 11, 2025

Merci for the changes :-) the docs need just one more adjustment, IMO.

And sorry, I should have picked it up earlier: you need to update line 273 in your code, adding the new args to the command runner, otherwise it will not pass them to the command line. See more in https://docs.ansible.com/ansible/latest/collections/community/general/docsite/guide_cmdrunner.html

One other thing - not mandatory, but recommended - is to add test cases to tests/unit/plugins/modules/test_cpanm.yaml for these new parameters. The case of line 273 would have been picked up by this. ;-)

@ZephOne
Copy link
Author

ZephOne commented Jan 11, 2025

One other thing - not mandatory, but recommended - is to add test cases to tests/unit/plugins/modules/test_cpanm.yaml for these new parameters. The case of line 273 would have been picked up by this. ;-)

Currently I cannot see any test in tests/unit/plugins/modules/test_cpanm.yaml. I will check the other modules plugins for a start.

@ZephOne
Copy link
Author

ZephOne commented Jan 11, 2025

My bad I must look at tests/unit/plugins/modules/test_cpanm.yaml and not at tests/unit/plugins/modules/test_cpanm.py.
Indeed there are tests 😄
I'll try to add something

@ZephOne ZephOne force-pushed the add-cpanm-options-with-recommands branch from 94206b0 to fd76584 Compare January 11, 2025 21:41
@ansibullbot ansibullbot added tests tests unit tests/unit needs_revision This PR fails CI tests or a maintainer has requested a review/revision of the PR labels Jan 11, 2025
@ZephOne ZephOne force-pushed the add-cpanm-options-with-recommands branch from cb9d15d to f8c145c Compare January 11, 2025 23:17
@ZephOne
Copy link
Author

ZephOne commented Jan 11, 2025

@russoz I added the tests.
Where can I find the doc concerning the link between test_cpanm.py and test_cpanm.yml, in fact the link between yml file and py file for testing.

@ansibullbot ansibullbot removed the needs_revision This PR fails CI tests or a maintainer has requested a review/revision of the PR label Jan 11, 2025
@russoz
Copy link
Collaborator

russoz commented Jan 12, 2025

@russoz I added the tests. Where can I find the doc concerning the link between test_cpanm.py and test_cpanm.yml, in fact the link between yml file and py file for testing.

Awesome, will take a look in a moment. As for the docs right they are.......... in my brain. I wrote that helper code, and it is in my to-do list to write a developer guide within the collection docs (I have a couple of other such guides there). It's in the list for 2025 :-)

Copy link
Collaborator

@russoz russoz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Copy link
Collaborator

@felixfontein felixfontein left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One small adjustment to the changelog, then it looks good from my side as well:

@ZephOne ZephOne force-pushed the add-cpanm-options-with-recommands branch from f8c145c to 0245115 Compare January 12, 2025 10:42
@felixfontein
Copy link
Collaborator

LGTM, will merge in a few days if nobody objects.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport-10 Automatically create a backport for the stable-10 branch check-before-release PR will be looked at again shortly before release and merged if possible. feature This issue/PR relates to a feature request module module new_contributor Help guide this first time contributor plugins plugin (any type) tests tests unit tests/unit
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add usage of cpanm options --with-recommands to module options
4 participants