From f9ce9b6015b45c6f00219abf5e12b8151a110a94 Mon Sep 17 00:00:00 2001 From: sunlei Date: Thu, 25 Jun 2026 03:51:46 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E6=AD=A3NapCat=E8=BF=90?= =?UTF-8?q?=E8=A1=8C=E6=97=B6=E5=8F=91=E5=B8=83=E7=A1=AE=E8=AE=A4=E9=97=A8?= =?UTF-8?q?=E7=A6=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../KT-NapCatQQ-Runtime-Release.Jenkinsfile | 6 +- src/selfTest.ts | 56 +++++++++++++++++++ 2 files changed, 59 insertions(+), 3 deletions(-) diff --git a/ci/jenkins/KT-NapCatQQ-Runtime-Release.Jenkinsfile b/ci/jenkins/KT-NapCatQQ-Runtime-Release.Jenkinsfile index 86be13b..1ee9863 100644 --- a/ci/jenkins/KT-NapCatQQ-Runtime-Release.Jenkinsfile +++ b/ci/jenkins/KT-NapCatQQ-Runtime-Release.Jenkinsfile @@ -46,9 +46,6 @@ pipeline { } steps { script { - if (params.CONFIRM_API_PROMOTION_TARGET != 'PROMOTE_KT_TEMPLATE_API_MAIN') { - error('CONFIRM_API_PROMOTION_TARGET must equal PROMOTE_KT_TEMPLATE_API_MAIN before API promotion runs.') - } requireRuntimeOverrides( params.QQBOT_NAPCAT_IMAGE_OVERRIDE, params.QQBOT_NAPCAT_DESKTOP_PROFILE_VERSION_OVERRIDE @@ -72,6 +69,9 @@ pipeline { } steps { script { + if (params.CONFIRM_API_PROMOTION_TARGET != 'PROMOTE_KT_TEMPLATE_API_MAIN') { + error('CONFIRM_API_PROMOTION_TARGET must equal PROMOTE_KT_TEMPLATE_API_MAIN before API promotion runs.') + } requireRuntimeOverrides( params.QQBOT_NAPCAT_IMAGE_OVERRIDE, params.QQBOT_NAPCAT_DESKTOP_PROFILE_VERSION_OVERRIDE diff --git a/src/selfTest.ts b/src/selfTest.ts index 3f12f9f..91f982f 100644 --- a/src/selfTest.ts +++ b/src/selfTest.ts @@ -524,6 +524,62 @@ export async function runSelfTest(): Promise { ); } } + const runtimeImageBuildStageStart = runtimeReleaseJenkinsTemplate.indexOf( + "stage('Runtime image build and publish')", + ); + const apiPromotionStageStart = runtimeReleaseJenkinsTemplate.indexOf( + "stage('API promotion')", + ); + const pipelineEndBeforeRuntimeHelpers = runtimeReleaseJenkinsTemplate.indexOf( + "\n}\n\n/**", + apiPromotionStageStart, + ); + if ( + runtimeImageBuildStageStart === -1 || + apiPromotionStageStart === -1 || + pipelineEndBeforeRuntimeHelpers === -1 || + runtimeImageBuildStageStart > apiPromotionStageStart + ) { + throw new Error("NapCat runtime Jenkins template stage slice self-check failed"); + } + const runtimeImageBuildStage = runtimeReleaseJenkinsTemplate.slice( + runtimeImageBuildStageStart, + apiPromotionStageStart, + ); + const apiPromotionStage = runtimeReleaseJenkinsTemplate.slice( + apiPromotionStageStart, + pipelineEndBeforeRuntimeHelpers, + ); + if (runtimeImageBuildStage.includes("CONFIRM_API_PROMOTION_TARGET")) { + throw new Error( + "NapCat runtime Jenkins runtime image build stage must not check API promotion confirmation", + ); + } + if (!apiPromotionStage.includes("CONFIRM_API_PROMOTION_TARGET")) { + throw new Error( + "NapCat runtime Jenkins API promotion stage missing confirmation target check", + ); + } + if (!apiPromotionStage.includes("PROMOTE_KT_TEMPLATE_API_MAIN")) { + throw new Error( + "NapCat runtime Jenkins API promotion stage missing production confirmation value", + ); + } + const apiPromotionConfirmationIndex = apiPromotionStage.indexOf( + "CONFIRM_API_PROMOTION_TARGET", + ); + const apiPromotionBuildIndex = apiPromotionStage.indexOf( + "build job: params.API_PROMOTION_JOB", + ); + if ( + apiPromotionConfirmationIndex === -1 || + apiPromotionBuildIndex === -1 || + apiPromotionConfirmationIndex > apiPromotionBuildIndex + ) { + throw new Error( + "NapCat runtime Jenkins API promotion confirmation must run before API build job", + ); + } const codexExecutionArtifactRoot = resolveInsideRoot( ".kt-workspace/test-artifacts/napcat-codex-runner-self-test", );