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

Add sbt/setup-sbt #469

Merged
merged 1 commit into from
Oct 29, 2024
Merged

Add sbt/setup-sbt #469

merged 1 commit into from
Oct 29, 2024

Conversation

Friendseeker
Copy link

@Friendseeker Friendseeker commented Oct 28, 2024

@eed3si9n @SethTisue good to go?

Btw I would also want to inquire whether changes are needed at sbt/setup-sbt too. I don't know how Scala Steward works but here's the only reference to sbt version in sbt/setup-sbt.

inputs:
  sbt-runner-version:
    description: "The runner version (The actual version is controlled via project/build.properties)"
    required: true
    default: 1.10.3

https://github.com/sbt/setup-sbt/blob/0e649c9d325023db10f4c28603a7870d04c16141/action.yml#L7

Do we need to add a build.properties file in sbt/setup-sbt for Scala Steward to pick up the sbt version & update action.yml?

Copy link

Changed repositories:

sbt/setup-sbt

Legends:
✅=Actor is a repo owner or an organization admin.
❔=Unable to validate. Requires manual validation.

@mzuehlke
Copy link

@Friendseeker Scala Steward gets the sbt version from project/build.properties.
See: https://github.com/scala-steward-org/scala-steward/blob/0bc0acba0ace93f4fc40f752170dd187d80d3404/modules/core/src/main/scala/org/scalasteward/core/buildtool/sbt/SbtAlg.scala#L50-L54

That version number will then be replaced in all files matching this pattern: https://github.com/scala-steward-org/scala-steward/blob/0bc0acba0ace93f4fc40f752170dd187d80d3404/docs/repo-specific-configuration.md?plain=1#L120

@tgodzik tgodzik merged commit b8a11f5 into VirtusLab:main Oct 29, 2024
1 check passed
@Friendseeker Friendseeker deleted the patch-1 branch October 29, 2024 18:22
@eed3si9n
Copy link

So here's a pull request I got from the robot today sbt/setup-sbt#15. I don't know the implementation of scala-steward, but I don't see how it would know that the sbt version in sbt.version=1.10.4 would translate to YAML

default: 1.10.3

@Friendseeker
Copy link
Author

Friendseeker commented Oct 31, 2024

Guess Scala Steward's algorithm is being overly pessimistic in this case...

Wonder if Scala Steward's algorithm can be improved somehow. If not, I guess I can write a custom bot tailed for setup-sbt to automatically submit PR to update the repo's sbt version and remove setup-sbt from list of Scala Steward repos.

@eed3si9n
Copy link

https://github.com/scala-steward-org/scala-steward/blob/9349c67f8f4ecf4fb54dfeceee234d0e2dc9bf8c/modules/core/src/test/scala/org/scalasteward/core/edit/RewriteTest.scala#L143-L155

  test("keyword with extra underscore") {
    val update =
      ("org.scala-js".g % Nel.of("sbt-scalajs".a, "scalajs-compiler".a) % "1.1.0" %> "1.1.1").group
    val original = Map(
      ".travis.yml" -> """ - SCALA_JS_VERSION=1.1.0""",
      "project/plugins.sbt" -> """val scalaJsVersion = Option(System.getenv("SCALA_JS_VERSION")).getOrElse("1.1.0")"""
    )
    val expected = Map(
      ".travis.yml" -> """ - SCALA_JS_VERSION=1.1.1""",
      "project/plugins.sbt" -> """val scalaJsVersion = Option(System.getenv("SCALA_JS_VERSION")).getOrElse("1.1.1")"""
    )
    runApplyUpdate(update, original, expected)
  }

so I'm guessing that YAML works for - SCALA_JS_VERSION=1.1.0 type of lists where it builds up environment variable with the artifact name in the variable name?

@mzuehlke
Copy link

mzuehlke commented Jan 9, 2025

@fthomas could describe this the best as he wrote the replacement algorithm.
But replacements need the artifact name close to the version number.

@fthomas
Copy link

fthomas commented Jan 9, 2025

But replacements need the artifact name close to the version number.

That's correct. If the field would be called something like default-sbt-version, Scala Steward would classify it as candidate for the sbt version. But since there is also a regular project/build.properties it prefers updating that over the version in the YAML file.

I think the easiest way to get Scala Steward to update that version is to write a sbt task that replaces the version in the YAML and then use that task in a postUpdateHook in a .scala-steward.conf:

postUpdateHooks = [{
  command = ["sbt", "updateYaml"],
  commitMessage = "Regenerated action.yaml",
  groupId = "org.scala-sbt",
  artifactId = "sbt"
}]

On sbt updates, Scala Steward would run sbt updateYaml after the update and commit the changes.

@tgodzik
Copy link
Member

tgodzik commented Jan 10, 2025

Och, that looks awesome, I wasn't even aware of that config option. Mind if I use your snippet and put it on Scala Space to spread the knowledge a bit?

@fthomas
Copy link

fthomas commented Jan 10, 2025

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.

6 participants