"Custom shell" (kotlin) should allow custom file name extension (`.main.kts`)
See original GitHub issueDescribe the enhancement
Actions allows to define a custom shell in worflow runs.
Kotlin has support for scripting.
I’ve tried to make use of Kotlin for runninng a script in Actions.
The issue is that kotlin expects a file name ending in .main.kts
, but the runner creates a file without extensions for “shells” that are not hardcoded in https://github.com/actions/runner/blob/a2e32170fd83851569804fa7b27d2cae235a5225/src/Runner.Worker/Handlers/ScriptHandlerHelpers.cs#L38
File name construction: https://github.com/actions/runner/blob/a2e32170fd83851569804fa7b27d2cae235a5225/src/Runner.Worker/Handlers/ScriptHandler.cs#L233
I would need some way to provide a map of kotlin
to .main.kts
to ScriptHandlerHelpers.GetScriptFileExtension()
Code Snippet
Consider this example workflow:
name: CI
on:
push:
workflow_dispatch:
jobs:
build:
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v2
- uses: fwilhe2/setup-kotlin@main
- run: |
#!/usr/bin/env kotlin
println("hello")
shell: kotlin {0}
I would expect to be able to run the given script in kotlin (the cli compiler is installed on the runner via fwilhe2/setup-kotlin
).
Additional information
Result of the given workflow script:
This is because kotlin requires the main.kts
suffix to know this should be run as a script.
Compare to running the script locally with the right or the wrong filename
~$ cat foo.main.kts
#!/usr/bin/env kotlin
println("hello")
~$ kotlin foo.main.kts
hello
~$ mv foo.main.kts foo
~$ kotlin foo
error: could not find or load main class foo
Did I overlook something? Is this already possible? If not, I’d be glad if some option to make this would be provided, as it would make the “custom shell” feature much more interesting.
Thanks!
Issue Analytics
- State:
- Created 3 years ago
- Reactions:2
- Comments:6
Top GitHub Comments
No worries, I was not working on this. Looking forward to have this available 💯
Related to https://github.com/actions/virtual-environments/issues/3687