From f32d40e69ddfa30b8258f54ef2c103b16d4f3c97 Mon Sep 17 00:00:00 2001 From: Kailuo Wang Date: Mon, 17 Sep 2018 14:08:35 -0400 Subject: [PATCH 1/6] wip adding mima exception tests --- .../main/scala/cats/BC/MImaExceptions.scala | 26 ++++++++++ .../scala/cats/BC/MimaExceptionsTest.scala | 10 ++++ build.sbt | 50 +++++++++++++------ core/src/main/scala/cats/data/OptionT.scala | 4 +- 4 files changed, 74 insertions(+), 16 deletions(-) create mode 100644 binCompactTest/src/main/scala/cats/BC/MImaExceptions.scala create mode 100644 binCompactTest/src/test/scala/cats/BC/MimaExceptionsTest.scala diff --git a/binCompactTest/src/main/scala/cats/BC/MImaExceptions.scala b/binCompactTest/src/main/scala/cats/BC/MImaExceptions.scala new file mode 100644 index 0000000000..5d93181fc7 --- /dev/null +++ b/binCompactTest/src/main/scala/cats/BC/MImaExceptions.scala @@ -0,0 +1,26 @@ +package cats +package BC + +object MimaExceptions { + import cats.implicits._ + import cats._, data._ + def isBinaryCompatible = { + + Monad[OptionT[List, ?]].pure(1) + var a: Any = cats.data.OptionT.catsDataTraverseForOptionT[List] + a = cats.data.Kleisli.catsDataCommutativeArrowForKleisliId + a = cats.data.OptionT.catsDataMonoidKForOptionT[List] + a = cats.data.OptionT.catsDataMonoidForOptionT[List, Int] + a = cats.data.Kleisli.catsDataMonadForKleisliId[Int] + a = cats.data.Kleisli.catsDataCommutativeArrowForKleisli[Option] + a = cats.data.Kleisli.catsDataCommutativeFlatMapForKleisli[Option, Int] + a = cats.data.IRWST.catsDataStrongForIRWST[List, Int, Int, Int] + a = cats.data.OptionT.catsDataMonadErrorMonadForOptionT[List] + + a = "e".leftNec[Int] + + + true + + } +} diff --git a/binCompactTest/src/test/scala/cats/BC/MimaExceptionsTest.scala b/binCompactTest/src/test/scala/cats/BC/MimaExceptionsTest.scala new file mode 100644 index 0000000000..c74eed985c --- /dev/null +++ b/binCompactTest/src/test/scala/cats/BC/MimaExceptionsTest.scala @@ -0,0 +1,10 @@ +package cats +package BC +import org.scalatest.{FunSuite} + + +class MimaExceptionsTest extends FunSuite { + test("is binary compatible") { + assert(MimaExceptions.isBinaryCompatible) + } +} diff --git a/build.sbt b/build.sbt index 548a3f0cbd..4e982e969c 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,18 @@ lazy val bench = project.dependsOn(macrosJVM, coreJVM, freeJVM, lawsJVM) )) .enablePlugins(JmhPlugin) + +lazy val binCompactTest = project + .settings(catsSettings) + .settings(noPublishSettings) + .settings(libraryDependencies ++= List( +// mimaPrevious("cats-core", scalaVersion.value, version.value).head % Compile, + "org.typelevel" %% "cats-core" % "1.2.0" % Compile, + "org.typelevel" %% "cats-core" % "1.3.0" % 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 +631,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;binCompTest/test;mimaReportBinaryIssues") + +addCommandAlias("validateJVM", ";scalastyle;buildJVM;bench/test;validateBC;makeMicrosite") addCommandAlias("validateJS", ";catsJS/compile;testsJS/test;js/test") diff --git a/core/src/main/scala/cats/data/OptionT.scala b/core/src/main/scala/cats/data/OptionT.scala index 606bc5d252..6104df74e5 100644 --- a/core/src/main/scala/cats/data/OptionT.scala +++ b/core/src/main/scala/cats/data/OptionT.scala @@ -218,8 +218,8 @@ object OptionT extends OptionTInstances { private[data] sealed abstract class OptionTInstances extends OptionTInstances0 { // to maintain binary compatibility - def catsDataMonadForOptionT[F[_]](implicit F0: Monad[F]): Monad[OptionT[F, ?]] = - new OptionTMonad[F] { implicit val F = F0 } +// def catsDataMonadForOptionT[F[_]](implicit F0: Monad[F]): Monad[OptionT[F, ?]] = +// new OptionTMonad[F] { implicit val F = F0 } implicit def catsDataTraverseForOptionT[F[_]](implicit F0: Traverse[F]): Traverse[OptionT[F, ?]] = new OptionTTraverse[F] with OptionTFunctor[F] { implicit val F = F0 } From 794ed7e6029c80596409e37082853a6245aed3c5 Mon Sep 17 00:00:00 2001 From: Kailuo Wang Date: Mon, 17 Sep 2018 14:16:25 -0400 Subject: [PATCH 2/6] uncomment bc breaking code --- core/src/main/scala/cats/data/OptionT.scala | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/core/src/main/scala/cats/data/OptionT.scala b/core/src/main/scala/cats/data/OptionT.scala index 6104df74e5..606bc5d252 100644 --- a/core/src/main/scala/cats/data/OptionT.scala +++ b/core/src/main/scala/cats/data/OptionT.scala @@ -218,8 +218,8 @@ object OptionT extends OptionTInstances { private[data] sealed abstract class OptionTInstances extends OptionTInstances0 { // to maintain binary compatibility -// def catsDataMonadForOptionT[F[_]](implicit F0: Monad[F]): Monad[OptionT[F, ?]] = -// new OptionTMonad[F] { implicit val F = F0 } + def catsDataMonadForOptionT[F[_]](implicit F0: Monad[F]): Monad[OptionT[F, ?]] = + new OptionTMonad[F] { implicit val F = F0 } implicit def catsDataTraverseForOptionT[F[_]](implicit F0: Traverse[F]): Traverse[OptionT[F, ?]] = new OptionTTraverse[F] with OptionTFunctor[F] { implicit val F = F0 } From 8158805d9da4978d83cab268ae4a3ee7f71149ad Mon Sep 17 00:00:00 2001 From: Kailuo Wang Date: Tue, 18 Sep 2018 14:20:27 -0400 Subject: [PATCH 3/6] binary compat test working --- .../main/scala/cats/BC/MImaExceptions.scala | 26 ------------------- .../main/scala/catsBC/MimaExceptions.scala | 21 +++++++++++++++ .../scala/cats/BC/MimaExceptionsTest.scala | 10 ------- .../scala/catsBC/MimaExceptionsTest.scala | 9 +++++++ build.sbt | 18 +++++++------ 5 files changed, 40 insertions(+), 44 deletions(-) delete mode 100644 binCompactTest/src/main/scala/cats/BC/MImaExceptions.scala create mode 100644 binCompactTest/src/main/scala/catsBC/MimaExceptions.scala delete mode 100644 binCompactTest/src/test/scala/cats/BC/MimaExceptionsTest.scala create mode 100644 binCompactTest/src/test/scala/catsBC/MimaExceptionsTest.scala diff --git a/binCompactTest/src/main/scala/cats/BC/MImaExceptions.scala b/binCompactTest/src/main/scala/cats/BC/MImaExceptions.scala deleted file mode 100644 index 5d93181fc7..0000000000 --- a/binCompactTest/src/main/scala/cats/BC/MImaExceptions.scala +++ /dev/null @@ -1,26 +0,0 @@ -package cats -package BC - -object MimaExceptions { - import cats.implicits._ - import cats._, data._ - def isBinaryCompatible = { - - Monad[OptionT[List, ?]].pure(1) - var a: Any = cats.data.OptionT.catsDataTraverseForOptionT[List] - a = cats.data.Kleisli.catsDataCommutativeArrowForKleisliId - a = cats.data.OptionT.catsDataMonoidKForOptionT[List] - a = cats.data.OptionT.catsDataMonoidForOptionT[List, Int] - a = cats.data.Kleisli.catsDataMonadForKleisliId[Int] - a = cats.data.Kleisli.catsDataCommutativeArrowForKleisli[Option] - a = cats.data.Kleisli.catsDataCommutativeFlatMapForKleisli[Option, Int] - a = cats.data.IRWST.catsDataStrongForIRWST[List, Int, Int, Int] - a = cats.data.OptionT.catsDataMonadErrorMonadForOptionT[List] - - a = "e".leftNec[Int] - - - true - - } -} diff --git a/binCompactTest/src/main/scala/catsBC/MimaExceptions.scala b/binCompactTest/src/main/scala/catsBC/MimaExceptions.scala new file mode 100644 index 0000000000..d76fcc94f3 --- /dev/null +++ b/binCompactTest/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/binCompactTest/src/test/scala/cats/BC/MimaExceptionsTest.scala b/binCompactTest/src/test/scala/cats/BC/MimaExceptionsTest.scala deleted file mode 100644 index c74eed985c..0000000000 --- a/binCompactTest/src/test/scala/cats/BC/MimaExceptionsTest.scala +++ /dev/null @@ -1,10 +0,0 @@ -package cats -package BC -import org.scalatest.{FunSuite} - - -class MimaExceptionsTest extends FunSuite { - test("is binary compatible") { - assert(MimaExceptions.isBinaryCompatible) - } -} diff --git a/binCompactTest/src/test/scala/catsBC/MimaExceptionsTest.scala b/binCompactTest/src/test/scala/catsBC/MimaExceptionsTest.scala new file mode 100644 index 0000000000..18971eae45 --- /dev/null +++ b/binCompactTest/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 4e982e969c..44938ecc21 100644 --- a/build.sbt +++ b/build.sbt @@ -504,14 +504,16 @@ lazy val bench = project.dependsOn(macrosJVM, coreJVM, freeJVM, lawsJVM) lazy val binCompactTest = project - .settings(catsSettings) + .disablePlugins(CoursierPlugin) .settings(noPublishSettings) - .settings(libraryDependencies ++= List( -// mimaPrevious("cats-core", scalaVersion.value, version.value).head % Compile, - "org.typelevel" %% "cats-core" % "1.2.0" % Compile, - "org.typelevel" %% "cats-core" % "1.3.0" % Test, - "org.scalatest" %%% "scalatest" % scalatestVersion(scalaVersion.value) % Test - )) + .settings( + addCompilerPlugin("org.spire-math" %% "kind-projector" % "0.9.7"), + libraryDependencies ++= List( + mimaPrevious("cats-core", scalaVersion.value, version.value).last % Provided, + "org.typelevel" %% "cats-core" % version.value % Test, + "org.scalatest" %%% "scalatest" % scalatestVersion(scalaVersion.value) % Test + ) + ) // cats-js is JS-only @@ -631,7 +633,7 @@ addCommandAlias("buildAlleycatsJVM", ";alleycatsCoreJVM/test;alleycatsLawsJVM/te addCommandAlias("buildJVM", ";buildKernelJVM;buildCoreJVM;buildTestsJVM;buildFreeJVM;buildAlleycatsJVM") -addCommandAlias("validateBC", ";catsJVM/publishLocal;binCompTest/test;mimaReportBinaryIssues") +addCommandAlias("validateBC", ";catsJVM/publishLocal;binCompactTest/test;mimaReportBinaryIssues") addCommandAlias("validateJVM", ";scalastyle;buildJVM;bench/test;validateBC;makeMicrosite") From 3bb271406619434ba29fd31219ee8b98ef425f06 Mon Sep 17 00:00:00 2001 From: Kailuo Wang Date: Tue, 18 Sep 2018 17:08:18 -0400 Subject: [PATCH 4/6] fix 2.13 build --- build.sbt | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/build.sbt b/build.sbt index 44938ecc21..558aeba588 100644 --- a/build.sbt +++ b/build.sbt @@ -509,7 +509,12 @@ lazy val binCompactTest = project .settings( addCompilerPlugin("org.spire-math" %% "kind-projector" % "0.9.7"), libraryDependencies ++= List( - mimaPrevious("cats-core", scalaVersion.value, version.value).last % Provided, + { + 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 ) From b81c98c15c3211db63236ba803415b1a0da7accd Mon Sep 17 00:00:00 2001 From: Kailuo Wang Date: Wed, 26 Sep 2018 10:06:53 -0400 Subject: [PATCH 5/6] fix typo --- .../src/main/scala/catsBC/MimaExceptions.scala | 0 .../src/test/scala/catsBC/MimaExceptionsTest.scala | 0 build.sbt | 2 +- 3 files changed, 1 insertion(+), 1 deletion(-) rename {binCompactTest => binCompatTest}/src/main/scala/catsBC/MimaExceptions.scala (100%) rename {binCompactTest => binCompatTest}/src/test/scala/catsBC/MimaExceptionsTest.scala (100%) diff --git a/binCompactTest/src/main/scala/catsBC/MimaExceptions.scala b/binCompatTest/src/main/scala/catsBC/MimaExceptions.scala similarity index 100% rename from binCompactTest/src/main/scala/catsBC/MimaExceptions.scala rename to binCompatTest/src/main/scala/catsBC/MimaExceptions.scala diff --git a/binCompactTest/src/test/scala/catsBC/MimaExceptionsTest.scala b/binCompatTest/src/test/scala/catsBC/MimaExceptionsTest.scala similarity index 100% rename from binCompactTest/src/test/scala/catsBC/MimaExceptionsTest.scala rename to binCompatTest/src/test/scala/catsBC/MimaExceptionsTest.scala diff --git a/build.sbt b/build.sbt index 558aeba588..e8f3e19445 100644 --- a/build.sbt +++ b/build.sbt @@ -503,7 +503,7 @@ lazy val bench = project.dependsOn(macrosJVM, coreJVM, freeJVM, lawsJVM) .enablePlugins(JmhPlugin) -lazy val binCompactTest = project +lazy val binCompatTest = project .disablePlugins(CoursierPlugin) .settings(noPublishSettings) .settings( From fd87dc320d5d68d48acfe958e2737a3411d0fdd7 Mon Sep 17 00:00:00 2001 From: "Kai(luo) Wang" Date: Wed, 26 Sep 2018 10:40:42 -0400 Subject: [PATCH 6/6] keep fixing typo --- build.sbt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.sbt b/build.sbt index e8f3e19445..22f5421db5 100644 --- a/build.sbt +++ b/build.sbt @@ -638,7 +638,7 @@ addCommandAlias("buildAlleycatsJVM", ";alleycatsCoreJVM/test;alleycatsLawsJVM/te addCommandAlias("buildJVM", ";buildKernelJVM;buildCoreJVM;buildTestsJVM;buildFreeJVM;buildAlleycatsJVM") -addCommandAlias("validateBC", ";catsJVM/publishLocal;binCompactTest/test;mimaReportBinaryIssues") +addCommandAlias("validateBC", ";catsJVM/publishLocal;binCompatTest/test;mimaReportBinaryIssues") addCommandAlias("validateJVM", ";scalastyle;buildJVM;bench/test;validateBC;makeMicrosite")