-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Changes from 1 commit
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
f32d40e
wip adding mima exception tests
kailuowang 794ed7e
uncomment bc breaking code
kailuowang 8158805
binary compat test working
kailuowang 3bb2714
fix 2.13 build
kailuowang b81c98c
fix typo
kailuowang fd87dc3
keep fixing typo
kailuowang File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
26 changes: 26 additions & 0 deletions
26
binCompactTest/src/main/scala/cats/BC/MImaExceptions.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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
10
binCompactTest/src/test/scala/cats/BC/MimaExceptionsTest.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should this be There was a problem hiding this comment. Choose a reason for hiding this commentThe 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") | ||
|
@@ -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") | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
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.