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 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
45 changes: 41 additions & 4 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -204,11 +204,48 @@ 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) = {
import sbtrelease.Version

def semverBinCompatVersions(major: Int, minor: Int, patch: Int): Set[(Int, Int, Int)] = {
val majorVersions: List[Int] = List(major)
val minorVersions : List[Int] =
if (major >= 1) Range(0, minor).inclusive.toList
else List(minor)
def patchVersions(currentMinVersion: Int): List[Int] =
if (minor == 0 && patch == 0) List.empty[Int]
else if (currentMinVersion != minor) List(0)
else Range(0, patch - 1).inclusive.toList

val versions = for {
maj <- majorVersions
min <- minorVersions
pat <- patchVersions(min)
} yield (maj, min, pat)
versions.toSet
}

def mimaSettings(moduleName: String) = Seq(
mimaPreviousArtifacts := binaryCompatibleVersions.map(v => "org.typelevel" %% moduleName % v)
)
def mimaVersions(version: String): Set[String] = {
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 _ =>
Set.empty[String]
}
}
// Safety Net For Exclusions
lazy val excludedVersions: Set[String] = Set()

// Safety Net for Inclusions
lazy val extraVersions: Set[String] = Set()

Seq(
mimaPreviousArtifacts := (mimaVersions(version.value) ++ extraVersions)
.filterNot(excludedVersions.contains(_))
.map(v => "org.typelevel" %% moduleName % v)
)
}

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