Merge pull request #2790 from pikasTech/fix/2744-plan-compact-output
收敛手动发布计划默认输出
This commit is contained in:
@@ -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");
|
||||
|
||||
@@ -1677,13 +1677,13 @@ async function manualRelease(config: UniDeskConfig, action: "plan" | "trigger",
|
||||
};
|
||||
}
|
||||
|
||||
function compactManualReleasePlan(plan: Record<string, any>): Record<string, unknown> {
|
||||
export function compactManualReleasePlan(plan: Record<string, any>): Record<string, unknown> {
|
||||
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<string, any>): Record<string, unk
|
||||
};
|
||||
}
|
||||
|
||||
function compactRegistryProbe(value: unknown): Record<string, unknown> | null {
|
||||
if (value === null || typeof value !== "object") return null;
|
||||
const probe = value as Record<string, unknown>;
|
||||
const services = Array.isArray(probe.services)
|
||||
? probe.services.map((item) => {
|
||||
const service = item !== null && typeof item === "object" ? item as Record<string, unknown> : {};
|
||||
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<Record<string, number>>((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,
|
||||
|
||||
Reference in New Issue
Block a user