-
Notifications
You must be signed in to change notification settings - Fork 104
feat(releases): Support comparing release versions without build code #5376
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
base: master
Are you sure you want to change the base?
Conversation
relay-cabi/src/processing.rs
Outdated
| ) -> i32 { | ||
| let ver_a = sentry_release_parser::Version::parse(unsafe { (*a).as_str() })?; | ||
| let ver_b = sentry_release_parser::Version::parse(unsafe { (*b).as_str() })?; | ||
| match cmp_no_build_code(&ver_a, &ver_b) { |
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.
We could call as_semver on the versions here, and then call cmp_precedence on the semver::Version, which does what you describe in the PR description:
Compare the major, minor, patch, and pre-release value of two versions, disregarding build metadata. Versions that differ only in build metadata are considered equal. This comparison is what the SemVer spec refers to as “precedence”.
https://docs.rs/semver/latest/semver/struct.Version.html#method.cmp_precedence
This would require enabling the semver feature in the release parser dependency:
Line 36 in 3e01f71
| sentry-release-parser = { workspace = true, features = ["serde"] } |
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.
@jjbayer Ah I see cmp_precedence is available for semver 1.0.27 (latest version) but sentry-release-parser uses semver 0.9.0 😭 I think that function was introduced after 0.9.0, I am getting this error:
Compiling relay-cabi v0.9.19 (/Users/sofiarest/code/relay/relay-cabi)
error[E0599]: no method named cmp_precedence found for struct semver::version::Version in the current scope
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.
Adding a feature flag to release-parser that allows semver 1.0 and cmp_precedence: getsentry/sentry-release-parser#49
relates to REPLAY-803
depends on getsentry/sentry-release-parser#49 (tests will fail until this gets released 😅 )
Per the semver spec:
When detecting regressions here and here, we call
relay_compare_versionswhich uses the build code. However, we do not order by build code or number throughout the vast majority of the codebase when ordering, determining the greatest semver release, etc. For example,get_semver_releasesorders by major, minor, patch, and prerelease. This gives us a bit of inconsistency when we do things like resolve an issue in the next release. We pick the next release to resolve by without using build code, but detect regressions with build code. So if the greatest semver in a project is 2.0+10 but 2.0+8 gets arbitrarily picked as the next release to resolve by, we could later detect a regression in 2.0+9 even though 2.0+9 < 2.0+10.Let's add a new rust function
relay_compare_versions_no_build_codethat considers two versions differing only in the build code as equal. We also add an arguse_build_codeto thecompare_versionpython function with the default set toTrue. We can then turn offuse_build_codewhen detecting regressions.