From f4977a3ebfec4c399aa81d20f423511882bd09ed Mon Sep 17 00:00:00 2001 From: Piotr Krzeminski Date: Sat, 6 Jun 2026 15:31:23 +0200 Subject: [PATCH 1/7] refactor: replace bash assertion with Kotlin logic step in bindings server workflow Replace the bash-based failsWithPhraseInLogs approach with a Kotlin logic step using ProcessBuilder for running scripts and asserting on exit codes and error messages inline in Kotlin. --- .github/workflows/bindings-server.main.kts | 71 ++++++++++++++-------- .github/workflows/bindings-server.yaml | 13 ++-- 2 files changed, 51 insertions(+), 33 deletions(-) diff --git a/.github/workflows/bindings-server.main.kts b/.github/workflows/bindings-server.main.kts index cdf3daf03..471d1b08d 100755 --- a/.github/workflows/bindings-server.main.kts +++ b/.github/workflows/bindings-server.main.kts @@ -15,9 +15,11 @@ import io.github.typesafegithub.workflows.domain.Environment import io.github.typesafegithub.workflows.domain.JobOutputs import io.github.typesafegithub.workflows.domain.RunnerType.UbuntuLatest import io.github.typesafegithub.workflows.domain.triggers.* +import io.github.typesafegithub.workflows.domain.contexts.Contexts as RunContexts import io.github.typesafegithub.workflows.dsl.JobBuilder import io.github.typesafegithub.workflows.dsl.expressions.Contexts import io.github.typesafegithub.workflows.dsl.expressions.expr +import java.io.File import io.github.typesafegithub.workflows.dsl.workflow import io.github.typesafegithub.workflows.yaml.CheckoutActionVersionSource import io.github.typesafegithub.workflows.yaml.DEFAULT_CONSISTENCY_CHECK_JOB_CONFIG @@ -122,24 +124,36 @@ workflow( runWithSpecificKotlinVersion( kotlinVersion = newestNotCompatibleVersion, - command = """ - cp .github/workflows/test-script-consuming-jit-bindings.main.kts .github/workflows/test-script-consuming-jit-bindings-too-old-kotlin.main.kts - ${failsWithPhraseInLogs( - command = ".github/workflows/test-script-consuming-jit-bindings-too-old-kotlin.main.kts", - // This test depicts the current behavior that the served bindings aren't - // compatible with some older Kotlin version. We may want to address it one day. - // For more info, see https://github.com/typesafegithub/github-workflows-kt/issues/1756 - phrase = "was compiled with an incompatible version of Kotlin", - )} - """.trimIndent(), - ) + ) { + // This test depicts the current behavior that the served bindings aren't + // compatible with some older Kotlin version. We may want to address it one day. + // For more info, see https://github.com/typesafegithub/github-workflows-kt/issues/1756 + File(".github/workflows/test-script-consuming-jit-bindings.main.kts").copyTo( + File(".github/workflows/test-script-consuming-jit-bindings-too-old-kotlin.main.kts"), + overwrite = true, + ) + val result = runScriptAndReturnOutput( + ".github/workflows/test-script-consuming-jit-bindings-too-old-kotlin.main.kts" + ) + if (result.exitCode == 0) { + error("Expected the script to fail but it succeeded") + } + if (!result.output.contains("was compiled with an incompatible version of Kotlin")) { + error("Expected error message not found. Output:\n${result.output}") + } + } runWithSpecificKotlinVersion( kotlinVersion = oldestCompatibleVersion, - command = """ - cp .github/workflows/test-script-consuming-jit-bindings.main.kts .github/workflows/test-script-consuming-jit-bindings-older-kotlin.main.kts - .github/workflows/test-script-consuming-jit-bindings-older-kotlin.main.kts - """.trimIndent(), - ) + ) { + File(".github/workflows/test-script-consuming-jit-bindings.main.kts").copyTo( + File(".github/workflows/test-script-consuming-jit-bindings-older-kotlin.main.kts"), + overwrite = true, + ) + val result = runScriptAndReturnOutput( + ".github/workflows/test-script-consuming-jit-bindings-older-kotlin.main.kts" + ) + check(result.exitCode == 0) { "Script failed with exit code ${result.exitCode}" } + } run( name = "Compile a Gradle project using the bindings from the server", @@ -193,7 +207,20 @@ fun JobBuilder.cleanMavenLocal() { ) } -fun JobBuilder.runWithSpecificKotlinVersion(kotlinVersion: String, command: String) { +data class ScriptInvocationResult(val output: String, val exitCode: Int) + +fun runScriptAndReturnOutput(scriptPath: String): ScriptInvocationResult { + val process = ProcessBuilder(scriptPath).redirectErrorStream(true).start() + val output = process.inputStream.bufferedReader().readText() + val exitCode = process.waitFor() + return ScriptInvocationResult(output, exitCode) +} + +@OptIn(ExperimentalKotlinLogicStep::class) +fun JobBuilder.runWithSpecificKotlinVersion( + kotlinVersion: String, + logic: RunContexts.() -> Unit, +) { uses( name = "Install Kotlin $kotlinVersion", action = SetupKotlin( @@ -203,15 +230,7 @@ fun JobBuilder.runWithSpecificKotlinVersion(kotlinVersion: Str cleanMavenLocal() run( name = "Execute the script using the bindings from the server, using older Kotlin ($kotlinVersion) as consumer", - command = command, + logic = logic, ) } -fun failsWithPhraseInLogs( - command: String, - phrase: String, -): String = - """ - ($command || true) >> output.txt 2>&1 - grep "$phrase" output.txt - """.trimIndent() diff --git a/.github/workflows/bindings-server.yaml b/.github/workflows/bindings-server.yaml index b343c308e..73a656786 100644 --- a/.github/workflows/bindings-server.yaml +++ b/.github/workflows/bindings-server.yaml @@ -91,10 +91,9 @@ jobs: run: 'rm -rf ~/.m2/repository/' - id: 'step-10' name: 'Execute the script using the bindings from the server, using older Kotlin (1.9.0) as consumer' - run: |2- - cp .github/workflows/test-script-consuming-jit-bindings.main.kts .github/workflows/test-script-consuming-jit-bindings-too-old-kotlin.main.kts - (.github/workflows/test-script-consuming-jit-bindings-too-old-kotlin.main.kts || true) >> output.txt 2>&1 - grep "was compiled with an incompatible version of Kotlin" output.txt + env: + GHWKT_GITHUB_CONTEXT_JSON: '${{ toJSON(github) }}' + run: 'GHWKT_RUN_STEP=''bindings-server.yaml:end-to-end-test:step-10'' ''.github/workflows/bindings-server.main.kts''' - id: 'step-11' name: 'Install Kotlin 2.0.0' uses: 'fwilhe2/setup-kotlin@v1' @@ -105,9 +104,9 @@ jobs: run: 'rm -rf ~/.m2/repository/' - id: 'step-13' name: 'Execute the script using the bindings from the server, using older Kotlin (2.0.0) as consumer' - run: |- - cp .github/workflows/test-script-consuming-jit-bindings.main.kts .github/workflows/test-script-consuming-jit-bindings-older-kotlin.main.kts - .github/workflows/test-script-consuming-jit-bindings-older-kotlin.main.kts + env: + GHWKT_GITHUB_CONTEXT_JSON: '${{ toJSON(github) }}' + run: 'GHWKT_RUN_STEP=''bindings-server.yaml:end-to-end-test:step-13'' ''.github/workflows/bindings-server.main.kts''' - id: 'step-14' name: 'Compile a Gradle project using the bindings from the server' run: |- From 0c417f07d606b3a53172ccf76169408ff6c0b7ef Mon Sep 17 00:00:00 2001 From: Piotr Krzeminski Date: Sat, 6 Jun 2026 16:01:58 +0200 Subject: [PATCH 2/7] Update versions --- .github/workflows/bindings-server.main.kts | 8 ++++---- .github/workflows/bindings-server.yaml | 12 ++++++------ 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/.github/workflows/bindings-server.main.kts b/.github/workflows/bindings-server.main.kts index 471d1b08d..b81463ab5 100755 --- a/.github/workflows/bindings-server.main.kts +++ b/.github/workflows/bindings-server.main.kts @@ -119,8 +119,8 @@ workflow( // There should be a difference of one (mostly minor) version between these two, // to be able to see the newest non-working and oldest working version. - val newestNotCompatibleVersion = "1.9.0" - val oldestCompatibleVersion = "2.0.0" + val newestNotCompatibleVersion = "2.2.0" + val oldestCompatibleVersion = "2.3.0" runWithSpecificKotlinVersion( kotlinVersion = newestNotCompatibleVersion, @@ -131,7 +131,7 @@ workflow( File(".github/workflows/test-script-consuming-jit-bindings.main.kts").copyTo( File(".github/workflows/test-script-consuming-jit-bindings-too-old-kotlin.main.kts"), overwrite = true, - ) + ).setExecutable(true) val result = runScriptAndReturnOutput( ".github/workflows/test-script-consuming-jit-bindings-too-old-kotlin.main.kts" ) @@ -148,7 +148,7 @@ workflow( File(".github/workflows/test-script-consuming-jit-bindings.main.kts").copyTo( File(".github/workflows/test-script-consuming-jit-bindings-older-kotlin.main.kts"), overwrite = true, - ) + ).setExecutable(true) val result = runScriptAndReturnOutput( ".github/workflows/test-script-consuming-jit-bindings-older-kotlin.main.kts" ) diff --git a/.github/workflows/bindings-server.yaml b/.github/workflows/bindings-server.yaml index 73a656786..275ef7db6 100644 --- a/.github/workflows/bindings-server.yaml +++ b/.github/workflows/bindings-server.yaml @@ -82,28 +82,28 @@ jobs: mv .github/workflows/test-served-bindings-depend-on-library.main.do-not-compile.kts .github/workflows/test-served-bindings-depend-on-library.main.kts .github/workflows/test-served-bindings-depend-on-library.main.kts - id: 'step-8' - name: 'Install Kotlin 1.9.0' + name: 'Install Kotlin 2.2.0' uses: 'fwilhe2/setup-kotlin@v1' with: - version: '1.9.0' + version: '2.2.0' - id: 'step-9' name: 'Clean Maven Local to fetch required POMs again' run: 'rm -rf ~/.m2/repository/' - id: 'step-10' - name: 'Execute the script using the bindings from the server, using older Kotlin (1.9.0) as consumer' + name: 'Execute the script using the bindings from the server, using older Kotlin (2.2.0) as consumer' env: GHWKT_GITHUB_CONTEXT_JSON: '${{ toJSON(github) }}' run: 'GHWKT_RUN_STEP=''bindings-server.yaml:end-to-end-test:step-10'' ''.github/workflows/bindings-server.main.kts''' - id: 'step-11' - name: 'Install Kotlin 2.0.0' + name: 'Install Kotlin 2.3.0' uses: 'fwilhe2/setup-kotlin@v1' with: - version: '2.0.0' + version: '2.3.0' - id: 'step-12' name: 'Clean Maven Local to fetch required POMs again' run: 'rm -rf ~/.m2/repository/' - id: 'step-13' - name: 'Execute the script using the bindings from the server, using older Kotlin (2.0.0) as consumer' + name: 'Execute the script using the bindings from the server, using older Kotlin (2.3.0) as consumer' env: GHWKT_GITHUB_CONTEXT_JSON: '${{ toJSON(github) }}' run: 'GHWKT_RUN_STEP=''bindings-server.yaml:end-to-end-test:step-13'' ''.github/workflows/bindings-server.main.kts''' From a56e0c17ec6efab22644a597daeaddc37a028142 Mon Sep 17 00:00:00 2001 From: Piotr Krzeminski Date: Sat, 6 Jun 2026 16:29:43 +0200 Subject: [PATCH 3/7] Update versions once again --- .github/workflows/bindings-server.main.kts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/bindings-server.main.kts b/.github/workflows/bindings-server.main.kts index b81463ab5..7722cefad 100755 --- a/.github/workflows/bindings-server.main.kts +++ b/.github/workflows/bindings-server.main.kts @@ -119,8 +119,8 @@ workflow( // There should be a difference of one (mostly minor) version between these two, // to be able to see the newest non-working and oldest working version. - val newestNotCompatibleVersion = "2.2.0" - val oldestCompatibleVersion = "2.3.0" + val newestNotCompatibleVersion = "2.1.0" + val oldestCompatibleVersion = "2.2.0" runWithSpecificKotlinVersion( kotlinVersion = newestNotCompatibleVersion, From 4f9b5e31c0f19e8c494d2c827422290835e0540d Mon Sep 17 00:00:00 2001 From: Piotr Krzeminski Date: Sat, 6 Jun 2026 16:32:21 +0200 Subject: [PATCH 4/7] Regenerate YAML --- .github/workflows/bindings-server.yaml | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/.github/workflows/bindings-server.yaml b/.github/workflows/bindings-server.yaml index 275ef7db6..636e721c9 100644 --- a/.github/workflows/bindings-server.yaml +++ b/.github/workflows/bindings-server.yaml @@ -82,28 +82,28 @@ jobs: mv .github/workflows/test-served-bindings-depend-on-library.main.do-not-compile.kts .github/workflows/test-served-bindings-depend-on-library.main.kts .github/workflows/test-served-bindings-depend-on-library.main.kts - id: 'step-8' - name: 'Install Kotlin 2.2.0' + name: 'Install Kotlin 2.1.0' uses: 'fwilhe2/setup-kotlin@v1' with: - version: '2.2.0' + version: '2.1.0' - id: 'step-9' name: 'Clean Maven Local to fetch required POMs again' run: 'rm -rf ~/.m2/repository/' - id: 'step-10' - name: 'Execute the script using the bindings from the server, using older Kotlin (2.2.0) as consumer' + name: 'Execute the script using the bindings from the server, using older Kotlin (2.1.0) as consumer' env: GHWKT_GITHUB_CONTEXT_JSON: '${{ toJSON(github) }}' run: 'GHWKT_RUN_STEP=''bindings-server.yaml:end-to-end-test:step-10'' ''.github/workflows/bindings-server.main.kts''' - id: 'step-11' - name: 'Install Kotlin 2.3.0' + name: 'Install Kotlin 2.2.0' uses: 'fwilhe2/setup-kotlin@v1' with: - version: '2.3.0' + version: '2.2.0' - id: 'step-12' name: 'Clean Maven Local to fetch required POMs again' run: 'rm -rf ~/.m2/repository/' - id: 'step-13' - name: 'Execute the script using the bindings from the server, using older Kotlin (2.3.0) as consumer' + name: 'Execute the script using the bindings from the server, using older Kotlin (2.2.0) as consumer' env: GHWKT_GITHUB_CONTEXT_JSON: '${{ toJSON(github) }}' run: 'GHWKT_RUN_STEP=''bindings-server.yaml:end-to-end-test:step-13'' ''.github/workflows/bindings-server.main.kts''' From b98bfb44a202028acf28f666f9049fe6ea3afe22 Mon Sep 17 00:00:00 2001 From: Piotr Krzeminski Date: Sat, 6 Jun 2026 16:36:13 +0200 Subject: [PATCH 5/7] Last adjust? --- .github/workflows/bindings-server.main.kts | 79 ++++++++++------------ .github/workflows/bindings-server.yaml | 45 ++++++++---- 2 files changed, 68 insertions(+), 56 deletions(-) diff --git a/.github/workflows/bindings-server.main.kts b/.github/workflows/bindings-server.main.kts index 7722cefad..a5918483b 100755 --- a/.github/workflows/bindings-server.main.kts +++ b/.github/workflows/bindings-server.main.kts @@ -14,12 +14,11 @@ import io.github.typesafegithub.workflows.annotations.ExperimentalKotlinLogicSte import io.github.typesafegithub.workflows.domain.Environment import io.github.typesafegithub.workflows.domain.JobOutputs import io.github.typesafegithub.workflows.domain.RunnerType.UbuntuLatest +import io.github.typesafegithub.workflows.domain.Shell import io.github.typesafegithub.workflows.domain.triggers.* -import io.github.typesafegithub.workflows.domain.contexts.Contexts as RunContexts import io.github.typesafegithub.workflows.dsl.JobBuilder import io.github.typesafegithub.workflows.dsl.expressions.Contexts import io.github.typesafegithub.workflows.dsl.expressions.expr -import java.io.File import io.github.typesafegithub.workflows.dsl.workflow import io.github.typesafegithub.workflows.yaml.CheckoutActionVersionSource import io.github.typesafegithub.workflows.yaml.DEFAULT_CONSISTENCY_CHECK_JOB_CONFIG @@ -119,41 +118,42 @@ workflow( // There should be a difference of one (mostly minor) version between these two, // to be able to see the newest non-working and oldest working version. - val newestNotCompatibleVersion = "2.1.0" - val oldestCompatibleVersion = "2.2.0" + val newestNotCompatibleVersion = "2.0.0" + val oldestCompatibleVersion = "2.1.0" runWithSpecificKotlinVersion( kotlinVersion = newestNotCompatibleVersion, - ) { - // This test depicts the current behavior that the served bindings aren't - // compatible with some older Kotlin version. We may want to address it one day. - // For more info, see https://github.com/typesafegithub/github-workflows-kt/issues/1756 - File(".github/workflows/test-script-consuming-jit-bindings.main.kts").copyTo( - File(".github/workflows/test-script-consuming-jit-bindings-too-old-kotlin.main.kts"), - overwrite = true, - ).setExecutable(true) - val result = runScriptAndReturnOutput( - ".github/workflows/test-script-consuming-jit-bindings-too-old-kotlin.main.kts" - ) - if (result.exitCode == 0) { - error("Expected the script to fail but it succeeded") - } - if (!result.output.contains("was compiled with an incompatible version of Kotlin")) { - error("Expected error message not found. Output:\n${result.output}") - } - } + command = """ + val src = java.io.File(".github/workflows/test-script-consuming-jit-bindings.main.kts") + val dest = java.io.File(".github/workflows/test-script-consuming-jit-bindings-too-old-kotlin.main.kts") + src.copyTo(dest, overwrite = true).setExecutable(true) + val process = ProcessBuilder("kotlin", dest.path).redirectErrorStream(true).start() + val output = process.inputStream.bufferedReader().readText() + val exitCode = process.waitFor() + if (exitCode == 0) { + System.err.println("Expected the script to fail but it succeeded") + System.exit(1) + } + if (!output.contains("was compiled with an incompatible version of Kotlin")) { + System.err.println("Expected error message not found. Output:") + System.err.println(output) + System.exit(1) + } + """.trimIndent(), + ) runWithSpecificKotlinVersion( kotlinVersion = oldestCompatibleVersion, - ) { - File(".github/workflows/test-script-consuming-jit-bindings.main.kts").copyTo( - File(".github/workflows/test-script-consuming-jit-bindings-older-kotlin.main.kts"), - overwrite = true, - ).setExecutable(true) - val result = runScriptAndReturnOutput( - ".github/workflows/test-script-consuming-jit-bindings-older-kotlin.main.kts" - ) - check(result.exitCode == 0) { "Script failed with exit code ${result.exitCode}" } - } + command = """ + val src = java.io.File(".github/workflows/test-script-consuming-jit-bindings.main.kts") + val dest = java.io.File(".github/workflows/test-script-consuming-jit-bindings-older-kotlin.main.kts") + src.copyTo(dest, overwrite = true).setExecutable(true) + val exitCode = ProcessBuilder("kotlin", dest.path).inheritIO().start().waitFor() + if (exitCode != 0) { + System.err.println("Script failed with exit code " + exitCode) + System.exit(exitCode) + } + """.trimIndent(), + ) run( name = "Compile a Gradle project using the bindings from the server", @@ -207,19 +207,9 @@ fun JobBuilder.cleanMavenLocal() { ) } -data class ScriptInvocationResult(val output: String, val exitCode: Int) - -fun runScriptAndReturnOutput(scriptPath: String): ScriptInvocationResult { - val process = ProcessBuilder(scriptPath).redirectErrorStream(true).start() - val output = process.inputStream.bufferedReader().readText() - val exitCode = process.waitFor() - return ScriptInvocationResult(output, exitCode) -} - -@OptIn(ExperimentalKotlinLogicStep::class) fun JobBuilder.runWithSpecificKotlinVersion( kotlinVersion: String, - logic: RunContexts.() -> Unit, + command: String, ) { uses( name = "Install Kotlin $kotlinVersion", @@ -230,7 +220,8 @@ fun JobBuilder.runWithSpecificKotlinVersion( cleanMavenLocal() run( name = "Execute the script using the bindings from the server, using older Kotlin ($kotlinVersion) as consumer", - logic = logic, + shell = Shell.Custom("kotlin -script {0}"), + command = command, ) } diff --git a/.github/workflows/bindings-server.yaml b/.github/workflows/bindings-server.yaml index 636e721c9..eac437e26 100644 --- a/.github/workflows/bindings-server.yaml +++ b/.github/workflows/bindings-server.yaml @@ -82,31 +82,52 @@ jobs: mv .github/workflows/test-served-bindings-depend-on-library.main.do-not-compile.kts .github/workflows/test-served-bindings-depend-on-library.main.kts .github/workflows/test-served-bindings-depend-on-library.main.kts - id: 'step-8' - name: 'Install Kotlin 2.1.0' + name: 'Install Kotlin 2.0.0' uses: 'fwilhe2/setup-kotlin@v1' with: - version: '2.1.0' + version: '2.0.0' - id: 'step-9' name: 'Clean Maven Local to fetch required POMs again' run: 'rm -rf ~/.m2/repository/' - id: 'step-10' - name: 'Execute the script using the bindings from the server, using older Kotlin (2.1.0) as consumer' - env: - GHWKT_GITHUB_CONTEXT_JSON: '${{ toJSON(github) }}' - run: 'GHWKT_RUN_STEP=''bindings-server.yaml:end-to-end-test:step-10'' ''.github/workflows/bindings-server.main.kts''' + name: 'Execute the script using the bindings from the server, using older Kotlin (2.0.0) as consumer' + shell: 'kotlin -script {0}' + run: |- + val src = java.io.File(".github/workflows/test-script-consuming-jit-bindings.main.kts") + val dest = java.io.File(".github/workflows/test-script-consuming-jit-bindings-too-old-kotlin.main.kts") + src.copyTo(dest, overwrite = true).setExecutable(true) + val process = ProcessBuilder("kotlin", dest.path).redirectErrorStream(true).start() + val output = process.inputStream.bufferedReader().readText() + val exitCode = process.waitFor() + if (exitCode == 0) { + System.err.println("Expected the script to fail but it succeeded") + System.exit(1) + } + if (!output.contains("was compiled with an incompatible version of Kotlin")) { + System.err.println("Expected error message not found. Output:") + System.err.println(output) + System.exit(1) + } - id: 'step-11' - name: 'Install Kotlin 2.2.0' + name: 'Install Kotlin 2.1.0' uses: 'fwilhe2/setup-kotlin@v1' with: - version: '2.2.0' + version: '2.1.0' - id: 'step-12' name: 'Clean Maven Local to fetch required POMs again' run: 'rm -rf ~/.m2/repository/' - id: 'step-13' - name: 'Execute the script using the bindings from the server, using older Kotlin (2.2.0) as consumer' - env: - GHWKT_GITHUB_CONTEXT_JSON: '${{ toJSON(github) }}' - run: 'GHWKT_RUN_STEP=''bindings-server.yaml:end-to-end-test:step-13'' ''.github/workflows/bindings-server.main.kts''' + name: 'Execute the script using the bindings from the server, using older Kotlin (2.1.0) as consumer' + shell: 'kotlin -script {0}' + run: |- + val src = java.io.File(".github/workflows/test-script-consuming-jit-bindings.main.kts") + val dest = java.io.File(".github/workflows/test-script-consuming-jit-bindings-older-kotlin.main.kts") + src.copyTo(dest, overwrite = true).setExecutable(true) + val exitCode = ProcessBuilder("kotlin", dest.path).inheritIO().start().waitFor() + if (exitCode != 0) { + System.err.println("Script failed with exit code " + exitCode) + System.exit(exitCode) + } - id: 'step-14' name: 'Compile a Gradle project using the bindings from the server' run: |- From 10395b02ef2f3fc230393660acd9719742397770 Mon Sep 17 00:00:00 2001 From: Piotr Krzeminski Date: Sat, 6 Jun 2026 17:02:58 +0200 Subject: [PATCH 6/7] fix: use heredoc to write temp .kts file for kotlin script runner Kotlin 2.0.0 doesn't support -script flag, and the kotlin command needs a .kts extension to recognize a file as a script. Write the inline Kotlin code to /tmp/script.kts via bash heredoc first, then run kotlin on it. --- .github/workflows/bindings-server.main.kts | 9 ++++++--- .github/workflows/bindings-server.yaml | 12 ++++++++---- 2 files changed, 14 insertions(+), 7 deletions(-) diff --git a/.github/workflows/bindings-server.main.kts b/.github/workflows/bindings-server.main.kts index a5918483b..6605f09b6 100755 --- a/.github/workflows/bindings-server.main.kts +++ b/.github/workflows/bindings-server.main.kts @@ -14,7 +14,6 @@ import io.github.typesafegithub.workflows.annotations.ExperimentalKotlinLogicSte import io.github.typesafegithub.workflows.domain.Environment import io.github.typesafegithub.workflows.domain.JobOutputs import io.github.typesafegithub.workflows.domain.RunnerType.UbuntuLatest -import io.github.typesafegithub.workflows.domain.Shell import io.github.typesafegithub.workflows.domain.triggers.* import io.github.typesafegithub.workflows.dsl.JobBuilder import io.github.typesafegithub.workflows.dsl.expressions.Contexts @@ -220,8 +219,12 @@ fun JobBuilder.runWithSpecificKotlinVersion( cleanMavenLocal() run( name = "Execute the script using the bindings from the server, using older Kotlin ($kotlinVersion) as consumer", - shell = Shell.Custom("kotlin -script {0}"), - command = command, + command = """ + cat > /tmp/script.kts << 'KOTLIN_SCRIPT' +$command +KOTLIN_SCRIPT + kotlin /tmp/script.kts + """.trimIndent(), ) } diff --git a/.github/workflows/bindings-server.yaml b/.github/workflows/bindings-server.yaml index eac437e26..33a697bbf 100644 --- a/.github/workflows/bindings-server.yaml +++ b/.github/workflows/bindings-server.yaml @@ -91,8 +91,8 @@ jobs: run: 'rm -rf ~/.m2/repository/' - id: 'step-10' name: 'Execute the script using the bindings from the server, using older Kotlin (2.0.0) as consumer' - shell: 'kotlin -script {0}' - run: |- + run: |2- + cat > /tmp/script.kts << 'KOTLIN_SCRIPT' val src = java.io.File(".github/workflows/test-script-consuming-jit-bindings.main.kts") val dest = java.io.File(".github/workflows/test-script-consuming-jit-bindings-too-old-kotlin.main.kts") src.copyTo(dest, overwrite = true).setExecutable(true) @@ -108,6 +108,8 @@ jobs: System.err.println(output) System.exit(1) } + KOTLIN_SCRIPT + kotlin /tmp/script.kts - id: 'step-11' name: 'Install Kotlin 2.1.0' uses: 'fwilhe2/setup-kotlin@v1' @@ -118,8 +120,8 @@ jobs: run: 'rm -rf ~/.m2/repository/' - id: 'step-13' name: 'Execute the script using the bindings from the server, using older Kotlin (2.1.0) as consumer' - shell: 'kotlin -script {0}' - run: |- + run: |2- + cat > /tmp/script.kts << 'KOTLIN_SCRIPT' val src = java.io.File(".github/workflows/test-script-consuming-jit-bindings.main.kts") val dest = java.io.File(".github/workflows/test-script-consuming-jit-bindings-older-kotlin.main.kts") src.copyTo(dest, overwrite = true).setExecutable(true) @@ -128,6 +130,8 @@ jobs: System.err.println("Script failed with exit code " + exitCode) System.exit(exitCode) } + KOTLIN_SCRIPT + kotlin /tmp/script.kts - id: 'step-14' name: 'Compile a Gradle project using the bindings from the server' run: |- From 0556598e2a64493957b2a30e0a6b29be0e8d4056 Mon Sep 17 00:00:00 2001 From: Piotr Krzeminski Date: Sat, 6 Jun 2026 17:09:37 +0200 Subject: [PATCH 7/7] fix: revert version numbers to 1.9.0/2.0.0 and restore issue comment --- .github/workflows/bindings-server.main.kts | 7 +++++-- .github/workflows/bindings-server.yaml | 15 +++++++++------ 2 files changed, 14 insertions(+), 8 deletions(-) diff --git a/.github/workflows/bindings-server.main.kts b/.github/workflows/bindings-server.main.kts index 6605f09b6..d99634be1 100755 --- a/.github/workflows/bindings-server.main.kts +++ b/.github/workflows/bindings-server.main.kts @@ -117,12 +117,15 @@ workflow( // There should be a difference of one (mostly minor) version between these two, // to be able to see the newest non-working and oldest working version. - val newestNotCompatibleVersion = "2.0.0" - val oldestCompatibleVersion = "2.1.0" + val newestNotCompatibleVersion = "1.9.0" + val oldestCompatibleVersion = "2.0.0" runWithSpecificKotlinVersion( kotlinVersion = newestNotCompatibleVersion, command = """ + // This test depicts the current behavior that the served bindings aren't + // compatible with some older Kotlin version. We may want to address it one day. + // For more info, see https://github.com/typesafegithub/github-workflows-kt/issues/1756 val src = java.io.File(".github/workflows/test-script-consuming-jit-bindings.main.kts") val dest = java.io.File(".github/workflows/test-script-consuming-jit-bindings-too-old-kotlin.main.kts") src.copyTo(dest, overwrite = true).setExecutable(true) diff --git a/.github/workflows/bindings-server.yaml b/.github/workflows/bindings-server.yaml index 33a697bbf..00133cde2 100644 --- a/.github/workflows/bindings-server.yaml +++ b/.github/workflows/bindings-server.yaml @@ -82,17 +82,20 @@ jobs: mv .github/workflows/test-served-bindings-depend-on-library.main.do-not-compile.kts .github/workflows/test-served-bindings-depend-on-library.main.kts .github/workflows/test-served-bindings-depend-on-library.main.kts - id: 'step-8' - name: 'Install Kotlin 2.0.0' + name: 'Install Kotlin 1.9.0' uses: 'fwilhe2/setup-kotlin@v1' with: - version: '2.0.0' + version: '1.9.0' - id: 'step-9' name: 'Clean Maven Local to fetch required POMs again' run: 'rm -rf ~/.m2/repository/' - id: 'step-10' - name: 'Execute the script using the bindings from the server, using older Kotlin (2.0.0) as consumer' + name: 'Execute the script using the bindings from the server, using older Kotlin (1.9.0) as consumer' run: |2- cat > /tmp/script.kts << 'KOTLIN_SCRIPT' + // This test depicts the current behavior that the served bindings aren't + // compatible with some older Kotlin version. We may want to address it one day. + // For more info, see https://github.com/typesafegithub/github-workflows-kt/issues/1756 val src = java.io.File(".github/workflows/test-script-consuming-jit-bindings.main.kts") val dest = java.io.File(".github/workflows/test-script-consuming-jit-bindings-too-old-kotlin.main.kts") src.copyTo(dest, overwrite = true).setExecutable(true) @@ -111,15 +114,15 @@ jobs: KOTLIN_SCRIPT kotlin /tmp/script.kts - id: 'step-11' - name: 'Install Kotlin 2.1.0' + name: 'Install Kotlin 2.0.0' uses: 'fwilhe2/setup-kotlin@v1' with: - version: '2.1.0' + version: '2.0.0' - id: 'step-12' name: 'Clean Maven Local to fetch required POMs again' run: 'rm -rf ~/.m2/repository/' - id: 'step-13' - name: 'Execute the script using the bindings from the server, using older Kotlin (2.1.0) as consumer' + name: 'Execute the script using the bindings from the server, using older Kotlin (2.0.0) as consumer' run: |2- cat > /tmp/script.kts << 'KOTLIN_SCRIPT' val src = java.io.File(".github/workflows/test-script-consuming-jit-bindings.main.kts")