Skip to content
New issue

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

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

Already on GitHub? # to your account

Action doesn't work on ubuntu-24.04 / ubuntu-latest (when it's ubuntu-24.04) because sbt is missing #663

Closed
jsoref opened this issue Dec 31, 2024 · 2 comments · Fixed by #669

Comments

@jsoref
Copy link
Contributor

jsoref commented Dec 31, 2024

As noted in:

GitHub's ubuntu-24.04 runners don't include sbt.

This means that a workflow like this (in a repository github-organization-owner/github-repository in a file .github/workflows/scala-steward.yml):

on:
  workflow_dispatch:
  schedule:
    - cron: "30 12 * * MON"

name: Scala Steward
permissions:
  contents: write
  pull-requests: write

jobs:
  scala-steward:
    runs-on: ubuntu-latest
    name: Scala Steward
    steps:
      - name: Scala Steward
        uses: scala-steward-org/scala-steward-action@v2
        with:
          author-email: ${{ env.email }}
          author-name: ${{ env.name }}
          scala-steward-version: 0.30.2

... will result in this error:

java.io.IOException: Cannot run program "sbt" (in directory "/home/runner/scala-steward/workspace/repos/github-organization-owner/github-repository"): error=2, No such file or directory
  	at java.base/java.lang.ProcessBuilder.start(ProcessBuilder.java:1143)
  	at java.base/java.lang.ProcessBuilder.start(ProcessBuilder.java:1073)
  	at org.scalasteward.core.io.process$.$anonfun$createProcess$2(process.scala:106)
  	at flatMap @ org.scalasteward.core.io.process$.createProcess(process.scala:104)
  	at flatMap @ org.scalasteward.core.io.process$.slurp(process.scala:62)
  	at delay @ org.typelevel.log4cats.slf4j.internal.Slf4jLoggerInternal$Slf4jLogger.isDebugEnabled(Slf4jLoggerInternal.scala:73)
  	at ifM$extension @ org.typelevel.log4cats.slf4j.internal.Slf4jLoggerInternal$Slf4jLogger.info(Slf4jLoggerInternal.scala:99)
  	at >>$extension @ org.scalasteward.core.update.artifact.ArtifactMigrationsLoader.loadMigrations(ArtifactMigrationsLoader.scala:45)
  	at main$ @ org.scalasteward.core.Main$.main(Main.scala:23)
  	at main$ @ org.scalasteward.core.Main$.main(Main.scala:23)
  Caused by: java.io.IOException: error=2, No such file or directory
  	at java.base/java.lang.ProcessImpl.forkAndExec(Native Method)
  	at java.base/java.lang.ProcessImpl.<init>(ProcessImpl.java:314)
  	at java.base/java.lang.ProcessImpl.start(ProcessImpl.java:244)
  	at java.base/java.lang.ProcessBuilder.start(ProcessBuilder.java:1110)
  	at java.base/java.lang.ProcessBuilder.start(ProcessBuilder.java:1073)
  	at org.scalasteward.core.io.process$.$anonfun$createProcess$2(process.scala:106)
  	at cats.effect.IOFiber.runLoop(IOFiber.scala:1004)
  	at cats.effect.IOFiber.asyncContinueSuccessfulR(IOFiber.scala:1368)
  	at cats.effect.IOFiber.run(IOFiber.scala:113)
  	at cats.effect.unsafe.WorkerThread.run(WorkerThread.scala:702)

The fix is to conditionally install sbt.

There are various ways to do this. Sadly, I can't find any particularly good ways to do this.

  • Calling other github actions actions/toolkit#1458 / Call another github action like an async function call actions/toolkit#1510 mean that a node action isn't in a position to call a composite action
  • a composite action can't use a local action with pre steps which means things would be a bit messy if one tried to rearrange things (but I'm going to try because it's interesting)
  • https://github.com/sbt/setup-sbt is a composite action that can set up sbt (and does fancy things for caching) but see the previous two points
  • one could write code to reimplement setup-sbt or manually try the various poor ways of installing sbt by hand
  • this action should at least have better error handling for when sbt is missing as the current top level output is really unhelpful:
    Run scala-steward-org/scala-steward-action@v2
    ✓ Scala Steward workspace created
    Trying to restore workspace contents from cache...
    Launching org.scala-steward:scala-steward-core_2.13:0.30.2
    Saving workspace to cache...
    Error:  ✕ Launching org.scala-steward:scala-steward-core_2.13:0.30.2 failed
    
@exoego
Copy link
Contributor

exoego commented Dec 31, 2024

Did sbt/setup-sbt@v1 not work ?
https://github.com/scala-steward-org/scala-steward-action

@jsoref
Copy link
Contributor Author

jsoref commented Dec 31, 2024

Adding it would work, but people shouldn't have to add it to dozens and dozens of repositories. It's a horrible pattern.

I added some stuff to this repository to add sbt/setup-sbt@v1:
https://github.com/scala-steward-org/scala-steward-action/compare/7462435caa8446668dcbb953750c0781c0397ae5
And that let a trial repository "just work":
https://github.com/check-spelling-sandbox/fantastic-pancake/actions/runs/12563272064/job/35024894338

But I can't quite figure out the right magic to get the release scripts for this repository to work.

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants