From 8ef9aaa39664300dc6a29f790ffce3682cbc9609 Mon Sep 17 00:00:00 2001 From: Mikhail Bystretskiy Date: Thu, 28 Aug 2025 10:57:22 +0300 Subject: [PATCH] Fix subset file list for Kotlin + check subset on CI --- .gitlab-ci.yml | 1 + subset/.gitlab-ci.yml | 12 +++++++ subset/check.mjs | 84 +++++++++++++++++++++++++++++++++++++++++++ subset/subset.json | 14 ++++---- 4 files changed, 104 insertions(+), 7 deletions(-) create mode 100644 subset/.gitlab-ci.yml create mode 100644 subset/check.mjs diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index a4d935ae8c..8cddc05b64 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -56,4 +56,5 @@ include: - ui2abc/tests-memo/.gitlab-ci.yml - ui2abc/ets-tests/.gitlab-ci.yml - interop/.gitlab-ci.yml + - subset/.gitlab-ci.yml - tools/.gitlab-ci.yml diff --git a/subset/.gitlab-ci.yml b/subset/.gitlab-ci.yml new file mode 100644 index 0000000000..5ea07e985d --- /dev/null +++ b/subset/.gitlab-ci.yml @@ -0,0 +1,12 @@ + check files: + stage: test + interruptible: true + extends: + - .linux-vm-shell-task + before_script: + - !reference [.setup, script] + - cd subset + script: + - node check.mjs + needs: + - job: install node modules (tools) \ No newline at end of file diff --git a/subset/check.mjs b/subset/check.mjs new file mode 100644 index 0000000000..286a068035 --- /dev/null +++ b/subset/check.mjs @@ -0,0 +1,84 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import fs from "fs" +import path from "path" + +const SUBSET_FILE = "subset.json" +const SUBSET = "subset" +const GENERATED_SUBSET = "generatedSubset" + +function isStringArray(array) { + if (!Array.isArray(array)) { + return false + } + for (let element of array) { + if (typeof element !== "string") { + return false + } + } + return true +} + +function fileExists(file) { + try { + const stat = fs.statSync(file) + return !stat.isDirectory() + } + catch (e) { + return false + } +} + +function fileExistsInSubsetOrFS(file) { + if (fileExists(file)) { + return true + } + return fileExists(path.join("..", file)) +} + +function checkSubset() { + const data = fs.readFileSync(SUBSET_FILE, "utf-8").trim() + const config = JSON.parse(data) + if (!(SUBSET in config) || !(GENERATED_SUBSET in config)) { + throw new Error(`${SUBSET_FILE} is expected to have "${SUBSET}" and "${GENERATED_SUBSET}" sections`) + } + if (!isStringArray(config[SUBSET]) || !isStringArray(config[GENERATED_SUBSET])) { + throw new Error(`"${SUBSET}" and "${GENERATED_SUBSET}" are expected to be string arrays`) + } + + const missedFiles1 = [] + config[SUBSET].forEach(it => { + if (!fileExistsInSubsetOrFS(it)) { + missedFiles1.push(it) + } + }) + if (missedFiles1.length > 0) { + throw new Error(`files are not found in the subset or filesystem: ${missedFiles1}`) + } + + const missedFiles2 = [] + config[GENERATED_SUBSET].forEach(it => { + if (!fileExists(it)) { + missedFiles2.push(it) + } + }) + if (missedFiles2.length > 0) { + throw new Error(`files are not found in the subset: ${missedFiles2}`) + } +} + +checkSubset() + diff --git a/subset/subset.json b/subset/subset.json index 2e1d106c21..d4a816e83b 100644 --- a/subset/subset.json +++ b/subset/subset.json @@ -21,13 +21,13 @@ "arkoala-cj/framework/cangjie/src/Main.cj", "arkoala-cj/framework/cangjie/src/NativePeerNode.cj", "arkoala-cj/framework/cangjie/src/PeerNode.cj", - "arkoala-kotlin/framework/kotlin/src/main.kt", - "arkoala-kotlin/framework/kotlin/src/CallbacksChecker.kt", - "arkoala-kotlin/framework/kotlin/src/CallbackTransformer.kt", - "arkoala-kotlin/framework/kotlin/src/ComponentBase.kt", - "arkoala-kotlin/framework/kotlin/src/NativePeerNode.kt", - "arkoala-kotlin/framework/kotlin/src/PeerNode.kt", - "arkoala-kotlin/framework/kotlin/src/Handwritten.kt", + "arkoala-kotlin/framework/src/Application.kt", + "arkoala-kotlin/framework/src/ArkUINativeModule.kt", + "arkoala-kotlin/framework/src/ComponentBase.kt", + "arkoala-kotlin/framework/src/NativeLog.kt", + "arkoala-kotlin/framework/src/NativePeerNode.kt", + "arkoala-kotlin/framework/src/PeerNode.kt", + "arkoala-kotlin/framework/src/UserView.kt", "arkoala-java/framework/java/src/org/koalaui/arkoala/Application.java", "arkoala-java/framework/java/src/org/koalaui/arkoala/ArkBase.java", "arkoala-java/framework/java/src/org/koalaui/arkoala/Ark_CustomObject.java", -- Gitee