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

Post update hooks have no effect #3213

Open
MaciejG604 opened this issue Nov 14, 2023 · 15 comments · Fixed by VirtusLab/scala-cli#3465
Open

Post update hooks have no effect #3213

MaciejG604 opened this issue Nov 14, 2023 · 15 comments · Fixed by VirtusLab/scala-cli#3465

Comments

@MaciejG604
Copy link

In the scala-cli repo we have updated our .scala-steward.conf to include:

postUpdateHooks = [{
  command = ["./mill", "-i", "generate-reference-doc.run"],
  commitMessage = "Generate the reference doc"
}]

However, no commits with this message are ever generated e.g. here.
After setting up a separate steward-running repo, the hooks are launched correctly e.g. here.

@alejandrohdezma
Copy link
Member

Hey @MaciejG604, is that command generating new files our updating old ones? Because if that's the case I believe given this new files won't be added, and thus, a commit won't be created.

@MaciejG604
Copy link
Author

Hi, it should only update files that already exists, nothing new added.

@alejandrohdezma
Copy link
Member

🤔 Could you run Steward in debug mode to get more clarity onto what's happening?

@MaciejG604
Copy link
Author

How do I do that?

@alejandrohdezma
Copy link
Member

If you are using the Scala Steward GitHub Action, check Run Scala Steward with step debug logging under Guides.

@fthomas
Copy link
Member

fthomas commented Jan 27, 2025

I tried this locally with my dev instance and the post-update hook failed with:

2025-01-27 08:32:13,287 INFO  Process update com.github.plokhotnyuk.jsoniter-scala:{(jsoniter-scala-core, jsoniter-scala-core_2.12, jsoniter-scala-core_2.13, jsoniter-scala-core_3), (jsoniter-scala-macros, jsoniter-scala-macros_2.12, jsoniter-scala-macros_2.13, jsoniter-scala-macros_3)} : 2.13.5.2 -> 2.13.39
2025-01-27 08:32:13,674 INFO  Create branch update/jsoniter-scala-core-2.13.39
2025-01-27 08:32:20,758 INFO  Executing post-update hook for com.github.plokhotnyuk.jsoniter-scala:jsoniter-scala-core with command './mill -i 'generate-reference-doc[]'.run'
2025-01-27 08:32:53,856 WARN  Post-update hook failed
org.scalasteward.core.io.process$ProcessFailedException: './mill -i 'generate-reference-doc[]'.run' exited with code 1.
[info] compiling 6 Scala sources to workspace/repos/VirtusLab/scala-cli/out/mill-build/compile.dest/classes ...
[warn] workspace/repos/VirtusLab/scala-cli/project/settings.sc:543:57: trait SbtModuleTests in trait SbtModule is deprecated (since Mill 0.11.10): Use SbtTests instead
[warn]   trait ScalaCliTests extends ScalaCliModule with super.SbtModuleTests with TestModule.Munit {
[warn]                                                         ^
[warn] workspace/repos/VirtusLab/scala-cli/project/settings.sc:578:15: method publish in class LocalIvyPublisher is deprecated (since Mill 0.11.7): Use publishLocal instead
[warn]     publisher.publish(
[warn]               ^
[warn] two warnings found
[info] done compiling
Parsing exception Position 1:1, found "'generate-"

Running the command in the shell works just fine but I can reproduce the above error with a simple Scala script:

$ cat run.sc 
val pb = new java.lang.ProcessBuilder("./mill", "-i", "'generate-reference-doc[]'.run")
pb.inheritIO
pb.start
$ scala-cli run run.sc 
[build.sc] [50/59] zincReportCachedProblems 
Parsing exception Position 1:1, found "'generate-"

Maybe the public Scala Steward instance fails with the same error. And I've no idea why that does not happen with the GH Action.

@fthomas
Copy link
Member

fthomas commented Jan 27, 2025

It works for me if the single quotes around generate-reference-doc[] are removed:

 postUpdateHooks = [{
-  command = ["./mill", "-i", "'generate-reference-doc[]'.run"],
+  command = ["./mill", "-i", "generate-reference-doc[].run"],
   commitMessage = "Generate the reference doc"
 }]

Please give this a try, @MaciejG604.

@Gedochao
Copy link

@fthomas seems to be still broken, even with the single quotes removed.
Had to run the command manually in today's yeild of scala-steward PRs:

I believe I tried to add the single quotes since they are necessary when running the command from the command line, manually.

./mill -i 'generate-reference-doc[]'.run

Not sure what's the proper syntax for scala-steward to pick it up, though...

@fthomas
Copy link
Member

fthomas commented Feb 18, 2025

I guess we need to have a look at the logs to find out why the post-update hook is not producing changes. @tgodzik could you paste the logs of VirtusLab/scala-cli from the Scala Steward run that produced the PRs @Gedochao mentioned?

@tgodzik
Copy link
Contributor

tgodzik commented Feb 18, 2025

I need to run with logs turned on, will have that by tomorrow.

@fthomas
Copy link
Member

fthomas commented Feb 18, 2025

I need to run with logs turned on, will have that by tomorrow.

Ok, if we are fortunate Scala Steward will raise a new PR in the scala-cli repo in that run and we'll see how the hook failed. If it won't raise a PR, we also won't see how the hook fails.

@tgodzik
Copy link
Contributor

tgodzik commented Feb 20, 2025

I didn't get any info unfortunately, will have to run again

@tgodzik
Copy link
Contributor

tgodzik commented Feb 24, 2025

2025-02-21 19:12:15,429 INFO  Executing post-update hook for org.scalameta:semanticdb-shared_2.13 with command './mill -i generate-reference-doc[].run'
2025-02-21 19:13:06,499 WARN  Post-update hook failed
org.scalasteward.core.io.process$ProcessFailedException: 'SCALA_STEWARD=1 ./mill -i generate-reference-doc[].run' exited with code 1.
./mill: line 69: /root/.cache/coursier/v1/https/github.com/coursier/coursier/releases/download/v2.1.24/cs-x86_64-pc-linux: cannot execute: required file not found
./mill: line 69: /root/.cache/coursier/v1/https/github.com/coursier/coursier/releases/download/v2.1.24/cs-x86_64-pc-linux: cannot execute: required file not found
[info] compiling 1 Scala source to /opt/workspace/repos/VirtusLab/scala-cli/out/mill-build/compile.dest/classes ...
[info] done compiling
[info] compiling 1 Scala source to /opt/workspace/repos/VirtusLab/scala-cli/out/core/3.3.5/compile.dest/classes ...
[info] done compiling
[info] compiling 104 Scala sources and 4 Java sources to /opt/workspace/repos/VirtusLab/scala-cli/out/build-module/3.3.5/compile.dest/classes ...
[error] -- [E008] Not Found Error: /opt/workspace/repos/VirtusLab/scala-cli/modules/build/src/main/scala/scala/build/internal/markdown/MarkdownCodeBlock.scala:68:7
[error] 66 |    val allLines = md
[error] 67 |      .lines()
[error] 68 |      .toList
[error]    |                   ^
[error]    |value toList is not a member of java.util.stream.Stream[String], but could be made available as an extension method.
[error]    |
[error]    |One of the following imports might make progress towards fixing the problem:
[error]    |
[error]    |  import geny.Generator.from
[error]    |  import sourcecode.Text.generate
[error]    |
[error] one error found
1 targets failed
build-module[3.3.5].compile Compilation failed

looks like an issue with our build

@fthomas
Copy link
Member

fthomas commented Feb 24, 2025

./mill: line 69: /root/.cache/coursier/v1/https/github.com/coursier/coursier/releases/download/v2.1.24/cs-x86_64-pc-linux: cannot execute: required file not found
./mill: line 69: /root/.cache/coursier/v1/https/github.com/coursier/coursier/releases/download/v2.1.24/cs-x86_64-pc-linux: cannot execute: required file not found

Or maybe the mill installation on the host that runs Scala Steward?

@tgodzik
Copy link
Contributor

tgodzik commented Feb 24, 2025

Looks like cs is somehow downloaded to a wrong place, but we could use the default one already installed. We use it to get the proper Java version (17 in our case)

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 a pull request may close this issue.

5 participants