Skip to content

Commit 75a7c8f

Browse files
authored
Merge pull request #542 from typelevel/pr/better-prepr
Better `prePR` command
2 parents caa5440 + d7ba294 commit 75a7c8f

File tree

3 files changed

+29
-26
lines changed

3 files changed

+29
-26
lines changed

core/src/main/scala/org/typelevel/sbt/TypelevelPlugin.scala

Lines changed: 28 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -39,22 +39,18 @@ object TypelevelPlugin extends AutoPlugin {
3939
override def trigger = allRequirements
4040

4141
object autoImport {
42+
@deprecated("No longer has an effect. Use `tlFatalWarnings` instead.", "0.5.0")
4243
lazy val tlFatalWarningsInCi = settingKey[Boolean](
4344
"Convert compiler warnings into errors under CI builds (default: true)")
4445
}
4546

46-
import autoImport._
4747
import TypelevelKernelPlugin.mkCommand
4848
import TypelevelCiPlugin.autoImport._
4949
import TypelevelSettingsPlugin.autoImport._
5050
import TypelevelSonatypeCiReleasePlugin.autoImport._
5151
import GenerativePlugin.autoImport._
5252
import GitHubActionsPlugin.autoImport._
5353

54-
override def globalSettings = Seq(
55-
tlFatalWarningsInCi := true
56-
)
57-
5854
override def buildSettings = Seq(
5955
organization := "org.typelevel",
6056
organizationName := "Typelevel",
@@ -70,7 +66,7 @@ object TypelevelPlugin extends AutoPlugin {
7066
tlCiHeaderCheck := true,
7167
tlCiScalafmtCheck := true,
7268
tlCiReleaseBranches := Seq("main"),
73-
Def.derive(tlFatalWarnings := (tlFatalWarningsInCi.value && githubIsWorkflowBuild.value)),
69+
Def.derive(tlFatalWarnings := githubIsWorkflowBuild.value),
7470
githubWorkflowJavaVersions := {
7571
Seq(JavaSpec.temurin(tlJdkRelease.value.getOrElse(8).toString))
7672
},
@@ -81,24 +77,7 @@ object TypelevelPlugin extends AutoPlugin {
8177
java <- githubWorkflowJavaVersions.value.tail // default java is head
8278
} yield MatrixExclude(Map("scala" -> scala, "java" -> java.render))
8379
}
84-
) ++ addCommandAlias(
85-
"prePR",
86-
mkCommand(
87-
List(
88-
"reload",
89-
"project /",
90-
"clean",
91-
"githubWorkflowGenerate",
92-
"headerCreateAll",
93-
"scalafmtAll",
94-
"scalafmtSbt",
95-
"set ThisBuild / tlFatalWarnings := tlFatalWarningsInCi.value",
96-
"Test / compile",
97-
"doc",
98-
"session clear"
99-
)
100-
)
101-
) ++ addCommandAlias(
80+
) ++ addPrePRCommandAlias ++ addCommandAlias(
10281
"tlPrePrBotHook",
10382
mkCommand(
10483
List(
@@ -110,4 +89,29 @@ object TypelevelPlugin extends AutoPlugin {
11089
)
11190
)
11291

92+
// partially re-implemnents addCommandAlias
93+
// this is so we can use the value of other settings to generate command
94+
private def addPrePRCommandAlias: Seq[Setting[_]] = Seq(
95+
GlobalScope / onLoad := {
96+
val header = tlCiHeaderCheck.value
97+
val scalafmt = tlCiScalafmtCheck.value
98+
val scalafix = tlCiScalafixCheck.value
99+
100+
(GlobalScope / Keys.onLoad).value.compose { (state: State) =>
101+
val command = mkCommand(
102+
List("project /", "githubWorkflowGenerate") ++
103+
List("+headerCreateAll").filter(_ => header) ++
104+
List("+scalafmtAll", "scalafmtSbt").filter(_ => scalafmt) ++
105+
List("+scalafixAll").filter(_ => scalafix)
106+
)
107+
BasicCommands.addAlias(state, "prePR", command)
108+
}
109+
},
110+
GlobalScope / Keys.onUnload := {
111+
(GlobalScope / Keys.onUnload)
112+
.value
113+
.compose((state: State) => BasicCommands.removeAlias(state, "prePR"))
114+
}
115+
)
116+
113117
}

docs/customization.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,6 @@ Instead of using the super-plugins, for finer-grained control you can always add
5858

5959
### sbt-typelevel
6060
- `TypelevelPlugin`: The super-super-plugin intended for bootstrapping the typical Typelevel project. Sets up CI release including snapshots, scalac settings, headers, and formatting.
61-
- `tlFatalWarningsInCi` (setting): Convert compiler warnings into errors under CI builds (default: true).
6261

6362
### sbt-typelevel-site
6463
- `TypelevelSitePlugin`: Sets up an [mdoc](https://scalameta.org/mdoc/)/[Laika](https://typelevel.org/Laika/)-generated website, automatically published to GitHub pages in CI.

docs/faq.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ You may also want to (globally) install the [sbt-rewarn](https://github.com/rtim
4444
If you are using **sbt-typelevel** fatal warnings are on by default in CI.
4545

4646
```scala
47-
ThisBuild / tlFatalWarningsInCi := false
47+
ThisBuild / tlFatalWarnings := false
4848
```
4949

5050
If you are only using **sbt-typelevel-ci-release**, you are completely in charge of your own `scalacOptions`, including fatal warnings.

0 commit comments

Comments
 (0)