Skip to content

Fix #11939: Set up MiMa for scala3-interfaces in scala3-library. #12371

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

Merged
merged 1 commit into from
May 15, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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: "(
Expand Down
52 changes: 48 additions & 4 deletions project/Build.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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._

Expand Down Expand Up @@ -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.
*/
Comment on lines +77 to +83
Copy link
Member

Choose a reason for hiding this comment

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

Can't we derive this from the version number?

Copy link
Member Author

Choose a reason for hiding this comment

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

No. When the base version is 3.1.0, how do you know what's the previous version? It could be any 3.0.x for any value of x. You don't know without going through all the published version to determine which one is the latest 3.0.x.

Copy link
Member

Choose a reason for hiding this comment

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

but couldn't you use 3.0.0 as a base (likewise for 3.0.2)? That means we can't reset the whitelist after every release but I don't think that's a big deal?

Copy link
Member Author

Choose a reason for hiding this comment

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

We could get away with that. That's not the established practice, though. And it means that you lose the ability to reasonably check experimental stuff that you introduce in the meantime, which you'd like not to accidentally break, at least.

IMO that's not a good trade off, but I can change if you prefer that it be automatically determined.

Copy link
Member

Choose a reason for hiding this comment

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

I think it's fine as is if it's established practice, but we need to add the need to update these variables to the release checklist /cc @anatoliykmetyuk

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
Expand Down Expand Up @@ -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")
Expand All @@ -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
Expand Down Expand Up @@ -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
}

Expand Down
13 changes: 13 additions & 0 deletions project/MiMaFilters.scala
Original file line number Diff line number Diff line change
@@ -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"),
)
}
2 changes: 2 additions & 0 deletions project/plugins.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -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")