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

Hello, sbt-typelevel #12

Merged
merged 70 commits into from
Dec 30, 2021
Merged

Conversation

armanbilge
Copy link
Member

@armanbilge armanbilge commented Dec 28, 2021

Executes #11.

Early days still, but it's solid enough to self-host and publish snapshots:
https://s01.oss.sonatype.org/content/repositories/snapshots/com/armanbilge/sbt-typelevel-ci-release_2.12_1.0/0.4-a57db49-SNAPSHOT/

If you feel empowered, please give it a try.

https://index.scala-lang.org/armanbilge/sbt-typelevel/

Highlights:

  1. Your choice of CI snapshots: off / "true" snapshot / "stable" snapshot.
  2. I think I fixed the double release problem in CI if you push a tag with a commit. Haven't tested this yet.
  3. Will eventually support both passphrase and non-passphrase protected keys. Support for the former is not quite ready yet, and haven't tested the latter. Confirmed to work for both!

Any and all feedback much appreciated, although it would be cool to get this merged as-is and the feedback can come in the form of issues or ideally PRs. I don't claim to have any real knowledge of what I was doing here, just tried my best 🙃

Update: published a stable hash release to maven. Last step: getting keys with passphrases to work. Done.

@armanbilge
Copy link
Member Author

armanbilge commented Dec 29, 2021

Alright, definitely not perfect, but overall seems to be functional :)

addSbtPlugin("com.armanbilge" % "sbt-typelevel-ci-release" % "0.4-ddf26e7")
enablePlugins(TypelevelCiReleasePlugin)

https://index.scala-lang.org/armanbilge/sbt-typelevel/

Notable features

  1. Batteries-included: sbt-typelevel-ci-release sets you up for CI publishing MiMa-verified artifacts to sonatype under semantic versioning.
  2. Flexible/modular: the "super-plugin" is composed of independent plugins for versioning, mima, scalac settings, gpg signing, publishing, CI, etc. Pick and choose to make your own personal super-plugin.
  3. IMO the code is fairly straightforward. Each plugin has a well-defined responsibility. No weird inter-dependencies to keep track of and not even a taskDyn. I hope this will make contributing easy.
  4. Support for GPG signing for keys with and without passphrases. This is determined automatically, no config required.
  5. Opt-in snapshot publishing, either as "true" snapshots (default) or "Spiewak-style" hash-versioned releases.
  6. No more double-publish mishaps when pushing a tagged commit. If a publish job is triggered by a commit (and not a tag) but there is a tag, it will not publish. The job triggered by the tag will publish normally.
  7. Temurin 8 is the default JVM.
  8. The new s01 sonatype host is the default. A single setting switches you back to the legacy host.

Full list of plugins

addSbtPlugin("com.armanbilge" % "sbt-typelevel-no-publish"          % "0.4-ddf26e7")
addSbtPlugin("com.armanbilge" % "sbt-typelevel-settings"            % "0.4-ddf26e7")
addSbtPlugin("com.armanbilge" % "sbt-typelevel-versioning"          % "0.4-ddf26e7")
addSbtPlugin("com.armanbilge" % "sbt-typelevel-mima"                % "0.4-ddf26e7")
addSbtPlugin("com.armanbilge" % "sbt-typelevel-sonatype"            % "0.4-ddf26e7")
addSbtPlugin("com.armanbilge" % "sbt-typelevel-sonatype-ci-release" % "0.4-ddf26e7")
addSbtPlugin("com.armanbilge" % "sbt-typelevel-ci-signing"          % "0.4-ddf26e7")
addSbtPlugin("com.armanbilge" % "sbt-typelevel-ci"                  % "0.4-ddf26e7")
addSbtPlugin("com.armanbilge" % "sbt-typelevel"                     % "0.4-ddf26e7")
addSbtPlugin("com.armanbilge" % "sbt-typelevel-ci-release"          % "0.4-ddf26e7")

.scalafmt.conf Show resolved Hide resolved
CODE_OF_CONDUCT.md Outdated Show resolved Hide resolved
build.sbt Outdated Show resolved Hide resolved
ci-signing/build.sbt Show resolved Hide resolved
ci/build.sbt Show resolved Hide resolved

