From a75a5e160d43703a437ebdc37b76a2795c3ee063 Mon Sep 17 00:00:00 2001 From: UniDesk Codex Date: Tue, 7 Jul 2026 08:16:53 +0800 Subject: [PATCH] fix: pass go base image through ci plan --- scripts/ci-plan.test.mjs | 9 +++++++++ scripts/src/ci-plan-lib.mjs | 4 ++++ 2 files changed, 13 insertions(+) diff --git a/scripts/ci-plan.test.mjs b/scripts/ci-plan.test.mjs index cb1ca5b2..09fbdb39 100644 --- a/scripts/ci-plan.test.mjs +++ b/scripts/ci-plan.test.mjs @@ -1170,6 +1170,8 @@ test("v03 planner builds one shared Go env artifact for compatible Go services", const workbenchRuntime = plan.services.find((service) => service.serviceId === "hwlab-workbench-runtime"); assert.equal(userBilling.envArtifactCacheRef, "127.0.0.1:5000/hwlab/cache/hwlab-go-runtime-env"); assert.equal(workbenchRuntime.envArtifactCacheRef, "127.0.0.1:5000/hwlab/cache/hwlab-go-runtime-env"); + assert.equal(userBilling.envReuseRecipe.goBaseImage, "127.0.0.1:5000/hwlab/hwlab-go-env-base:go1-bookworm-slim"); + assert.equal(workbenchRuntime.envReuseRecipe.goBaseImage, "127.0.0.1:5000/hwlab/hwlab-go-env-base:go1-bookworm-slim"); assert.equal(userBilling.environmentImage, `127.0.0.1:5000/hwlab/hwlab-go-runtime-env:env-${userBilling.environmentInputHash.slice(0, 12)}`); assert.equal(workbenchRuntime.environmentImage, userBilling.environmentImage); assert.equal(workbenchRuntime.sharedEnvBuildSkipped, true); @@ -1220,10 +1222,12 @@ test("v03 planner ignores Go launcher comment-only changes for env identity", as test("Go env build path declares base image, stable timing, and late volatile labels", async () => { const deploy = await readStructuredFile(process.cwd(), path.join(process.cwd(), "deploy/deploy.yaml")); + const recipe = envReuseRecipeForLane(deploy, "v03"); assert.equal( deploy.lanes?.v03?.envRecipe?.goBaseImage, "127.0.0.1:5000/hwlab/hwlab-go-env-base:go1-bookworm-slim" ); + assert.equal(recipe.publicRecipe.goBaseImage, "127.0.0.1:5000/hwlab/hwlab-go-env-base:go1-bookworm-slim"); const source = await readFile(path.join(process.cwd(), "scripts/artifact-publish.mjs"), "utf8"); const envDockerfileSource = source.slice( @@ -1374,6 +1378,11 @@ async function addGoEnvReuseFixture(repo) { ]); deploy.lanes.v03.bootScripts["hwlab-user-billing"] = "deploy/runtime/boot/hwlab-user-billing.sh"; deploy.lanes.v03.bootScripts["hwlab-workbench-runtime"] = "deploy/runtime/boot/hwlab-workbench-runtime.sh"; + deploy.lanes.v03.envRecipe.goOsPackages = ["golang-go"]; + deploy.lanes.v03.envRecipe.goBaseImage = "127.0.0.1:5000/hwlab/hwlab-go-env-base:go1-bookworm-slim"; + deploy.lanes.v03.envRecipe.runtimeGoModCachePath = "/opt/hwlab-env/go/pkg/mod"; + deploy.lanes.v03.envRecipe.runtimeGoBuildCachePath = "/opt/hwlab-env/go/cache"; + deploy.lanes.v03.envRecipe.goToolchain = "local"; deploy.lanes.v03.serviceDeclarations["hwlab-user-billing"] = { runtimeKind: "go-service", entrypoint: "cmd/hwlab-user-billing/main.go", diff --git a/scripts/src/ci-plan-lib.mjs b/scripts/src/ci-plan-lib.mjs index 35819a8b..68197617 100644 --- a/scripts/src/ci-plan-lib.mjs +++ b/scripts/src/ci-plan-lib.mjs @@ -504,6 +504,7 @@ function envReuseRecipeForLaneConfig(laneConfig, lane = "v02") { const runtimeGoModCachePath = normalizeAbsolutePath(configured.runtimeGoModCachePath); const runtimeGoBuildCachePath = normalizeAbsolutePath(configured.runtimeGoBuildCachePath); const goToolchain = normalizeDeclarationString(configured.goToolchain); + const goBaseImage = normalizeDeclarationString(configured.goBaseImage); if (!runtimeNodeModulesPath) throw new Error(`deploy.lanes.${lane}.envRecipe.runtimeNodeModulesPath must be absolute`); const additionalEnvPaths = uniqueSorted(normalizeStringList(configured.additionalEnvPaths, []).map(normalizeRepoPath)); const launcherInputPaths = uniqueSorted([ @@ -527,6 +528,7 @@ function envReuseRecipeForLaneConfig(laneConfig, lane = "v02") { runtimeGoModCachePath, runtimeGoBuildCachePath, goToolchain, + goBaseImage, additionalEnvPaths, launcherInputPaths, downloadStack, @@ -540,6 +542,7 @@ function envReuseRecipeForLaneConfig(laneConfig, lane = "v02") { runtimeGoModCachePath, runtimeGoBuildCachePath, goToolchain, + goBaseImage, additionalEnvPaths, downloadStack, hwpodAliases @@ -554,6 +557,7 @@ function envReuseRecipeForService(recipe, model) { runtimeGoModCachePath: _runtimeGoModCachePath, runtimeGoBuildCachePath: _runtimeGoBuildCachePath, goToolchain: _goToolchain, + goBaseImage: _goBaseImage, ...nodeRecipe } = recipe; return nodeRecipe;