@@ -99,7 +99,31 @@ workflow(
9999 """ .trimIndent(),
100100 )
101101
102- cleanMavenLocal()
102+ // There should be a difference of one (mostly minor) version between these two,
103+ // to be able to see the newest non-working and oldest working version.
104+ val newestNotCompatibleVersion = " 1.9.0"
105+ val oldestCompatibleVersion = " 2.0.0"
106+
107+ runWithSpecificKotlinVersion(
108+ kotlinVersion = newestNotCompatibleVersion,
109+ command = """
110+ cp .github/workflows/test-script-consuming-jit-bindings.main.kts .github/workflows/test-script-consuming-jit-bindings-too-old-kotlin.main.kts
111+ ${failsWithPhraseInLogs(
112+ command = " .github/workflows/test-script-consuming-jit-bindings-too-old-kotlin.main.kts" ,
113+ // This test depicts the current behavior that the served bindings aren't
114+ // compatible with some older Kotlin version. We may want to address it one day.
115+ // For more info, see https://github.com/typesafegithub/github-workflows-kt/issues/1756
116+ phrase = " was compiled with an incompatible version of Kotlin" ,
117+ )}
118+ """ .trimIndent(),
119+ )
120+ runWithSpecificKotlinVersion(
121+ kotlinVersion = oldestCompatibleVersion,
122+ command = """
123+ cp .github/workflows/test-script-consuming-jit-bindings.main.kts .github/workflows/test-script-consuming-jit-bindings-older-kotlin.main.kts
124+ .github/workflows/test-script-consuming-jit-bindings-older-kotlin.main.kts
125+ """ .trimIndent(),
126+ )
103127
104128 run (
105129 name = " Compile a Gradle project using the bindings from the server" ,
@@ -150,3 +174,31 @@ fun JobBuilder<JobOutputs.EMPTY>.cleanMavenLocal() {
150174 command = " rm -rf ~/.m2/repository/"
151175 )
152176}
177+
178+ fun JobBuilder<JobOutputs.EMPTY>.runWithSpecificKotlinVersion (kotlinVersion : String , command : String ) {
179+ run (
180+ name = " Download older Kotlin compiler ($kotlinVersion )" ,
181+ command = " curl -Lo kotlin-compiler-$kotlinVersion .zip https://github.com/JetBrains/kotlin/releases/download/v$kotlinVersion /kotlin-compiler-$kotlinVersion .zip" ,
182+ )
183+ run (
184+ name = " Unzip and add to PATH" ,
185+ command = " unzip kotlin-compiler-$kotlinVersion .zip -d kotlin-compiler-$kotlinVersion " ,
186+ )
187+ cleanMavenLocal()
188+ run (
189+ name = " Execute the script using the bindings from the server, using older Kotlin ($kotlinVersion ) as consumer" ,
190+ command = """
191+ PATH=${' $' } (pwd)/kotlin-compiler-$kotlinVersion /kotlinc/bin:${' $' } PATH
192+ $command
193+ """ .trimIndent(),
194+ )
195+ }
196+
197+ fun failsWithPhraseInLogs (
198+ command : String ,
199+ phrase : String ,
200+ ): String =
201+ """
202+ ($command || true) >> output.txt 2>&1
203+ grep "$phrase " output.txt
204+ """ .trimIndent()
0 commit comments