Hi, I might have a similar problem as Leonardo had...
# github-workflows-kt
f
Hi, I might have a similar problem as Leonardo had here. Specifically, I'm trying to call ActionsSetupGradle() in several workflow files and when I call it like this:
Copy code
uses(
            name = "SetupGradle",
            action = ActionsSetupGradle()
        )
I have no issues. However, calling it like this:
Copy code
uses(
        name = "Run Gradle Checks",
        action = ActionsSetupGradle(
            arguments = ":test:testClasses ktlintCheck " +
                "--stacktrace " +
                "-Ptarget=Android " +
                "-Pplatform=Local " +
                "-PdeviceType=Virtual " +
                "-Padjust.token=$ADJUST_TOKEN"
        )
    )
Results in me getting an error stating that I'm trying to use a private constructor. However, this only happened suddenly. I've had this exact same call in my workflow file for a longer time now and since about two weeks it throws this error but only in PRs. When I'm trying to create the yaml file from this locally it works. Unfortunately, the repository is company internal 😅 otherwise I would share the whole code or repository link with you. The dependencies I use in the file are as follows:
Copy code
@file:Repository("<https://repo.maven.apache.org/maven2/>")
@file:Repository("<https://bindings.krzeminski.it>")
@file:DependsOn("io.github.typesafegithub:github-workflows-kt:3.4.0")
@file:DependsOn("actions:checkout:v4")
@file:DependsOn("actions:setup-java:v4")
@file:DependsOn("gradle:actions__setup-gradle:v4")
@file:DependsOn("gradle:actions__wrapper-validation:v4")
✅ 1
p
hi Finja, welcome! I'm missing a full reproducer, in particular the binding's coordinates (from
@file:DependsOn
). However, I noticed that the
arguments
input was typed as a simple string in v3 (ref), and in v4 (ref) it became a list. Perhaps you have some outdated binding locally. Try purging the Maven cache entry for this action (look in
~/.m2
) and you should be able to reproduce & fix this issue locally
f
Hi Piotr, thank you for the fast answer! Sorry for the missing top part, I'll fill that in in a second. I'm using v4 so it's interesting that the call didn't throw any errors before 😄 I'll change it to a list and come back to you
👍 1
p
this problem definitely deserves an entry in the FAQ since there's no easy way to make the compiler complain in a clearer way
ah, I probably see what happened - so @Vampire contributed the typings for Gradle's actions v4 only 2 weeks ago (https://github.com/typesafegithub/github-actions-typing-catalog/pull/66), and it means that until then, the bindings server was using typings for v3. Once the contribution was merged, it effectively meant a breaking change for you. Your local binding stayed in the cache because the Maven coords didn't change, and on GitHub the fresh bindings are fetched every time this is a tricky edge case where we currently optimistically assume that typings between actions' major version usually don't change that much so we fall back to previous version's typings instead of returning untyped bindings and breaking the uses every time. The ultimate solution to this is hosting the typings by the actions, but unfortunately it's still not that popular (a few dozen actions so far support it)
👍 1
f
Ohh wow okay that's good to know, thank you for the clarification!
I just changed the arguments to a list
Copy code
uses(
        name = "Run Gradle Checks",
        action = ActionsSetupGradle(
            arguments = listOf(
                ":test:testClasses ktlintCheck",
                "--stacktrace",
                "-Ptarget=Android",
                "-Pplatform=Local",
                "-PdeviceType=Virtual",
                "-Padjust.token=$ADJUST_TOKEN"
            )
        )
    )
This should be correct, right? However I still get that weird "constructor is private" issue... Did I do anything wrong here?
p
you need to remove the cached binding in
~/.m2
dir - your local Maven cache probably still remembers the binding with
action
being a simple string
❀ 1
if you push the change you pasted above to a PR, it should work fine
let me know if you need more help with removing the cached binding
BTW, I think the recommendation for the new Gradle actions is like: first, setup Gradle, and then call Gradle through
./gradlew
. See the deprecation notice here. So I'd convert the above code to something like:
Copy code
uses(name = "Set up Gradle", action = ActionsSetupGradle())
run(name = "Run Gradle Checks", command = "./gradlew :test:testClasses ktlintCheck ...")
👆 2
😄 1
v
Besides that, I also wondered before why it is telling that the constructor is private. Why should it use the private primary constructor? If one of the named arguments is misspelled, or the type is wrong, you get "you try to use private constructor", which does not make any sense to me, as the arguments also do not match that constructor. A "constructor with that signture was not found" or similar would make more sense to me. Maybe another KTS bug we didn't report yet?
đŸ€· 1
p
I wonder if it works the same way in regular, non-KTS Kotlin
v
Indeed it is. If I remove the
private
, then I get "Argument type mismatch" or "No parameter with name ... found". But if the constructor is private, it complains that it cannot be accessed instead of complaining about parameter name or argument type regarding the accessible constructor. 🙄
Another reason to get #1644 going, because with that we do not have a private constructor anymore, so the error message in such a case is much more helpful
👍 1
f
Hey, sorry for the delay, I was stuck in a few appointments 🙂 I never removed the cached binding before so if you have a little guidance for me there that would be amazing. Everything I tried didn't do the trick yet 😅
Good to know btw with the
./gradlew
call, thank you! I changed that somewhere else in the project but not there lol
p
try:
Copy code
rm -rf ~/.m2/repository/gradle/actions__setup-gradle/
👍 2
relevant only locally - on GitHub it should just work because we don't store the cache anywhere (unless you do)
f
Thank you!! I restructured the call to the
./gradlew
call now and it worked 😄 The command you just sent me worked as well btw, so thank you for that as well :)
👍 1
Thank you so much for your help!
đŸŽ© 1
👌 1
v
Maybe this can improve a bit the user-experience when this happens: https://github.com/typesafegithub/github-workflows-kt/pull/1967 🙂
p
the intent is good, but I'm afraid it won't help much as long as IntelliJ cannot fetch the sources form the bindings server 😞
v
Why not? I tried and got the deprecation message displayed. IJ can take those from the pure binary artifact.
Just like with the other deprecation messages we generate
p
ah, ok!
in my queue
👌 1
FYI, the PR 👆is merged!