fix: detect runtime config changes in ci plan

This commit is contained in:
lyon
2026-06-17 22:07:10 +08:00
parent e36272b2b6
commit 545fa2fbc3
2 changed files with 72 additions and 5 deletions
+20
View File
@@ -1,3 +1,4 @@
// SPEC: PJ2026-010401 Web工作台 - Workbench 可见性与性能探针
import assert from "node:assert/strict";
import { execFile } from "node:child_process";
import { mkdir, mkdtemp, readFile, writeFile } from "node:fs/promises";
@@ -53,6 +54,25 @@ test("node CI planner treats docs-only changes as no image build", async () => {
assert.equal(plan.changedPathSummary.docsOnly, true);
});
test("node CI planner rolls service runtime config changes without rebuilding image", async () => {
const repo = await createFixtureRepo();
const deployPath = path.join(repo, "deploy/deploy.yaml");
const deploy = await readStructuredFile(repo, deployPath);
deploy.lanes.v02.serviceDeclarations["hwlab-cloud-api"].env.HWLAB_METRICS_NAMESPACE = "hwlab-v02";
await writeStructuredFile(repo, deployPath, deploy);
await git(repo, ["add", "deploy/deploy.yaml"]);
await git(repo, ["commit", "-m", "change cloud api runtime env"]);
const plan = await planV02CoreServices(repo, { baseRef: "HEAD~1", targetRef: "HEAD" });
assert.deepEqual(plan.affectedServices, ["hwlab-cloud-api"]);
assert.deepEqual(plan.buildServices, []);
assert.equal(plan.imageBuildRequired, false);
const cloudApi = plan.services.find((service) => service.serviceId === "hwlab-cloud-api");
assert.equal(cloudApi.runtimeConfigChanged, true);
assert.equal(cloudApi.envChanged, false);
assert.deepEqual(cloudApi.reason, ["runtime-config-changed"]);
});
test("planner rebuilds when catalog digest is missing instead of blocking reuse", async () => {
const repo = await createFixtureRepo({ catalog: "missing-digest" });
await mkdir(path.join(repo, "docs/reference"), { recursive: true });