From a22316fc6ab1c51f6fc3adf740d20ad86cc0e3f7 Mon Sep 17 00:00:00 2001 From: pikastech Date: Tue, 21 Jul 2026 15:58:33 +0200 Subject: [PATCH] =?UTF-8?q?fix:=20=E6=94=B6=E6=95=9B=E5=8F=91=E5=B8=83?= =?UTF-8?q?=E8=AE=A1=E5=88=92=E9=BB=98=E8=AE=A4=E8=BE=93=E5=87=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...-infra-pipelines-as-code-bootstrap.test.ts | 25 ++++++++++++++++- .../src/platform-infra-pipelines-as-code.ts | 28 +++++++++++++++++-- 2 files changed, 50 insertions(+), 3 deletions(-) diff --git a/scripts/src/platform-infra-pipelines-as-code-bootstrap.test.ts b/scripts/src/platform-infra-pipelines-as-code-bootstrap.test.ts index 2359def6..a4cc7e49 100644 --- a/scripts/src/platform-infra-pipelines-as-code-bootstrap.test.ts +++ b/scripts/src/platform-infra-pipelines-as-code-bootstrap.test.ts @@ -5,7 +5,7 @@ import { resolve } from "node:path"; import type { GiteaConfig, GiteaMirrorRepository } from "./platform-infra-gitea-config"; import { renderMirrorBootstrap } from "./platform-infra-gitea-render"; import { pacBootstrapYamlMatchFailure, projectPacBootstrapResult, renderPacBootstrap, resolvePacBootstrapMirrorRepository } from "./platform-infra-pipelines-as-code-bootstrap"; -import { manualReleaseNext, PacReleaseManifestRenderError, parsePacConfigDocument, readPacConfig, renderPacReleaseManifest, runPlatformInfraPipelinesAsCodeCommand, validatePacConfig, validPacConsumers } from "./platform-infra-pipelines-as-code"; +import { compactManualReleasePlan, manualReleaseNext, PacReleaseManifestRenderError, parsePacConfigDocument, readPacConfig, renderPacReleaseManifest, runPlatformInfraPipelinesAsCodeCommand, validatePacConfig, validPacConsumers } from "./platform-infra-pipelines-as-code"; import { materializeYamlComposition } from "./yaml-composition"; const mirror: GiteaMirrorRepository = { @@ -413,6 +413,29 @@ test("PaC default release plan projection keeps review fields without changed-pa expect(projector).not.toContain("changedPaths:"); }); +test("PaC compact release plan keeps bounded registry probe results", () => { + const compact = compactManualReleasePlan({ + registryProbe: { + enabled: true, + services: [ + { serviceId: "api", status: "present", image: "registry/api:large", digest: `sha256:${"a".repeat(64)}` }, + { serviceId: "worker", status: "missing", image: "registry/worker:large", digest: null }, + ], + }, + }); + expect(compact.registryProbe).toEqual({ + enabled: true, + serviceCount: 2, + statusCounts: { present: 1, missing: 1 }, + services: [ + { serviceId: "api", status: "present" }, + { serviceId: "worker", status: "missing" }, + ], + }); + expect(JSON.stringify(compact)).not.toContain("registry/api:large"); + expect(JSON.stringify(compact)).not.toContain("sha256:aaaaaaaa"); +}); + test("PaC release manifest renders YAML-owned watcher startup backlog probes", () => { const pac = readPacConfig({ consumerId: "hwlab-nc01-v03", selectDefault: true }); const source = readFileSync(resolve(import.meta.dir, "fixtures/pac/release-leading-comment-only.yaml"), "utf8"); diff --git a/scripts/src/platform-infra-pipelines-as-code.ts b/scripts/src/platform-infra-pipelines-as-code.ts index f070d726..2e2c5053 100644 --- a/scripts/src/platform-infra-pipelines-as-code.ts +++ b/scripts/src/platform-infra-pipelines-as-code.ts @@ -1677,13 +1677,13 @@ async function manualRelease(config: UniDeskConfig, action: "plan" | "trigger", }; } -function compactManualReleasePlan(plan: Record): Record { +export function compactManualReleasePlan(plan: Record): Record { return { sourceCommit: plan.sourceCommit ?? null, baseCommit: plan.baseCommit ?? null, sourceBranch: plan.sourceBranch ?? null, planIdentity: plan.planIdentity ?? null, - registryProbe: plan.registryProbe ?? null, + registryProbe: compactRegistryProbe(plan.registryProbe), changedPathCount: plan.changedPathCount ?? null, artifactCatalog: plan.artifactCatalog === null ? null : { status: plan.artifactCatalog?.status ?? null, @@ -1706,6 +1706,30 @@ function compactManualReleasePlan(plan: Record): Record | null { + if (value === null || typeof value !== "object") return null; + const probe = value as Record; + const services = Array.isArray(probe.services) + ? probe.services.map((item) => { + const service = item !== null && typeof item === "object" ? item as Record : {}; + return { + serviceId: typeof service.serviceId === "string" ? service.serviceId : null, + status: typeof service.status === "string" ? service.status : null, + }; + }).filter((item) => item.serviceId !== null) + : []; + const statusCounts = services.reduce>((counts, service) => { + const status = service.status ?? "unknown"; + return { ...counts, [status]: (counts[status] ?? 0) + 1 }; + }, {}); + return { + enabled: probe.enabled === true, + serviceCount: services.length, + statusCounts, + services, + }; +} + export function manualReleaseNext( action: "plan" | "trigger", targetId: string,