diff --git a/build-tools/packages/build-cli/src/commands/generate/layerCompatGeneration.ts b/build-tools/packages/build-cli/src/commands/generate/layerCompatGeneration.ts index e503f6f2b91d..3dbbff30ea39 100644 --- a/build-tools/packages/build-cli/src/commands/generate/layerCompatGeneration.ts +++ b/build-tools/packages/build-cli/src/commands/generate/layerCompatGeneration.ts @@ -138,7 +138,7 @@ export function generateLayerFileContent(generation: number): string { * Copyright (c) Microsoft Corporation and contributors. All rights reserved. * Licensed under the MIT License. * - * THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY. + * THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY */ export const generation = ${generation}; diff --git a/build-tools/packages/build-cli/src/handlers/checkFunctions.ts b/build-tools/packages/build-cli/src/handlers/checkFunctions.ts index c069a83d357a..1c6fd90426c4 100644 --- a/build-tools/packages/build-cli/src/handlers/checkFunctions.ts +++ b/build-tools/packages/build-cli/src/handlers/checkFunctions.ts @@ -430,7 +430,7 @@ export const checkPolicy: StateHandlerFunction = async ( }; /** - * Checks that a release branch exists. + * Checks whether assert tagging has been done. * * @param state - The current state machine state. * @param machine - The state machine. @@ -903,3 +903,54 @@ export const checkValidReleaseGroup: StateHandlerFunction = async ( return true; }; + +/** + * Checks whether layer compat generation needs to be updated. + * + * @param state - The current state machine state. + * @param machine - The state machine. + * @param testMode - Set to true to run function in test mode. + * @param log - A logger that the function can use for logging. + * @param data - An object with handler-specific contextual data. + * @returns True if the state was handled; false otherwise. + */ +export const checkLayerCompatGeneration: StateHandlerFunction = async ( + state: MachineState, + machine: Machine, + testMode: boolean, + log: CommandLogger, + data: FluidReleaseStateHandlerData, +): Promise => { + if (testMode) return true; + + const { context, bumpType } = data; + const gitRepo = await context.getGitRepository(); + + if (bumpType === "patch") { + log.verbose(`Skipping layer compat generation check for patch release.`); + BaseStateHandler.signalSuccess(machine, state); + 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); + + // check for policy check violation + const afterPolicyCheckStatus = await gitRepo.gitClient.status(); + const isClean = afterPolicyCheckStatus.isClean(); + if (!isClean) { + 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")}`, + ); + BaseStateHandler.signalFailure(machine, state); + return false; + } + + BaseStateHandler.signalSuccess(machine, state); + return true; +}; diff --git a/build-tools/packages/build-cli/src/handlers/fluidReleaseStateHandler.ts b/build-tools/packages/build-cli/src/handlers/fluidReleaseStateHandler.ts index 7253cc5946a8..554b39bb833d 100644 --- a/build-tools/packages/build-cli/src/handlers/fluidReleaseStateHandler.ts +++ b/build-tools/packages/build-cli/src/handlers/fluidReleaseStateHandler.ts @@ -26,6 +26,7 @@ import { checkDependenciesInstalled, checkDoesReleaseFromReleaseBranch, checkHasRemote, + checkLayerCompatGeneration, checkMainNextIntegrated, checkNoPrereleaseDependencies, checkOnReleaseBranch, @@ -163,6 +164,7 @@ export class FluidReleaseStateHandler extends InitFailedStateHandler { ["CheckDoesReleaseFromReleaseBranch2", checkDoesReleaseFromReleaseBranch], ["CheckDoesReleaseFromReleaseBranch3", checkDoesReleaseFromReleaseBranch], ["CheckHasRemote", checkHasRemote], + ["CheckLayerCompatGeneration", checkLayerCompatGeneration], ["CheckMainNextIntegrated", checkMainNextIntegrated], ["CheckNoPrereleaseDependencies", checkNoPrereleaseDependencies], ["CheckNoPrereleaseDependencies2", checkNoPrereleaseDependencies], diff --git a/build-tools/packages/build-cli/src/machines/FluidRelease.fsl b/build-tools/packages/build-cli/src/machines/FluidRelease.fsl index 16781f5d4159..d5cd3b51095a 100644 --- a/build-tools/packages/build-cli/src/machines/FluidRelease.fsl +++ b/build-tools/packages/build-cli/src/machines/FluidRelease.fsl @@ -68,6 +68,7 @@ Init 'success' => CheckDependenciesInstalled 'success' => CheckPolicy 'success' => CheckAssertTagging 'success' +=> CheckLayerCompatGeneration 'success' => CheckReleaseNotes 'success' => CheckChangelogs 'success' => CheckHasRemote 'success' @@ -94,6 +95,10 @@ CheckPolicy CheckAssertTagging ] 'failure' -> PromptToCommitPolicy; +[ +CheckLayerCompatGeneration +] 'failure' -> PromptToCommitPolicy; + [ CheckReleaseNotes ] 'failure' -> PromptToGenerateReleaseNotes; diff --git a/build-tools/packages/build-cli/src/machines/FluidRelease.fsl.svg b/build-tools/packages/build-cli/src/machines/FluidRelease.fsl.svg index f0a4f8b70b17..c35585641e5f 100644 --- a/build-tools/packages/build-cli/src/machines/FluidRelease.fsl.svg +++ b/build-tools/packages/build-cli/src/machines/FluidRelease.fsl.svg @@ -4,8 +4,8 @@ - + - + G - + n0 - -Init + +Init n1 - -CheckShouldRunOptionalChecks + +CheckShouldRunOptionalChecks n0->n1 - - -success + + +success - - -n13 - -Failed + + +n14 + +Failed - + -n0->n13 - - -failure +n0->n14 + + +failure n2 - -CheckValidReleaseGroup + +CheckValidReleaseGroup n1->n2 - - -success + + +success - - -n10 - -CheckNoPrereleaseDependencies + + +n11 + +CheckNoPrereleaseDependencies - + -n1->n10 - - -failure +n1->n11 + + +failure n3 - -CheckDependenciesInstalled + +CheckDependenciesInstalled n2->n3 - - -success + + +success - + -n2->n13 - - -failure +n2->n14 + + +failure n4 - -CheckPolicy + +CheckPolicy n3->n4 - - -success + + +success - + -n3->n13 - - -failure +n3->n14 + + +failure n5 - -CheckAssertTagging + +CheckAssertTagging n4->n5 - - -success + + +success - - -n14 - -PromptToCommitPolicy + + +n15 + +PromptToCommitPolicy - + -n4->n14 - - -failure +n4->n15 + + +failure n6 - -CheckReleaseNotes + +CheckLayerCompatGeneration n5->n6 - - -success + + +success - + -n5->n14 - - -failure +n5->n15 + + +failure n7 - -CheckChangelogs + +CheckReleaseNotes n6->n7 - - -success - - - -n15 - -PromptToGenerateReleaseNotes + + +success n6->n15 - - -failure + + +failure n8 - -CheckHasRemote + +CheckChangelogs n7->n8 - - -success + + +success n16 - -PromptToGenerateChangelogs + +PromptToGenerateReleaseNotes n7->n16 - - -failure + + +failure n9 - -CheckBranchUpToDate + +CheckHasRemote n8->n9 - - -success + + +success + + + +n17 + +PromptToGenerateChangelogs - + -n8->n13 - - -failure +n8->n17 + + +failure + + + +n10 + +CheckBranchUpToDate n9->n10 - - -success + + +success - + -n9->n13 - - -failure - - - -n11 - -AskForReleaseType +n9->n14 + + +failure n10->n11 - - -success + + +success + + + +n10->n14 + + +failure n12 + +AskForReleaseType + + + +n11->n12 + + +success + + + +n13 DoBumpReleasedDependencies - - -n10->n12 - - -failure + + +n11->n13 + + +failure - - -n30 + + +n31 DoPatchRelease - - -n11->n30 - - -patch + + +n12->n31 + + +patch - - -n42 + + +n43 DoMinorRelease - - -n11->n42 - + + +n12->n43 + -minor +minor - - -n51 + + +n52 DoMajorRelease - - -n11->n51 - - -major + + +n12->n52 + + +major - - -n17 + + +n18 CheckNoPrereleaseDependencies2 - - -n12->n17 + + +n13->n18 success - - -n20 + + +n21 CheckNoPrereleaseDependencies3 - - -n12->n20 + + +n13->n21 failure - - -n18 + + +n19 CheckShouldCommitDeps - - -n17->n18 + + +n18->n19 success - - -n21 + + +n22 PromptToReleaseDeps - - -n17->n21 + + +n18->n22 failure - - -n19 + + +n20 PromptToPRDeps - - -n18->n19 + + +n19->n20 success - - -n25 + + +n26 PromptToCommitDeps - - -n18->n25 + + +n19->n26 failure - - -n20->n21 + + +n21->n22 failure - - -n22 + + +n23 CheckShouldCommitReleasedDepsBump - - -n20->n22 + + +n21->n23 success - - -n23 + + +n24 PromptToPRReleasedDepsBump - - -n22->n23 + + +n23->n24 success - - -n24 + + +n25 PromptToCommitReleasedDepsBump - - -n22->n24 + + +n23->n25 failure - - -n26 - -DoReleaseGroupBump - n27 + +DoReleaseGroupBump + + + +n28 CheckShouldCommitBump - - -n26->n27 + + +n27->n28 success - - -n28 + + +n29 PromptToPRBump - - -n27->n28 + + +n28->n29 success - - -n29 + + +n30 PromptToCommitBump - - -n27->n29 + + +n28->n30 failure - - -n31 - -CheckDoesReleaseFromReleaseBranch - - - -n30->n31 - - -success - n32 - -CheckOnReleaseBranch + +CheckDoesReleaseFromReleaseBranch - + n31->n32 - - -success + + +success n33 - -CheckReleaseIsDone - - - -n31->n33 - - -failure - - - -n32->n13 - - -failure + +CheckOnReleaseBranch n32->n33 - - -success + + +success n34 - -CheckReleaseGroupIsBumpedPatch + +CheckReleaseIsDone + + + +n32->n34 + + +failure + + + +n33->n14 + + +failure n33->n34 + + +success + + + +n35 + +CheckReleaseGroupIsBumpedPatch + + + +n34->n35 success - - -n38 + + +n39 PromptToRelease - - -n33->n38 + + +n34->n39 failure - - -n34->n26 + + +n35->n27 failure - - -n35 + + +n36 CheckTypeTestPrepare - - -n34->n35 + + +n35->n36 success - - -n36 + + +n37 CheckTypeTestGenerate - - -n35->n36 + + +n36->n37 success - - -n39 + + +n40 PromptToRunTypeTests - - -n35->n39 + + +n36->n40 failure - - -n37 + + +n38 ReleaseComplete - - -n36->n37 + + +n37->n38 success - - -n36->n39 + + +n37->n40 failure - - -n40 + + +n41 CheckTypeTestPrepare2 - - -n40->n39 + + +n41->n40 failure - - -n41 + + +n42 CheckTypeTestGenerate2 - - -n40->n41 + + +n41->n42 success - - -n41->n37 + + +n42->n38 success - - -n41->n39 + + +n42->n40 failure - - -n43 + + +n44 CheckDoesReleaseFromReleaseBranch2 - - -n42->n43 + + +n43->n44 success - - -n44 + + +n45 CheckOnReleaseBranch2 - - -n43->n44 + + +n44->n45 success - - -n46 + + +n47 CheckReleaseIsDone2 - - -n43->n46 + + +n44->n47 failure - - -n45 + + +n46 CheckReleaseGroupIsBumpedPatch2 - - -n44->n45 + + +n45->n46 success - - -n48 + + +n49 CheckReleaseGroupIsBumpedMinor - - -n44->n48 + + +n45->n49 failure - - -n45->n26 + + +n46->n27 failure - - -n45->n46 + + +n46->n47 success - - -n46->n38 + + +n47->n39 failure - - -n47 + + +n48 CheckReleaseGroupIsBumpedMinor2 - - -n46->n47 + + +n47->n48 success - - -n47->n26 + + +n48->n27 failure - - -n47->n40 + + +n48->n41 success - - -n48->n26 + + +n49->n27 failure - - -n49 + + +n50 CheckReleaseBranchExists - - -n48->n49 + + +n49->n50 success - - -n49->n33 + + +n50->n34 success - - -n50 + + +n51 PromptToCreateReleaseBranch - - -n49->n50 + + +n50->n51 failure - - -n52 - -CheckDoesReleaseFromReleaseBranch3 - - - -n51->n52 - - -success - n53 - -CheckMainNextIntegrated + +CheckDoesReleaseFromReleaseBranch3 - + n52->n53 - - -success + + +success n54 - -CheckReleaseIsDone3 - - - -n52->n54 - - -failure + +CheckMainNextIntegrated n53->n54 - - -success + + +success n55 - -CheckOnReleaseBranch3 + +CheckReleaseIsDone3 n53->n55 - - -failure - - - -n54->n38 - - -success + + +failure - + -n54->n42 - - -failure - - - -n55->n13 - - -success +n54->n55 + + +success n56 - -CheckBranchName + +CheckOnReleaseBranch3 + + + +n54->n56 + + +failure - + -n55->n56 - - -failure +n55->n39 + + +success - - -n56->n13 - - -failure + + +n55->n43 + + +failure + + + +n56->n14 + + +success n57 - -PromptToIntegrateNext + +CheckBranchName - + n56->n57 - - -success + + +failure + + + +n57->n14 + + +failure + + + +n58 + +PromptToIntegrateNext + + + +n57->n58 + + +success diff --git a/build-tools/packages/build-tools/src/fluidBuild/fluidCompatMetadata.ts b/build-tools/packages/build-tools/src/fluidBuild/fluidCompatMetadata.ts index 5f72545bedad..f2fc37167ca6 100644 --- a/build-tools/packages/build-tools/src/fluidBuild/fluidCompatMetadata.ts +++ b/build-tools/packages/build-tools/src/fluidBuild/fluidCompatMetadata.ts @@ -7,7 +7,7 @@ * Metadata used for Fluid compatibility tracking and validation. */ export interface IFluidCompatibilityMetadata { - /** The generation of a Fluid layer which is used for validating layer compatibility */ + /** The current generation of a Fluid layer which is used for validating layer compatibility */ generation: number; /** The release date when the generation was last updated. Must be in YYYY-MM-DD format */ releaseDate: string;