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 across different versions #1018

Closed
wants to merge 3 commits into from
Closed
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
16 changes: 13 additions & 3 deletions build.sbt
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import sbt.Def
import MimaSettings.mimaSettings

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 +67,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 +106,7 @@ lazy val zioKafka =
.enablePlugins(BuildInfoPlugin)
.settings(stdSettings("zio-kafka"))
.settings(buildInfoSettings("zio.kafka"))
.settings(mimaSettings(failOnProblem = true))
.settings(enableZIO(enableStreaming = true))
.settings(
libraryDependencies ++= Seq(
Expand All @@ -126,6 +129,7 @@ lazy val zioKafkaTestkit =
.dependsOn(zioKafka)
.enablePlugins(BuildInfoPlugin)
.settings(stdSettings("zio-kafka-testkit"))
.settings(mimaSettings(failOnProblem = false))
erikvanoosten marked this conversation as resolved.
Show resolved Hide resolved
.settings(
libraryDependencies ++= Seq(
"dev.zio" %% "zio" % zioVersion.value,
Expand Down Expand Up @@ -187,6 +191,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 +211,8 @@ lazy val docs = project
)
.enablePlugins(WebsitePlugin)
.dependsOn(zioKafka, zioKafkaTestkit)

lazy val lint = {
val defaultLint = zio.sbt.Commands.ComposableCommand.lint
defaultLint.copy(commandStrings = defaultLint.commandStrings :+ "mimaCheck").toCommand
Copy link
Contributor Author

@myazinn myazinn Aug 9, 2023

Choose a reason for hiding this comment

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

This is an awful hack that I'm not proud of. But it's the only one that I can think of that works ¯\_(ツ)_/¯

}
18 changes: 18 additions & 0 deletions project/MimaSettings.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
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 {
lazy val bincompatVersionToCompare = "2.4.2"

def mimaSettings(failOnProblem: Boolean) =
Seq(
mimaPreviousArtifacts := Set(organization.value %% name.value % bincompatVersionToCompare),
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.9.16")
addSbtPlugin("com.typesafe" % "sbt-mima-plugin" % "1.1.3")

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