Skip to content
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

Add MIMA checks to ensure binary compatibility #1214

Merged
merged 5 commits into from
Apr 14, 2024
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
27 changes: 24 additions & 3 deletions build.sbt
Original file line number Diff line number Diff line change
@@ -1,4 +1,15 @@
import sbt.Def
import MimaSettings.mimaSettings

/**
* As of zio-kafka version 2.8.0 releases are binary compatible. This is checked with Mima.
*
* Keep this value set to the oldest minor release (with patch version set to "0") that is still binary compatible.
*
* Set this value to `None` when master is _not_ binary compatible with the latest minor release, the next release shall
* increase the minor version.
*/
lazy val binCompatVersionToCompare = None // Some("2.8.0")

lazy val kafkaVersion = "3.7.0"
lazy val embeddedKafkaVersion = "3.7.0" // Should be the same as kafkaVersion, except for the patch part
Expand Down Expand Up @@ -66,9 +77,10 @@ val excludeInferAny = { options: Seq[String] => options.filterNot(Set("-Xlint:in
lazy val root = project
.in(file("."))
.settings(
name := "zio-kafka",
publish / skip := true,
crossScalaVersions := Nil // https://www.scala-sbt.org/1.x/docs/Cross-Build.html#Cross+building+a+project+statefully
name := "zio-kafka",
publish / skip := true,
crossScalaVersions := Nil, // https://www.scala-sbt.org/1.x/docs/Cross-Build.html#Cross+building+a+project+statefully,
commands += lint
)
.aggregate(
zioKafka,
Expand Down Expand Up @@ -104,6 +116,7 @@ lazy val zioKafka =
.enablePlugins(BuildInfoPlugin)
.settings(stdSettings("zio-kafka"))
.settings(buildInfoSettings("zio.kafka"))
.settings(mimaSettings(binCompatVersionToCompare, failOnProblem = true))
.settings(enableZIO(enableStreaming = true))
.settings(
libraryDependencies ++= Seq(
Expand All @@ -126,6 +139,7 @@ lazy val zioKafkaTestkit =
.dependsOn(zioKafka)
.enablePlugins(BuildInfoPlugin)
.settings(stdSettings("zio-kafka-testkit"))
.settings(mimaSettings(binCompatVersionToCompare, failOnProblem = false))
.settings(
libraryDependencies ++= Seq(
"dev.zio" %% "zio" % zioVersion.value,
Expand Down Expand Up @@ -187,6 +201,7 @@ lazy val zioKafkaExample =

addCommandAlias("fmt", "all scalafmtSbt scalafmt test:scalafmt")
addCommandAlias("check", "all scalafmtSbtCheck scalafmtCheck test:scalafmtCheck")
addCommandAlias("mimaCheck", "+zioKafka/mimaReportBinaryIssues;+zioKafkaTestkit/mimaReportBinaryIssues")

lazy val docs = project
.in(file("zio-kafka-docs"))
Expand All @@ -206,3 +221,9 @@ lazy val docs = project
)
.enablePlugins(WebsitePlugin)
.dependsOn(zioKafka, zioKafkaTestkit)

// Extend 'lint' with mimaCheck
lazy val lint = {
val defaultLint = zio.sbt.Commands.ComposableCommand.lint
defaultLint.copy(commandStrings = defaultLint.commandStrings :+ "mimaCheck").toCommand
}
24 changes: 24 additions & 0 deletions project/MimaSettings.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import com.typesafe.tools.mima.core.*
import com.typesafe.tools.mima.core.ProblemFilters.*
import com.typesafe.tools.mima.plugin.MimaKeys.*
import sbt.*
import sbt.Keys.{ name, organization }

object MimaSettings {

def mimaSettings(binCompatVersionToCompare: Option[String], failOnProblem: Boolean): Seq[Def.Setting[?]] =
binCompatVersionToCompare match {
case None =>
Seq(mimaPreviousArtifacts := Set.empty)
case Some(binCompatVersion) =>
Seq(
mimaPreviousArtifacts := Set(organization.value %% name.value % binCompatVersion),
mimaBinaryIssueFilters ++= Seq(
exclude[Problem]("zio.kafka.consumer.internal.*")
),
mimaFailOnProblem := failOnProblem
)

}

}
1 change: 1 addition & 0 deletions project/plugins.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,6 @@ addSbtPlugin("dev.zio" % "zio-sbt-ci" % zioSbtVersion)
addSbtPlugin("ch.epfl.scala" % "sbt-scalafix" % "0.12.0")
addSbtPlugin("org.typelevel" % "sbt-tpolecat" % "0.5.1")
addSbtPlugin("com.github.sbt" % "sbt-native-packager" % "1.10.0")
addSbtPlugin("com.typesafe" % "sbt-mima-plugin" % "1.1.3")

resolvers ++= Resolver.sonatypeOssRepos("public")
Loading