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 argument to update version in galaxy.yml file #127

Closed
wants to merge 25 commits into from

Conversation

KB-perByte
Copy link

usage - antsibull-changelog release --version 6.0.0 --update-galaxy-file

updates the version in the changelog and also in the galaxy.yml

src/antsibull_changelog/update_galaxy.py Outdated Show resolved Hide resolved
src/antsibull_changelog/update_galaxy.py Outdated Show resolved Hide resolved
src/antsibull_changelog/update_galaxy.py Outdated Show resolved Hide resolved
@gotmax23
Copy link
Contributor

gotmax23 commented Jul 5, 2023

I'm a bit conflicted as to whether antsibull-changelog is the right place/level in the stack to handle bumping the version. Also, pyyaml is lossy and does not preserve comments or formatting which is problematic for galaxy.yml. @felixfontein, wdyt?

@gotmax23
Copy link
Contributor

gotmax23 commented Jul 5, 2023

@KB-perByte, thanks for the PR! I left some feedback.

@gotmax23
Copy link
Contributor

gotmax23 commented Jul 5, 2023

Also, a changelog fragment is needed for this change.

KB-perByte and others added 3 commits July 5, 2023 17:56
Co-authored-by: Maxwell G <maxwell@gtmx.me>
Co-authored-by: Maxwell G <maxwell@gtmx.me>
@KB-perByte
Copy link
Author

I'm a bit conflicted as to whether antsibull-changelog is the right place/level in the stack to handle bumping the version. Also, pyyaml is lossy and does not preserve comments or formatting which is problematic for galaxy.yml. @felixfontein, wdyt?

Thanks for the quick review, @gotmax23
I have similar concerns the comments and formatting are definitely not preserved and it also hinders the yaml start (---).
But this would be great to have for the collections to consume in CI.
Ref : the push workflow a separate task needs to be invoked to update the galaxy.yml file.
and, I'll be adding tests, still figuring out better alternatives to update the yaml file.
Regards

@KB-perByte KB-perByte requested a review from gotmax23 July 5, 2023 13:24
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. I started adding comments earlier today, but then got interrupted... and now most of the things already changed ;) So here's a new set of comments.

changelogs/fragments/update_galaxy.yaml Outdated Show resolved Hide resolved
src/antsibull_changelog/config.py Outdated Show resolved Hide resolved
src/antsibull_changelog/config.py Outdated Show resolved Hide resolved
src/antsibull_changelog/cli.py Outdated Show resolved Hide resolved
src/antsibull_changelog/cli.py Outdated Show resolved Hide resolved
@felixfontein
Copy link
Collaborator

I'm a bit conflicted as to whether antsibull-changelog is the right place/level in the stack to handle bumping the version. Also, pyyaml is lossy and does not preserve comments or formatting which is problematic for galaxy.yml. @felixfontein, wdyt?

I agree, this feels a bit wrong. For such changes ruamel is the better library, but I don't think we should add a dependency on a second YAML library just for that. Maybe it would make sense to add this to collection_prep, as it already has a similar tool (https://github.com/ansible-network/collection_prep/blob/master/collection_prep/cmd/version.py)?

@gotmax23
Copy link
Contributor

gotmax23 commented Jul 5, 2023

I'm a bit conflicted as to whether antsibull-changelog is the right place/level in the stack to handle bumping the version. Also, pyyaml is lossy and does not preserve comments or formatting which is problematic for galaxy.yml. @felixfontein, wdyt?

I agree, this feels a bit wrong. For such changes ruamel is the better library, but I don't think we should add a dependency on a second YAML library just for that. Maybe it would make sense to add this to collection_prep, as it already has a similar tool (https://github.com/ansible-network/collection_prep/blob/master/collection_prep/cmd/version.py)?

I'm happy to merge this if you think there's a significant usecase, but I think the sed approach that preserves formatting is more ideal. Even ruamel.yaml doesn't preserve formatting, just comments, and I agree that it doesn't make sense to add that as an extra dependency. I'm not sure about the current maintenance status of collection_prep, but yeah, that might be a better place.

KB-perByte and others added 4 commits July 6, 2023 10:47
Co-authored-by: Felix Fontein <felix@fontein.de>
Co-authored-by: Felix Fontein <felix@fontein.de>
Co-authored-by: Felix Fontein <felix@fontein.de>
Co-authored-by: Felix Fontein <felix@fontein.de>
@KB-perByte
Copy link
Author

@gotmax23 @felixfontein Thanks for the quick and detailed reviews,
I am not sure about collection_prep being the right place for this change, as the changelog version is added and decided with the antsibull-changelog command itself. thinking deep
Regards

@gotmax23
Copy link
Contributor

@KB-perByte, do you plan to fix the lint errors and address the remaining feedback?