override def buildSettings =
addCommandAlias(
"ci",
Copy link
Member

Choose a reason for hiding this comment

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

Thought exercise: how would we make this open to extension for projects that run additional checks? This has frustrated me in other plugins that use aliases.

Copy link
Member

Choose a reason for hiding this comment

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

Oh, replaceCommandAlias?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yep, got that here:

object autoImport {
lazy val tlIsScala3 = settingKey[Boolean]("True if building with Scala 3")
def replaceCommandAlias(name: String, contents: String): Seq[Setting[State => State]] =
Seq(GlobalScope / onLoad ~= { (f: State => State) =>
f andThen { s: State =>

Copy link
Member

Choose a reason for hiding this comment

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

So much else is structured, and we manipulate aliases as semi-colon delimited strings. But I guess we inherit that from SBT's model. This is probably the best we can do.

import GitHubActionsPlugin.autoImport._

override def globalSettings = Seq(
tlFatalWarningsInCi := true
Copy link
Member

Choose a reason for hiding this comment

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

I have never been particularly fond of this setting varying from local development.

Copy link
Member Author

Choose a reason for hiding this comment

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

True. But also, fatal warnings make development/experimentation extremely annoying.

Copy link
Member

Choose a reason for hiding this comment

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

I generally solve that by adjusting my scalacOptions in session while in that mode. That way it's consistent with CI by default, and I can opt out while hacking. But I won't die on this hill if other people like it.

Copy link
Member Author

Choose a reason for hiding this comment

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

Interesting. OTOH I generally solve this problem by actually paying attention to the warnings indicated in the IDE 😉

One compromise is providing a prePR command that emulates a CI compile.

Copy link
Member

Choose a reason for hiding this comment

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

I like the compromise, but I thought that was the intent of the ci alias?

Copy link
Member Author

Choose a reason for hiding this comment

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

I always thought of ci as what you want CI to do—run the entire test suite, run MiMa, generate docs, etc. etc. Meanwhile, prePR are "lighter-weight" checks you can do locally, e.g. formatting, compiling with fatal warnings, etc.

Copy link
Member Author

Choose a reason for hiding this comment

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

Hmm, this is trickier to implement than I thought.

addCommandAlias(
    "prePR",
    "; root/clean; set tlFatalWarnings := tlFatalWarningsInCi.value; +root/Test/compile")

The problem is, how do you reset tlFatalWarnings to the old setting after prePR? Not sure if this is possible, or my sbt-fu isn't good enough anyway. Someone smarter can chime in, otherwise we can shunt this for now.

Copy link
Member

Choose a reason for hiding this comment

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

It could be done with a custom task, but it may not be worth the trouble.


object autoImport {
lazy val tlIsScala3 = settingKey[Boolean]("True if building with Scala 3")
def replaceCommandAlias(name: String, contents: String): Seq[Setting[State => State]] =
Copy link
Member

Choose a reason for hiding this comment

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

Does this deserve a tl prefix since it's auto-imported?

Copy link
Member Author

Choose a reason for hiding this comment

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

auto-imports definitely need a prefix. The similar isDotty setting in sbt-spiewak is the reason http4s is not in the Scala 3 Community Build:

Comment on lines +19 to +21
lazy val tlUntaggedAreSnapshots =
settingKey[Boolean](
"If true, an untagged commit is given a snapshot version, e.g. 0.4-00218f9-SNAPSHOT. If false, it is given a release version, e.g. 0.4-00218f9. (default: true)")
Copy link
Member Author

Choose a reason for hiding this comment

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

@rossabaker wdyt?

Copy link
Member

Choose a reason for hiding this comment

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

I like it.

@armanbilge
Copy link
Member Author

armanbilge commented Dec 30, 2021

Please let me know what else is needed here so we can land this. I know there's still a lot to iterate on, but at least for me it'll be much easier to keep track of in issues and separate PRs rather than trying to track all the comments in this one. Thanks!

After this merges I'll open follow-up issues for all the unresolved comments.

@armanbilge
Copy link
Member Author

Nice, was able to publish a snapshot under org.typelevel :)

https://oss.sonatype.org/content/repositories/snapshots/org/typelevel/sbt-typelevel_2.12_1.0/0.4-df43b10-SNAPSHOT/

build.sbt Outdated

enablePlugins(TypelevelCiReleasePlugin)
ThisBuild / tlCiReleaseSnapshots := true
ThisBuild / tlCiReleaseBranches := Seq("series/armanbilge")
Copy link
Member Author

Choose a reason for hiding this comment

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

I'll change this before we merge, but for now lets me publish from my branch.

Suggested change
ThisBuild / tlCiReleaseBranches := Seq("series/armanbilge")
ThisBuild / tlCiReleaseBranches := Seq("main")

@armanbilge
Copy link
Member Author

armanbilge commented Dec 30, 2021

Darn, I'll have to rollback the s01 default. https://github.com/typelevel/general/issues/114#issuecomment-1003058561

Copy link
Member

@rossabaker rossabaker left a comment

Choose a reason for hiding this comment

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

I don't think there are any showstoppers here. I'll give the snapshot a try on a lower-profile project.

@armanbilge armanbilge merged commit 60549ca into typelevel:main Dec 30, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants