Skip to content

Commit e6790f4

Browse files
committed
Add testing the doctool to community build
1 parent 36442ff commit e6790f4

File tree

3 files changed

+90
-9
lines changed

3 files changed

+90
-9
lines changed

community-build/src/scala/dotty/communitybuild/Main.scala

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,5 +9,18 @@ object Main {
99
* but for now stdlib is the only usecase.
1010
*/
1111
def main(args: Array[String]): Unit =
12-
projects.stdLib213.publish()
12+
if args.length != 2 then
13+
println("USAGE: <COMMAND> <PROJECT NAME>")
14+
println("COMMAND is one of: publish doc")
15+
println("Available projects are:")
16+
projects.projectMap.keys.foreach { k =>
17+
println(s"\t$k")
18+
}
19+
sys.exit(0)
20+
21+
val Array(cmd, proj) = args
22+
cmd match {
23+
case "doc" => projects(proj).doc()
24+
case "publish" => projects(proj).publish()
25+
}
1326
}

community-build/src/scala/dotty/communitybuild/projects.scala

Lines changed: 74 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -29,30 +29,43 @@ def exec(projectDir: Path, binary: String, arguments: String*): Int =
2929
val exitCode = process.waitFor()
3030
exitCode
3131

32-
3332
sealed trait CommunityProject:
3433
private var published = false
3534

3635
val project: String
3736
val testCommand: String
3837
val publishCommand: String
38+
val docCommand: String
3939
val dependencies: List[CommunityProject]
4040
val binaryName: String
4141
val runCommandsArgs: List[String] = Nil
4242

4343
final val projectDir = communitybuildDir.resolve("community-projects").resolve(project)
4444

45+
final def publishDependencies(): Unit =
46+
dependencies.foreach(_.publish())
47+
4548
/** Publish this project to the local Maven repository */
4649
final def publish(): Unit =
4750
if !published then
48-
dependencies.foreach(_.publish())
51+
publishDependencies()
4952
log(s"Publishing $project")
5053
if publishCommand eq null then
5154
throw RuntimeException(s"Publish command is not specified for $project. Project details:\n$this")
5255
val exitCode = exec(projectDir, binaryName, (runCommandsArgs :+ publishCommand): _*)
5356
if exitCode != 0 then
5457
throw RuntimeException(s"Publish command exited with code $exitCode for project $project. Project details:\n$this")
5558
published = true
59+
60+
final def doc(): Unit =
61+
publishDependencies()
62+
log(s"Documenting $project")
63+
if docCommand eq null then
64+
throw RuntimeException(s"Doc command is not specified for $project. Project details:\n$this")
65+
val exitCode = exec(projectDir, binaryName, (runCommandsArgs :+ docCommand): _*)
66+
if exitCode != 0 then
67+
throw RuntimeException(s"Doc command exited with code $exitCode for project $project. Project details:\n$this")
68+
5669
end CommunityProject
5770

