From c8d3f956ffbd1a5176a79c41fcf282156198abbe Mon Sep 17 00:00:00 2001 From: root Date: Tue, 14 Jul 2026 00:09:28 +0200 Subject: [PATCH] =?UTF-8?q?test(pac):=20=E5=9B=BA=E5=8C=96=20runtime=20Git?= =?UTF-8?q?Ops=20=E6=96=87=E4=BB=B6=E5=90=88=E5=90=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- scripts/gitops-render.test.ts | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/scripts/gitops-render.test.ts b/scripts/gitops-render.test.ts index 9dba2d0b..aa6e260e 100644 --- a/scripts/gitops-render.test.ts +++ b/scripts/gitops-render.test.ts @@ -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) {