https://kotlinlang.org logo
#github-workflows-kt
Title
# github-workflows-kt
j

jmfayard

03/12/2022, 9:26 PM
Is it possible to publish a 1.0-SNAPSHOT version of the library to mvaenLocal() and to use it then in a Kotlin script?
b

Big Chungus

03/12/2022, 10:06 PM
Can't see why not. It's just a maven lib at that point. Although I'm not sure if kscripts support local maven repo out of the box.
You might need to declare it in a script with file:// protocol
l

louiscad

03/13/2022, 3:16 AM
So long as you run the script only locally, yes you can.
p

Piotr Krzemiński

03/13/2022, 11:46 AM
In theory you can build and publish the library to Maven Local within a GitHub workflow
j

jmfayard

03/13/2022, 1:04 PM
My issue is that inside
script-gennerator
I have a test
GenerateKotlinScripts
who produces Kotlin code from YAML workflows. I have 3 possibilities, each with drawbacks: • I produce a script
examples/my-script.kts
from
examples/my-script.yml
with the latest published version, for example
0.9.0
of github-actions-dsl-kotlin. But then I can't use features that changed since the last published version • Same but I use a version
1.0-SNAPSHOT
with the maven repository
/Users/xxx/.m2
. But then the scripts aren't directly executable, you have to publish the library to maven local, maybe re-run the test. • Or I keep scripts inside
script-generator/src/test/resources/GenerateKotlinScripts.kts
, that's inside the resources folder, without
@file:DependsOn()
and
#!/usr/bin/env kotlin
, but then I can't execute the script
b

Big Chungus

03/13/2022, 1:07 PM
You could publish snapshot to your GH repo's packages for your own needs and pull from there.
That's assuming you're OK with having to authenticate the repo and it being a public repo to get GH packages for free.
OR create a free artifactory account and use that for public access https://jfrog.com/pricing/
p

Piotr Krzemiński

03/13/2022, 7:04 PM
Yet another idea, thinking outside the box (not solving the Maven Local problem at all): use a scripting host in the tests. Never done it myself, but what I imagine is that you could pass the Kotlin script string to it along with library in the classpath, the scripting engine would just compile and run it, and you could assert any side effects in the test. At least I'd try with this approach if I were writing such tests
4 Views