Merge remote-tracking branch 'origin/v0.3' into fix/2835-cicd-plan
This commit is contained in:
@@ -446,6 +446,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 });
|
||||
|
||||
@@ -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),
|
||||
|
||||
Reference in New Issue
Block a user