Adam S
05/31/2023, 7:56 AM- name: Cache Kotlin Konan
id: cache-kotlin-konan
uses: actions/cache@v3
with:
path: |
~/.konan/**/*
key: kotlin-konan-${{ runner.os }}
and it was pretty easy to do this.
uses(
name = "Cache Kotlin Konan",
action = CacheV3(
path = listOf(
"~/.konan/**/*",
),
key = "kotlin-konan-${expr { runner.os }}",
),
)
---
Having to use listOf()
for the paths is a bit clunky, but this will be improved eventually https://youtrack.jetbrains.com/issue/KT-43871
---
expr {}
syntax to access the variables.jmfayard
05/31/2023, 7:58 AMjmfayard
05/31/2023, 8:01 AMrunner.os
alone would work only in the simple cases. you would be able to use incorrectly in other cases, and you wouldn’t be able to use in other casesAdam S
05/31/2023, 8:01 AMjmfayard
05/31/2023, 8:02 AMjmfayard
05/31/2023, 8:03 AMAdam S
05/31/2023, 8:04 AMjmfayard
05/31/2023, 8:06 AMjmfayard
05/31/2023, 8:09 AM_expr_ *{* "${github.repository_owner} == 'typesafegithub' || ${github.event_name} != 'schedule'" *}*
^^ here is an example of why accessing directly the variables wouldn’t work, there would be multiple ${{ }}
instead of just one.
The expression makes only sense… inside an expression bloc.
That’s what expr { }
is modellingAdam S
05/31/2023, 8:14 AMval regenWorkflow by tasks.registering(Exec::class) {
group = "workflows-kt"
workingDir(layout.projectDirectory.dir(".github/workflows/"))
executable("./build.main.kts")
}
Apparently I don’t have kotlin
on my path, so it doesn’t work for me. But it should be possible to set up some Gradle magic to download it, adhoc.Adam S
05/31/2023, 8:33 AMkotlin
is installed, but it should be pretty simple to download it automatically.Adam S
05/31/2023, 8:42 AMjmfayard
05/31/2023, 9:13 AMAdam S
05/31/2023, 9:15 AMkotlin
is present.jmfayard
05/31/2023, 9:16 AMAdam S
05/31/2023, 9:20 AMVampire
05/31/2023, 10:32 AMsh
derivate like bash
and have Kotlin installed and available in your PATH
, you can just call the scripts like any other shellscript using:
$ ./foo.main.kts
If you have Kotlin available somewhere (including the version that the IntelliJ plugin unpacks onto your disk in its plugins folder) you can just call it with the script as argument using:
$ path/to/kotlin foo.main.kts
You can register a Gradle task that does the work for you and trigger it whenever you like like this which also supports `@file:Import`ed scripts:
https://github.com/Vampire/setup-wsl/blob/master/gradle/build-logic/src/main/kotlin/net/kautler/github_actions.gradle.kts
You can create an IntelliJ run configuration that executes the script and execute it using:jmfayard
05/31/2023, 10:51 AM@juliandunn now that we have clarified that we are not asking to get rid of YAML, but just for a simple mecanism to execute something like github-workflows-kt that will produce a valid YAML workflow, what do you think of the proposal?