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

feat: add semantic version utilities for e2e tests #2502

Merged
merged 6 commits into from
Oct 14, 2022

Conversation

colin-axner
Copy link
Contributor

Description

closes: #XXXX


Before we can merge this PR, please make sure that all the following items have been
checked off. If any of the checklist items are not applicable, please leave them but
write a little note why.

  • Targeted PR against correct branch (see CONTRIBUTING.md)
  • Linked to Github issue with discussion and accepted design OR link to spec that describes this work.
  • Code follows the module structure standards.
  • Wrote unit and integration tests
  • Updated relevant documentation (docs/) or specification (x/<module>/spec/)
  • Added relevant godoc comments.
  • Added a relevant changelog entry to the Unreleased section in CHANGELOG.md
  • Re-reviewed Files changed in the Github PR explorer
  • Review Codecov Report in the comment section below once CI passes

{"supported semantic version", "v6.1.0", true},
{"supported semantic version", "v7.1.0", true},
{"supported semantic version", "v22.5.1", true},
{"supported semantic version with v", "2.5.0", true},
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
{"supported semantic version with v", "2.5.0", true},
{"supported semantic version without v", "2.5.0", true},

}
}

func ParseChainVersion(version string) (Version, bool) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this function is only used in IsSupported, can it be unexported? If it cannot, can we add a godoc then?

// or is greater than or equal to the list of minor releases it was included in.
func (fr FeatureReleases) IsSupported(versionStr string) bool {
// assume any non semantic version formatted version support the feature
// this will be useful during development of the e2e test with the new feature
Copy link
Contributor

Choose a reason for hiding this comment

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

So this is to support images with names of working branches, right?

Copy link
Contributor

Choose a reason for hiding this comment

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

right, this will mean a version of pr-1234 will "support" a feature.

Copy link
Contributor

Choose a reason for hiding this comment

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

All right... maybe this is an edge case, but if we have a PR for a branch that does not support the feature (for example, a backport to release/v2.4.x) then the test will fail, right? Because this will wrongly assume that the PR supports the feature... Although maybe this is not a problem if the metadata tests are only run as part of the compatibility check.

Copy link
Contributor

@chatton chatton left a comment

Choose a reason for hiding this comment

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

The test cases look great ❤️

I think a lot of the custom logic that we have here can be replaced with the semver package. Especially since our inputs are strings.

Comment on lines 41 to 44
return Version{
Major: major,
Minor: minor,
}, true
Copy link
Contributor

Choose a reason for hiding this comment

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

The majority of the parsing logic here seems to be duplicating semver.Major and semver.Minor

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ah! I was looking for that, wasn't sure it existed, looks to be importable under "semver"?

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 the import path is "golang.org/x/mod/semver"

@chatton
Copy link
Contributor

chatton commented Oct 12, 2022

After the refactor, the custom types to represent versions were removed in favour of strings which are natively supported by the semver package. A few small functions were added to aid readability. All test cases remain the same.

Copy link
Member

@damiannolan damiannolan left a comment

Choose a reason for hiding this comment

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

LGTM! Nice work @colin-axner and @chatton 🙏

Copy link
Contributor Author

@colin-axner colin-axner left a comment

Choose a reason for hiding this comment

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

ACK, thanks @chatton! Feel free to merge for me whenever you feel ready

Copy link
Contributor

@charleenfei charleenfei left a comment

Choose a reason for hiding this comment

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

nice work @colin-axner @chatton !

@chatton chatton enabled auto-merge (squash) October 14, 2022 11:04
Copy link
Contributor Author

@colin-axner colin-axner left a comment

Choose a reason for hiding this comment

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

Approve! (can't click approve button on github, feel free to do it on my behalf)

Copy link
Contributor

@chatton chatton left a comment

Choose a reason for hiding this comment

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

(on behalf of @colin-axner ❤️ )

@chatton chatton merged commit aed1dd2 into main Oct 14, 2022
@chatton chatton deleted the colin/e2e-version-helper-funcs branch October 14, 2022 11:16
@chatton chatton restored the colin/e2e-version-helper-funcs branch October 14, 2022 11:17
@chatton chatton deleted the colin/e2e-version-helper-funcs branch October 14, 2022 11:17
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.

5 participants