Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improved prePR #729

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 8 additions & 3 deletions core/src/main/scala/org/typelevel/sbt/TypelevelPlugin.scala
Original file line number Diff line number Diff line change
Expand Up @@ -76,24 +76,29 @@ object TypelevelPlugin extends AutoPlugin {
java <- githubWorkflowJavaVersions.value.tail // default java is head
} yield MatrixExclude(Map("scala" -> scala, "java" -> java.render))
},
GlobalScope / tlCommandAliases ++= {
GlobalScope / tlPrePRSteps ++= {
val header = tlCiHeaderCheck.value
val scalafmt = tlCiScalafmtCheck.value
val javafmt = tlCiJavafmtCheck.value
val scalafix = tlCiScalafixCheck.value

val prePR = List("project /", "githubWorkflowGenerate") ++
List("githubWorkflowGenerate") ++
List("+headerCreateAll").filter(_ => header) ++
List("+scalafixAll").filter(_ => scalafix) ++
List("+scalafmtAll", "scalafmtSbt").filter(_ => scalafmt) ++
List("javafmtAll").filter(_ => javafmt)
},
GlobalScope / tlCommandAliases ++= {
val header = tlCiHeaderCheck.value
val scalafmt = tlCiScalafmtCheck.value
val javafmt = tlCiJavafmtCheck.value

val botHook = List("githubWorkflowGenerate") ++
List("+headerCreateAll").filter(_ => header) ++
List("javafmtAll").filter(_ => javafmt) ++
List("+scalafmtAll", "scalafmtSbt").filter(_ => scalafmt)
zarthross marked this conversation as resolved.
Show resolved Hide resolved

Map(
"prePR" -> prePR,
"tlPrePrBotHook" -> botHook
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,9 @@ object TypelevelKernelPlugin extends AutoPlugin {
"Command aliases defined for this build"
)

lazy val tlPrePRSteps =
settingKey[List[String]]("Steps to be performed before a user submits a PR")
Comment on lines +48 to +49
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Mostly curious, why did you introduce this setting in the kernel plugin? I think we could introduce and set the default in the CI plugin, without need a blank default.

Also the doc can be more specific that these are the steps run by the prePR command alias.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added it to kernel because at my work we are using the Github plugin without using TypelevelCiPlugin, so for our use it made more sense to push it into Kernel. Maybe there is an argument that we should be extending TypelevelCiPlugin... Ill take a look next week, but now that Ive looked closer at the CIPlugin it might make sense.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you are only using the kernel plugin, then it's fairly straightforward to do whatever you want directly with tlCommandAliases.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

While it is, and I did... I thought I would basically push back up the changes I was making for myself internally. My thought process was that as people add different 'linters' or other things that are expected to pass in CI, such as scalafix/fmt, mima, or sbt-explicit-dependency, or sbt-missinglink , I wanted an easy way to aggregate those into a check at the the same time (in the same auto-plugin) as i was adding the github workflow.

What ended up happening in my world is people started defining a command alias called 'build' in each project and just put in the various steps, but somehow it would always be out of sync with what we actually did in CI.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Alright, so the reason I'd prefer to keep prePR in kernel is because we have our own custom ci steps and we'd like the easier to extend prePR.


@deprecated(
"Use `tlCommandAliases` for a more composable command definition experience",
"0.6.1")
Expand All @@ -62,7 +65,8 @@ object TypelevelKernelPlugin extends AutoPlugin {
override def globalSettings = Seq(
Def.derive(tlIsScala3 := scalaVersion.value.startsWith("3.")),
tlCommandAliases := Map(
"tlReleaseLocal" -> List("reload", "project /", "+publishLocal")
"tlReleaseLocal" -> List("reload", "project /", "+publishLocal"),
"prePR" -> ("reload" :: "project /" :: tlPrePRSteps.value)
),
onLoad := {
val aliases = tlCommandAliases.value
Expand All @@ -78,7 +82,8 @@ object TypelevelKernelPlugin extends AutoPlugin {
onUnload.value.compose { (state: State) =>
aliases.foldLeft(state) { (state, alias) => BasicCommands.removeAlias(state, alias) }
}
}
},
tlPrePRSteps := List.empty
)

@nowarn("cat=deprecation")
Expand Down
Loading