Skip to content

Commit 4f64814

Browse files
authored
ci(kotlin): test Kotlin 2.4.10 on JDK 26 (#4002)
## Why? ## What does this PR do? ## Related issues ## AI Contribution Checklist - [ ] Substantial AI assistance was used in this PR: `yes` / `no` - [ ] If `yes`, I included a completed [AI Contribution Checklist](https://github.com/apache/fory/blob/main/AI_POLICY.md#9-contributor-checklist-for-ai-assisted-prs) in this PR description and the required `AI Usage Disclosure`. - [ ] If `yes`, my PR description includes the required `ai_review` summary and screenshot evidence or equivalent persisted links of the final clean AI review results from both fresh reviewers described in `AI_POLICY.md`, the Fory-guided reviewer and the independent general reviewer, on the current PR diff or current HEAD after the latest code changes. ## Does this PR introduce any user-facing change? - [ ] Does this PR introduce any public API change? - [ ] Does this PR introduce any binary protocol compatibility change? ## Benchmark
1 parent 141778b commit 4f64814

3 files changed

Lines changed: 62 additions & 20 deletions

File tree

.github/workflows/ci.yml

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -728,15 +728,27 @@ jobs:
728728
run: python ./ci/run_ci.py kotlin --task native-json
729729

730730
kotlin:
731-
name: Kotlin CI
731+
name: Kotlin CI (${{ matrix.label }})
732732
needs: changes
733733
if: needs.changes.outputs.kotlin == 'true'
734734
runs-on: ubuntu-latest
735735
env:
736736
MY_VAR: "PATH"
737737
strategy:
738738
matrix:
739-
java-version: ["8", "11", "17", "21", "25", "26"]
739+
include:
740+
- java-version: "8"
741+
kotlin_args: ""
742+
label: JDK 8
743+
- java-version: "11"
744+
kotlin_args: ""
745+
label: JDK 11
746+
- java-version: "17"
747+
kotlin_args: ""
748+
label: JDK 17
749+
- java-version: "26"
750+
kotlin_args: --kotlin-version 2.4.10
751+
label: Kotlin 2.4.10 / JDK 26
740752
steps:
741753
- uses: actions/checkout@v5
742754
- name: Set up JDK ${{ matrix.java-version }}
@@ -756,7 +768,7 @@ jobs:
756768
with:
757769
python-version: 3.11
758770
- name: Run Kotlin CI
759-
run: python ./ci/run_ci.py kotlin
771+
run: python ./ci/run_ci.py kotlin ${{ matrix.kotlin_args }}
760772

761773
scala:
762774
name: Scala CI

ci/run_ci.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -347,6 +347,11 @@ def parse_args():
347347
default="tests",
348348
help="Kotlin CI task to execute",
349349
)
350+
kotlin_parser.add_argument(
351+
"--kotlin-version",
352+
default=None,
353+
help="Override the Kotlin compiler and library version",
354+
)
350355
kotlin_parser.set_defaults(func=kotlin.run)
351356

352357
# Python subparser

ci/tasks/kotlin.py

Lines changed: 42 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,15 @@ def java_major_version():
6363
return int(version.split(".")[0])
6464

6565

66+
def kotlin_version_option(version):
67+
"""Return the Maven property for an explicit stable Kotlin version."""
68+
if version is None:
69+
return ""
70+
if re.fullmatch(r"\d+\.\d+\.\d+", version) is None:
71+
raise ValueError(f"Invalid Kotlin version: {version}")
72+
return f"-Dkotlin.version={version}"
73+
74+
6675
def install_java_json(include_jpms=False):
6776
"""Install the Java artifacts consumed by Kotlin JSON modules."""
6877
modules = "fory-json,fory-annotation-processor"
@@ -87,20 +96,24 @@ def install_java_json(include_jpms=False):
8796
)
8897

8998

90-
def install_artifacts(include_corpus=True, modules=PRODUCTION_MODULES):
99+
def install_artifacts(
100+
include_corpus=True, modules=PRODUCTION_MODULES, kotlin_version=None
101+
):
91102
"""Install Kotlin production artifacts and the shared JSON corpus."""
92103
# Artifact consumers need only main JARs. Test stages compile their own test sources later.
104+
version_option = kotlin_version_option(kotlin_version)
93105
common.cd_project_subdir("kotlin")
94106
common.exec_cmd(
95107
"mvn -T16 --batch-mode --no-transfer-progress "
96108
f"-pl {modules} -am clean install -Dmaven.test.skip=true "
97-
"-Ddokka.skip=true -Dmaven.source.skip=true"
109+
f"-Ddokka.skip=true -Dmaven.source.skip=true {version_option}"
98110
)
99111
if include_corpus:
100112
common.cd_project_subdir("integration_tests/kotlin_json_corpus")
101113
common.exec_cmd(
102114
"mvn -T16 --batch-mode --no-transfer-progress clean install "
103-
"-Dmaven.test.skip=true -Ddokka.skip=true -Dmaven.source.skip=true"
115+
"-Dmaven.test.skip=true -Ddokka.skip=true -Dmaven.source.skip=true "
116+
f"{version_option}"
104117
)
105118
verify_corpus_artifact()
106119

@@ -164,39 +177,45 @@ def _kotlin_version():
164177
return version
165178

166179

167-
def run_tests():
180+
def run_tests(kotlin_version=None):
168181
"""Run the Kotlin JVM matrix for the active JDK."""
169182
logging.info("Executing fory kotlin tests")
170183
os.environ.setdefault("ENABLE_FORY_DEBUG_OUTPUT", "1")
171184
major = java_major_version()
185+
version_option = kotlin_version_option(kotlin_version)
172186
install_java_json(include_jpms=major == 25)
173187
modules = PRODUCTION_MODULES if major >= 17 else LOW_JDK_MODULES
174-
install_artifacts(include_corpus=major >= 17, modules=modules)
188+
install_artifacts(
189+
include_corpus=major >= 17,
190+
modules=modules,
191+
kotlin_version=kotlin_version,
192+
)
175193
common.cd_project_subdir("kotlin")
176194
if major >= 17:
177195
common.exec_cmd(
178-
"mvn -T16 --batch-mode --no-transfer-progress test -DfailIfNoTests=false"
196+
"mvn -T16 --batch-mode --no-transfer-progress test "
197+
f"-DfailIfNoTests=false {version_option}"
179198
)
180199
common.exec_cmd("mvn -T16 --batch-mode --no-transfer-progress spotless:check")
181200
common.cd_project_subdir("integration_tests/kotlin_json_corpus")
182201
common.exec_cmd(
183202
"mvn -T16 --batch-mode --no-transfer-progress clean test "
184-
"-DfailIfNoTests=false"
203+
f"-DfailIfNoTests=false {version_option}"
185204
)
186205
else:
187206
logging.info(
188207
"Skipping KSP generation tests on JDK < 17 because ksp-maven-plugin requires Java 17+"
189208
)
190209
common.exec_cmd(
191210
"mvn -T16 --batch-mode --no-transfer-progress "
192-
f"-pl {LOW_JDK_MODULES} -am test -DfailIfNoTests=false"
211+
f"-pl {LOW_JDK_MODULES} -am test -DfailIfNoTests=false {version_option}"
193212
)
194213
if major == 25:
195214
common.cd_project_subdir("kotlin")
196215
common.exec_cmd(
197216
"mvn -T16 --batch-mode --no-transfer-progress "
198217
f"-pl {PRODUCTION_MODULES} -am package -DskipTests "
199-
"-Dgpg.skip=true -Papache-release"
218+
f"-Dgpg.skip=true -Papache-release {version_option}"
200219
)
201220
common.cd_project_subdir("")
202221
common.exec_cmd("python ci/release.py verify_kotlin_artifacts")
@@ -206,28 +225,34 @@ def run_tests():
206225
logging.info("Executing fory kotlin tests succeeds")
207226

208227

209-
def run_native_json():
228+
def run_native_json(kotlin_version=None):
210229
"""Build and execute the dedicated Kotlin JSON Native Image fixture."""
211230
os.environ.setdefault("ENABLE_FORY_DEBUG_OUTPUT", "1")
231+
version_option = kotlin_version_option(kotlin_version)
212232
install_java_json()
213-
install_artifacts(include_corpus=True)
233+
install_artifacts(include_corpus=True, kotlin_version=kotlin_version)
214234
common.cd_project_subdir("integration_tests/graalvm_kotlin_tests")
215235
common.exec_cmd(
216-
"mvn --batch-mode --no-transfer-progress -DskipTests=true -Pnative clean package"
236+
"mvn --batch-mode --no-transfer-progress -DskipTests=true -Pnative clean package "
237+
f"{version_option}"
217238
)
218239
common.exec_cmd("./target/main")
219240

220241

221-
def run(task="tests"):
242+
def run(task="tests", kotlin_version=None):
222243
"""Run the selected Kotlin CI task."""
223244
if task == "tests":
224-
run_tests()
245+
run_tests(kotlin_version)
225246
elif task == "install-json":
226247
install_java_json()
227-
install_artifacts(include_corpus=True, modules=JSON_MODULES)
248+
install_artifacts(
249+
include_corpus=True,
250+
modules=JSON_MODULES,
251+
kotlin_version=kotlin_version,
252+
)
228253
elif task == "install-kotlin":
229-
install_artifacts(include_corpus=True)
254+
install_artifacts(include_corpus=True, kotlin_version=kotlin_version)
230255
elif task == "native-json":
231-
run_native_json()
256+
run_native_json(kotlin_version)
232257
else:
233258
raise ValueError(f"Unsupported Kotlin CI task: {task}")

0 commit comments

Comments
 (0)