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

fix #155 by extracting version without suffix #175

Merged
merged 5 commits into from
Aug 3, 2023

Conversation

seigert
Copy link

@seigert seigert commented Jul 28, 2023

As proposed by @julienrf I've changed semver version extraction method to allow suffixes after first three numbers.

Test are updated accordingly.

@seigert seigert changed the title fix scalacenter/sbt-version-policy#155 by extracting version without suffix fix #155 by extracting version without suffix Jul 28, 2023
Copy link
Collaborator

@julienrf julienrf left a comment

Choose a reason for hiding this comment

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

Thank you @seigert for working on this!

I don’t think the fix is correct, please see my comment below.

isCompatible("1.0.0-RC1", "1.0.0-RC1")
isCompatible("1.0.0", "1.0.0-RC1")
Copy link
Collaborator

Choose a reason for hiding this comment

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

This is inconsistent with what versions does, see https://scastie.scala-lang.org/LQVPcpnLSuqRzz9z8J4jQA.

We should ignore the suffix of the current version only (as in https://scastie.scala-lang.org/miZPzsvfS7mrB6FGoyMVEQ).

So, we should have the following assertions:

isBreaking("1.0.0", "1.0.0-RC1")
isBreaking("1.0.1", "1.0.0-RC1")
isBreaking("1.1.0", "1.0.0-RC1")
isBreaking("2.0.0", "1.0.0-RC1")
isCompatible("1.0.0-RC1", "1.0.0-RC1")
isCompatible("1.1.0-RC1", "1.0.0")
isCompatible("1.2.1-SNAPSHOT", "1.2.0")

Copy link
Author

Choose a reason for hiding this comment

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

I've changed logic to ignore suffix only for current version with just one note: isCompatible("1.1.0-RC1", "1.0.0") => isCompatible("1.0.1-RC1", "1.0.0"), because 1.1.0 is allowed to be source incompatible.

This leads to question: what should we do with changes in suffix? Should RC2 vs RC1 or RC1 vs SNAPSHOT be assumed compatible or not?

Copy link
Collaborator

@julienrf julienrf left a comment

Choose a reason for hiding this comment

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

This leads to question: what should we do with changes in suffix? Should RC2 vs RC1 or RC1 vs SNAPSHOT be assumed compatible or not?

We should conform to the following checks:

isBreaking("1.0.0-RC2", "1.0.0-RC1")
isBreaking("1.1.0-RC2", "1.1.0-RC1")
// however:
isCompatible("1.0.1-RC2", "1.0.1-RC1")

The reason is that 1.0.1-RC1 and 1.0.1-RC2 are both candidates for patch releases, and patch releases cannot introduce source incompatibilities anyway.

@seigert
Copy link
Author

seigert commented Aug 2, 2023

isBreaking("1.0.0-RC2", "1.0.0-RC1")
isBreaking("1.1.0-RC2", "1.1.0-RC1")
// however:
isCompatible("1.0.1-RC2", "1.0.1-RC1")

I think I've implemented this correctly -- at least, all checks pass. :)

Also, I've reordered checks by (currentVersion, previousVersion, breaks > compatible).

Copy link
Collaborator

@julienrf julienrf left a comment

Choose a reason for hiding this comment

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

Thank you very much for the quick update!

I’ve left two minor comments, but otherwise it looks good to me!

Comment on lines 171 to 175
def compatPatch =
(currentSemVer.patch > 0 && samePatch) ||
(currentSemVer.patch > previousSemVer.patch && previousSemVer.suffix.isEmpty)

sameMajor && sameMinor && ((samePatch && sameSuffix) || compatPatch)
Copy link
Collaborator

Choose a reason for hiding this comment

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

I wonder if this could be simplified to:

Suggested change
def compatPatch =
(currentSemVer.patch > 0 && samePatch) ||
(currentSemVer.patch > previousSemVer.patch && previousSemVer.suffix.isEmpty)
sameMajor && sameMinor && ((samePatch && sameSuffix) || compatPatch)
def compatPatch =
previousSemVer.suffix.isEmpty || previousSemVer.patch > 0
sameMajor && sameMinor && compatPatch

(untested)

Copy link
Author

Choose a reason for hiding this comment

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

I've used your check, but we still need (samePatch && sameSuffix) to allow 1.0.0-RC1 be source compat to itself. :(

Copy link
Collaborator

@julienrf julienrf left a comment

Choose a reason for hiding this comment

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

Thank you @seigert

@sjrd, could you please trigger the CI and then merge the PR if it passes?

@sjrd
Copy link
Contributor

sjrd commented Aug 3, 2023

[error] sbt-version-policy: Failed binary compatibility check against ch.epfl.scala:sbt-version-policy:2.1.2 (e:sbtVersion=1.0, e:scalaVersion=2.12)! Found 2 potential problems
[error]  * class sbtversionpolicy.DependencyCheckReport#SemVerVersion does not have a correspondent in other version
[error]    filter with: ProblemFilters.exclude[MissingClassProblem]("sbtversionpolicy.DependencyCheckReport$SemVerVersion")
[error]  * object sbtversionpolicy.DependencyCheckReport#SemVerVersion does not have a correspondent in other version
[error]    filter with: ProblemFilters.exclude[MissingClassProblem]("sbtversionpolicy.DependencyCheckReport$SemVerVersion$")
[error] Module sbt-version-policy:2.1.2+8-802b687c-SNAPSHOT is not source compatible with version 2.1.2. You have to relax your compatibility intention by changing the value of versionPolicyIntention.
[error] java.lang.RuntimeException: Failed binary compatibility check against ch.epfl.scala:sbt-version-policy:2.1.2 (e:sbtVersion=1.0, e:scalaVersion=2.12)! Found 2 potential problems
[error] (sbt-version-policy / versionPolicyMimaCheck) java.lang.RuntimeException: Failed binary compatibility check against ch.epfl.scala:sbt-version-policy:2.1.2 (e:sbtVersion=1.0, e:scalaVersion=2.12)! Found 2 potential problems

@seigert
Copy link
Author

seigert commented Aug 3, 2023

Should I add it to filters? Class is private and only method that uses it is private too.

@sjrd
Copy link
Contributor

sjrd commented Aug 3, 2023

Yes, please add it to the filters with a comment that says it is private.

@seigert
Copy link
Author

seigert commented Aug 3, 2023

Yes, please add it to the filters with a comment that says it is private.

Done.

@sjrd sjrd merged commit 18d39bf into scalacenter:main Aug 3, 2023
@julienrf
Copy link
Collaborator

julienrf commented Aug 3, 2023

Thank you @sjrd for merging the PR. It would be great to publish the fix by creating a new release on GitHub (version 2.1.3)

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.

3 participants