Skip to content

Commit aab8d2b

Browse files
authored
test(server): use fwilhe2/setup-kotlin action to install older Kotlin (#1758)
1 parent 0a1bf40 commit aab8d2b

2 files changed

Lines changed: 25 additions & 32 deletions

File tree

.github/workflows/bindings-server.main.kts

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,10 @@
55
@file:Repository("https://bindings.krzeminski.it")
66
@file:DependsOn("actions:checkout:v4")
77
@file:DependsOn("gradle:actions__setup-gradle:v4")
8+
@file:DependsOn("fwilhe2:setup-kotlin:0.11.0")
89

910
import io.github.typesafegithub.workflows.actions.actions.Checkout
11+
import io.github.typesafegithub.workflows.actions.fwilhe2.SetupKotlin
1012
import io.github.typesafegithub.workflows.actions.gradle.ActionsSetupGradle
1113
import io.github.typesafegithub.workflows.annotations.ExperimentalKotlinLogicStep
1214
import io.github.typesafegithub.workflows.domain.Environment
@@ -176,21 +178,16 @@ fun JobBuilder<JobOutputs.EMPTY>.cleanMavenLocal() {
176178
}
177179

178180
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",
181+
uses(
182+
name = "Install Kotlin $kotlinVersion",
183+
action = SetupKotlin(
184+
version = kotlinVersion,
185+
),
186186
)
187187
cleanMavenLocal()
188188
run(
189189
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(),
190+
command = command,
194191
)
195192
}
196193

.github/workflows/bindings-server.yaml

Lines changed: 17 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -62,45 +62,41 @@ jobs:
6262
mv .github/workflows/test-served-bindings-depend-on-library.main.do-not-compile.kts .github/workflows/test-served-bindings-depend-on-library.main.kts
6363
.github/workflows/test-served-bindings-depend-on-library.main.kts
6464
- id: 'step-8'
65-
name: 'Download older Kotlin compiler (1.9.0)'
66-
run: 'curl -Lo kotlin-compiler-1.9.0.zip https://github.com/JetBrains/kotlin/releases/download/v1.9.0/kotlin-compiler-1.9.0.zip'
65+
name: 'Install Kotlin 1.9.0'
66+
uses: 'fwilhe2/setup-kotlin@0.11.0'
67+
with:
68+
version: '1.9.0'
6769
- id: 'step-9'
68-
name: 'Unzip and add to PATH'
69-
run: 'unzip kotlin-compiler-1.9.0.zip -d kotlin-compiler-1.9.0'
70-
- id: 'step-10'
7170
name: 'Clean Maven Local to fetch required POMs again'
7271
run: 'rm -rf ~/.m2/repository/'
73-
- id: 'step-11'
72+
- id: 'step-10'
7473
name: 'Execute the script using the bindings from the server, using older Kotlin (1.9.0) as consumer'
7574
run: |2-
76-
PATH=$(pwd)/kotlin-compiler-1.9.0/kotlinc/bin:$PATH
77-
cp .github/workflows/test-script-consuming-jit-bindings.main.kts .github/workflows/test-script-consuming-jit-bindings-too-old-kotlin.main.kts
75+
cp .github/workflows/test-script-consuming-jit-bindings.main.kts .github/workflows/test-script-consuming-jit-bindings-too-old-kotlin.main.kts
7876
(.github/workflows/test-script-consuming-jit-bindings-too-old-kotlin.main.kts || true) >> output.txt 2>&1
7977
grep "was compiled with an incompatible version of Kotlin" output.txt
78+
- id: 'step-11'
79+
name: 'Install Kotlin 2.0.0'
80+
uses: 'fwilhe2/setup-kotlin@0.11.0'
81+
with:
82+
version: '2.0.0'
8083
- id: 'step-12'
81-
name: 'Download older Kotlin compiler (2.0.0)'
82-
run: 'curl -Lo kotlin-compiler-2.0.0.zip https://github.com/JetBrains/kotlin/releases/download/v2.0.0/kotlin-compiler-2.0.0.zip'
83-
- id: 'step-13'
84-
name: 'Unzip and add to PATH'
85-
run: 'unzip kotlin-compiler-2.0.0.zip -d kotlin-compiler-2.0.0'
86-
- id: 'step-14'
8784
name: 'Clean Maven Local to fetch required POMs again'
8885
run: 'rm -rf ~/.m2/repository/'
89-
- id: 'step-15'
86+
- id: 'step-13'
9087
name: 'Execute the script using the bindings from the server, using older Kotlin (2.0.0) as consumer'
91-
run: |2-
92-
PATH=$(pwd)/kotlin-compiler-2.0.0/kotlinc/bin:$PATH
93-
cp .github/workflows/test-script-consuming-jit-bindings.main.kts .github/workflows/test-script-consuming-jit-bindings-older-kotlin.main.kts
88+
run: |-
89+
cp .github/workflows/test-script-consuming-jit-bindings.main.kts .github/workflows/test-script-consuming-jit-bindings-older-kotlin.main.kts
9490
.github/workflows/test-script-consuming-jit-bindings-older-kotlin.main.kts
95-
- id: 'step-16'
91+
- id: 'step-14'
9692
name: 'Compile a Gradle project using the bindings from the server'
9793
run: |-
9894
cd .github/workflows/test-gradle-project-using-bindings-server
9995
./gradlew build
100-
- id: 'step-17'
96+
- id: 'step-15'
10197
name: 'Fetch maven-metadata.xml for top-level action'
10298
run: 'curl --fail http://localhost:8080/actions/checkout/maven-metadata.xml | grep ''<version>v4</version>'''
103-
- id: 'step-18'
99+
- id: 'step-16'
104100
name: 'Fetch maven-metadata.xml for nested action'
105101
run: 'curl --fail http://localhost:8080/actions/cache__save/maven-metadata.xml | grep ''<version>v4</version>'''
106102
deploy:

0 commit comments

Comments
 (0)