5871
final case class MillCommunityProject(
@@ -62,6 +75,7 @@ final case class MillCommunityProject(
6275
override val binaryName: String = "./mill"
6376
override val testCommand = s"$baseCommand.test"
6477
override val publishCommand = s"$baseCommand.publishLocal"
78+
override val docCommand = null
6579
override val runCommandsArgs = List("-i", "-D", s"dottyVersion=$compilerVersion")
6680

6781
final case class SbtCommunityProject(
@@ -70,11 +84,16 @@ final case class SbtCommunityProject(
7084
extraSbtArgs: List[String] = Nil,
7185
forceUpgradeSbtScalajsPlugin: Boolean = false,
7286
dependencies: List[CommunityProject] = Nil,
73-
sbtPublishCommand: String = null) extends CommunityProject:
87+
sbtPublishCommand: String = null,
88+
sbtDocCommand: String = null
89+
) extends CommunityProject:
7490
override val binaryName: String = "sbt"
7591
private val baseCommand = s";clean ;set logLevel in Global := Level.Error ;set updateOptions in Global ~= (_.withLatestSnapshots(false)) ;++$compilerVersion! "
7692
override val testCommand = s"$baseCommand$sbtTestCommand"
77-
override val publishCommand = s"$baseCommand$sbtPublishCommand"
93+
override val publishCommand = if sbtPublishCommand eq null then null else s"$baseCommand$sbtPublishCommand"
94+
override val docCommand =
95+
if sbtDocCommand eq null then null else
96+
s"$baseCommand;set every useScala3doc := true $sbtDocCommand"
7897

7998
override val runCommandsArgs: List[String] =
8099
// Run the sbt command with the compiler version and sbt plugin set in the build
@@ -86,11 +105,12 @@ final case class SbtCommunityProject(
86105
else Nil
87106
extraSbtArgs ++ sbtProps ++ List(
88107
"-sbt-version", "1.3.8",
89-
"-Dsbt.supershell=false",
108+
"-Dsbt.supershell=false",
90109
s"--addPluginSbtFile=$sbtPluginFilePath"
91110
) ++ scalaJSPluginArgs
92111

93112
object projects:
113+
94114
lazy val utest = MillCommunityProject(
95115
project = "utest",
96116
baseCommand = s"utest.jvm[$compilerVersion]",
@@ -212,6 +232,7 @@ object projects:
212232
lazy val betterfiles = SbtCommunityProject(
213233
project = "betterfiles",
214234
sbtTestCommand = "dotty-community-build/compile",
235+
sbtDocCommand = ";core/doc ;akka/doc ;shapelessScanner/doc"
215236
)
216237

217238
lazy val ScalaPB = SbtCommunityProject(
@@ -308,6 +329,7 @@ object projects:
308329
lazy val scalaz = SbtCommunityProject(
309330
project = "scalaz",
310331
sbtTestCommand = "rootJVM/test",
332+
// has doc/sources set to Nil
311333
dependencies = List(scalacheck)
312334
)
313335

@@ -324,7 +346,51 @@ object projects:
324346

325347
lazy val catsEffect3 = SbtCommunityProject(
326348
project = "cats-effect-3",
327-
sbtTestCommand = "testIfRelevant"
328-
)
329-
349+
sbtTestCommand = "testIfRelevant",
350+
// has doc/sources disabled by SpiewakPlugin
351+
)
352+
353+
val projectMap = Map(
354+
"utest" -> utest,
355+
"sourcecode" -> sourcecode,
356+
"oslib" -> oslib,
357+
"oslibWatch" -> oslibWatch,
358+
"ujson" -> ujson,
359+
"upickle" -> upickle,
360+
"upickleCore" -> upickleCore,
361+
"geny" -> geny,
362+
"fansi" -> fansi,
363+
"pprint" -> pprint,
364+
"requests" -> requests,
365+
"scas" -> scas,
366+
"intent" -> intent,
367+
"algebra" -> algebra,
368+
"scalacheck" -> scalacheck,
369+
"scalatest" -> scalatest,
370+
"scalatestplusScalacheck" -> scalatestplusScalacheck,
371+
"scalaXml" -> scalaXml,
372+
"scopt" -> scopt,
373+
"scalap" -> scalap,
374+
"squants" -> squants,
375+
"betterfiles" -> betterfiles,
376+
"ScalaPB" -> ScalaPB,
377+
"minitest" -> minitest,
378+
"fastparse" -> fastparse,
379+
"stdLib213" -> stdLib213,
380+
"shapeless" -> shapeless,
381+
"xmlInterpolator" -> xmlInterpolator,
382+
"effpi" -> effpi,
383+
"sconfig" -> sconfig,
384+
"zio" -> zio,
385+
"munit" -> munit,
386+
"scodecBits" -> scodecBits,
387+
"scodec" -> scodec,
388+
"scalaParserCombinators" -> scalaParserCombinators,
389+
"dottyCpsAsync" -> dottyCpsAsync,
390+
"scalaz" -> scalaz,
391+
"endpoints4s" -> endpoints4s,
392+
"catsEffect2" -> catsEffect2,
393+
"catsEffect3" -> catsEffect3,
394+
)
395+
def apply(key: String) = projectMap(key)
330396
end projects

project/Build.scala

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1280,6 +1280,7 @@ object Build {
12801280
(publishLocal in `tasty-core-bootstrapped`).value
12811281
(publishLocal in `scala3-library-bootstrapped`).value
12821282
(publishLocal in `scala3-doc-bootstrapped`).value
1283+
(publishLocal in `scala3doc`).value
12831284
(publishLocal in `scala3-compiler-bootstrapped`).value
12841285
(publishLocal in `sbt-dotty`).value
12851286
(publishLocal in `scala3-bootstrapped`).value
@@ -1298,6 +1299,7 @@ object Build {
12981299
TestFrameworks.JUnit,
12991300
"--include-categories=dotty.communitybuild.TestCategory",
13001301
),
1302+
Compile/run := (Compile/run).dependsOn(prepareCommunityBuild).evaluated,
13011303
(Test / testOnly) := ((Test / testOnly) dependsOn prepareCommunityBuild).evaluated,
13021304
(Test / test ) := ((Test / test ) dependsOn prepareCommunityBuild).value,
13031305
javaOptions ++= {

0 commit comments

Comments
 (0)