Skip to content

Commit

Permalink
add mima to lint
Browse files Browse the repository at this point in the history
  • Loading branch information
ThijsBroersen committed Nov 17, 2024
1 parent 444874d commit f9cbda1
Show file tree
Hide file tree
Showing 9 changed files with 27 additions and 31 deletions.
1 change: 1 addition & 0 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ inThisBuild(
developers := List(
Developer("khajavi", "Milad Khajavi", "[email protected]", url("https://github.com/khajavi"))
),
checkMima / skip := true,
ciEnabledBranches := Seq("main")
)
)
Expand Down
4 changes: 2 additions & 2 deletions project/plugins.sbt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// Build Server Plugins
addSbtPlugin("ch.epfl.scala" % "sbt-bloop" % "2.0.3")
addSbtPlugin("ch.epfl.scala" % "sbt-bloop" % "2.0.5")

// Linting Plugins
addSbtPlugin("org.scalameta" % "sbt-scalafmt" % "2.5.2")
Expand All @@ -8,7 +8,7 @@ addSbtPlugin("com.github.cb372" % "sbt-explicit-dependencies" % "0.3.1")
addSbtPlugin("com.typesafe" % "sbt-mima-plugin" % "1.1.4")

// Versioning and Release Plugins
addSbtPlugin("com.eed3si9n" % "sbt-buildinfo" % "0.12.0")
addSbtPlugin("com.eed3si9n" % "sbt-buildinfo" % "0.13.1")
addSbtPlugin("com.github.sbt" % "sbt-ci-release" % "1.9.0")

// Docs Plugins
Expand Down
16 changes: 1 addition & 15 deletions zio-sbt-ci/src/main/scala/zio/sbt/ZioSbtCiPlugin.scala
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,6 @@ object ZioSbtCiPlugin extends AutoPlugin {
val ciBackgroundJobs: SettingKey[Seq[String]] = settingKey[Seq[String]]("Background jobs")
val ciBuildJobs: SettingKey[Seq[Job]] = settingKey[Seq[Job]]("CI Build Jobs")
val ciLintJobs: SettingKey[Seq[Job]] = settingKey[Seq[Job]]("CI Lint Jobs")
val ciCheckMima: SettingKey[Boolean] = settingKey[Boolean]("Enable Lint Job: Check binary compatibility")
val ciTestJobs: SettingKey[Seq[Job]] = settingKey[Seq[Job]]("CI Test Jobs")
val ciUpdateReadmeJobs: SettingKey[Seq[Job]] = settingKey[Seq[Job]]("CI Update Readme Jobs")
val ciReleaseJobs: SettingKey[Seq[Job]] = settingKey[Seq[Job]]("CI Release Jobs")
Expand Down Expand Up @@ -153,8 +152,7 @@ object ZioSbtCiPlugin extends AutoPlugin {
) ++ checkGithubWorkflow.flatMap(
_.flatten
) ++
Seq(Lint.value) ++
(if (ciCheckMima.value) Seq(CheckMima.value) else Seq.empty[Step.SingleStep])
Seq(Lint.value)
)
)
}
Expand Down Expand Up @@ -688,7 +686,6 @@ object ZioSbtCiPlugin extends AutoPlugin {
ciDefaultJavaVersion := zio.sbt.JavaVersion.`17`,
ciBuildJobs := buildJobs.value,
ciLintJobs := lintJobs.value,
ciCheckMima := false,
ciTestJobs := testJobs.value,
ciUpdateReadmeJobs := updateReadmeJobs.value,
ciReleaseJobs := releaseJobs.value,
Expand Down Expand Up @@ -788,17 +785,6 @@ object ZioSbtCiPlugin extends AutoPlugin {
)
}

lazy val CheckMima: Def.Initialize[Step.SingleStep] = Def.setting {
val backgroundJobs = ciBackgroundJobs.value
val prefixJobs = makePrefixJobs(backgroundJobs)
val isSingleBuild = IsSingleBuild.value

Step.SingleStep(
name = "Check binary compatibility",
run = Some(prefixJobs + "sbt " + (if (isSingleBuild) "checkMima" else "+checkMima"))
)
}

