Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What this done intentionally? I don't recall seeing a corresponding change to the command that generates this?

*/

export const generation = ${generation};
Expand Down
53 changes: 52 additions & 1 deletion build-tools/packages/build-cli/src/handlers/checkFunctions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -430,7 +430,7 @@ export const checkPolicy: StateHandlerFunction = async (
};

/**
* Checks that a release branch exists.
* Checks whether assert tagging has been done.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch!

*
* @param state - The current state machine state.
* @param machine - The state machine.
Expand Down Expand Up @@ -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 (
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The terminology still really confuses me here. We have a "layer check" tool. Are these the same layers?

state: MachineState,
machine: Machine<unknown>,
testMode: boolean,
log: CommandLogger,
data: FluidReleaseStateHandlerData,
): Promise<boolean> => {
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);
Comment on lines +937 to +940
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a reason we can't call the code that this command invokes? Exec-ing is the least preferred method of integrating if we can just call a function.


// 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;
};
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import {
checkDependenciesInstalled,
checkDoesReleaseFromReleaseBranch,
checkHasRemote,
checkLayerCompatGeneration,
checkMainNextIntegrated,
checkNoPrereleaseDependencies,
checkOnReleaseBranch,
Expand Down Expand Up @@ -163,6 +164,7 @@ export class FluidReleaseStateHandler extends InitFailedStateHandler {
["CheckDoesReleaseFromReleaseBranch2", checkDoesReleaseFromReleaseBranch],
["CheckDoesReleaseFromReleaseBranch3", checkDoesReleaseFromReleaseBranch],
["CheckHasRemote", checkHasRemote],
["CheckLayerCompatGeneration", checkLayerCompatGeneration],
["CheckMainNextIntegrated", checkMainNextIntegrated],
["CheckNoPrereleaseDependencies", checkNoPrereleaseDependencies],
["CheckNoPrereleaseDependencies2", checkNoPrereleaseDependencies],
Expand Down
5 changes: 5 additions & 0 deletions build-tools/packages/build-cli/src/machines/FluidRelease.fsl
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ Init 'success'
=> CheckDependenciesInstalled 'success'
=> CheckPolicy 'success'
=> CheckAssertTagging 'success'
=> CheckLayerCompatGeneration 'success'
=> CheckReleaseNotes 'success'
=> CheckChangelogs 'success'
=> CheckHasRemote 'success'
Expand All @@ -94,6 +95,10 @@ CheckPolicy
CheckAssertTagging
] 'failure' -> PromptToCommitPolicy;

[
CheckLayerCompatGeneration
] 'failure' -> PromptToCommitPolicy;

[
CheckReleaseNotes
] 'failure' -> PromptToGenerateReleaseNotes;
Expand Down
Loading