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

Adding tests for binary compat that can't be tested by Mima #2509

Merged
merged 6 commits into from
Sep 26, 2018
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
26 changes: 26 additions & 0 deletions binCompactTest/src/main/scala/cats/BC/MImaExceptions.scala
Original file line number Diff line number Diff line change
@@ -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

}
}
10 changes: 10 additions & 0 deletions binCompactTest/src/test/scala/cats/BC/MimaExceptionsTest.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package cats
package BC
import org.scalatest.{FunSuite}


class MimaExceptionsTest extends FunSuite {
test("is binary compatible") {
assert(MimaExceptions.isBinaryCompatible)
}
}
50 changes: 36 additions & 14 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -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] = {
Copy link
Contributor Author

@kailuowang kailuowang Sep 17, 2018

Choose a reason for hiding this comment

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

Note for @rossabaker , no need to read these changes regarding change to mimaPreviousArtifacts change. For now I'm not using them and hard coded the two cats versions to test binary compat (1.2.0 and 1.3.0)

Update: No longer relevant.

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
Expand All @@ -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._
Expand All @@ -278,6 +285,7 @@ def mimaSettings(moduleName: String) = {
)
}


lazy val docs = project
.enablePlugins(MicrositesPlugin)
.enablePlugins(ScalaUnidocPlugin)
Expand Down Expand Up @@ -494,6 +502,18 @@ lazy val bench = project.dependsOn(macrosJVM, coreJVM, freeJVM, lawsJVM)
))
.enablePlugins(JmhPlugin)


lazy val binCompactTest = project
Copy link
Contributor

Choose a reason for hiding this comment

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

Should this be binCompatTest (and also in the source folder)?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

oops

.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")
Expand Down Expand Up @@ -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")

Expand Down
4 changes: 2 additions & 2 deletions core/src/main/scala/cats/data/OptionT.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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 }
Expand Down