Skip to content

Commit 640c9a8

Browse files
committed
Fix #11939: Set up MiMa for scala3-interfaces in scala3-library.
This already detects a couple things that break the backward source compatibility guarantee. They are excluded in `project/MiMaFilters.scala`. They should be reverted before we publish 3.0.1, or we should jump straight to 3.1.0.
1 parent f84322e commit 640c9a8

File tree

4 files changed

+68
-4
lines changed

4 files changed

+68
-4
lines changed

.github/workflows/ci.yaml

+4
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,10 @@ jobs:
114114
./project/scripts/sbt ";scala3-bootstrapped/compile ;scala3-bootstrapped/test;sjsSandbox/run;sjsSandbox/test;sjsJUnitTests/test;sjsCompilerTests/test ;sbt-test/scripted scala2-compat/* ;configureIDE ;stdlib-bootstrapped/test:run ;stdlib-bootstrapped-tasty-tests/test"
115115
./project/scripts/bootstrapCmdTests
116116
117+
- name: MiMa
118+
run: |
119+
./project/scripts/sbt ";scala3-interfaces/mimaReportBinaryIssues ;scala3-library-bootstrapped/mimaReportBinaryIssues ;scala3-library-bootstrappedJS/mimaReportBinaryIssues"
120+
117121
test_windows_fast:
118122
runs-on: [self-hosted, Windows]
119123
if: "(

project/Build.scala

+48-4
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ import xerial.sbt.pack.PackPlugin
1515
import xerial.sbt.pack.PackPlugin.autoImport._
1616
import xerial.sbt.Sonatype.autoImport._
1717

18+
import com.typesafe.tools.mima.plugin.MimaPlugin.autoImport._
19+
1820
import dotty.tools.sbtplugin.DottyIDEPlugin.{ installCodeExtension, prepareCommand, runProcess }
1921
import dotty.tools.sbtplugin.DottyIDEPlugin.autoImport._
2022

@@ -74,6 +76,29 @@ object Build {
7476
val publishedDottyVersion = referenceVersion
7577
val sbtDottyVersion = "0.5.5"
7678

79+
/** Version against which we check binary compatibility.
80+
*
81+
* This must be the latest published release in the same versioning line.
82+
* For example, if the next version is going to be 3.1.4, then this must be
83+
* set to 3.1.3. If it is going to be 3.1.0, it must be set to the latest
84+
* 3.0.x release.
85+
*/
86+
val previousDottyVersion = "3.0.0-RC3"
87+
val previousDottyBinaryVersion = "3.0.0-RC3"
88+
89+
object CompatMode {
90+
final val BinaryCompatible = 0
91+
final val SourceAndBinaryCompatible = 1
92+
}
93+
94+
val compatMode = {
95+
val VersionRE = """^\d+\.(\d+).(\d+).*""".r
96+
baseVersion match {
97+
case VersionRE(_, "0") => CompatMode.BinaryCompatible
98+
case _ => CompatMode.SourceAndBinaryCompatible
99+
}
100+
}
101+
77102
/** scala-library version required to compile Dotty.
78103
*
79104
* Both the non-bootstrapped and bootstrapped version should match, unless
@@ -381,6 +406,22 @@ object Build {
381406
javaOptions += "-DBENCH_CLASS_PATH=" + Attributed.data((`scala3-library-bootstrapped` / Compile / fullClasspath).value).mkString("", File.pathSeparator, "")
382407
)
383408

409+
lazy val commonMiMaSettings = Def.settings(
410+
mimaPreviousArtifacts += {
411+
val thisProjectID = projectID.value
412+
val crossedName = thisProjectID.crossVersion match {
413+
case cv: Disabled => thisProjectID.name
414+
case cv: Binary => s"${thisProjectID.name}_${cv.prefix}$previousDottyBinaryVersion${cv.suffix}"
415+
}
416+
(thisProjectID.organization % crossedName % previousDottyVersion)
417+
},
418+
419+
mimaCheckDirection := (compatMode match {
420+
case CompatMode.BinaryCompatible => "backward"
421+
case CompatMode.SourceAndBinaryCompatible => "both"
422+
}),
423+
)
424+
384425
/** Projects -------------------------------------------------------------- */
385426

386427
val dottyCompilerBootstrappedRef = LocalProject("scala3-compiler-bootstrapped")
@@ -400,7 +441,8 @@ object Build {
400441
lazy val `scala3-bootstrapped` = project.asDottyRoot(Bootstrapped)
401442

402443
lazy val `scala3-interfaces` = project.in(file("interfaces")).
403-
settings(commonJavaSettings)
444+
settings(commonJavaSettings).
445+
settings(commonMiMaSettings)
404446

405447
/** Find an artifact with the given `name` in `classpath` */
406448
def findArtifact(classpath: Def.Classpath, name: String): File = classpath
@@ -1532,15 +1574,17 @@ object Build {
15321574
).
15331575
settings(dottyLibrarySettings)
15341576
if (mode == Bootstrapped) {
1535-
base.settings(Seq(
1577+
base.settings(
15361578
(Compile/doc) := {
15371579
// Workaround for
15381580
// [error] |object IArray cannot have the same name as object IArray in package scala
15391581
// -- cannot define object member with the same name as a object member in self reference _.
15401582
val doWork = (Compile/doc).result.value
15411583
(Compile/doc/target).value
1542-
}
1543-
))
1584+
},
1585+
commonMiMaSettings,
1586+
mimaBinaryIssueFilters ++= MiMaFilters.Library,
1587+
)
15441588
} else base
15451589
}
15461590

project/MiMaFilters.scala

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
2+
import com.typesafe.tools.mima.core._
3+
import com.typesafe.tools.mima.core.ProblemFilters._
4+
5+
object MiMaFilters {
6+
val Library: Seq[ProblemFilter] = Seq(
7+
// !!! These things are already violating the source compatibility guarantees of 3.0.1
8+
// They need to be reverted, or we need to set the next version to 3.1.0
9+
exclude[DirectMissingMethodProblem]("scala.quoted.Quotes#reflectModule#TermParamClauseMethods.isErased"),
10+
exclude[ReversedMissingMethodProblem]("scala.quoted.Quotes#reflectModule#TermParamClauseMethods.isErased"),
11+
exclude[MissingClassProblem]("scala.annotation.internal.ErasedParam"),
12+
exclude[MissingClassProblem]("scala.annotation.internal.Stable"),
13+
)
14+
}

project/plugins.sbt

+2
Original file line numberDiff line numberDiff line change
@@ -13,3 +13,5 @@ addSbtPlugin("org.xerial.sbt" % "sbt-pack" % "0.13")
1313
addSbtPlugin("pl.project13.scala" % "sbt-jmh" % "0.3.2")
1414

1515
addSbtPlugin("com.eed3si9n" % "sbt-buildinfo" % "0.9.0")
16+
17+
addSbtPlugin("com.typesafe" % "sbt-mima-plugin" % "0.9.0")

0 commit comments

Comments
 (0)