From 805129ea55f15e9893b9dd670019632307f2dff6 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Mon, 24 Nov 2025 19:11:36 +0000 Subject: [PATCH 1/5] Initial plan From e4e64e5655c3e5c7b59e53d5894799210f0ee2f7 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Mon, 24 Nov 2025 19:21:27 +0000 Subject: [PATCH 2/5] Add CheckCompatLayerGeneration to release prepare command Co-authored-by: tylerbutler <19589+tylerbutler@users.noreply.github.com> --- .../build-cli/src/commands/release/prepare.ts | 2 + .../build-cli/src/handlers/checkFunctions.ts | 18 +++----- .../packages/build-cli/src/library/index.ts | 1 + .../src/library/releasePrepChecks.ts | 43 +++++++++++++++++++ 4 files changed, 52 insertions(+), 12 deletions(-) diff --git a/build-tools/packages/build-cli/src/commands/release/prepare.ts b/build-tools/packages/build-cli/src/commands/release/prepare.ts index 689f649de315..8bcbef886e23 100644 --- a/build-tools/packages/build-cli/src/commands/release/prepare.ts +++ b/build-tools/packages/build-cli/src/commands/release/prepare.ts @@ -8,6 +8,7 @@ import chalk from "picocolors"; import { findPackageOrReleaseGroup, packageOrReleaseGroupArg } from "../../args.js"; import { BaseCommand } from "../../library/index.js"; import { + CheckCompatLayerGeneration, CheckDependenciesInstalled, type CheckFunction, CheckHasNoPrereleaseDependencies, @@ -32,6 +33,7 @@ const allChecks: ReadonlyMap = new Map([ ["Has no pre-release Fluid dependencies", CheckHasNoPrereleaseDependencies], ["No repo policy violations", CheckNoPolicyViolations], ["No untagged asserts", CheckNoUntaggedAsserts], + ["Compatibility layer generation is up to date", CheckCompatLayerGeneration], ]); /** diff --git a/build-tools/packages/build-cli/src/handlers/checkFunctions.ts b/build-tools/packages/build-cli/src/handlers/checkFunctions.ts index 608815809015..b673a6514415 100644 --- a/build-tools/packages/build-cli/src/handlers/checkFunctions.ts +++ b/build-tools/packages/build-cli/src/handlers/checkFunctions.ts @@ -22,6 +22,9 @@ import { getPreReleaseDependencies, getReleaseSourceForReleaseGroup, isReleased, + // library is overloaded with too much stuff now, and we should consider allowing interior imports. + // eslint-disable-next-line import/no-internal-modules + runCompatLayerGenerationCheck, } from "../library/index.js"; import type { CommandLogger } from "../logging.js"; import type { MachineState } from "../machines/index.js"; @@ -931,21 +934,12 @@ export const checkCompatLayerGeneration: StateHandlerFunction = async ( return true; } - // layerGeneration:gen should be run from the root. It will only update packages that have the layerGeneration:gen - // script defined in their package.json. - const result = await execa.command(`pnpm run -r layerGeneration:gen`, { - cwd: context.root, - }); - log.verbose(result.stdout); + const isUpToDate = await runCompatLayerGenerationCheck(context); - // check for policy check violation - const gitRepo = await context.getGitRepository(); - const afterPolicyCheckStatus = await gitRepo.gitClient.status(); - const isClean = afterPolicyCheckStatus.isClean(); - if (!isClean) { + if (!isUpToDate) { log.logHr(); log.errorLog( - `Layer generation needs to be updated. Please create a PR for the changes and merge before retrying.\n${afterPolicyCheckStatus.files.map((fileStatus) => `${fileStatus.index} ${fileStatus.path}`).join("\n")}`, + `Layer generation needs to be updated. Please create a PR for the changes and merge before retrying.`, ); BaseStateHandler.signalFailure(machine, state); return false; diff --git a/build-tools/packages/build-cli/src/library/index.ts b/build-tools/packages/build-cli/src/library/index.ts index 5e2c4070012a..cb0e7afd397b 100644 --- a/build-tools/packages/build-cli/src/library/index.ts +++ b/build-tools/packages/build-cli/src/library/index.ts @@ -65,3 +65,4 @@ export { } from "./release.js"; export { LayerGraph } from "./layerGraph.js"; export { type Handler, policyHandlers } from "./repoPolicyCheck/index.js"; +export { runCompatLayerGenerationCheck } from "./releasePrepChecks.js"; diff --git a/build-tools/packages/build-cli/src/library/releasePrepChecks.ts b/build-tools/packages/build-cli/src/library/releasePrepChecks.ts index af48f19b6e3e..5f400a2e631e 100644 --- a/build-tools/packages/build-cli/src/library/releasePrepChecks.ts +++ b/build-tools/packages/build-cli/src/library/releasePrepChecks.ts @@ -228,3 +228,46 @@ export const CheckNoUntaggedAsserts: CheckFunction = async ( }; } }; + +/** + * Runs the compatibility layer generation command and checks if it made any changes to the repository. + * This is a shared helper function used by both the prepare command checks and the state machine checks. + * + * @param context - The repository context. + * @returns `true` if no changes were made (i.e., layer generation is up to date), `false` otherwise. + */ +export async function runCompatLayerGenerationCheck(context: Context): Promise { + // layerGeneration:gen should be run from the root. It will only update packages that have the layerGeneration:gen + // script defined in their package.json. + await execa("pnpm", ["run", "-r", "layerGeneration:gen"], { + cwd: context.root, + }); + + // check if the command made any changes + const gitRepo = await context.getGitRepository(); + const afterGenStatus = await gitRepo.gitClient.status(); + const isClean = afterGenStatus.isClean(); + + // Reset any changes that were made + if (!isClean) { + await gitRepo.gitClient.reset(ResetMode.HARD); + } + + return isClean; +} + +/** + * Checks that the compatibility layer generation is up to date. Any necessary changes will return a failure result. + */ +export const CheckCompatLayerGeneration: CheckFunction = async ( + context: Context, +): Promise => { + const isUpToDate = await runCompatLayerGenerationCheck(context); + + if (!isUpToDate) { + return { + message: "Layer generation needs to be updated.", + fixCommand: "pnpm run -r layerGeneration:gen", + }; + } +}; From 05fec9f26ed3342781b945f40793ca3bce4104e9 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Mon, 24 Nov 2025 19:24:20 +0000 Subject: [PATCH 3/5] Fix CheckCompatLayerGeneration function signature and return statement Co-authored-by: tylerbutler <19589+tylerbutler@users.noreply.github.com> --- .../packages/build-cli/src/library/releasePrepChecks.ts | 3 +++ 1 file changed, 3 insertions(+) diff --git a/build-tools/packages/build-cli/src/library/releasePrepChecks.ts b/build-tools/packages/build-cli/src/library/releasePrepChecks.ts index 5f400a2e631e..c476c0766521 100644 --- a/build-tools/packages/build-cli/src/library/releasePrepChecks.ts +++ b/build-tools/packages/build-cli/src/library/releasePrepChecks.ts @@ -261,6 +261,7 @@ export async function runCompatLayerGenerationCheck(context: Context): Promise => { const isUpToDate = await runCompatLayerGenerationCheck(context); @@ -270,4 +271,6 @@ export const CheckCompatLayerGeneration: CheckFunction = async ( fixCommand: "pnpm run -r layerGeneration:gen", }; } + + return; }; From 3b4a3dbab89948e0d42904d5714eea8521813a61 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Mon, 24 Nov 2025 19:25:50 +0000 Subject: [PATCH 4/5] Remove unnecessary eslint-disable comment Co-authored-by: tylerbutler <19589+tylerbutler@users.noreply.github.com> --- build-tools/packages/build-cli/src/handlers/checkFunctions.ts | 2 -- 1 file changed, 2 deletions(-) diff --git a/build-tools/packages/build-cli/src/handlers/checkFunctions.ts b/build-tools/packages/build-cli/src/handlers/checkFunctions.ts index b673a6514415..b3d60e119e68 100644 --- a/build-tools/packages/build-cli/src/handlers/checkFunctions.ts +++ b/build-tools/packages/build-cli/src/handlers/checkFunctions.ts @@ -22,8 +22,6 @@ import { getPreReleaseDependencies, getReleaseSourceForReleaseGroup, isReleased, - // library is overloaded with too much stuff now, and we should consider allowing interior imports. - // eslint-disable-next-line import/no-internal-modules runCompatLayerGenerationCheck, } from "../library/index.js"; import type { CommandLogger } from "../logging.js"; From 7571073a10f782d1e90323286092f20fc62ef4ba Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Mon, 24 Nov 2025 19:28:20 +0000 Subject: [PATCH 5/5] Mark unused releaseGroupOrPackage parameter with underscore prefix Co-authored-by: tylerbutler <19589+tylerbutler@users.noreply.github.com> --- build-tools/packages/build-cli/src/library/releasePrepChecks.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build-tools/packages/build-cli/src/library/releasePrepChecks.ts b/build-tools/packages/build-cli/src/library/releasePrepChecks.ts index c476c0766521..b5f48cf0f136 100644 --- a/build-tools/packages/build-cli/src/library/releasePrepChecks.ts +++ b/build-tools/packages/build-cli/src/library/releasePrepChecks.ts @@ -261,7 +261,7 @@ export async function runCompatLayerGenerationCheck(context: Context): Promise => { const isUpToDate = await runCompatLayerGenerationCheck(context);