From 6d1475c1f94711687cec1037669160847562c087 Mon Sep 17 00:00:00 2001 From: Chris Davenport Date: Tue, 22 May 2018 15:09:32 -0400 Subject: [PATCH 1/3] Add Function To Check All Relevant MiMa Versions --- build.sbt | 34 +++++++++++++++++++++++++++++----- 1 file changed, 29 insertions(+), 5 deletions(-) diff --git a/build.sbt b/build.sbt index 4924e545e6..9864393d67 100644 --- a/build.sbt +++ b/build.sbt @@ -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 + 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) From 05698e551bf841569a8791371422f6a95494e554 Mon Sep 17 00:00:00 2001 From: Chris Davenport Date: Tue, 22 May 2018 16:22:24 -0400 Subject: [PATCH 2/3] Fix Incorrectly Assumed Patch Equivalence, Add Safety Nets --- build.sbt | 45 +++++++++++++++++++++++++++++---------------- 1 file changed, 29 insertions(+), 16 deletions(-) diff --git a/build.sbt b/build.sbt index 9864393d67..8f451da686 100644 --- a/build.sbt +++ b/build.sbt @@ -206,21 +206,26 @@ lazy val docSettings = Seq( 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 - for { - maj <- majorVersions - min <- minorVersions - pat <- patchVersions - } yield (maj, min, pat) - } + + 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 mimaVersions(version: String): Set[String] = { Version(version) match { case Some(Version(major, Seq(minor, patch), _)) => semverBinCompatVersions(major.toInt, minor.toInt, patch.toInt) @@ -229,8 +234,16 @@ def mimaSettings(moduleName: String) = { List.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).map(v => "org.typelevel" %% moduleName % v).toSet + mimaPreviousArtifacts := (mimaVersions(version.value) ++ extraVersions) + .filterNot(excludedVersions.contains(_)) + .map(v => "org.typelevel" %% moduleName % v) ) } From 31c9ebedc9d5bb4540140b78b225b2b06bf30e26 Mon Sep 17 00:00:00 2001 From: Chris Davenport Date: Tue, 22 May 2018 16:34:22 -0400 Subject: [PATCH 3/3] Fix Returned List Rather than Set --- build.sbt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.sbt b/build.sbt index 8f451da686..a79901709e 100644 --- a/build.sbt +++ b/build.sbt @@ -231,7 +231,7 @@ def mimaSettings(moduleName: String) = { semverBinCompatVersions(major.toInt, minor.toInt, patch.toInt) .map{case (maj, min, pat) => s"${maj}.${min}.${pat}"} case _ => - List.empty[String] + Set.empty[String] } } // Safety Net For Exclusions