From 4f94865951679a62f5ff8c89faedd5f26735063f Mon Sep 17 00:00:00 2001 From: David Michon Date: Fri, 13 Dec 2024 16:38:28 -0800 Subject: [PATCH] [rush] Fix build cache ids when "enableSubPathScan" is enabled (#5045) Co-authored-by: David Michon --- .../rush/git-filter-fixes_2024-12-14-00-09.json | 10 ++++++++++ .../src/cli/scriptActions/PhasedScriptAction.ts | 7 ++++++- libraries/rush-lib/src/logic/ProjectChangeAnalyzer.ts | 3 ++- 3 files changed, 18 insertions(+), 2 deletions(-) create mode 100644 common/changes/@microsoft/rush/git-filter-fixes_2024-12-14-00-09.json diff --git a/common/changes/@microsoft/rush/git-filter-fixes_2024-12-14-00-09.json b/common/changes/@microsoft/rush/git-filter-fixes_2024-12-14-00-09.json new file mode 100644 index 0000000000..34e8460eab --- /dev/null +++ b/common/changes/@microsoft/rush/git-filter-fixes_2024-12-14-00-09.json @@ -0,0 +1,10 @@ +{ + "changes": [ + { + "packageName": "@microsoft/rush", + "comment": "Fix an issue with the `enableSubpathScan` experiment where the set of returned hashes would result in incorrect build cache identifiers when using `--only`.", + "type": "none" + } + ], + "packageName": "@microsoft/rush" +} \ No newline at end of file diff --git a/libraries/rush-lib/src/cli/scriptActions/PhasedScriptAction.ts b/libraries/rush-lib/src/cli/scriptActions/PhasedScriptAction.ts index f182b9173b..4bc5acf731 100644 --- a/libraries/rush-lib/src/cli/scriptActions/PhasedScriptAction.ts +++ b/libraries/rush-lib/src/cli/scriptActions/PhasedScriptAction.ts @@ -556,7 +556,12 @@ export class PhasedScriptAction extends BaseScriptAction { const analyzer: ProjectChangeAnalyzer = new ProjectChangeAnalyzer(this.rushConfiguration); const getInputsSnapshotAsync: GetInputsSnapshotAsyncFn | undefined = - await analyzer._tryGetSnapshotProviderAsync(projectConfigurations, terminal, projectSelection); + await analyzer._tryGetSnapshotProviderAsync( + projectConfigurations, + terminal, + // We need to include all dependencies, otherwise build cache id calculation will be incorrect + Selection.expandAllDependencies(projectSelection) + ); const initialSnapshot: IInputsSnapshot | undefined = await getInputsSnapshotAsync?.(); repoStateStopwatch.stop(); diff --git a/libraries/rush-lib/src/logic/ProjectChangeAnalyzer.ts b/libraries/rush-lib/src/logic/ProjectChangeAnalyzer.ts index 5916d0db0c..a2adc060d5 100644 --- a/libraries/rush-lib/src/logic/ProjectChangeAnalyzer.ts +++ b/libraries/rush-lib/src/logic/ProjectChangeAnalyzer.ts @@ -296,9 +296,10 @@ export class ProjectChangeAnalyzer { if ( projectSelection && + projectSelection.size > 0 && this._rushConfiguration.experimentsConfiguration.configuration.enableSubpathScan ) { - filterPath = Array.from(projectSelection).map(({ projectFolder }) => projectFolder); + filterPath = Array.from(projectSelection, ({ projectFolder }) => projectFolder); } return async function tryGetSnapshotAsync(): Promise {