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

Add Function To Check All Relevant MiMa Versions #2265

Merged
Merged
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
34 changes: 29 additions & 5 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -204,11 +204,35 @@ lazy val docSettings = Seq(
includeFilter in Jekyll := (includeFilter in makeSite).value
)

lazy val binaryCompatibleVersions = Set("1.0.0", "1.1.0")

def mimaSettings(moduleName: String) = Seq(
mimaPreviousArtifacts := binaryCompatibleVersions.map(v => "org.typelevel" %% moduleName % v)
)
def mimaSettings(moduleName: String) = {
import sbtrelease.Version
def mimaVersions(version: String): List[String] = {
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
else List(minor)
val patchVersions: List[Int] =
if (minor == 0 || patch == 0) List.empty[Int]
else Range(0, patch - 1).inclusive.toList
Copy link
Contributor

Choose a reason for hiding this comment

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

hmmm, I wonder if this would work. Your patchVersions is derived from the current major.minor.patch range, but you don't know if your previous minor version's patch range right?
e.g. if the current version is 1.1.0, you wouldn't check against 1.0.1? or if the current version is 1.1.3-SNAPSHOT, your list would include 1.0.2 which doesn't exist. Another issue is that if either if the current patch is 0, you wouldn't check against anything, e.g. 1.2.0-SNAPSHOT wouldn't check mima, right?

Copy link
Member Author

@ChristopherDavenport ChristopherDavenport May 22, 2018

Choose a reason for hiding this comment

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

This is why I knew this would be the place. 😄
edit: Your right I could only check the .0 for min versions different than the current version.

for {
maj <- majorVersions
min <- minorVersions
pat <- patchVersions
} yield (maj, min, pat)
}
Version(version) 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 _ =>
List.empty[String]
}
}
Seq(
mimaPreviousArtifacts := mimaVersions(version.value).map(v => "org.typelevel" %% moduleName % v).toSet
)
}

lazy val docs = project
.enablePlugins(MicrositesPlugin)
Expand Down