Skip to content

Commit

Permalink
Merge pull request #711 from armanbilge/feature/javafmt
Browse files Browse the repository at this point in the history
Support checking Java formatting
  • Loading branch information
armanbilge committed May 16, 2024
2 parents d01bac4 + 7754484 commit bdc0e9a
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 26 deletions.
53 changes: 28 additions & 25 deletions ci/src/main/scala/org/typelevel/sbt/TypelevelCiPlugin.scala
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ object TypelevelCiPlugin extends AutoPlugin {
settingKey[Boolean]("Whether to do header check in CI (default: false)")
lazy val tlCiScalafmtCheck =
settingKey[Boolean]("Whether to do scalafmt check in CI (default: false)")
lazy val tlCiJavafmtCheck =
settingKey[Boolean]("Whether to do javafmt check in CI (default: false)")
lazy val tlCiScalafixCheck =
settingKey[Boolean]("Whether to do scalafix check in CI (default: false)")
lazy val tlCiMimaBinaryIssueCheck =
Expand All @@ -57,6 +59,7 @@ object TypelevelCiPlugin extends AutoPlugin {
override def buildSettings = Seq(
tlCiHeaderCheck := false,
tlCiScalafmtCheck := false,
tlCiJavafmtCheck := false,
tlCiScalafixCheck := false,
tlCiMimaBinaryIssueCheck := false,
tlCiDocCheck := false,
Expand All @@ -68,32 +71,32 @@ object TypelevelCiPlugin extends AutoPlugin {
githubWorkflowPublishTargetBranches := Seq(),
githubWorkflowBuild := {

val style = (tlCiHeaderCheck.value, tlCiScalafmtCheck.value) match {
case (true, true) => // headers + formatting
List(
WorkflowStep.Sbt(
List("headerCheckAll", "scalafmtCheckAll", "project /", "scalafmtSbtCheck"),
name = Some("Check headers and formatting"),
cond = Some(primaryAxisCond.value)
)
)
case (true, false) => // headers
List(
WorkflowStep.Sbt(
List("headerCheckAll"),
name = Some("Check headers"),
cond = Some(primaryAxisCond.value)
)
)
case (false, true) => // formatting
List(
WorkflowStep.Sbt(
List("scalafmtCheckAll", "project /", "scalafmtSbtCheck"),
name = Some("Check formatting"),
cond = Some(primaryAxisCond.value)
)
val style = {
val headers = List("headerCheckAll").filter(_ => tlCiHeaderCheck.value)

val scalafmt = List(
"scalafmtCheckAll",
"project /",
"scalafmtSbtCheck"
).filter(_ => tlCiScalafmtCheck.value)

val javafmt = List("javafmtCheckAll").filter(_ => tlCiJavafmtCheck.value)

val formatting = javafmt ++ scalafmt

val headersFormatting = headers ++ formatting

val names =
List("headers").filter(_ => headers.nonEmpty) ++ List("formatting").filter(_ =>
formatting.nonEmpty)

List(
WorkflowStep.Sbt(
headers ++ formatting,
name = Some(s"Check ${names.mkString(" and ")}"),
cond = Some(primaryAxisCond.value)
)
case (false, false) => Nil // nada
).filter(_ => headersFormatting.nonEmpty)
}

val test = List(
Expand Down
4 changes: 3 additions & 1 deletion core/src/main/scala/org/typelevel/sbt/TypelevelPlugin.scala
Original file line number Diff line number Diff line change
Expand Up @@ -79,12 +79,14 @@ object TypelevelPlugin extends AutoPlugin {
GlobalScope / tlCommandAliases ++= {
val header = tlCiHeaderCheck.value
val scalafmt = tlCiScalafmtCheck.value
val javafmt = tlCiJavafmtCheck.value
val scalafix = tlCiScalafixCheck.value

val prePR = List("project /", "githubWorkflowGenerate") ++
List("+headerCreateAll").filter(_ => header) ++
List("+scalafixAll").filter(_ => scalafix) ++
List("+scalafmtAll", "scalafmtSbt").filter(_ => scalafmt)
List("+scalafmtAll", "scalafmtSbt").filter(_ => scalafmt) ++
List("javafmtAll").filter(_ => javafmt)

val botHook = List("githubWorkflowGenerate") ++
List("+headerCreateAll").filter(_ => header) ++
Expand Down
1 change: 1 addition & 0 deletions docs/customization.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ Both plugins are documented in [**sbt-typelevel-github-actions**](gha.md).

- `tlCiHeaderCheck` (setting): Whether to do header check in CI (default: `false`).
- `tlCiScalafmtCheck` (setting): Whether to do scalafmt check in CI (default: `false`).
- `tlCiJavafmtCheck` (setting): Whether to do javafmt check in CI (default: `false`).
- `tlCiScalafixCheck` (setting): Whether to do scalafix check in CI (default: `false`).
- `tlCiMimaBinaryIssueCheck` (setting): Whether to do MiMa binary issues check in CI (default: `false`).
- `tlCiDocCheck` (setting): Whether to build API docs in CI (default: `false`).
Expand Down

0 comments on commit bdc0e9a

Please sign in to comment.