From 6ba8a39ff2668cd4449c33f775269c317878c5e9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Doeraene?= Date: Fri, 7 May 2021 16:20:44 +0200 Subject: [PATCH] Fix #11939: Set up MiMa for scala3-interfaces in scala3-library. --- .github/workflows/ci.yaml | 4 +++ project/Build.scala | 52 ++++++++++++++++++++++++++++++++++++--- project/MiMaFilters.scala | 13 ++++++++++ project/plugins.sbt | 2 ++ 4 files changed, 67 insertions(+), 4 deletions(-) create mode 100644 project/MiMaFilters.scala diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index c69cbab2a0fb..c66a8459aa0d 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -114,6 +114,10 @@ jobs: ./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" ./project/scripts/bootstrapCmdTests + - name: MiMa + run: | + ./project/scripts/sbt ";scala3-interfaces/mimaReportBinaryIssues ;scala3-library-bootstrapped/mimaReportBinaryIssues ;scala3-library-bootstrappedJS/mimaReportBinaryIssues" + test_windows_fast: runs-on: [self-hosted, Windows] if: "( diff --git a/project/Build.scala b/project/Build.scala index 61b4d5076486..56cca68ff2c2 100644 --- a/project/Build.scala +++ b/project/Build.scala @@ -15,6 +15,8 @@ import xerial.sbt.pack.PackPlugin import xerial.sbt.pack.PackPlugin.autoImport._ import xerial.sbt.Sonatype.autoImport._ +import com.typesafe.tools.mima.plugin.MimaPlugin.autoImport._ + import dotty.tools.sbtplugin.DottyIDEPlugin.{ installCodeExtension, prepareCommand, runProcess } import dotty.tools.sbtplugin.DottyIDEPlugin.autoImport._ @@ -72,6 +74,29 @@ object Build { val publishedDottyVersion = referenceVersion val sbtDottyVersion = "0.5.5" + /** 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. + */ + val previousDottyVersion = "3.0.0-RC3" + val previousDottyBinaryVersion = "3.0.0-RC3" + + object CompatMode { + final val BinaryCompatible = 0 + final val SourceAndBinaryCompatible = 1 + } + + val compatMode = { + val VersionRE = """^\d+\.(\d+).(\d+).*""".r + baseVersion match { + case VersionRE(_, "0") => CompatMode.BinaryCompatible + case _ => CompatMode.SourceAndBinaryCompatible + } + } + /** scala-library version required to compile Dotty. * * Both the non-bootstrapped and bootstrapped version should match, unless @@ -392,6 +417,22 @@ object Build { javaOptions += "-DBENCH_CLASS_PATH=" + Attributed.data((`scala3-library-bootstrapped` / Compile / fullClasspath).value).mkString("", File.pathSeparator, "") ) + lazy val commonMiMaSettings = Def.settings( + mimaPreviousArtifacts += { + val thisProjectID = projectID.value + val crossedName = thisProjectID.crossVersion match { + case cv: Disabled => thisProjectID.name + case cv: Binary => s"${thisProjectID.name}_${cv.prefix}$previousDottyBinaryVersion${cv.suffix}" + } + (thisProjectID.organization % crossedName % previousDottyVersion) + }, + + mimaCheckDirection := (compatMode match { + case CompatMode.BinaryCompatible => "backward" + case CompatMode.SourceAndBinaryCompatible => "both" + }), + ) + /** Projects -------------------------------------------------------------- */ val dottyCompilerBootstrappedRef = LocalProject("scala3-compiler-bootstrapped") @@ -411,7 +452,8 @@ object Build { lazy val `scala3-bootstrapped` = project.asDottyRoot(Bootstrapped) lazy val `scala3-interfaces` = project.in(file("interfaces")). - settings(commonJavaSettings) + settings(commonJavaSettings). + settings(commonMiMaSettings) /** Find an artifact with the given `name` in `classpath` */ def findArtifact(classpath: Def.Classpath, name: String): File = classpath @@ -1636,15 +1678,17 @@ object Build { ). settings(dottyLibrarySettings) if (mode == Bootstrapped) { - base.settings(Seq( + base.settings( (Compile/doc) := { // Workaround for // [error] |object IArray cannot have the same name as object IArray in package scala // -- cannot define object member with the same name as a object member in self reference _. val doWork = (Compile/doc).result.value (Compile/doc/target).value - } - )) + }, + commonMiMaSettings, + mimaBinaryIssueFilters ++= MiMaFilters.Library, + ) } else base } diff --git a/project/MiMaFilters.scala b/project/MiMaFilters.scala new file mode 100644 index 000000000000..3d4da124a2ff --- /dev/null +++ b/project/MiMaFilters.scala @@ -0,0 +1,13 @@ + +import com.typesafe.tools.mima.core._ +import com.typesafe.tools.mima.core.ProblemFilters._ + +object MiMaFilters { + val Library: Seq[ProblemFilter] = Seq( + // New APIs marked @experimental in 3.0.1 + exclude[DirectMissingMethodProblem]("scala.quoted.Quotes#reflectModule#TermParamClauseMethods.isErased"), + exclude[ReversedMissingMethodProblem]("scala.quoted.Quotes#reflectModule#TermParamClauseMethods.isErased"), + exclude[MissingClassProblem]("scala.annotation.internal.ErasedParam"), + exclude[MissingClassProblem]("scala.annotation.experimental"), + ) +} diff --git a/project/plugins.sbt b/project/plugins.sbt index 8b88da956299..e0071ea63676 100644 --- a/project/plugins.sbt +++ b/project/plugins.sbt @@ -13,3 +13,5 @@ addSbtPlugin("org.xerial.sbt" % "sbt-pack" % "0.13") addSbtPlugin("pl.project13.scala" % "sbt-jmh" % "0.3.2") addSbtPlugin("com.eed3si9n" % "sbt-buildinfo" % "0.9.0") + +addSbtPlugin("com.typesafe" % "sbt-mima-plugin" % "0.9.0")