Skip to content

Commit 61d0d6c

Browse files
committed
Fix #11939: Set up MiMa for scala3-interfaces in scala3-library.
1 parent 4410752 commit 61d0d6c

File tree

4 files changed

+67
-4
lines changed

4 files changed

+67
-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

@@ -72,6 +74,29 @@ object Build {
7274
val publishedDottyVersion = referenceVersion
7375
val sbtDottyVersion = "0.5.5"
7476

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

420+
lazy val commonMiMaSettings = Def.settings(
421+
mimaPreviousArtifacts += {
422+
val thisProjectID = projectID.value
423+
val crossedName = thisProjectID.crossVersion match {
424+
case cv: Disabled => thisProjectID.name
425+
case cv: Binary => s"${thisProjectID.name}_${cv.prefix}$previousDottyBinaryVersion${cv.suffix}"
426+
}
427+
(thisProjectID.organization % crossedName % previousDottyVersion)
428+
},
429+
430+
mimaCheckDirection := (compatMode match {
431+
case CompatMode.BinaryCompatible => "backward"
432+
case CompatMode.SourceAndBinaryCompatible => "both"
433+
}),
434+
)
435+
395436
/** Projects -------------------------------------------------------------- */
396437

397438
val dottyCompilerBootstrappedRef = LocalProject("scala3-compiler-bootstrapped")
@@ -411,7 +452,8 @@ object Build {
411452
lazy val `scala3-bootstrapped` = project.asDottyRoot(Bootstrapped)
412453

413454
lazy val `scala3-interfaces` = project.in(file("interfaces")).
414-
settings(commonJavaSettings)
455+
settings(commonJavaSettings).
456+
settings(commonMiMaSettings)
415457

416458
/** Find an artifact with the given `name` in `classpath` */
417459
def findArtifact(classpath: Def.Classpath, name: String): File = classpath
@@ -1636,15 +1678,17 @@ object Build {
16361678
).
16371679
settings(dottyLibrarySettings)
16381680
if (mode == Bootstrapped) {
1639-
base.settings(Seq(
1681+
base.settings(
16401682
(Compile/doc) := {
16411683
// Workaround for
16421684
// [error] |object IArray cannot have the same name as object IArray in package scala
16431685
// -- cannot define object member with the same name as a object member in self reference _.
16441686
val doWork = (Compile/doc).result.value
16451687
(Compile/doc/target).value
1646-
}
1647-
))
1688+
},
1689+
commonMiMaSettings,
1690+
mimaBinaryIssueFilters ++= MiMaFilters.Library,
1691+
)
16481692
} else base
16491693
}
16501694

project/MiMaFilters.scala

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
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+
// New APIs marked @experimental in 3.0.1
8+
exclude[DirectMissingMethodProblem]("scala.quoted.Quotes#reflectModule#TermParamClauseMethods.isErased"),
9+
exclude[ReversedMissingMethodProblem]("scala.quoted.Quotes#reflectModule#TermParamClauseMethods.isErased"),
10+
exclude[MissingClassProblem]("scala.annotation.internal.ErasedParam"),
11+
exclude[MissingClassProblem]("scala.annotation.internal.Stable"),
12+
)
13+
}

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)