fix: scope Go envreuse packages to Go services (#1131)

This commit is contained in:
Lyon
2026-06-13 16:22:21 +08:00
committed by GitHub
parent 0edcf9e588
commit ea3b26b895
4 changed files with 36 additions and 3 deletions
+21 -2
View File
@@ -97,6 +97,7 @@ export async function createCiPlan(options = {}) {
const buildSystemMatches = matchingPaths(normalizedChangedPaths, model.buildSystemPaths);
const envReuse = envReuseServices.has(model.serviceId);
const bootSh = envReuse ? bootShForService(deployJson, model.serviceId, lane) : null;
const serviceEnvReuseRecipe = envReuse ? envReuseRecipeForService(envReuseRecipe.publicRecipe, model) : null;
const envInputPaths = envReuse ? uniqueSorted([
...model.runtimeDeps,
...envReuseRecipe.launcherInputPaths
@@ -120,7 +121,7 @@ export async function createCiPlan(options = {}) {
...buildSystemMatches
].filter((item) => !isTestOnlyPath(item) && !isDocsOnlyPath(item)));
const catalogRecord = catalogByServiceId.get(model.serviceId) ?? null;
const environmentInputHash = envReuse ? await hashEnvReuseInputs(repoRoot, targetRef, envInputPaths, envReuseRecipe.publicRecipe, {
const environmentInputHash = envReuse ? await hashEnvReuseInputs(repoRoot, targetRef, envInputPaths, serviceEnvReuseRecipe, {
skipPath: (filePath) => isTestOnlyPath(filePath) || isDocsOnlyPath(filePath),
semanticPackageJson: true
}) : null;
@@ -202,7 +203,7 @@ export async function createCiPlan(options = {}) {
sharedPaths: model.sharedPaths,
runtimeDeps: model.runtimeDeps,
buildSystemPaths: model.buildSystemPaths,
envReuseRecipe: envReuse ? envReuseRecipe.publicRecipe : null,
envReuseRecipe: serviceEnvReuseRecipe,
componentCommitId,
componentInputHash,
catalogSourceCommitId: catalogSourceCommitId || null,
@@ -363,6 +364,7 @@ function envReuseRecipeForLaneConfig(laneConfig, lane = "v02") {
const configured = laneConfig?.envRecipe;
if (!configured) throw new Error(`deploy.lanes.${lane}.envRecipe is required`);
const osPackages = normalizeStringList(configured.osPackages, []);
const goOsPackages = normalizeStringList(configured.goOsPackages, []);
const bunVersion = requireDeclarationString(configured.bunVersion, lane, "envRecipe.bunVersion");
const launcherPath = normalizeRepoPath(requireDeclarationString(configured.launcherPath, lane, "envRecipe.launcherPath"));
const runtimeNodeModulesPath = normalizeAbsolutePath(configured.runtimeNodeModulesPath);
@@ -378,10 +380,14 @@ function envReuseRecipeForLaneConfig(laneConfig, lane = "v02") {
const hwpodAliases = normalizeHwpodAliases(configured.hwpodAliases);
const downloadStack = normalizeDownloadStack(configured.downloadStack, lane);
if (osPackages.length === 0) throw new Error(`deploy.lanes.${lane}.envRecipe.osPackages is required`);
if ((runtimeGoModCachePath || runtimeGoBuildCachePath) && goOsPackages.length === 0) {
throw new Error(`deploy.lanes.${lane}.envRecipe.goOsPackages is required when Go cache paths are configured`);
}
if (additionalEnvPaths.length === 0) throw new Error(`deploy.lanes.${lane}.envRecipe.additionalEnvPaths is required`);
if (hwpodAliases.length === 0) throw new Error(`deploy.lanes.${lane}.envRecipe.hwpodAliases is required`);
return {
osPackages,
goOsPackages,
bunVersion,
launcherPath,
runtimeNodeModulesPath,
@@ -394,6 +400,7 @@ function envReuseRecipeForLaneConfig(laneConfig, lane = "v02") {
hwpodAliases,
publicRecipe: {
osPackages,
goOsPackages,
bunVersion,
launcherPath,
runtimeNodeModulesPath,
@@ -407,6 +414,18 @@ function envReuseRecipeForLaneConfig(laneConfig, lane = "v02") {
};
}
function envReuseRecipeForService(recipe, model) {
if (model?.runtimeKind === "go-service" || model?.artifactKind === "go-service") return recipe;
const {
goOsPackages: _goOsPackages,
runtimeGoModCachePath: _runtimeGoModCachePath,
runtimeGoBuildCachePath: _runtimeGoBuildCachePath,
goToolchain: _goToolchain,
...nodeRecipe
} = recipe;
return nodeRecipe;
}
function normalizeDownloadStack(value, lane) {
const configured = effectiveDownloadStackConfig(value, process.env);
if (!configured) throw new Error(`deploy.lanes.${lane}.envRecipe.downloadStack is required`);