diff --git a/ci/src/main/scala/org/typelevel/sbt/TypelevelCiPlugin.scala b/ci/src/main/scala/org/typelevel/sbt/TypelevelCiPlugin.scala index 877fa5f3..8d3cfabc 100644 --- a/ci/src/main/scala/org/typelevel/sbt/TypelevelCiPlugin.scala +++ b/ci/src/main/scala/org/typelevel/sbt/TypelevelCiPlugin.scala @@ -56,6 +56,9 @@ object TypelevelCiPlugin extends AutoPlugin { settingKey[String]( "Condition for checking on CI whether this project is a fork of another (default: `github.event.repository.fork == false`)") + lazy val tlCiLintCommands = settingKey[Seq[String]]( + "sbt commands run in the 'Check headers and formatting' CI step (default: derived from `tlCiHeaderCheck`, `tlCiScalafmtCheck`, and `tlCiJavafmtCheck`)") + } import autoImport._ @@ -69,6 +72,19 @@ object TypelevelCiPlugin extends AutoPlugin { tlCiDocCheck := false, tlCiDependencyGraphJob := true, tlCiForkCondition := "github.event.repository.fork == false", + tlCiLintCommands := { + val headers = List("headerCheckAll").filter(_ => tlCiHeaderCheck.value) + + val scalafmt = List( + "scalafmtCheckAll", + "project /", + "scalafmtSbtCheck" + ).filter(_ => tlCiScalafmtCheck.value) + + val javafmt = List("javafmtCheckAll").filter(_ => tlCiJavafmtCheck.value) + + headers ++ javafmt ++ scalafmt + }, githubWorkflowTargetBranches ++= Seq( "!update/**", // ignore steward branches "!pr/**" // escape-hatch to disable ci on a branch @@ -77,31 +93,15 @@ object TypelevelCiPlugin extends AutoPlugin { githubWorkflowBuild := { 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) + val commands = tlCiLintCommands.value.toList List( WorkflowStep.Sbt( - headers ++ formatting, - name = Some(s"Check ${names.mkString(" and ")}"), + commands, + name = Some("Check headers and formatting"), cond = Some(primaryAxisCond.value) ) - ).filter(_ => headersFormatting.nonEmpty) + ).filter(_ => commands.nonEmpty) } val test = List( diff --git a/docs/customization.md b/docs/customization.md index 3691fb25..cad6542b 100644 --- a/docs/customization.md +++ b/docs/customization.md @@ -67,6 +67,7 @@ Both plugins are documented in [**sbt-typelevel-github-actions**](gha.md). - `tlCiDocCheck` (setting): Whether to build API docs in CI (default: `false`). - `tlCiDependencyGraphJob` (setting): Whether to add a job to submit dependencies to GH (default: `true`). - `tlCiForkCondition` (setting): Condition for checking on CI whether this project is a fork of another (default: `github.event.repository.fork == false`). +- `tlCiLintCommands` (setting): sbt commands run in the "Check headers and formatting" CI step. Defaults are derived from `tlCiHeaderCheck`, `tlCiScalafmtCheck`, and `tlCiJavafmtCheck`. Append your own check (e.g. `tlCiLintCommands += "myLintCheckAll"`) to fold it into the same step. Scalafix is gated separately via `tlCiScalafixCheck` and runs as its own step. - `tlCiStewardValidateConfig` (setting): The location of the Scala Steward config to validate (default: `.scala-steward.conf`, if exists). - `tlCrossRootProject` (method): helper to create a `root` project that can aggregate both `Project`s and `CrossProject`s. Automatically creates separate jobs in the CI matrix for each platform (JVM, JS, etc.).