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 validate-tags command #456

Merged
merged 11 commits into from
Nov 23, 2022
Merged

Conversation

gotmax23
Copy link
Contributor

This adds a new validate-tags command to retrieve the tags in each collection's git repository and ensure that the current version is tagged.

Currently, this is a separate command, but I'd like to have antsibull-build include the data from get_collections_tags() in ansible-build-data and the ansible sdist after this has gotten more testing/feedback.

I also split CollectionsMetadata into a separate file and added the new keys. Previously, this class was part of changelog.py and only used for retrieving changelog URLs.

Relates: ansible-community/community-topics#148
Depends-on: ansible-community/ansible-build-data#176

@gotmax23
Copy link
Contributor Author

$ antsibull-build validate-tags -i tags.yaml --data-dir ./build/ansible-build-data/7 7.0.0b1 
ERROR:antsibull:func=validate_tags:mod=antsibull.tagging|cisco.nso 1.0.3 is not tagged in https://github.com/CiscoDevNet/ansible-nso
ERROR:antsibull:func=validate_tags:mod=antsibull.tagging|cyberark.pas 1.0.14 is not tagged in https://github.com/cyberark/ansible-security-automation-collection
ERROR:antsibull:func=validate_tags:mod=antsibull.tagging|f5networks.f5_modules 1.20.0 is not tagged in https://github.com/F5Networks/f5-ansible
ERROR:antsibull:func=validate_tags:mod=antsibull.tagging|fortinet.fortimanager 2.1.6 is not tagged in https://github.com/fortinet-ansible-dev/ansible-galaxy-fortimanager-collection
ERROR:antsibull:func=validate_tags:mod=antsibull.tagging|hpe.nimble 1.1.4 is not tagged in https://github.com/hpe-storage/nimble-ansible-modules
ERROR:antsibull:func=validate_tags:mod=antsibull.tagging|inspur.sm 2.3.0 is not tagged in https://github.com/ISIB-Group/inspur.sm
ERROR:antsibull:func=validate_tags:mod=antsibull.tagging|mellanox.onyx 1.0.0 is not tagged in https://github.com/ansible-collections/mellanox.onyx
ERROR:antsibull:func=validate_tags:mod=antsibull.tagging|ovirt.ovirt 2.3.1 is not tagged in https://github.com/ovirt/ovirt-ansible-collection

src/antsibull/tagging.py Outdated Show resolved Hide resolved
@gotmax23 gotmax23 changed the title [Draft] Add validate-tags command Add validate-tags command Nov 12, 2022
@gotmax23 gotmax23 marked this pull request as ready for review November 12, 2022 19:01
Copy link
Contributor Author

@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.

I've marked this as ready for review. I'm happy with the tag retrieval code, but I'd like your opinion on my other question :).

src/antsibull/cli/antsibull_build.py Outdated Show resolved Hide resolved
src/antsibull/cli/antsibull_build.py Outdated Show resolved Hide resolved
src/antsibull/cli/antsibull_build.py Outdated Show resolved Hide resolved
src/antsibull/collection_meta.py Show resolved Hide resolved
src/antsibull/collection_meta.py Outdated Show resolved Hide resolved
changelogs/fragments/456-validate-tags.yaml Outdated Show resolved Hide resolved
src/antsibull/tagging.py Outdated Show resolved Hide resolved
src/antsibull/tagging.py Outdated Show resolved Hide resolved
src/antsibull/tagging.py Outdated Show resolved Hide resolved
This adds a new validate-tags command to retrieve the tags in each
collection's git repository and ensure that the current version is
tagged.

Currently, this is a separate command, but I'd like to have
`antsibull-build` include the data from `get_collections_tags()` in
ansible-build-data and the ansible sdist after this has gotten more
testing/feedback.

I also split CollectionsMetadata into a separate file and added the new
keys. Previously, this class was part of changelog.py and only used for
retrieving changelog URLs.

Relates: ansible-community/community-topics#148
Depends-on: ansible-community/ansible-build-data#176
We should ensure that the input file exists (if that option is passed)
and that the deps file exists to avoid exceptions down the line. Also,
this fixes a typo in _normalize_validate_tags_options.
@gotmax23
Copy link
Contributor Author

collection_parser = subparsers.add_parser('collection',
parents=[build_parser],
description='Build a collection which will'
' install Ansible')
collection_parser.add_argument('--deps-file', default=None,
help='File which contains the list of collections and'
' versions which were included in this version of Ansible.'
' This is considered to be relative to --data-dir.'
f' The default is {DEFAULT_FILE_BASE}-X.Y.Z.deps')
build_parser.add_argument('--collection-dir', default='.',
help='Directory to write collection to')

Is --collection-dir supposed to be added to build_parser here or should the last line above be collection_parser.add_argument(...)? build_parser is defined 120 lines up. --collection-dir is being added as an argument to validate-tags which I don't want.

@gotmax23
Copy link
Contributor Author

Anyways, I've added a separate validate-tags-file command and applied the rest of your feedback.

@gotmax23
Copy link
Contributor Author

gotmax23 commented Nov 13, 2022

Also...

ovirt.ovirt 2.3.1 is not tagged in https://github.com/ovirt/ovirt-ansible-collection

ovirt.ovirt 2.3.1 is tagged as 2.3.1-1. All of that collection's tag names are suffixed with -1. Do we want to add some sort of tag_format field or ask them to change the way they tag releases? The requirements say "the tag name MUST exactly match the Galaxy version number," but they also say that "tag names MUST have a consistent format from release to release." There's a reason I wrote the exactly match part, but telling them to change their already established format is unreasonable, IMO.

@felixfontein
Copy link
Collaborator

Also...

ovirt.ovirt 2.3.1 is not tagged in https://github.com/ovirt/ovirt-ansible-collection

ovirt.ovirt 2.3.1 is tagged as 2.3.1-1. All of that collection's tag names are suffixed with -1. Do we want to add some sort of tag_format field or ask them to change the way they tag releases? The requirements say "the tag name MUST exactly match the Galaxy version number," but they also say that "tag names MUST have a consistent format from release to release." There's a reason I wrote the exactly match part, but telling them to change their already established format is unreasonable, IMO.

How about allowing to configure a regex per collection that allows to extract the version? The default would be ^v?(.*)$, and for that collection we could set ^(.*)-1$.

@gotmax23
Copy link
Contributor Author

ovirt.ovirt's tags are fetched correctly with the latest commit and

diff --git a/7/collection-meta.yaml b/7/collection-meta.yaml
index ff380d8..d9e9c42 100644
--- a/7/collection-meta.yaml
+++ b/7/collection-meta.yaml
@@ -275,6 +275,7 @@ collections:
     repository: https://github.com/ansible-collections/openvswitch.openvswitch
   ovirt.ovirt:
     repository: https://github.com/ovirt/ovirt-ansible-collection
+    tag_version_regex: "^(.*)-1$"
   purestorage.flasharray:
     repository: https://github.com/Pure-Storage-Ansible/FlashArray-Collection
   purestorage.flashblade:

@gotmax23
Copy link
Contributor Author

#456 (comment) is still a problem :).

src/antsibull/cli/antsibull_build.py Outdated Show resolved Hide resolved
src/antsibull/cli/antsibull_build.py Outdated Show resolved Hide resolved
repository,
)
flog.debug(f'Running {args}')
proc = await asyncio.create_subprocess_exec(
Copy link
Collaborator

Choose a reason for hiding this comment

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

Why not use sh for running commands as all other parts of antsibull do?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, but isn't it blocking (in the asyncio sense)?

Copy link
Collaborator

Choose a reason for hiding this comment

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

It's blocking (sh does not support asyncio yet, see amoffat/sh#552).

src/antsibull/tagging.py Outdated Show resolved Hide resolved
Remove --input from the validate-tags subcommand in favor of a separate
validate-tags-file command.
We don't want git to ask for a password when a repository is
inaccessible. The program should consider it a failure and move on.
Some collections don't tag versions as v{version} or {version}. While
collections should use a standard tag name format per the Collection
Requirements, we won't impose this on existing collections.
@felixfontein felixfontein merged commit b38fd8b into ansible-community:main Nov 23, 2022
@felixfontein
Copy link
Collaborator

@gotmax23 thanks for your contribution!

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.

2 participants