Repository navigation
Expand file tree
/
Copy pathbuild.sbt
More file actions
269 lines (249 loc) · 10.4 KB
/
Copy pathbuild.sbt
File metadata and controls
269 lines (249 loc) · 10.4 KB
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
val scala3Version = "3.8.4"
val zioVersion = "2.1.26"
// lets enable semanticdb
ThisBuild / semanticdbEnabled := true
// Global settings. Iterable/mechanoid overrides group via PUBLISH_ORG from ZipxGitHubPackages.
ThisBuild / scalaVersion := scala3Version
ThisBuild / organization := sys.env.getOrElse("PUBLISH_ORG", "rocks.earlyeffect")
ThisBuild / organizationName := sys.env.getOrElse("PUBLISH_ORG_NAME", "Early Effect")
ThisBuild / organizationHomepage := Some(url("https://www.earlyeffect.rocks"))
ThisBuild / licenses := List("Apache-2.0" -> url("http://www.apache.org/licenses/LICENSE-2.0.txt"))
ThisBuild / homepage := Some(url("https://github.com/early-effect/mechanoid"))
ThisBuild / scmInfo := Some(
ScmInfo(
url("https://github.com/early-effect/mechanoid"),
"scm:git@github.com:early-effect/mechanoid.git",
)
)
ThisBuild / developers := List(
Developer(
id = "russwyte",
name = "Russ White",
email = "356303+russwyte@users.noreply.github.com",
url = url("https://github.com/russwyte"),
)
)
ThisBuild / versionScheme := Some("early-semver")
// Dual publish: Central by default; GitHub Packages when CI sets PUBLISH_PACKAGES_REPO.
val githubPackagesRepo: Option[MavenRepository] =
sys.env.get("PUBLISH_PACKAGES_REPO").map("GitHub Package Registry" at _)
ThisBuild / credentials ++= sys.env
.get("GITHUB_TOKEN")
.map { token =>
Credentials("GitHub Package Registry", "maven.pkg.github.com", "_", token)
}
.toSeq
ThisBuild / resolvers ++= githubPackagesRepo.toSeq
ThisBuild / publishTo := githubPackagesRepo.orElse {
val centralSnapshots =
"https://central.sonatype.com/repository/maven-snapshots/"
if (isSnapshot.value) Some("central-snapshots" at centralSnapshots)
else localStaging.value
}
// CI-only Central signing. Fork Packages publishes are unsigned (token auth).
githubPackagesRepo match {
case None => usePgpKeyHex(sys.env.getOrElse("PGP_KEY_HEX", "MISSING_KEY_HEX"))
case Some(_) => Seq.empty
}
// zipx: Aggregate verify + dual publish by repo + Steward.
zipxJavaVersion := "21"
zipxScalaSteward := true
zipxCapabilities ++= {
val upstream = JobCondition.repositoryIs("early-effect/mechanoid")
Seq(
Capability.once("fmt", "scalafmtCheckAll"),
Capability.once(
name = "test",
command = "test; docs/mdoc",
needsCapabilities = List("fmt"),
// GHA VMs are disposable; skip Ryuk so Hub flakes on testcontainers/ryuk cannot fail CI.
env = Map("TESTCONTAINERS_RYUK_DISABLED" -> EnvValue.plain("true")),
extraSteps = _ =>
List(
Step(
name = Some("Pre-pull Postgres image"),
run = Some(
"""|set -euo pipefail
|image=postgres:latest
|max=5
|for attempt in $(seq 1 "$max"); do
| if docker pull "$image"; then
| exit 0
| fi
| if [ "$attempt" -eq "$max" ]; then
| echo "Failed to pull $image after $max attempts" >&2
| exit 1
| fi
| sleep $((attempt * 10))
|done
|""".stripMargin
),
)
),
),
ZipxCentral.release
.copy(command = _ => "core/publishSigned; postgres/publishSigned; sonaRelease")
.withCondition(upstream),
ZipxGitHubPackages.sharedRegistry(
repository = Some("Iterable/mechanoid"),
packagesRepo = Some("https://maven.pkg.github.com/iterable/maven-packages"),
publishOrg = Some("com.iterable"),
publishOrgName = Some("Iterable"),
),
)
}
ThisBuild / libraryDependencies ++= Seq(
"dev.zio" %% "zio" % zioVersion % "provided",
"dev.zio" %% "zio-streams" % zioVersion % "provided",
"dev.zio" %% "zio-logging" % "2.5.3" % "provided",
"dev.zio" %% "zio-logging-slf4j" % "2.5.3" % "provided",
"dev.zio" %% "zio-logging-slf4j-bridge" % "2.5.3" % "provided",
"dev.zio" %% "zio-json" % "0.9.2" % "provided",
"dev.zio" %% "zio-test" % zioVersion % Test,
"dev.zio" %% "zio-test-sbt" % zioVersion % Test,
"dev.zio" %% "zio-test-magnolia" % zioVersion % Test,
)
lazy val commonSettings = Seq(
scalacOptions ++= Seq(
"-deprecation",
"-Wunused:all",
"-feature",
),
scalafixDependencies += "com.github.vovapolu" %% "scaluzzi" % "0.1.23",
// Exclude macros, inline methods, and export-only package objects from coverage
// - Macros/inline run at compile time, incompatible with scoverage
// - Mechanoid$package is just type re-exports with no runtime code
coverageExcludedPackages := "mechanoid\\.macros\\..*;mechanoid\\.machine\\.Macros.*;mechanoid\\.machine\\.MacroUtils.*;mechanoid\\.machine\\.AssemblyMacros.*;mechanoid\\.machine\\.MachineMacros.*;mechanoid\\.machine\\.ProducingMacros.*;mechanoid\\.core\\.Finite.*;mechanoid\\.core\\.Redactor.*;mechanoid\\.Mechanoid\\$package.*",
// Minimum coverage thresholds - fail build if coverage drops below these
coverageFailOnMinimum := true,
coverageMinimumStmtTotal := 95,
coverageMinimumBranchTotal := 95,
)
lazy val publishSettings = Seq(
publishMavenStyle := true,
pomIncludeRepository := { _ => false },
)
addCommandAlias("testCoverage", "clean; coverage; test; coverageAggregate; coverageReport")
// Parameterized coverage command: moduleCoverage <module>
// Example: sbt "moduleCoverage core" or sbt "moduleCoverage postgres"
commands += Command.single("moduleCoverage") { (state, module) =>
s"clean; coverage; $module/test; $module/coverageReport" :: state
}
lazy val root = project
.in(file("."))
.aggregate(core, postgres, examples, compileTimeChecks)
.settings(
name := "mechanoid-root",
publish / skip := true,
)
lazy val core = project
.in(file("core"))
.settings(commonSettings)
.settings(publishSettings)
.settings(
name := "mechanoid",
description := "A type-safe, effect-oriented finite state machine library for Scala built on ZIO",
)
lazy val postgres = project
.in(file("postgres"))
.dependsOn(core % "compile->compile;test->test")
.settings(commonSettings)
.settings(publishSettings)
.settings(
name := "mechanoid-postgres",
description := "PostgreSQL persistence implementation for Mechanoid FSM library",
libraryDependencies ++= Seq(
"rocks.earlyeffect" %% "saferis" % "0.19.0",
"org.postgresql" % "postgresql" % "42.7.13",
"org.testcontainers" % "postgresql" % "1.21.4" % Test,
"dev.zio" %% "zio-test" % zioVersion % Test,
"dev.zio" %% "zio-test-sbt" % zioVersion % Test,
),
// Override vulnerable transitive deps from testcontainers -> docker-java
dependencyOverrides ++= Seq(
"com.fasterxml.jackson.core" % "jackson-core" % "2.18.6",
"com.fasterxml.jackson.core" % "jackson-annotations" % "2.18.6",
"org.apache.commons" % "commons-compress" % "1.28.0",
),
)
lazy val examples = project
.in(file("examples"))
.dependsOn(core, postgres)
.settings(commonSettings)
.settings(
name := "mechanoid-examples",
publish / skip := true,
zipxPublish := Some(false),
// ZIO deps are "provided" at root level, so examples needs them explicitly
libraryDependencies ++= Seq(
"dev.zio" %% "zio" % zioVersion,
"dev.zio" %% "zio-streams" % zioVersion,
"dev.zio" %% "zio-json" % "0.9.2",
"dev.zio" %% "zio-logging" % "2.5.3",
"dev.zio" %% "zio-logging-slf4j" % "2.5.3",
"dev.zio" %% "zio-logging-slf4j-bridge" % "2.5.3",
"dev.zio" %% "zio-test" % zioVersion % Test,
"dev.zio" %% "zio-test-sbt" % zioVersion % Test,
),
assembly / mainClass := Some("mechanoid.examples.heartbeat.Main"),
assembly / assemblyJarName := "app.jar",
assembly / assemblyMergeStrategy := {
case PathList("META-INF", "MANIFEST.MF") => MergeStrategy.discard
case PathList("META-INF", xs @ _*) if xs.lastOption.exists(_.endsWith(".SF")) => MergeStrategy.discard
case PathList("META-INF", xs @ _*) if xs.lastOption.exists(_.endsWith(".DSA")) => MergeStrategy.discard
case PathList("META-INF", xs @ _*) if xs.lastOption.exists(_.endsWith(".RSA")) => MergeStrategy.discard
case PathList("META-INF", "services", _*) => MergeStrategy.concat
case PathList("reference.conf") => MergeStrategy.concat
case _ => MergeStrategy.first
},
)
lazy val compileExperiments = project
.in(file("compile-experiments"))
.dependsOn(core)
.settings(commonSettings)
.settings(
name := "compile-experiments",
publish / skip := true,
zipxPublish := Some(false),
)
lazy val compileTimeChecks = project
.in(file("compile-time-checks"))
.dependsOn(core)
.settings(
name := "compile-time-checks",
publish / skip := true,
zipxPublish := Some(false),
// Turn warnings into errors so typeCheck can catch them
scalacOptions ++= Seq(
"-Werror",
"-deprecation",
"-feature",
),
libraryDependencies ++= Seq(
"dev.zio" %% "zio-test" % zioVersion % Test,
"dev.zio" %% "zio-test-sbt" % zioVersion % Test,
),
testFrameworks += new TestFramework("zio.test.sbt.ZTestFramework"),
)
lazy val docs = project
.in(file("mechanoid-docs"))
.dependsOn(core, postgres)
.enablePlugins(MdocPlugin)
.settings(
name := "mechanoid-docs",
publish / skip := true,
zipxPublish := Some(false), // never join Central / Packages publish jobs
mdocVariables := Map(
"VERSION" -> version.value
),
mdocIn := baseDirectory.value / "docs",
mdocOut := (ThisBuild / baseDirectory).value,
// ZIO deps are "provided" at root level, so mdoc needs them explicitly
libraryDependencies ++= Seq(
"dev.zio" %% "zio" % zioVersion,
"dev.zio" %% "zio-streams" % zioVersion,
"dev.zio" %% "zio-json" % "0.9.2",
),
// Override vulnerable transitive dep from mdoc -> undertow
dependencyOverrides += "io.undertow" % "undertow-core" % "2.2.39.Final",
)