fix(cicd): absorb semantic code hash drift

This commit is contained in:
root
2026-07-21 12:50:35 +02:00
parent 7d2c66bebd
commit 61ffb311c8
2 changed files with 23 additions and 2 deletions
+16 -2
View File
@@ -161,6 +161,7 @@ export async function createCiPlan(options = {}) {
...buildSystemMatches
].filter((item) => !isTestOnlyPath(item) && !isDocsOnlyPath(item)));
const catalogRecord = catalogByServiceId.get(model.serviceId) ?? null;
const catalogEnvironmentSourceCommitId = envReuse ? text(catalogRecord?.sourceCommitId) : "";
const environmentInputHash = envReuse ? await hashEnvReuseInputs(repoRoot, targetRef, envInputPaths, serviceEnvReuseRecipe, {
skipPath: (filePath) => isTestOnlyPath(filePath) || isDocsOnlyPath(filePath),
semanticPackageJson: true
@@ -169,10 +170,15 @@ export async function createCiPlan(options = {}) {
skipPath: (filePath) => isTestOnlyPath(filePath) || isDocsOnlyPath(filePath),
semanticPackageJson: true
}) : null;
const catalogCodeInputHashAtSource = envReuse && catalogEnvironmentSourceCommitId
? await hashGitPathsIfCommitExists(repoRoot, catalogEnvironmentSourceCommitId, codeInputPaths, {
skipPath: (filePath) => isTestOnlyPath(filePath) || isDocsOnlyPath(filePath),
semanticPackageJson: true
})
: null;
const currentEnvironmentImage = envReuse ? envReuseImageRef(registryPrefix, model.serviceId, environmentInputHash, envArtifactGroup) : null;
const catalogEnvironmentImage = envReuse ? environmentImageFromCatalog(model.serviceId, catalogRecord) : null;
const catalogEnvironmentDigest = envReuse ? environmentDigestFromCatalog(catalogRecord) : null;
const catalogEnvironmentSourceCommitId = envReuse ? text(catalogRecord?.sourceCommitId) : "";
const catalogEnvironmentInputHashAtSource = envReuse && catalogEnvironmentSourceCommitId
? await hashEnvReuseInputsIfCommitExists(repoRoot, catalogEnvironmentSourceCommitId, envInputPaths, serviceEnvReuseRecipe, {
skipPath: (filePath) => isTestOnlyPath(filePath) || isDocsOnlyPath(filePath),
@@ -224,7 +230,12 @@ export async function createCiPlan(options = {}) {
const effectiveEnvironmentInputChanged = environmentInputChanged === true && !environmentMetadataHashDrift;
const environmentReady = envReuse && Boolean(environmentImage) && (reuseRegistryProbe ? reuseRegistry?.status === "present" && digestReady : !effectiveEnvironmentInputChanged && digestReady);
const envChanged = envReuse ? Boolean(relevantEnvMatches.length > 0 || !environmentReady || reuseRegistryUnavailable) : null;
const codeChanged = envReuse ? relevantCodeMatches.length > 0 || catalogRecord?.codeInputHash !== codeInputHash : null;
const codeInputChanged = envReuse ? catalogRecord?.codeInputHash !== codeInputHash : null;
const codeMetadataHashDrift = envReuse
&& codeInputChanged === true
&& Boolean(catalogCodeInputHashAtSource)
&& catalogCodeInputHashAtSource === codeInputHash;
const codeChanged = envReuse ? relevantCodeMatches.length > 0 || (codeInputChanged === true && !codeMetadataHashDrift) : null;
const componentInputPaths = uniqueSorted([
...model.componentPaths,
...model.sharedPaths,
@@ -338,6 +349,9 @@ export async function createCiPlan(options = {}) {
catalogEnvironmentInputHashAtSource,
environmentSourceUnchanged,
codeChanged,
codeInputChanged,
codeMetadataHashDrift,
catalogCodeInputHashAtSource,
reuseRegistry,
environmentInputHash,
codeInputHash,