-
Notifications
You must be signed in to change notification settings - Fork 8
/
build.sbt
252 lines (229 loc) · 8.17 KB
/
build.sbt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
val Scala212 = "2.12.14"
ThisBuild / crossScalaVersions := Seq(Scala212, "2.13.6", "3.0.1")
ThisBuild / scalaVersion := Scala212
val MicrositesCond = s"matrix.scala == '$Scala212'"
ThisBuild / githubWorkflowPublishTargetBranches := Seq()
ThisBuild / githubWorkflowBuildPreamble ++= Seq(
WorkflowStep.Use(
UseRef.Public("ruby", "setup-ruby", "v1"),
params = Map("ruby-version" -> "2.6"),
cond = Some(MicrositesCond)
),
WorkflowStep.Run(List("gem install sass"), cond = Some(MicrositesCond)),
WorkflowStep.Run(List("gem install jekyll -v 3.2.1"), cond = Some(MicrositesCond))
)
ThisBuild / githubWorkflowBuild := Seq(
WorkflowStep.Sbt(
List("test", "mimaReportBinaryIssues"),
name = Some("Validate unit tests and binary compatibility")
),
WorkflowStep.Sbt(List("docs/makeMicrosite"), cond = Some(MicrositesCond))
)
lazy val `cats-testkit-scalatest` = project.in(file("."))
.disablePlugins(MimaPlugin)
.settings(commonSettings, releaseSettings, skipOnPublishSettings)
.settings(crossScalaVersions := Seq())
.aggregate(coreJVM, coreJS)
lazy val core = crossProject(JSPlatform, JVMPlatform)
.crossType(CrossType.Pure)
.in(file("core"))
.settings(commonSettings, releaseSettings, mimaSettings)
.settings(
name := "cats-testkit-scalatest"
)
lazy val coreJVM = core.jvm
lazy val coreJS = core.js
lazy val docs = project.in(file("docs"))
.disablePlugins(MimaPlugin)
.settings(commonSettings, skipOnPublishSettings, micrositeSettings)
.settings(
crossScalaVersions := crossScalaVersions.value.filter(_.startsWith("2."))
)
.dependsOn(coreJVM)
.enablePlugins(MicrositesPlugin)
lazy val contributors = Seq(
"rossabaker" -> "Ross A Baker",
"kailuowang" -> "Kai(luo) Wang",
"ceedubs" -> "Cody Allen",
"non" -> "Erik Osheim",
"travisbrown" -> "Travis Brown",
"paulp" -> "Paul Phillips",
"dwijnand" -> "Dale Wijnand",
"Alistair-Johnson" -> "Alistair Johnson",
"adelbertc" -> "Adelbert Chang",
"ChristopherDavenport" -> "Christopher Davenport"
)
val catsV = "2.6.1"
val disciplineScalatestVersion = "2.1.5"
// General Settings
lazy val commonSettings = Seq(
organization := "org.typelevel",
scalacOptions in (Compile, doc) ++= Seq(
"-groups",
"-sourcepath", (baseDirectory in LocalRootProject).value.getAbsolutePath,
"-doc-source-url", "https://github.com/typelevel/cats-testkit-scalatest/blob/v" + version.value + "€{FILE_PATH}.scala"
),
libraryDependencies ++= Seq(
"org.typelevel" %%% "cats-laws" % catsV,
"org.typelevel" %%% "discipline-scalatest" % disciplineScalatestVersion
)
)
lazy val releaseSettings = {
import ReleaseTransformations._
Seq(
releaseCrossBuild := true,
releaseProcess := Seq[ReleaseStep](
checkSnapshotDependencies,
inquireVersions,
runClean,
runTest,
setReleaseVersion,
commitReleaseVersion,
tagRelease,
// For non cross-build projects, use releaseStepCommand("publishSigned")
releaseStepCommandAndRemaining("+publishSigned"),
setNextVersion,
commitNextVersion,
releaseStepCommand("sonatypeReleaseAll"),
pushChanges
),
publishTo := {
val nexus = "https://oss.sonatype.org/"
if (isSnapshot.value)
Some("snapshots" at nexus + "content/repositories/snapshots")
else
Some("releases" at nexus + "service/local/staging/deploy/maven2")
},
credentials ++= (
for {
username <- Option(System.getenv().get("SONATYPE_USERNAME"))
password <- Option(System.getenv().get("SONATYPE_PASSWORD"))
} yield
Credentials(
"Sonatype Nexus Repository Manager",
"oss.sonatype.org",
username,
password
)
).toSeq,
publishArtifact in Test := false,
releasePublishArtifactsAction := PgpKeys.publishSigned.value,
scmInfo := Some(
ScmInfo(
url("https://github.com/typelevel/cats-testkit-scalatest"),
"[email protected]:typelevel/cats-testkit-scalatest.git"
)
),
homepage := Some(url("https://github.com/typelevel/cats-testkit-scalatest")),
licenses += ("MIT", url("http://opensource.org/licenses/MIT")),
publishMavenStyle := true,
pomIncludeRepository := { _ =>
false
},
pomExtra := {
<developers>
{for ((username, name) <- contributors) yield
<developer>
<id>{username}</id>
<name>{name}</name>
<url>http://github.com/{username}</url>
</developer>
}
</developers>
}
)
}
lazy val mimaSettings = {
import sbtrelease.Version
def semverBinCompatVersions(major: Int, minor: Int, patch: Int): Set[(Int, Int, Int)] = {
val majorVersions: List[Int] =
if (major == 0 && minor == 0) List.empty[Int] // If 0.0.x do not check MiMa
else 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)
.map{case (maj, min, pat) => maj.toString + "." + min.toString + "." + pat.toString}
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(
mimaFailOnNoPrevious := false,
mimaFailOnProblem := mimaVersions(version.value).toList.headOption.isDefined,
mimaPreviousArtifacts := {
if (scalaVersion.value.startsWith("3")) // TODO: remove Scala 3 exclusion after releasing for 3.0.0
Set()
else
(mimaVersions(version.value) ++ extraVersions)
.filterNot(excludedVersions.contains(_))
.map{v =>
val moduleN = moduleName.value + "_" + scalaBinaryVersion.value.toString
organization.value % moduleN % v
}
},
mimaBinaryIssueFilters ++= {
import com.typesafe.tools.mima.core._
import com.typesafe.tools.mima.core.ProblemFilters._
Seq()
}
)
}
lazy val micrositeSettings = {
import microsites._
Seq(
micrositeName := "cats-testkit-scalatest",
micrositeDescription := "Cats Testkit for Scalatest",
micrositeAuthor := "Typelevel",
micrositeGithubOwner := "typelevel",
micrositeGithubRepo := "cats-testkit-scalatest",
micrositeBaseUrl := "/cats-testkit-scalatest",
micrositeDocumentationUrl := "https://www.javadoc.io/doc/org.typelevel/cats-testkit-scalatest_2.12",
micrositeGitterChannelUrl := "typelevel/cats",
micrositeFooterText := None,
micrositeHighlightTheme := "atom-one-light",
micrositePalette := Map(
"brand-primary" -> "#3e5b95",
"brand-secondary" -> "#294066",
"brand-tertiary" -> "#2d5799",
"gray-dark" -> "#49494B",
"gray" -> "#7B7B7E",
"gray-light" -> "#E5E5E6",
"gray-lighter" -> "#F4F3F4",
"white-color" -> "#FFFFFF"
),
libraryDependencies += "com.47deg" %% "github4s" % "0.28.3",
micrositePushSiteWith := GitHub4s,
micrositeGithubToken := sys.env.get("GITHUB_TOKEN"),
micrositeExtraMdFiles := Map(
file("CHANGELOG.md") -> ExtraMdFileConfig("changelog.md", "page", Map("title" -> "changelog", "section" -> "changelog", "position" -> "100")),
file("CODE_OF_CONDUCT.md") -> ExtraMdFileConfig("code-of-conduct.md", "page", Map("title" -> "code of conduct", "section" -> "code of conduct", "position" -> "101")),
file("LICENSE") -> ExtraMdFileConfig("license.md", "page", Map("title" -> "license", "section" -> "license", "position" -> "102"))
),
)
}
lazy val skipOnPublishSettings = Seq(
skip in publish := true,
publish := (()),
publishLocal := (()),
publishArtifact := false,
publishTo := None
)