@KB-perByte
Copy link
Author

@gotmax23 this completely went out of my radar, l'll update the PR.
Thank you.

@KB-perByte
Copy link
Author

I am trying to add unit tests! WIP

Copy link
Contributor

@gotmax23 gotmax23 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 updating this! I have some follow ups :).

src/antsibull_changelog/update_galaxy.py Outdated Show resolved Hide resolved
src/antsibull_changelog/update_galaxy.py Show resolved Hide resolved
src/antsibull_changelog/update_galaxy.py Show resolved Hide resolved
@@ -609,7 +616,8 @@ def command_release(args: Any) -> int:
version, codename = _get_version_and_codename(
paths, config, collection_details, args
)

if args.update_galaxy_file and paths.galaxy_path:
Copy link
Contributor

Choose a reason for hiding this comment

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

If galaxy_path is None but --update-galaxy-file is passed, this should raise an error instead of continuing silently.

Copy link
Contributor

Choose a reason for hiding this comment

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

I think it should return 1 and exit with an error code, not just print a log message.

src/antsibull_changelog/update_galaxy.py Outdated Show resolved Hide resolved
src/antsibull_changelog/update_galaxy.py Outdated Show resolved Hide resolved
KB-perByte and others added 3 commits July 19, 2023 11:28
Co-authored-by: Maxwell G <maxwell@gtmx.me>
Co-authored-by: Maxwell G <maxwell@gtmx.me>
Co-authored-by: Maxwell G <maxwell@gtmx.me>
@KB-perByte
Copy link
Author

making galaxy_path : str from galaxy_path : StrOrBytesPath for the following errors

src/antsibull_changelog/update_galaxy.py:27: error: Argument 1 to "load_yaml" has incompatible type "str | bytes | PathLike[str] | PathLike[bytes]"; expected "str"  [arg-type]
src/antsibull_changelog/update_galaxy.py:33: error: Argument 1 to "store_yaml" has incompatible type "str | bytes | PathLike[str] | PathLike[bytes]"; expected "str"  [arg-type]
src/antsibull_changelog/cli.py:623: error: Argument "galaxy_path" to "update_galaxy" has incompatible type "str | None"; expected "str | bytes | PathLike[str] | PathLike[bytes]"  [arg-type]

@gotmax23
Copy link
Contributor

making galaxy_path : str from galaxy_path : StrOrBytesPath for the following errors

Ah, right. We also need to update the load_yaml and store_yaml signatures... You can revert my suggestion in that case.

src/antsibull_changelog/cli.py:623: error: Argument "galaxy_path" to "update_galaxy" has incompatible type "str | None"; expected "str | bytes | PathLike[str] | PathLike[bytes]" [arg-type]

This one seems legitimate. The calling code should make sure that the function isn't called when that variable is None.

Copy link
Contributor

Choose a reason for hiding this comment

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

It looks like you added a fixture but didn't make any test changes?

Copy link
Author

Choose a reason for hiding this comment

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

I haven't added any tests yet.

Co-authored-by: Maxwell G <maxwell@gtmx.me>
@KB-perByte
Copy link
Author

@gotmax23 I have this specific use case to preserve the yaml start (---) wherever it is present, ruamel is a valid candidate as per my need. ref
Would you be fine with a yaml wrapper that uses ruamel?
I personally don't like the idea, but I am running out of substitutes.

@gotmax23
Copy link
Contributor

gotmax23 commented Jul 20, 2023

Yeah, ruamel.yaml would be better here, but I'm not particularly inclined to add another dependency; we already use pyyaml through antsibull_core.yaml (edit: antsibull-changelog has its own copy of the code. It doesn't depend on antsibull_core). See #127 (comment). I'm happy to maintain a short bit of code for this, but I don't want this to turn into a big thing when it's already a bit outside the scope of the project.

src/antsibull_changelog/cli.py Show resolved Hide resolved
src/antsibull_changelog/update_galaxy.py Outdated Show resolved Hide resolved
tags:
- test
- dummy
version: 2.0.0
Copy link
Collaborator

Choose a reason for hiding this comment

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

This file isn't used so far.

@felixfontein felixfontein marked this pull request as draft July 24, 2023 07:49
KB-perByte and others added 2 commits August 3, 2023 15:11
Co-authored-by: Felix Fontein <felix@fontein.de>
Co-authored-by: Felix Fontein <felix@fontein.de>
@felixfontein
Copy link
Collaborator

@KB-perByte this PR hasn't progressed in a year. Are you still planning to work on this or can we close it? Thanks.

@KB-perByte
Copy link
Author

We can close this off! Thanks

@KB-perByte KB-perByte closed this Aug 21, 2024
@felixfontein
Copy link
Collaborator

Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants