test(pac): 固化 runtime GitOps 文件合同

This commit is contained in:
root
2026-07-14 00:09:28 +02:00
parent f800cad5d4
commit c8d3f956ff
+30
View File
@@ -5,6 +5,7 @@ import { mkdir, mkdtemp, readFile, readdir, rm, writeFile } from "node:fs/promis
import os from "node:os";
import path from "node:path";
import test from "node:test";
import { parse as parseYaml } from "yaml";
import { configString } from "./src/gitops-render/core.mjs";
import { opencodeEgressProxyUrlForProfile } from "./src/gitops-render/runtime-manifests.mjs";
@@ -17,6 +18,35 @@ function taskByName(pipeline, name) {
return task;
}
test("NC01 PaC artifact keeps the runtime GitOps file contract", async () => {
const pipelinePath = "ci/pipelines/hwlab-nc01-v03-ci-image-publish.yaml";
const pacSource = await readFile(".tekton/hwlab-nc01-v03-pac.yaml", "utf8");
const pipelineSource = await readFile(pipelinePath, "utf8");
const pipeline = parseYaml(pipelineSource);
assert.match(pacSource, new RegExp(`pipelinesascode\\.tekton\\.dev/pipeline: ${pipelinePath.replaceAll("/", "\\/")}`, "u"));
const gitopsPromote = taskByName(pipeline, "gitops-promote");
assert.deepEqual(gitopsPromote.taskSpec.volumes, [{
name: "unidesk-runtime-gitops-scripts",
configMap: {
name: "hwlab-nc01-v03-ci-image-publish-runtime-gitops-scripts",
defaultMode: 493
}
}]);
const promoteStep = gitopsPromote.taskSpec.steps.find((step) => step.name === "promote");
assert.ok(promoteStep, "missing gitops-promote promote step");
assert.deepEqual(promoteStep.volumeMounts, [{
name: "unidesk-runtime-gitops-scripts",
mountPath: "/etc/unidesk-cicd-runtime-gitops",
readOnly: true
}]);
assert.match(promoteStep.script, /UNIDESK_RUNTIME_GITOPS_OVERLAY_FILE=\/etc\/unidesk-cicd-runtime-gitops\/runtime-gitops-overlay\.json node \/etc\/unidesk-cicd-runtime-gitops\/runtime-gitops-postprocess\.mjs/u);
assert.match(promoteStep.script, /UNIDESK_RUNTIME_GITOPS_OVERLAY_FILE=\/etc\/unidesk-cicd-runtime-gitops\/runtime-gitops-overlay\.json node \/etc\/unidesk-cicd-runtime-gitops\/runtime-gitops-verify\.mjs/u);
assert.doesNotMatch(promoteStep.script, /UNIDESK_RUNTIME_GITOPS_OVERLAY_B64/u);
});
async function collectGeneratedFiles(root) {
const files = [];
async function walk(dir) {