lazy val Release: Def.Initialize[SingleStep] = Def.setting {
val backgroundJobs = ciBackgroundJobs.value

Expand Down
2 changes: 1 addition & 1 deletion zio-sbt-ecosystem/build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ addSbtPlugin("ch.epfl.scala" % "sbt-scalafix" % "0.13.0")
addSbtPlugin("com.github.cb372" % "sbt-explicit-dependencies" % "0.3.1")

// Versioning and Release Plugins
addSbtPlugin("com.eed3si9n" % "sbt-buildinfo" % "0.12.0")
addSbtPlugin("com.eed3si9n" % "sbt-buildinfo" % "0.13.1")
addSbtPlugin("com.github.sbt" % "sbt-ci-release" % "1.9.0")

// Docs Plugins
Expand Down
5 changes: 5 additions & 0 deletions zio-sbt-ecosystem/src/main/scala/zio/sbt/Commands.scala
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,9 @@ object Commands {
val fmt: ComposableCommand =
(quietOn >> "scalafmtSbt" >> "+scalafmt" >> "+Test / scalafmt") ?? ("fmt", "Formats source files using scalafmt.")

val checkMima: ComposableCommand =
(quietOn >> "+checkMima") ?? ("checkMima", "Checks binary compatibility against previous versions.")

// TODO: have the correct license headers
val lint: ComposableCommand = {
quietOn >>
Expand All @@ -96,6 +99,7 @@ object Commands {
"+scalafmtCheckAll" >>
// "+headerCheckAll" >>
fixLint >>
checkMima >>
"disableStrictCompile"
} ?? (
"lint",
Expand Down Expand Up @@ -125,6 +129,7 @@ object Commands {
lint.toItem,
fmt.toItem,
fix.toItem,
checkMima.toItem,
prepare.toItem,
// buildAll.toItem,
prepare.toItem,
Expand Down
21 changes: 14 additions & 7 deletions zio-sbt-ecosystem/src/main/scala/zio/sbt/MimaSettings.scala
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
*/

package zio.sbt

import com.typesafe.tools.mima.plugin.MimaKeys._
import sbt.Keys._
import sbt._
Expand All @@ -26,15 +25,23 @@ import zio.sbt.BuildAssertions.Keys.isScalaJVM
trait MimaSettings {

lazy val checkMima: TaskKey[Unit] = taskKey[Unit]("Checks binary compatibility against previous versions.")
}

object MimaSettings extends MimaSettings {

def enableMimaSettings(failOnProblem: Boolean = true): Seq[Setting[_]] =
def projectSettings: Seq[Setting[_]] =
Def.settings(
checkMima := { if (isScalaJVM.value && !(checkMima / skip).value) mimaReportBinaryIssues.value else () },
mimaFailOnProblem := failOnProblem,
mimaPreviousArtifacts := previousStableVersion.value
checkMima := {
Def.taskIf {
if (isScalaJVM.value && !((checkMima / skip).value || (publish / skip).value)) mimaReportBinaryIssues.value
else ()
}.value
},
mimaFailOnProblem := false,
// mimaPreviousArtifacts := Set.empty,
mimaPreviousArtifacts := (ThisBuild / previousStableVersion).value
.map(organization.value %% moduleName.value % _)
.fold(Set.empty[ModuleID])(Set(_)),
mimaBinaryIssueFilters := Seq()
.fold(Set.empty[ModuleID])(Set(_))
)

}
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import org.scalafmt.sbt.ScalafmtPlugin
import sbt.Keys._
import sbt.nio.Keys.{ReloadOnSourceChanges, onChangedBuildSource}
import sbt.{Def, _}
import sbtbuildinfo.BuildInfoPlugin
import sbtdynver.DynVerPlugin
import scalafix.sbt.ScalafixPlugin

import zio.sbt.ZioSbtShared.autoImport.{banners, usefulTasksAndSettings, welcomeMessage}
Expand All @@ -35,7 +35,7 @@ object ZioSbtEcosystemPlugin extends AutoPlugin {
override def trigger = allRequirements

override def requires: Plugins =
super.requires && HeaderPlugin && ScalafixPlugin && ScalafmtPlugin && BuildInfoPlugin && ZioSbtCrossbuildPlugin && MimaPlugin
super.requires && HeaderPlugin && ScalafixPlugin && ScalafmtPlugin && MimaPlugin && DynVerPlugin && ZioSbtCrossbuildPlugin

object autoImport extends ScalaCompilerSettings with MimaSettings {

Expand Down Expand Up @@ -75,7 +75,7 @@ object ZioSbtEcosystemPlugin extends AutoPlugin {
onLoadMessage := {
if (SharedTasks.isRoot.value) welcomeMessage.init.value else ""
}
)
) ++ MimaSettings.projectSettings

override def buildSettings: Seq[Def.Setting[_]] = super.buildSettings ++ Seq(
zioVersion := zioVersion.?.value.getOrElse(Versions.zioVersion)
Expand Down
2 changes: 0 additions & 2 deletions zio-sbt-project/src/main/scala/zio/sbt/ScalaPlatform.scala
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,6 @@ object ScalaPlatforms {
.toSet
}

def buildSettings: Seq[Setting[_]] = Seq.empty

def globalSettings: Seq[Setting[_]] = Seq(
allScalaPlatformsSetting
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,6 @@ object ZioSbtCrossbuildPlugin extends AutoPlugin {
override def buildSettings: Seq[Def.Setting[_]] =
super.buildSettings ++
ScalaVersions.buildSettings ++
ScalaPlatforms.buildSettings ++
JavaVersions.buildSettings

override def globalSettings: Seq[Def.Setting[_]] =
Expand Down

0 comments on commit f9cbda1

Please sign in to comment.