Skip to content

Commit

Permalink
Add MiMa binary compatibility checks
Browse files Browse the repository at this point in the history
  • Loading branch information
plokhotnyuk committed Jan 14, 2025
1 parent e604945 commit 9367595
Show file tree
Hide file tree
Showing 3 changed files with 64 additions and 13 deletions.
20 changes: 19 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -106,9 +106,27 @@ jobs:
- name: Run tests
run: sbt ++${{ matrix.scala }}! test${{ matrix.platform }}

mima_check:
runs-on: ubuntu-20.04
timeout-minutes: 30
steps:
- name: Checkout current branch
uses: actions/checkout@v4
with:
fetch-depth: 300
- name: Fetch tags
run: git fetch --depth=300 origin +refs/tags/*:refs/tags/*
- name: Setup Java (temurin@21)
uses: actions/setup-java@v4
with:
distribution: temurin
java-version: 21
cache: sbt
- run: sbt +mimaReportBinaryIssues

ci:
runs-on: ubuntu-20.04
needs: [lint, mdoc, benchmarks, test]
needs: [lint, mdoc, benchmarks, test, mima_check]
steps:
- name: Aggregate of lint, and all tests
run: echo "ci passed"
Expand Down
5 changes: 4 additions & 1 deletion build.sbt
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import BuildHelper.*
import com.typesafe.tools.mima.plugin.MimaKeys.mimaPreviousArtifacts
import explicitdeps.ExplicitDepsPlugin.autoImport.moduleFilterRemoveValue
import sbtcrossproject.CrossPlugin.autoImport.crossProject

Expand Down Expand Up @@ -60,7 +61,8 @@ val zioVersion = "2.1.14"
lazy val zioJsonRoot = project
.in(file("."))
.settings(
publish / skip := true,
publish / skip := true,
mimaPreviousArtifacts := Set(),
unusedCompileDependenciesFilter -= moduleFilter("org.scala-js", "scalajs-library")
)
.aggregate(
Expand Down Expand Up @@ -400,6 +402,7 @@ lazy val docs = project
zioJsonInteropScalaz7x.jvm,
zioJsonGolden
),
mimaPreviousArtifacts := Set(),
readmeAcknowledgement :=
"""|- Uses [JsonTestSuite](https://github.com/nst/JSONTestSuite) to test parsing. (c) 2016 Nicolas Seriot)
|
Expand Down
52 changes: 41 additions & 11 deletions project/BuildHelper.scala
Original file line number Diff line number Diff line change
@@ -1,10 +1,15 @@
import com.typesafe.tools.mima.core.Problem
import com.typesafe.tools.mima.core.ProblemFilters.exclude
import com.typesafe.tools.mima.plugin.MimaKeys.{ mimaBinaryIssueFilters, mimaFailOnProblem, mimaPreviousArtifacts }
import com.typesafe.tools.mima.plugin.MimaPlugin.autoImport.mimaCheckDirection
import explicitdeps.ExplicitDepsPlugin.autoImport.*
import org.portablescala.sbtplatformdeps.PlatformDepsPlugin.autoImport.*
import sbt.*
import sbt.Keys.*
import sbtbuildinfo.*
import sbtbuildinfo.BuildInfoKeys.*
import sbtcrossproject.CrossPlugin.autoImport.*
import sbtdynver.DynVerPlugin.autoImport.previousStableVersion

import scala.scalanative.sbtplugin.ScalaNativePlugin.autoImport.*

Expand Down Expand Up @@ -237,7 +242,28 @@ object BuildHelper {
Test / parallelExecution := true,
incOptions ~= (_.withLogRecompileOnMacro(false)),
autoAPIMappings := true,
unusedCompileDependenciesFilter -= moduleFilter("org.scala-js", "scalajs-library")
unusedCompileDependenciesFilter -= moduleFilter("org.scala-js", "scalajs-library"),
mimaPreviousArtifacts := previousStableVersion.value.map(organization.value %% name.value % _).toSet,
mimaCheckDirection := {
def isPatch: Boolean = {
val Array(newMajor, newMinor, _) = version.value.split('.')
val Array(oldMajor, oldMinor, _) = previousStableVersion.value.getOrElse(version.value).split('.')
newMajor == oldMajor && newMinor == oldMinor
}

if (isPatch) "both"
else "backward"
},
mimaBinaryIssueFilters ++= Seq(
exclude[Problem]("zio.json.macros#package.<clinit>"),
exclude[Problem]("zio.JsonPackagePlatformSpecific.*"),
exclude[Problem]("zio.json.JsonDecoderPlatformSpecific.*"),
exclude[Problem]("zio.json.JsonEncoderPlatformSpecific.*"),
exclude[Problem]("zio.json.internal.*"),
exclude[Problem]("zio.json.package.*"),
exclude[Problem]("zio.json.yaml.internal.*")
),
mimaFailOnProblem := true
)

def macroExpansionSettings = Seq(
Expand All @@ -258,14 +284,14 @@ object BuildHelper {

def macroDefinitionSettings = Seq(
scalacOptions += "-language:experimental.macros",
libraryDependencies ++= {
if (scalaVersion.value == ScalaDotty) Seq()
else
libraryDependencies ++= (CrossVersion.partialVersion(scalaVersion.value) match {
case Some((2, _)) =>
Seq(
"org.scala-lang" % "scala-reflect" % scalaVersion.value % "provided",
"org.scala-lang" % "scala-compiler" % scalaVersion.value % "provided"
)
}
case _ => Seq()
})
)

val scalaJavaTimeVersion = "2.6.0"
Expand All @@ -290,12 +316,16 @@ object BuildHelper {
)

val scalaReflectTestSettings: List[Setting[_]] = List(
libraryDependencies ++= {
if (scalaVersion.value == ScalaDotty)
Seq("org.scala-lang" % "scala-reflect" % Scala213 % Test)
else
Seq("org.scala-lang" % "scala-reflect" % scalaVersion.value % Test)
}
libraryDependencies ++= (CrossVersion.partialVersion(scalaVersion.value) match {
case Some((2, _)) =>
Seq(
"org.scala-lang" % "scala-reflect" % scalaVersion.value % Test
)
case _ =>
Seq(
"org.scala-lang" % "scala-reflect" % Scala213 % Test
)
})
)

def welcomeMessage = onLoadMessage := {
Expand Down

0 comments on commit 9367595

Please sign in to comment.