Skip to content

Commit

Permalink
Strengthen MiMa checks (#20068)
Browse files Browse the repository at this point in the history
Using the latest patch release of the current minor version may lead to
some breakages that are not properly checked/tagged in the MiMa filers.
For example, if we accidentally introduce a breaking change in 3.M.1 but
check against 3.M.2, we would lose this breaking change before the next
minor release. If we would check against 3.M.0, we would catch this.

In general we need to track all the changes that have happened in the
current minor version. There should not be any breaking changes unless
the PR needs a minor release.
  • Loading branch information
nicolasstucki authored Apr 19, 2024
2 parents 99c19a7 + 72f2da6 commit 0bf4911
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 21 deletions.
27 changes: 16 additions & 11 deletions project/Build.scala
Original file line number Diff line number Diff line change
Expand Up @@ -97,17 +97,22 @@ object Build {
val publishedDottyVersion = referenceVersion
val sbtDottyVersion = "0.5.5"

/** Version against which we check binary compatibility.
/** Minor version against which we check binary compatibility.
*
* This must be the latest published release in the same versioning line.
* For example, if the next version is going to be 3.1.4, then this must be
* set to 3.1.3. If it is going to be 3.1.0, it must be set to the latest
* 3.0.x release.
* This must be the earliest published release in the same versioning line.
* For a baseVersion `3.M.P` the mimaPreviousDottyVersion should be set to:
* - `3.M.0` if `P > 0`
* - `3.(M-1).0` if `P = 0`
*/
val previousDottyVersion = "3.4.1"
val mimaPreviousDottyVersion = "3.4.0"

/** Version against which we check binary compatibility. */
val ltsDottyVersion = "3.3.0"
/** LTS version against which we check binary compatibility.
*
* This must be the earliest published release in the LTS versioning line.
* For example, if the latest LTS release is be 3.3.4, then this must be
* set to 3.3.0.
*/
val mimaPreviousLTSDottyVersion = "3.3.0"

object CompatMode {
final val BinaryCompatible = 0
Expand Down Expand Up @@ -501,7 +506,7 @@ object Build {
case cv: Disabled => thisProjectID.name
case cv: Binary => s"${thisProjectID.name}_${cv.prefix}3${cv.suffix}"
}
(thisProjectID.organization % crossedName % previousDottyVersion)
(thisProjectID.organization % crossedName % mimaPreviousDottyVersion)
},

mimaCheckDirection := (compatMode match {
Expand Down Expand Up @@ -1150,7 +1155,7 @@ object Build {
},
tastyMiMaConfig ~= { _.withMoreProblemFilters(TastyMiMaFilters.StdlibBootstrapped) },
tastyMiMaReportIssues := tastyMiMaReportIssues.dependsOn(Def.task {
val minorVersion = previousDottyVersion.split('.')(1)
val minorVersion = mimaPreviousDottyVersion.split('.')(1)
// TODO find a way around this and test in the CI
streams.value.log.warn(
s"""To allow TASTy-MiMa to read TASTy files generated by this version of the compile you must:
Expand Down Expand Up @@ -2184,7 +2189,7 @@ object Build {
case cv: Disabled => thisProjectID.name
case cv: Binary => s"${thisProjectID.name}_${cv.prefix}3${cv.suffix}"
}
(thisProjectID.organization % crossedName % ltsDottyVersion)
(thisProjectID.organization % crossedName % mimaPreviousLTSDottyVersion)
},
mimaForwardIssueFilters := MiMaFilters.Scala3Library.ForwardsBreakingChanges,
mimaBackwardIssueFilters := MiMaFilters.Scala3Library.BackwardsBreakingChanges,
Expand Down
20 changes: 10 additions & 10 deletions project/MiMaFilters.scala
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@ object MiMaFilters {

val ForwardsBreakingChanges: Map[String, Seq[ProblemFilter]] = Map(
// Additions that require a new minor version of the library
Build.previousDottyVersion -> Seq(
Build.mimaPreviousDottyVersion -> Seq(
ProblemFilters.exclude[DirectMissingMethodProblem]("scala.annotation.experimental.this"),
),

// Additions since last LTS
Build.ltsDottyVersion -> Seq(
Build.mimaPreviousLTSDottyVersion -> Seq(
ProblemFilters.exclude[DirectMissingMethodProblem]("scala.quoted.Quotes#reflectModule.ValOrDefDefMethods"),
ProblemFilters.exclude[DirectMissingMethodProblem]("scala.quoted.Quotes#reflectModule.ValOrDefDefTypeTest"),
ProblemFilters.exclude[DirectMissingMethodProblem]("scala.quoted.Quotes#reflectModule#defnModule.FunctionClass"),
Expand Down Expand Up @@ -48,10 +48,10 @@ object MiMaFilters {
// Only exceptional cases should be added here.

// Breaking changes since last reference version
Build.previousDottyVersion -> Seq.empty, // We should never break backwards compatibility
Build.mimaPreviousDottyVersion -> Seq.empty, // We should never break backwards compatibility

// Breaking changes since last LTS
Build.ltsDottyVersion -> Seq(
Build.mimaPreviousLTSDottyVersion -> Seq(
// Quotes is assumed to only be implemented by the compiler and on the same version of the library.
// It is exceptionally OK to break this compatibility. In these cases, there add new abstract methods that would
// potentially not be implemented by others. If some other library decides to implement these,
Expand All @@ -71,35 +71,35 @@ object MiMaFilters {
object TastyCore {
val ForwardsBreakingChanges: Map[String, Seq[ProblemFilter]] = Map(
// Additions that require a new minor version of tasty core
Build.previousDottyVersion -> Seq(
Build.mimaPreviousDottyVersion -> Seq(
ProblemFilters.exclude[DirectMissingMethodProblem]("dotty.tools.tasty.TastyFormat.FLEXIBLEtype")
),

// Additions since last LTS
Build.ltsDottyVersion -> Seq(
Build.mimaPreviousLTSDottyVersion -> Seq(
)
)

val BackwardsBreakingChanges: Map[String, Seq[ProblemFilter]] = Map(
// Breaking changes since last LTS
Build.ltsDottyVersion -> Seq.empty // We should never break backwards compatibility
Build.mimaPreviousLTSDottyVersion -> Seq.empty // We should never break backwards compatibility
)
}

object Interfaces {
val ForwardsBreakingChanges: Map[String, Seq[ProblemFilter]] = Map(
// Additions that require a new minor version of interfaces
Build.previousDottyVersion -> Seq(
Build.mimaPreviousDottyVersion -> Seq(
),

// Additions since last LTS
Build.ltsDottyVersion -> Seq(
Build.mimaPreviousLTSDottyVersion -> Seq(
)
)

val BackwardsBreakingChanges: Map[String, Seq[ProblemFilter]] = Map(
// Breaking changes since last LTS
Build.ltsDottyVersion -> Seq.empty // We should never break backwards compatibility
Build.mimaPreviousLTSDottyVersion -> Seq.empty // We should never break backwards compatibility
)
}

Expand Down

0 comments on commit 0bf4911

Please sign in to comment.