diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 0d3a10dd5f..35ee3d8b82 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -219,6 +219,31 @@ jobs: steps: - uses: release-drafter/release-drafter@v5 + mima_check: + name: Mima Check + if: ${{ github.event_name == 'pull_request' }} + strategy: + matrix: + os: [ubuntu-latest] + scala: [2.13.10] + java: [temurin@21] + runs-on: ${{ matrix.os }} + steps: + - name: Checkout current branch (full) + uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - name: Setup Java (temurin@21) + if: matrix.java == 'temurin@21' + uses: actions/setup-java@v4 + with: + distribution: temurin + java-version: 21 + cache: sbt + + - run: sbt mimaChecks + unsafeRunScoverage: name: Unsafe Scoverage strategy: diff --git a/aliases.sbt b/aliases.sbt index 1a952200cf..802211368b 100644 --- a/aliases.sbt +++ b/aliases.sbt @@ -3,9 +3,11 @@ addCommandAlias("fmtCheck", "scalafmtCheck; Test / scalafmtCheck; sFixCheck") addCommandAlias("sFix", "scalafix OrganizeImports; Test / scalafix OrganizeImports") addCommandAlias("sFixCheck", "scalafix --check OrganizeImports; Test / scalafix --check OrganizeImports") addCommandAlias("generateMediaTypes", "zioHttpTools/runMain zio.http.tools.GenerateMediaTypes") +addCommandAlias("mimaChecks", "zioHttpJVM/mimaReportBinaryIssues; zioHttpHtmx/mimaReportBinaryIssues" + ) onLoadMessage := { - import scala.Console._ + import scala.Console.* def header(text: String): String = s"${RED}$text${RESET}" def item(text: String): String = s"${GREEN}> ${CYAN}$text${RESET}" diff --git a/build.sbt b/build.sbt index 51eca7c909..cc48774a24 100644 --- a/build.sbt +++ b/build.sbt @@ -33,6 +33,13 @@ ThisBuild / githubWorkflowAddedJobs := steps = List(WorkflowStep.Use(UseRef.Public("release-drafter", "release-drafter", s"v${releaseDrafterVersion}"))), cond = Option("${{ github.base_ref == 'main' }}"), ), + WorkflowJob( + id = "mima_check", + name = "Mima Check", + steps = WorkflowStep.CheckoutFull +: WorkflowStep.SetupJava(List(JavaSpec.temurin("21"))) :+ WorkflowStep.Sbt(List("mimaChecks")), + cond = Option("${{ github.event_name == 'pull_request' }}"), + javas = List(JavaSpec.temurin("21")), + ), ) ++ ScoverageWorkFlow(50, 60) ++ JmhBenchmarkWorkflow(1) ++ BenchmarkWorkFlow() ThisBuild / githubWorkflowTargetTags ++= Seq("v*") @@ -176,6 +183,7 @@ lazy val zioHttp = crossProject(JSPlatform, JVMPlatform) }, libraryDependencies ++= netty ++ Seq(`netty-incubator`), ) + .jvmSettings(MimaSettings.mimaSettings(failOnProblem = true)) .jsSettings( ThisProject / fork := false, testFrameworks := Seq(new TestFramework("zio.test.sbt.ZTestFramework")), @@ -274,6 +282,7 @@ lazy val zioHttpHtmx = (project in file("zio-http-htmx")) ), ) .dependsOn(zioHttpJVM) + .settings(MimaSettings.mimaSettings(failOnProblem = true)) lazy val zioHttpExample = (project in file("zio-http-example")) .settings(stdSettings("zio-http-example")) diff --git a/project/MimaSettings.scala b/project/MimaSettings.scala new file mode 100644 index 0000000000..1edcce1f98 --- /dev/null +++ b/project/MimaSettings.scala @@ -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.{Def, *} +import sbt.Keys.{name, organization} +import sbtdynver.DynVerPlugin.autoImport.* + +object MimaSettings { + def mimaSettings(failOnProblem: Boolean): Seq[Def.Setting[?]] = + Seq( + mimaPreviousArtifacts ++= previousStableVersion.value.map(organization.value %% name.value % _).toSet, + mimaBinaryIssueFilters ++= Seq( + exclude[Problem]("zio.http.internal.*"), + exclude[Problem]("zio.http.codec.internal.*"), + ), + mimaFailOnProblem := failOnProblem + ) +} diff --git a/project/plugins.sbt b/project/plugins.sbt index 0295afcde9..737041f101 100644 --- a/project/plugins.sbt +++ b/project/plugins.sbt @@ -14,6 +14,7 @@ addSbtPlugin("org.scala-js" % "sbt-scalajs" % "1.16.0") addSbtPlugin("org.portable-scala" % "sbt-scalajs-crossproject" % "1.3.2") addSbtPlugin("com.thesamet" % "sbt-protoc" % "1.0.7") addSbtPlugin("com.thesamet" % "sbt-protoc-gen-project" % "0.1.8") +addSbtPlugin("com.typesafe" % "sbt-mima-plugin" % "1.1.4") addSbtPlugin("org.jetbrains.scala" % "sbt-ide-settings" % "1.1.2")