Merge pull request #2763 from pikasTech/fix/2762-service-runtime-plan
Pipelines as Code CI / hwlab-nc01-v03-ci-poll-e2e2ef0d651699bc7762fcc2789b78f35c144f25 Success

fix: 识别 lane service 运行配置变化
This commit is contained in:
Lyon
2026-07-22 14:23:24 +08:00
committed by GitHub
2 changed files with 48 additions and 1 deletions
+36
View File
@@ -437,6 +437,42 @@ test("node CI planner scopes runtime config rendering to the changed service wit
assert.equal(plan.ciCdPlan.noImageBuildReason, "runtime-config-only-change");
});
test("v03 planner scopes lane service runtime overrides without image builds", async () => {
const selectedServices = ["hwlab-cloud-api", "hwlab-cloud-web", "hwlab-gateway"];
const repo = await createFixtureRepo({ serviceIds: selectedServices });
const deployPath = path.join(repo, "deploy/deploy.yaml");
const deploy = await readStructuredFile(repo, deployPath);
deploy.lanes.v03.services = selectedServices.map((serviceId) => ({ serviceId, env: { RUNTIME_REVISION: "v1" } }));
await writeStructuredFile(repo, deployPath, deploy);
await git(repo, ["add", "deploy/deploy.yaml"]);
await git(repo, ["commit", "-m", "seed v03 runtime overrides"]);
deploy.lanes.v03.services.find((service) => service.serviceId === "hwlab-cloud-api").env.RUNTIME_REVISION = "v2";
deploy.lanes.v03.services.find((service) => service.serviceId === "hwlab-cloud-web").env.RUNTIME_REVISION = "v2";
await writeStructuredFile(repo, deployPath, deploy);
await git(repo, ["add", "deploy/deploy.yaml"]);
await git(repo, ["commit", "-m", "change two v03 runtime overrides"]);
const plan = await createCiPlan({
repoRoot: repo,
lane: "v03",
baseRef: "HEAD~1",
targetRef: "HEAD",
artifactCatalogPath: "deploy/artifact-catalog.v03.json",
services: selectedServices
});
assert.deepEqual(plan.affectedServices, ["hwlab-cloud-api", "hwlab-cloud-web"]);
assert.deepEqual(plan.rolloutServices, ["hwlab-cloud-api", "hwlab-cloud-web"]);
assert.deepEqual(plan.buildServices, []);
assert.deepEqual(plan.rolloutWithoutImageBuildServices, ["hwlab-cloud-api", "hwlab-cloud-web"]);
assert.deepEqual(plan.reusedServices, ["hwlab-gateway"]);
assert.equal(plan.services.find((service) => service.serviceId === "hwlab-cloud-api").runtimeConfigChanged, true);
assert.equal(plan.services.find((service) => service.serviceId === "hwlab-cloud-web").runtimeConfigChanged, true);
assert.equal(plan.services.find((service) => service.serviceId === "hwlab-gateway").runtimeConfigChanged, false);
assert.equal(plan.ciCdPlan.noImageBuildReason, "runtime-config-only-change");
});
test("node CI planner keeps Tekton renderer changes out of runtime rollout scope", async () => {
const repo = await createFixtureRepo();
await mkdir(path.join(repo, "scripts/src/gitops-render"), { recursive: true });
+12 -1
View File
@@ -748,10 +748,21 @@ function serviceRuntimeConfigIdentity(deployJson, lane, serviceId) {
healthPort: Number.isInteger(declaration.healthPort) ? declaration.healthPort : null,
healthProbe: normalizeServiceHealthProbe(declaration.healthProbe),
env: normalizeServiceEnv(declaration.env),
observable: declaration.observable === true
observable: declaration.observable === true,
baseRuntimeService: runtimeServiceConfigById(deployJson?.services, serviceId),
laneRuntimeService: runtimeServiceConfigById(laneConfig?.services, serviceId)
};
}
function runtimeServiceConfigById(services, serviceId) {
if (!Array.isArray(services)) return null;
let match = null;
for (const service of services) {
if (service?.serviceId === serviceId) match = service;
}
return match;
}
export async function packageRuntimeFieldsChanged(repoRoot, baseRef, targetRef, filePath = "package.json") {
const [before, after] = await Promise.all([
readJsonFromGit(repoRoot, baseRef, filePath, null),