-
Notifications
You must be signed in to change notification settings - Fork 3
/
build.sbt
399 lines (370 loc) · 12.2 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
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
val scala213Version = "2.13.12"
ThisBuild / scalaVersion := scala213Version
ThisBuild / crossScalaVersions := Seq(scala213Version, "3.3.0")
ThisBuild / organization := "io.github.valdemargr"
ThisBuild / tlBaseVersion := "0.4"
ThisBuild / tlCiHeaderCheck := false
ThisBuild / tlCiDocCheck := false
ThisBuild / tlCiScalafmtCheck := false
ThisBuild / tlUntaggedAreSnapshots := false
ThisBuild / licenses := List("Apache-2.0" -> url("http://www.apache.org/licenses/LICENSE-2.0"))
ThisBuild / developers := List(
Developer("valdemargr", "Valdemar Grange", "[email protected]", url("https://github.com/valdemargr"))
)
ThisBuild / headerLicense := Some(HeaderLicense.Custom("Copyright (c) 2023 Valdemar Grange"))
ThisBuild / headerEmptyLine := false
// I might re-enable this later
ThisBuild / tlCiMimaBinaryIssueCheck := false
ThisBuild / tlMimaPreviousVersions := Set.empty
ThisBuild / mimaReportSignatureProblems := false
ThisBuild / mimaFailOnProblem := false
ThisBuild / mimaPreviousArtifacts := Set.empty
ThisBuild / tlSonatypeUseLegacyHost := true
//ThisBuild / tlFatalWarnings := true
val dbStep = WorkflowStep.Use(
ref = UseRef.Public("hoverkraft-tech", "compose-action", "v2.0.1")
)
ThisBuild / githubWorkflowJobSetup += dbStep
ThisBuild / githubWorkflowAddedJobs ++= Seq(
WorkflowJob(
id = "compile-docs",
name = "Verify that the docs compile",
scalas = List(scala213Version),
steps = WorkflowStep.Use(
UseRef.Public("actions", "checkout", "v3"),
name = Some("Checkout current branch (fast)"),
params = Map("fetch-depth" -> "0")
) :: dbStep ::
WorkflowStep.SetupJava(githubWorkflowJavaVersions.value.toList) ++
githubWorkflowGeneratedCacheSteps.value ++
List(
WorkflowStep.Sbt(List("docs/mdoc"), name = Some("Compile the documentation scala code")),
WorkflowStep.Sbt(List("readme/mdoc"), name = Some("Compile the readme scala code"))
)
),
WorkflowJob(
id = "docs",
name = "Run mdoc docs",
needs = List("compile-docs"),
scalas = List(scala213Version),
steps = WorkflowStep.Use(
UseRef.Public("actions", "checkout", "v3"),
name = Some("Checkout current branch (fast)"),
params = Map("fetch-depth" -> "0")
) :: dbStep ::
WorkflowStep.SetupJava(githubWorkflowJavaVersions.value.toList) ++
githubWorkflowGeneratedCacheSteps.value ++
// We need all commits to track down the tag for the VERSION variable
List(
WorkflowStep.Run(
List(
"git fetch --all --tags --force"
)
),
WorkflowStep.Sbt(List("docs/mdoc")),
WorkflowStep.Use(
UseRef.Public("actions", "setup-node", "v3"),
params = Map("node-version" -> "18")
),
WorkflowStep.Run(List("cd website && yarn install")),
WorkflowStep.Run(
List(
"git config --global user.name ValdemarGr",
"git config --global user.email [email protected]",
"cd website && yarn deploy"
),
env = Map(
"GIT_USER" -> "valdemargr",
"GIT_PASS" -> "${{ secrets.GITHUB_TOKEN }}"
)
)
),
cond = Some("""github.event_name != 'pull_request' && (startsWith(github.ref, 'refs/tags/v') || github.ref == 'refs/heads/main')""")
)
)
lazy val sharedSettings = Seq(
organization := "io.github.valdemargr",
organizationName := "Valdemar Grange",
autoCompilerPlugins := true,
tlCiMimaBinaryIssueCheck := false,
tlMimaPreviousVersions := Set.empty,
mimaReportSignatureProblems := false,
mimaFailOnProblem := false,
mimaPreviousArtifacts := Set.empty,
Test / unmanagedResources += file("./schema.graphql"),
fork := true,
scalacOptions ++= {
if (scalaVersion.value.startsWith("2")) {
Seq(
"-Wunused:-nowarn",
"-Wconf:cat=unused-nowarn:s",
"-Ywarn-unused:-nowarn",
"-Xmigration",
"-Xsource:3"
)
} else Seq.empty // Seq("-explain")
},
libraryDependencies ++= Seq(
"org.typelevel" %% "cats-effect" % "3.5.7",
"org.typelevel" %% "cats-mtl" % "1.3.1",
"org.typelevel" %% "cats-core" % "2.12.0",
"org.typelevel" %% "cats-free" % "2.12.0",
"co.fs2" %% "fs2-core" % "3.11.0",
"co.fs2" %% "fs2-io" % "3.11.0",
"org.typelevel" %% "cats-parse" % "0.3.8",
"io.circe" %% "circe-core" % "0.14.6",
"io.circe" %% "circe-parser" % "0.14.6",
"io.circe" %% "circe-literal" % "0.14.6",
"org.tpolecat" %% "sourcepos" % "1.1.0",
"org.typelevel" %% "paiges-core" % "0.4.4",
"org.scalameta" %% "munit" % "1.0.0-RC1" % Test,
"org.typelevel" %% "munit-cats-effect" % "2.0.0" % Test
)
)
lazy val parser = project
.in(file("modules/parser"))
.settings(sharedSettings)
.settings(name := "gql-parser")
lazy val core = project
.in(file("modules/core"))
.settings(sharedSettings)
.settings(name := "gql-core")
.dependsOn(parser)
lazy val monadicArrow = project
.in(file("modules/monadic-arrow"))
.settings(sharedSettings)
.settings(name := "gql-monadic-arrow")
.dependsOn(core)
lazy val server = project
.in(file("modules/server"))
.settings(sharedSettings)
.settings(
name := "gql-server",
fork := true
)
.dependsOn(core)
lazy val client = project
.in(file("modules/client"))
.settings(sharedSettings)
.settings(name := "gql-client")
.dependsOn(core)
lazy val clientCodegen = project
.in(file("modules/client-codegen"))
.settings(sharedSettings)
.settings(name := "gql-client-codegen")
.dependsOn(core)
.dependsOn(client)
lazy val clientCodegenCli = project
.in(file("modules/client-codegen-cli"))
.settings(sharedSettings)
.settings(
name := "gql-client-codegen-cli",
libraryDependencies ++= Seq(
"com.monovore" %% "decline" % "2.4.1",
"com.monovore" %% "decline-effect" % "2.4.1"
)
)
.dependsOn(core)
.dependsOn(client)
.dependsOn(clientCodegen)
lazy val clientCodegenSbt = project
.in(file("modules/client-codegen-sbt"))
.enablePlugins(BuildInfoPlugin)
.enablePlugins(SbtPlugin)
.settings(
sbtPlugin := true,
scalaVersion := "2.12.18",
name := "gql-client-codegen-sbt",
libraryDependencies ++= Seq(
"io.circe" %% "circe-core" % "0.14.6"
)
)
.aggregate(clientCodegenCli)
/* .enablePlugins(NoPublishPlugin) */
val codeGenForTest = taskKey[Seq[File]]("Generate code for test")
lazy val testCodeGen = project
.in(file("modules/client-codegen-test"))
.settings(sharedSettings)
.dependsOn(clientCodegenCli)
.dependsOn(client)
.dependsOn(server % "test->test")
.dependsOn(http4sClient % "test->test")
.dependsOn(serverHttp4s % "test->test")
.settings(
tlFatalWarnings := false,
codeGenForTest := {
Def.taskDyn {
val sp = file("./modules/client-codegen-test/src/main/resources/schema.graphql").absolutePath.replace("\\", "\\\\")
val qp = file("./modules/client-codegen-test/src/main/resources/queries/query.graphql").absolutePath.replace("\\", "\\\\")
val f = (Compile / sourceManaged).value / "gql"
IO.createDirectory(f)
val s0 = f / "shared.scala"
val s = s0.absolutePath.replace("\\", "\\\\")
val outf = f / "query.scala"
val outs = outf.absolutePath.replace("\\", "\\\\")
val input =
s""" --validate --input {"schema":"${sp}","shared":"${s}","queries":[{"query":"${qp}","output":"${outs}"}],"packageName":"gql.client.gen.test"}"""
val ip2: String = input.toString()
(clientCodegenCli / Compile / run).toTask(ip2).map(_ => Seq(outf, s0))
}.value
},
// Testing consists of doing a code-gen run and then compiling the generated code
Compile / sourceGenerators += codeGenForTest,
Test / test := {
val _ = (Compile / compile).value
(Test / test).value
}
)
.enablePlugins(NoPublishPlugin)
lazy val http4sClient = project
.in(file("modules/client-http4s"))
.dependsOn(core)
.dependsOn(client)
.settings(sharedSettings)
.settings(
name := "gql-client-http4s",
libraryDependencies ++= Seq(
"org.http4s" %% "http4s-circe" % "1.0.0-M39",
"org.http4s" %% "http4s-dsl" % "1.0.0-M39",
"org.http4s" %% "http4s-client" % "1.0.0-M39"
)
)
lazy val serverNatchez = project
.in(file("modules/server-natchez"))
.settings(sharedSettings)
.settings(
name := "gql-natchez",
libraryDependencies ++= Seq(
"org.tpolecat" %% "natchez-core" % "0.3.7"
)
)
.dependsOn(core)
.dependsOn(server)
lazy val graphqlWs = project
.in(file("modules/graphql-ws"))
.settings(sharedSettings)
.settings(name := "gql-graphqlws")
.dependsOn(core)
lazy val serverGraphqlWs = project
.in(file("modules/server-graphql-ws"))
.settings(sharedSettings)
.settings(name := "gql-server-graphqlws")
.dependsOn(core)
.dependsOn(graphqlWs)
.dependsOn(server)
lazy val serverGoi = project
.in(file("modules/server-goi"))
.settings(sharedSettings)
.settings(
name := "gql-server-goi",
libraryDependencies ++= Seq(
"com.beachape" %% "enumeratum" % "1.7.3",
"org.typelevel" %% "twiddles-core" % "0.6.1"
)
)
.dependsOn(core)
.dependsOn(server)
lazy val serverHttp4s = project
.in(file("modules/server-http4s"))
.dependsOn(core % "compile->compile;test->test")
.dependsOn(server % "compile->compile;test->test")
.dependsOn(serverGraphqlWs)
.settings(sharedSettings)
.settings(
name := "gql-server-http4s",
libraryDependencies ++= Seq(
"org.http4s" %% "http4s-server" % "1.0.0-M39",
"org.http4s" %% "http4s-circe" % "1.0.0-M39",
"org.http4s" %% "http4s-dsl" % "1.0.0-M39",
"org.http4s" %% "http4s-client" % "1.0.0-M39" % Test
)
)
.dependsOn(server)
lazy val relational = project
.in(file("modules/relational"))
.settings(sharedSettings)
.dependsOn(server)
.settings(
name := "gql-relational"
)
lazy val relationalSkunk = project
.in(file("modules/relational-skunk"))
.settings(sharedSettings)
.dependsOn(server)
.dependsOn(relational % "compile->compile;compile->test")
.settings(
name := "gql-relational-skunk",
libraryDependencies ++= Seq(
"org.tpolecat" %% "skunk-core" % "0.6.0",
"org.tpolecat" %% "natchez-noop" % "0.3.7" % Test
)
)
lazy val relationalDoobie = project
.in(file("modules/relational-doobie"))
.settings(sharedSettings)
.dependsOn(server)
.dependsOn(relational % "compile->compile;compile->test")
.settings(
name := "gql-relational-doobie",
libraryDependencies ++= Seq(
"org.tpolecat" %% "doobie-core" % "1.0.0-RC4",
"org.tpolecat" %% "doobie-postgres" % "1.0.0-RC4" % Test
)
)
lazy val mdocExt = project
.in(file("modules/mdoc-ext"))
.settings(sharedSettings)
.enablePlugins(NoPublishPlugin)
lazy val readme = project
.in(file("modules/readme"))
.settings(
moduleName := "gql-readme",
mdocIn := file("readme/README.md"),
mdocOut := file("./README.md"),
mdocVariables ++= Map(
"VERSION" -> tlLatestVersion.value.getOrElse(version.value)
),
tlFatalWarnings := false
)
.dependsOn(server % "compile->compile;test->test;compile->test")
.dependsOn(core % "compile->compile;compile->test")
.dependsOn(serverHttp4s)
.dependsOn(serverGraphqlWs)
.dependsOn(serverNatchez)
.dependsOn(clientCodegen)
.dependsOn(clientCodegenCli)
.dependsOn(serverGoi)
.dependsOn(client)
.dependsOn(http4sClient)
.dependsOn(mdocExt)
.enablePlugins(MdocPlugin, NoPublishPlugin)
lazy val docs = project
.in(file("modules/docs"))
.settings(
moduleName := "gql-docs",
mdocOut := file("website/docs"),
mdocVariables ++= Map(
"VERSION" -> tlLatestVersion.value.getOrElse(version.value)
),
libraryDependencies ++= Seq(
"com.47deg" %% "fetch" % "3.1.2",
"org.tpolecat" %% "natchez-noop" % "0.3.7"
),
tlFatalWarnings := false
)
.dependsOn(server % "compile->compile;test->test;compile->test")
.dependsOn(core % "compile->compile;compile->test")
.dependsOn(serverHttp4s)
.dependsOn(serverGraphqlWs)
.dependsOn(relational)
.dependsOn(relationalSkunk)
.dependsOn(relationalDoobie)
.dependsOn(serverNatchez)
.dependsOn(clientCodegen)
.dependsOn(clientCodegenCli)
.dependsOn(serverGoi)
.dependsOn(client)
.dependsOn(monadicArrow)
.dependsOn(http4sClient)
.dependsOn(mdocExt)
.enablePlugins(MdocPlugin, DocusaurusPlugin, NoPublishPlugin)