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

Sort by Strings is not totally accurate #675

Merged
merged 1 commit into from
May 9, 2022
Merged

Sort by Strings is not totally accurate #675

merged 1 commit into from
May 9, 2022

Conversation

dmikusa
Copy link
Contributor

@dmikusa dmikusa commented May 6, 2022

Summary

In a couple of the actions, we were sorting an array of string versions. String versions do not sort correctly though under some circumstances, like if you have minor/patch releases in the list that are both less than and greater than 10. You get a sort like 1, 10, 11, 2, 3, 4, etc.. not 1, 2, 3, 4, 10, 11. This can cause updates to be missed.

This PR rewrites the two impacted actions such that they are using Semver to sort and pick the latest order, which guarantees that we get the most recent release. This PR also makes some optimizations so that the version number is loaded from metadata instead of the JVM file, or that we only download and read the version from at least one JVM.

In addition, it removes support for Java 8 from GraalVM, which dropped Java 8 support.

Use Cases

Checklist

  • I have viewed, signed, and submitted the Contributor License Agreement.
  • I have linked issue(s) that this PR should close using keywords or the Github UI (See docs)
  • I have added an integration test, if necessary.
  • I have reviewed the styleguide for guidance on my code quality.
  • I'm happy with the commit history on this PR (I have rebased/squashed as needed).

In a couple of the actions, we were sorting an array of string versions. String versions do not sort correctly though under some circumstances, like if you have minor/patch releases in the list that are both less than and greater than 10. You get a sort like 1, 10, 11, 2, 3, 4, etc.. not 1, 2, 3, 4, 10, 11. This can cause updates to be missed.

This PR rewrites the two impacted actions such that they are using Semver to sort and pick the latest order, which guarantees that we get the most recent release. This PR also makes some optimizations so that the version number is loaded from metadata instead of the JVM file, or that we only download and read the version from at least one JVM.

In addition, it removes support for Java 8 from GraalVM, which dropped Java 8 support.

Signed-off-by: Daniel Mikusa <[email protected]>
@dmikusa dmikusa added type:bug A general bug semver:patch A change requiring a patch version bump labels May 6, 2022
@dmikusa dmikusa requested a review from a team May 6, 2022 17:37
for _, a := range r.Assets {
if globRegex.MatchString(*a.Name) {
version := tag[1]
if strings.HasPrefix(tag[1], "8u") {
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
if strings.HasPrefix(tag[1], "8u") {
if strings.HasPrefix(version, "8u") {

@dmikusa dmikusa merged commit 9c08b03 into main May 9, 2022
@dmikusa dmikusa deleted the sort_bug branch May 9, 2022 18:06
This was referenced May 25, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
semver:patch A change requiring a patch version bump type:bug A general bug
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants