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 all commits
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
21 changes: 21 additions & 0 deletions binCompatTest/src/main/scala/catsBC/MimaExceptions.scala
Original file line number Diff line number Diff line change
@@ -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]
)

}
9 changes: 9 additions & 0 deletions binCompatTest/src/test/scala/catsBC/MimaExceptionsTest.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package catsBC

import org.scalatest.FunSuite

class MimaExceptionsTest extends FunSuite {
test("is binary compatible") {
MimaExceptions.isBinaryCompatible
}
}
57 changes: 43 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,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")
Expand Down Expand Up @@ -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")

Expand Down