-
Notifications
You must be signed in to change notification settings - Fork 91
Add option to exclude package names from deletion #10
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
Conversation
input.numOldVersionsToDelete, | ||
input.token | ||
).pipe(map(versionInfo => versionInfo.map(info => info.id))) | ||
).pipe( |
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.
@Hsn723 did you look into a solution that exclude the versions from the query in the first place? If that is even possible.
Could you run into a situation where there'll never be any versions left. The case where numOldVersionsToDelete
is smaller than the number of versions matching you regular expression? Would one have to "know your versions" and set this value higher to avoid that or what do you think?
Kind of related: Do you know if this action could remove all versions or will it at least leave one?
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 did look into passing the filter into the query however the current GitHub GraphQL API v4 does not support any filtering at this time.
Could you run into a situation where there'll never be any versions left.
Indeed, there's the possibility of the oldest numOldVersionsToDelete
versions all match the filtering pattern and therefore ending up with nothing to delete. Unfortunately I don't have an elegant solution other than "know your versions" as you mentioned. Or, having a versioning scheme that allows some predictability. Automatically counting up is also an option, however that will require several passes.
Do you know if this action could remove all versions or will it at least leave one?
Yes, even with the initial implementation this action can very well remove all versions, for instance if numOldVersionsToDelete
is set higher to the total number of packages. Leaving at least one (the latest version) would indeed be desirable, although probably out of the scope of the current PR (I can gladly prepare another PR for that though).
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.
Thanks for your valuable replies. I can see the complexities.
I find it odd that the default implementation would let you delete all versions. I'm afraid to use the action without this "protection".
Also, the numOldVersionsToDelete
is kind of up-side-down isn't it? Wouldn't it make more sense with a keepNumVersions
+ what your PR providers?
Leaving at least one (the latest version) would indeed be desirable, although probably out of the scope of the current PR
Yeah, that would be a different PR.
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.
keepNumVersions
has also been proposed in #5, also that one is also tricky with the current GitHub GraphQL API v4 as the API doesn't provide a way to return "all" package versions unless you call the API asking for the "first N packages" with a large enough number.
By the way, if #5 gets implemented it would also be possible to combine it with the ignore-package-names
proposed in this PR.
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.
API doesn't provide a way to return "all" package versions unless you call the API asking for the "first N packages" with a large enough number.
I guess any, not necessarily large, number would suffice. As long as you don't add more than whatever that number is. At each delete action execution it would carve away old versions until there are no more of them. Isn't that how it would/could work?
By the way, if #5 gets implemented it would also be possible to combine it with the ignore-package-names proposed in this PR.
Good to know, thank you.
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.
At each delete action execution it would carve away old versions until there are no more of them.
In theory yes, for instance if you set keepNumVersions
to 5 and call the API every time requesting the 10 latest versions. What could possibly betray user expectations however is that this way you would end up deleting old (but not oldest) packages and slowly working your way down when the user would rather have oldest packages deleted first. Though the reality is that automation with the current API has no "one size fits all" and some users' expectations may be betrayed regardless.
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 see. Thanks for the explanation.
@Hsn723 have you been using your branch. Seems like there is nothing happening in this repo. UPDATE using your branch now in an action and it works great. I hope this will get merged. |
Thanks for the feedback. We've been using a branch (https://github.com/MatsuriJapon/delete-package-versions/tree/matsuri) that contains this and other proposed changes (#9) in production for a while now and haven't encountered issues so far. |
@Hsn723 Somehow it's not working for me.
This is what I am using. The action says the following: When I look at the packages, the version doesn't get deleted. Do you have any ideas? Thanks in advance. |
@cprell You're right! Also btw, you'll need to escape slashes inside your regular expression as it seems that otherwise the slashes get consumed once by the input parser. I'd also like to advise against using the "matsuri" branch of our fork. We use it internally and may change it periodically (for instance rebasing with any upstream changes, which was why we cut that branch in the first place). I'm pleasantly surprised to see it being used elsewhere, but cannot assume responsibility for any broken builds 🙏. |
@Hsn723 Thanks for the quick reply!
In this case I think the regex works correctly for what I want to achieve. It filters out release versions like 1.2.0 but not snapshot versions like 1.2.0-SNAPSHOT.
Thanks for the heads up, but I forked your fork and use our fork, so that I can use a stable version without any changes. I think using the matsuri branch is fine then. (and I like the branch name!)
Of course, you've done great work. Thanks for that! |
This feature has been released with the latest version |
This PR contains the changes proposed in #8 but split into two PRs: one for each proposed feature. This one provides the
ignore-package-names
option allowing to provide a regular expression to specify package names to exclude from deletion. This should address use cases like those in #6. For instance, with package namesAnd the following configuration:
Only
4.20.20200329
and4.21.20200330
would be deleted. As the current GraphQL API doesn't allow to query packages with a filter pattern, filtering is done after retrieving the last N packages. As a result, less than N packages may be deleted, which admittedly may be contrary to user expectation (though the same happens when requesting N older packages when there are less than N).