-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathbuild.sbt
278 lines (259 loc) · 9.54 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
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
import microsites._
ThisBuild / organization := "com.bbrownsound"
lazy val paradiseVersion = "2.1.1"
//https://github.com/circe/circe/blob/master/build.sbt
val compilerOptions = Seq(
"-deprecation",
"-feature",
"-unchecked",
"-language:postfixOps",
"-language:implicitConversions",
"-language:experimental.macros",
"-Ywarn-unused-import"
)
def priorTo2_13(scVersion: String): Boolean =
CrossVersion.partialVersion(scVersion) match {
case Some((2, minor)) if minor < 13 => true
case _ => false
}
lazy val allCrossVersions = Seq("2.11.12", "2.12.12", "2.13.8")
Global / onChangedBuildSource := ReloadOnSourceChanges
def adopt(version: String): JavaSpec = JavaSpec(JavaSpec.Distribution.Adopt, version)
ThisBuild / crossScalaVersions := allCrossVersions
ThisBuild / scalaVersion := crossScalaVersions.value.last
ThisBuild / githubWorkflowJavaVersions := Seq(adopt("8"), adopt("11"), adopt("15"))
ThisBuild / githubWorkflowArtifactUpload := false
ThisBuild / githubWorkflowAddedJobs ++= Seq(
WorkflowJob(
"formatting",
"Check formatting",
githubWorkflowJobSetup.value.toList ::: List(
WorkflowStep
.Run(List(s"sbt ++${crossScalaVersions.value.last} checkAll"), name = Some("Check formatting"))
)
),
WorkflowJob(
"coverage",
"Coverage",
githubWorkflowJobSetup.value.toList ::: List(
WorkflowStep.Use(UseRef.Public("actions", "setup-python", "v2"), name = Some("Setup Python")),
WorkflowStep.Run(List("pip install codecov"), name = Some("Install Codecov")),
WorkflowStep
.Sbt(List("coverage", "macros/test", "macros/coverageReport"), name = Some("Calculate test coverage")),
WorkflowStep.Run(List("codecov"), name = Some("Upload coverage results")),
WorkflowStep.Run(List("sbt clean coverage test coverageReport"), name = Some("Generate Coverage Report")),
WorkflowStep.Run(List("sbt coverageAggregate coveralls"), name = Some("Publish Coverage Report"))
),
env = Map(
"COVERALLS_REPO_TOKEN" -> "${{ secrets.COVERALLS_REPO_TOKEN }}",
"COVERALLS_FLAG_NAME" -> "MACROS",
"github-token" -> "${{ secrets.GITHUB_TOKEN }}"
),
scalas = List(crossScalaVersions.value.last),
cond = Some("github.event_name != 'pull_request'")
),
WorkflowJob(
"microsite",
"Microsite",
githubWorkflowJobSetup.value.toList ::: List(
WorkflowStep.Use(
UseRef.Public("ruby", "setup-ruby", "v1"),
name = Some("Setup Ruby"),
params = Map("ruby-version" -> "2.6", "bundler-cache" -> "true")
),
WorkflowStep.Run(List("gem install jekyll -v 2.5"), name = Some("Install Jekyll")),
WorkflowStep.Sbt(List("docs/clean"), name = Some("Clean microsite")),
WorkflowStep.Sbt(List("docs/makeMicrosite"), name = Some("Build microsite"))
),
scalas = List(crossScalaVersions.value.last),
cond = Some("github.event_name != 'pull_request'")
),
//eventually do everything with earthly
WorkflowJob(
"earthly",
"Earthly Checks",
List(
WorkflowStep.Use(
UseRef.Public("actions", "checkout", "v2"),
name = Some("Checkout current branch (full)"),
params = Map("fetch-depth" -> "0")
),
WorkflowStep.Run(
List(
"sudo /bin/sh -c 'wget https://github.com/earthly/earthly/releases/download/v0.5.9/earthly-linux-amd64 -O /usr/local/bin/earthly && chmod +x /usr/local/bin/earthly'"
),
name = Some("Install Earthly")
),
WorkflowStep.Run(List("earthly --version"), name = Some("Earthly version")),
WorkflowStep.Run(List("earthly +lint-check"), name = Some("Run checks")),
WorkflowStep.Run(List("earthly +unit-test"), name = Some("Run test"))
),
scalas = List(crossScalaVersions.value.last)
)
)
ThisBuild / githubWorkflowPublishTargetBranches :=
Seq(
RefPredicate.StartsWith(Ref.Tag("*")),
RefPredicate.Contains(Ref.Branch("master")),
RefPredicate.Contains(Ref.Branch("main"))
)
ThisBuild / githubWorkflowPublish := Seq(
WorkflowStep.Sbt(
List("ci-release"),
env = Map(
"PGP_PASSPHRASE" -> "${{ secrets.PGP_PASSPHRASE }}",
"PGP_SECRET" -> "${{ secrets.PGP_SECRET }}",
"SONATYPE_PASSWORD" -> "${{ secrets.SONATYPE_PASSWORD }}",
"SONATYPE_USERNAME" -> "${{ secrets.SONATYPE_USERNAME }}"
)
)
)
lazy val baseSettings = Seq(
scalacOptions ++= {
if (priorTo2_13(scalaVersion.value)) compilerOptions
else
compilerOptions.flatMap {
case "-Ywarn-unused-import" => Seq("-Ywarn-unused:imports", "-Wunused")
case "-Xfuture" => Nil
case other => Seq(other)
}
},
(Compile / console / scalacOptions) ~= {
_.filterNot(Set("-Ywarn-unused-import", "-Ywarn-unused:imports", "-Yno-predef"))
},
(Test / console / scalacOptions) ~= {
_.filterNot(Set("-Ywarn-unused-import", "-Ywarn-unused:imports", "-Yno-predef"))
},
(Test / scalacOptions) ~= {
_.filterNot(Set("-Yno-predef"))
},
libraryDependencies ++= Seq(
"org.slf4j" % "slf4j-api" % "2.0.13" % Provided,
"org.slf4j" % "slf4j-simple" % "2.0.13" % Provided
),
resolvers ++= Seq("public", "snapshots", "releases").map(Resolver.sonatypeRepo),
(publish / skip) := true
)
lazy val macroSettings: Seq[Setting[_]] = Seq(
libraryDependencies ++= Seq(
scalaOrganization.value % "scala-compiler" % scalaVersion.value % Provided,
scalaOrganization.value % "scala-reflect" % scalaVersion.value % Provided
) ++ (
if (priorTo2_13(scalaVersion.value)) {
Seq(
compilerPlugin(("org.scalamacros" % "paradise" % paradiseVersion).cross(CrossVersion.full))
)
} else Nil
),
scalacOptions ++= (
if (priorTo2_13(scalaVersion.value)) {
compilerOptions
} else {
compilerOptions.flatMap {
case "-language:experimental.macros" => Seq("-language:experimental.macros", "-Ymacro-annotations")
case "-Ywarn-unused-import" => Seq("-Ywarn-unused:imports", "-Wunused")
case other => Seq(other)
}
}
),
crossScalaVersions := allCrossVersions
)
lazy val macros = (project in file("./macros"))
.settings(
name := "macros",
(publish / skip) := false,
macroSettings ++ Release.settings,
libraryDependencies ++= Seq(
"ch.qos.logback" % "logback-classic" % "1.5.5",
"org.scalatest" %% "scalatest" % "3.2.15" % "test"
)
)
lazy val docSettings = Seq(
micrositeName := "Macros",
micrositeDescription := "Documentation for macro helper library",
micrositeAuthor := "Brandon Brown",
micrositeTwitterCreator := "@brbrown",
micrositeGithubOwner := "brbrown25",
micrositeGithubRepo := "macros",
micrositeGithubLinks := true,
micrositeGitterChannel := false,
micrositeShareOnSocial := true,
micrositeTheme := "pattern",
micrositePalette := Map(
"brand-primary" -> "#E05236",
"brand-secondary" -> "#3F3242",
"brand-tertiary" -> "#2D232F",
"gray-dark" -> "#453E46",
"gray" -> "#837F84",
"gray-light" -> "#E3E2E3",
"gray-lighter" -> "#F4F3F4",
"white-color" -> "#FFFFFF"
),
micrositeFooterText := Some(
"""
|<p>© 2020 Brandon Brown</p>
|<p style="font-size: 80%; margin-top: 10px">Website built with <a href="https://47deg.github.io/sbt-microsites/">sbt-microsites © 2020</a></p>
|""".stripMargin
),
ghpagesNoJekyll := false,
git.remoteRepo := "git@github.com:brbrown25/macros.git",
(makeSite / includeFilter) := "*.html" | "*.css" | "*.png" | "*.jpg" | "*.gif" | "*.js" | "*.swf" | "*.yml" | "*.md" | "*.svg",
(Jekyll / includeFilter) := (makeSite / includeFilter).value,
mdocIn := (LocalRootProject / baseDirectory).value / "docs" / "src" / "main" / "mdoc",
mdocExtraArguments := Seq("--no-link-hygiene"),
micrositeGithubToken := sys.env.get("MICROSITE_TOKEN")
)
lazy val docs = project
.in(file("macros-docs"))
.enablePlugins(MdocPlugin)
.enablePlugins(MicrositesPlugin)
.settings(macroSettings)
.settings(
moduleName := "macros-docs",
(publish / skip) := true,
mdocVariables := Map(
"SNAPSHOT_VERSION" -> version.value,
"RELEASE_VERSION" -> "1.0.2",
"ORG" -> organization.value,
"NAME" -> "macros",
"CROSS_VERSIONS" -> allCrossVersions.mkString(", ")
)
)
.settings(docSettings)
.dependsOn(macros)
lazy val root = (project in file("."))
.settings(
name := "annotation-playground",
baseSettings ++ macroSettings
)
.aggregate(macros)
inThisBuild(
List(
organization := "com.bbrownsound",
homepage := Some(url("https://github.com/brbrown25/macros")),
licenses := List("Apache-2.0" -> url("http://www.apache.org/licenses/LICENSE-2.0")),
developers := List(
Developer(
"brbrown25",
"Brandon Brown",
"brandon@bbrownsound.com",
url("https://bbrownsound.com")
)
),
semanticdbEnabled := true, // enable SemanticDB
semanticdbVersion := scalafixSemanticdb.revision, // use Scalafix compatible version
scalafixScalaBinaryVersion := CrossVersion.binaryScalaVersion(scalaVersion.value),
scalafixDependencies += "com.github.liancheng" %% "organize-imports" % "0.6.0"
)
)
addCommandAlias("fix", "scalafixAll")
addCommandAlias("fixCheck", "scalafixAll --check")
addCommandAlias("fmt", "all scalafmtSbt scalafmtAll")
addCommandAlias("fmtCheck", "all scalafmtSbtCheck scalafmtCheckAll")
addCommandAlias("prepare", "fix; fmt; githubWorkflowGenerate")
addCommandAlias("checkAll", "fixCheck; fmtCheck; githubWorkflowCheck")
ThisBuild / coverageEnabled := true
ThisBuild / coverageMinimumStmtTotal := 80
ThisBuild / coverageFailOnMinimum := true
import org.scoverage.coveralls.Imports.CoverallsKeys._
coverallsToken := sys.env.get("COVERALLS_REPO_TOKEN")