diff --git a/binCompatTest/src/main/scala/catsBC/MimaExceptions.scala b/binCompatTest/src/main/scala/catsBC/MimaExceptions.scala new file mode 100644 index 0000000000..d76fcc94f3 --- /dev/null +++ b/binCompatTest/src/main/scala/catsBC/MimaExceptions.scala @@ -0,0 +1,21 @@ +package catsBC +import cats.implicits._ +import cats._, data._, cats.arrow._ + +object MimaExceptions { + import cats.implicits._ + + def isBinaryCompatible = ( + Monad[OptionT[List, ?]], + cats.data.OptionT.catsDataTraverseForOptionT[List], + cats.data.Kleisli.catsDataCommutativeArrowForKleisliId, + cats.data.OptionT.catsDataMonoidKForOptionT[List], + cats.data.OptionT.catsDataMonoidForOptionT[List, Int], + cats.data.Kleisli.catsDataMonadForKleisliId[Int], + cats.data.Kleisli.catsDataCommutativeArrowForKleisli[Option], + cats.data.Kleisli.catsDataCommutativeFlatMapForKleisli[Option, Int], + cats.data.IRWST.catsDataStrongForIRWST[List, Int, Int, Int], + cats.data.OptionT.catsDataMonadErrorMonadForOptionT[List] + ) + +} diff --git a/binCompatTest/src/test/scala/catsBC/MimaExceptionsTest.scala b/binCompatTest/src/test/scala/catsBC/MimaExceptionsTest.scala new file mode 100644 index 0000000000..18971eae45 --- /dev/null +++ b/binCompatTest/src/test/scala/catsBC/MimaExceptionsTest.scala @@ -0,0 +1,9 @@ +package catsBC + +import org.scalatest.FunSuite + +class MimaExceptionsTest extends FunSuite { + test("is binary compatible") { + MimaExceptions.isBinaryCompatible + } +} diff --git a/build.sbt b/build.sbt index 548a3f0cbd..22f5421db5 100644 --- a/build.sbt +++ b/build.sbt @@ -216,10 +216,10 @@ lazy val docSettings = Seq( includeFilter in Jekyll := (includeFilter in makeSite).value ) -def mimaSettings(moduleName: String) = { +def mimaPrevious(moduleName: String, scalaVer: String, ver: String): List[ModuleID] = { import sbtrelease.Version - def semverBinCompatVersions(major: Int, minor: Int, patch: Int): Set[(Int, Int, Int)] = { + def semverBinCompatVersions(major: Int, minor: Int, patch: Int): List[(Int, Int, Int)] = { val majorVersions: List[Int] = List(major) val minorVersions : List[Int] = if (major >= 1) Range(0, minor).inclusive.toList @@ -234,30 +234,37 @@ def mimaSettings(moduleName: String) = { min <- minorVersions pat <- patchVersions(min) } yield (maj, min, pat) - versions.toSet + versions.toList } - def mimaVersions(version: String): Set[String] = { - Version(version) match { + val mimaVersions: List[String] = { + Version(ver) match { case Some(Version(major, Seq(minor, patch), _)) => semverBinCompatVersions(major.toInt, minor.toInt, patch.toInt) .map{case (maj, min, pat) => s"${maj}.${min}.${pat}"} case _ => - Set.empty[String] + List.empty[String] } } // Safety Net For Exclusions - lazy val excludedVersions: Set[String] = Set() + lazy val excludedVersions: List[String] = List() // Safety Net for Inclusions - lazy val extraVersions: Set[String] = Set() + lazy val extraVersions: List[String] = List() + + + if(priorTo2_13(scalaVer)) { + (mimaVersions ++ extraVersions) + .filterNot(excludedVersions.contains(_)) + .map(v => "org.typelevel" %% moduleName % v) + } else List() + +} + +def mimaSettings(moduleName: String) = { Seq( - mimaPreviousArtifacts := { if(priorTo2_13(scalaVersion.value)) { - (mimaVersions(version.value) ++ extraVersions) - .filterNot(excludedVersions.contains(_)) - .map(v => "org.typelevel" %% moduleName % v) - } else Set() }, + mimaPreviousArtifacts := mimaPrevious(moduleName, scalaVersion.value, version.value).toSet, mimaBinaryIssueFilters ++= { import com.typesafe.tools.mima.core._ @@ -278,6 +285,7 @@ def mimaSettings(moduleName: String) = { ) } + lazy val docs = project .enablePlugins(MicrositesPlugin) .enablePlugins(ScalaUnidocPlugin) @@ -494,6 +502,25 @@ lazy val bench = project.dependsOn(macrosJVM, coreJVM, freeJVM, lawsJVM) )) .enablePlugins(JmhPlugin) + +lazy val binCompatTest = project + .disablePlugins(CoursierPlugin) + .settings(noPublishSettings) + .settings( + addCompilerPlugin("org.spire-math" %% "kind-projector" % "0.9.7"), + libraryDependencies ++= List( + { + if (priorTo2_13(scalaVersion.value)) + mimaPrevious("cats-core", scalaVersion.value, version.value).last % Provided + else //We are not testing BC on Scala 2.13 yet. + "org.typelevel" %% "cats-core" % version.value % Provided + }, + "org.typelevel" %% "cats-core" % version.value % Test, + "org.scalatest" %%% "scalatest" % scalatestVersion(scalaVersion.value) % Test + ) + ) + + // cats-js is JS-only lazy val js = project .dependsOn(macrosJS, coreJS, testsJS % "test-internal -> test") @@ -611,7 +638,9 @@ addCommandAlias("buildAlleycatsJVM", ";alleycatsCoreJVM/test;alleycatsLawsJVM/te addCommandAlias("buildJVM", ";buildKernelJVM;buildCoreJVM;buildTestsJVM;buildFreeJVM;buildAlleycatsJVM") -addCommandAlias("validateJVM", ";scalastyle;buildJVM;bench/test;mimaReportBinaryIssues;makeMicrosite") +addCommandAlias("validateBC", ";catsJVM/publishLocal;binCompatTest/test;mimaReportBinaryIssues") + +addCommandAlias("validateJVM", ";scalastyle;buildJVM;bench/test;validateBC;makeMicrosite") addCommandAlias("validateJS", ";catsJS/compile;testsJS/test;js/test")