fix: add cloud web env reuse runtime

This commit is contained in:
Codex
2026-05-31 14:37:28 +08:00
parent fd30feeef4
commit 89b83465e4
7 changed files with 219 additions and 23 deletions
+23 -7
View File
@@ -428,6 +428,20 @@ function bootShForService(deployService, serviceId) {
return text;
}
function envReuseServiceIdsForLane(deploy, lane) {
if (lane !== "v02") return new Set();
const configured = deploy?.lanes?.v02?.envReuseServices;
const allowed = new Set(serviceIdsForLane(lane));
return new Set((Array.isArray(configured) ? configured : []).filter((serviceId) => allowed.has(serviceId)));
}
function deployServiceForBoot(deploy, serviceId) {
return {
serviceId,
bootSh: deploy?.lanes?.v02?.bootScripts?.[serviceId]
};
}
function bootMetadataForService({ args, catalog, deployService, serviceId, source }) {
const catalogService = catalogServiceById(catalog, serviceId);
const environmentImage = catalogService?.environmentImage ?? imageFor(args.registryPrefix, `${serviceId}-env`, `env-${String(catalogService?.environmentInputHash ?? source.full).slice(0, 12)}`);
@@ -507,7 +521,7 @@ function isV02RemovedServiceId(serviceId) {
return v02RemovedServiceIds.has(serviceId);
}
function artifactCatalogSkeleton({ args, source }) {
function artifactCatalogSkeleton({ args, deploy, source }) {
const environment = artifactEnvironment(args);
const namespace = args.lane === "v02" ? "hwlab-v02" : "hwlab-dev";
const tag = imageTagForSource(args, source);
@@ -528,11 +542,11 @@ function artifactCatalogSkeleton({ args, source }) {
},
allowedProfiles: [environment],
forbiddenProfiles: args.lane === "v02" ? ["dev", "prod"] : ["prod"],
services: serviceIdsForLane(args.lane).map((serviceId) => artifactCatalogSkeletonService({ args, source, serviceId, environment, namespace, tag }))
services: serviceIdsForLane(args.lane).map((serviceId) => artifactCatalogSkeletonService({ args, deploy, source, serviceId, environment, namespace, tag }))
};
}
function artifactCatalogSkeletonService({ args, source, serviceId, environment, namespace, tag }) {
function artifactCatalogSkeletonService({ args, deploy, source, serviceId, environment, namespace, tag }) {
const base = {
serviceId,
profile: environment,
@@ -544,7 +558,9 @@ function artifactCatalogSkeletonService({ args, source, serviceId, environment,
digest: null,
buildBackend: "contract-skeleton"
};
if (args.lane !== "v02" || serviceId !== "hwlab-device-pod") return base;
const envReuseServiceIds = envReuseServiceIdsForLane(deploy, args.lane);
if (!envReuseServiceIds.has(serviceId)) return base;
const bootSh = bootShForService(deployServiceForBoot(deploy, serviceId), serviceId);
const environmentImage = imageFor(args.registryPrefix, `${serviceId}-env`, `env-${String(source.full).slice(0, 12)}`);
return {
...base,
@@ -557,13 +573,13 @@ function artifactCatalogSkeletonService({ args, source, serviceId, environment,
environmentInputHash: null,
bootRepo: args.sourceRepo,
bootCommit: source.full,
bootSh: `deploy/runtime/boot/${serviceId}.sh`,
bootSh,
codeInputHash: null,
bootEnvEvidence: {
env: {
HWLAB_BOOT_REPO: args.sourceRepo,
HWLAB_BOOT_COMMIT: source.full,
HWLAB_BOOT_SH: `deploy/runtime/boot/${serviceId}.sh`
HWLAB_BOOT_SH: bootSh
}
}
};
@@ -4226,7 +4242,7 @@ async function plannedFiles(args) {
const source = await resolveSourceRevision(args.sourceRevision);
source.imageTag = imageTagForSource(args, source);
let artifactCatalog = await readJsonIfPresent(args.catalogPath, null);
if (!artifactCatalog && args.lane === "v02") artifactCatalog = artifactCatalogSkeleton({ args, source });
if (!artifactCatalog && args.lane === "v02") artifactCatalog = artifactCatalogSkeleton({ args, deploy, source });
if (!artifactCatalog) artifactCatalog = await readJson(args.catalogPath);
const settings = ciLaneSettings(args);
const profiles = laneRuntimeProfiles(args);