From a31fb488545a572190e99354203dfcab9e40f78a Mon Sep 17 00:00:00 2001 From: Ze Cheng Date: Tue, 19 Sep 2023 22:50:03 -0700 Subject: [PATCH 1/5] feat(rush-lib): add experiment flag to allow skipping build with success with warning status --- common/config/rush/experiments.json | 6 ++++++ common/reviews/api/rush-lib.api.md | 1 + .../rush-lib/src/api/ExperimentsConfiguration.ts | 6 ++++++ .../src/cli/scriptActions/PhasedScriptAction.ts | 3 +++ .../src/logic/operations/LegacySkipPlugin.ts | 13 +++++++++++-- .../rush-lib/src/schemas/experiments.schema.json | 4 ++++ 6 files changed, 31 insertions(+), 2 deletions(-) diff --git a/common/config/rush/experiments.json b/common/config/rush/experiments.json index fef826208c3..cd6288f2281 100644 --- a/common/config/rush/experiments.json +++ b/common/config/rush/experiments.json @@ -36,6 +36,12 @@ */ // "buildCacheWithAllowWarningsInSuccessfulBuild": true, + /** + * If true, build skipping will respect the allowWarningsInSuccessfulBuild flag and skip builds with warnings. + * This will not replay warnings from the skipped build. + */ + // "buildSkipWithAllowWarningsInSuccessfulBuild": true, + /** * If true, the phased commands feature is enabled. To use this feature, create a "phased" command * in common/config/rush/command-line.json. diff --git a/common/reviews/api/rush-lib.api.md b/common/reviews/api/rush-lib.api.md index e7e22736cb8..88615c48574 100644 --- a/common/reviews/api/rush-lib.api.md +++ b/common/reviews/api/rush-lib.api.md @@ -444,6 +444,7 @@ export interface IExecutionResult { // @beta export interface IExperimentsJson { buildCacheWithAllowWarningsInSuccessfulBuild?: boolean; + buildSkipWithAllowWarningsInSuccessfulBuild?: boolean; cleanInstallAfterNpmrcChanges?: boolean; forbidPhantomResolvableNodeModulesFolders?: boolean; noChmodFieldInTarHeaderNormalization?: boolean; diff --git a/libraries/rush-lib/src/api/ExperimentsConfiguration.ts b/libraries/rush-lib/src/api/ExperimentsConfiguration.ts index 10b995ffee8..5c63db4acd5 100644 --- a/libraries/rush-lib/src/api/ExperimentsConfiguration.ts +++ b/libraries/rush-lib/src/api/ExperimentsConfiguration.ts @@ -49,6 +49,12 @@ export interface IExperimentsJson { */ buildCacheWithAllowWarningsInSuccessfulBuild?: boolean; + /** + * If true, build skipping will respect the allowWarningsInSuccessfulBuild flag and skip builds with warnings. + * This will not replay warnings from the skipped build. + */ + buildSkipWithAllowWarningsInSuccessfulBuild?: boolean; + /** * If true, the phased commands feature is enabled. To use this feature, create a "phased" command * in common/config/rush/command-line.json. diff --git a/libraries/rush-lib/src/cli/scriptActions/PhasedScriptAction.ts b/libraries/rush-lib/src/cli/scriptActions/PhasedScriptAction.ts index 376946bfc82..c0dffb75cd8 100644 --- a/libraries/rush-lib/src/cli/scriptActions/PhasedScriptAction.ts +++ b/libraries/rush-lib/src/cli/scriptActions/PhasedScriptAction.ts @@ -363,6 +363,9 @@ export class PhasedScriptAction extends BaseScriptAction { } else if (!this._disableBuildCache) { // Explicitly disabling the build cache also disables legacy skip detection. new LegacySkipPlugin({ + allowWarningsInSuccessfulBuild: + !!this.rushConfiguration.experimentsConfiguration.configuration + .buildSkipWithAllowWarningsInSuccessfulBuild, terminal, changedProjectsOnly, isIncrementalBuildAllowed: this._isIncrementalBuildAllowed diff --git a/libraries/rush-lib/src/logic/operations/LegacySkipPlugin.ts b/libraries/rush-lib/src/logic/operations/LegacySkipPlugin.ts index e3ab5eaa36f..638db6fcabf 100644 --- a/libraries/rush-lib/src/logic/operations/LegacySkipPlugin.ts +++ b/libraries/rush-lib/src/logic/operations/LegacySkipPlugin.ts @@ -55,6 +55,7 @@ export interface ILegacySkipPluginOptions { terminal: ITerminal; changedProjectsOnly: boolean; isIncrementalBuildAllowed: boolean; + allowWarningsInSuccessfulBuild: boolean; } /** @@ -72,7 +73,8 @@ export class LegacySkipPlugin implements IPhasedCommandPlugin { let projectChangeAnalyzer!: ProjectChangeAnalyzer; - const { terminal, changedProjectsOnly, isIncrementalBuildAllowed } = this._options; + const { terminal, changedProjectsOnly, isIncrementalBuildAllowed, allowWarningsInSuccessfulBuild } = + this._options; hooks.createOperations.tap( PLUGIN_NAME, @@ -257,7 +259,14 @@ export class LegacySkipPlugin implements IPhasedCommandPlugin { const { packageDeps, packageDepsPath } = skipRecord; - if ((packageDeps && status === OperationStatus.Success) || status === OperationStatus.NoOp) { + if ( + (packageDeps && status === OperationStatus.Success) || + (packageDeps && + status === OperationStatus.SuccessWithWarning && + record.operation.runner!.warningsAreAllowed && + allowWarningsInSuccessfulBuild) || + status === OperationStatus.NoOp + ) { // Write deps on success. await JsonFile.saveAsync(packageDeps, packageDepsPath, { ensureFolderExists: true diff --git a/libraries/rush-lib/src/schemas/experiments.schema.json b/libraries/rush-lib/src/schemas/experiments.schema.json index 4537cc375a8..d14fc18534d 100644 --- a/libraries/rush-lib/src/schemas/experiments.schema.json +++ b/libraries/rush-lib/src/schemas/experiments.schema.json @@ -34,6 +34,10 @@ "description": "If true, build caching will respect the allowWarningsInSuccessfulBuild flag and cache builds with warnings. This will not replay warnings from the cached build.", "type": "boolean" }, + "buildSkipWithAllowWarningsInSuccessfulBuild": { + "description": "If true, build skipping will respect the allowWarningsInSuccessfulBuild flag and skip builds with warnings. This will not replay warnings from the skipped build.", + "type": "boolean" + }, "phasedCommands": { "description": "If true, the phased commands feature is enabled. To use this feature, create a \"phased\" command in common/config/rush/command-line.json.", "type": "boolean" From d968c8a05df1c780d0237f552c047202d9fdd263 Mon Sep 17 00:00:00 2001 From: Ze Cheng Date: Tue, 19 Sep 2023 23:35:03 -0700 Subject: [PATCH 2/5] doc: add changelog --- ...kip-build-with-warning-status_2023-09-20-06-34.json | 10 ++++++++++ 1 file changed, 10 insertions(+) create mode 100644 common/changes/@microsoft/rush/feat-skip-build-with-warning-status_2023-09-20-06-34.json diff --git a/common/changes/@microsoft/rush/feat-skip-build-with-warning-status_2023-09-20-06-34.json b/common/changes/@microsoft/rush/feat-skip-build-with-warning-status_2023-09-20-06-34.json new file mode 100644 index 00000000000..155571c3b64 --- /dev/null +++ b/common/changes/@microsoft/rush/feat-skip-build-with-warning-status_2023-09-20-06-34.json @@ -0,0 +1,10 @@ +{ + "changes": [ + { + "packageName": "@microsoft/rush", + "comment": "Add experiment `buildSkipWithAllowWarningsInSuccessfulBuild` to allow skipping builds that succeeded with warnings in the previous run.", + "type": "none" + } + ], + "packageName": "@microsoft/rush" +} \ No newline at end of file From 13e39b8d2d86ce66d09d899b16247145da0beaac Mon Sep 17 00:00:00 2001 From: Ze Cheng Date: Thu, 16 Nov 2023 01:01:40 -0800 Subject: [PATCH 3/5] Update libraries/rush-lib/src/logic/operations/LegacySkipPlugin.ts Co-authored-by: Ian Clanton-Thuon --- .../rush-lib/src/logic/operations/LegacySkipPlugin.ts | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/libraries/rush-lib/src/logic/operations/LegacySkipPlugin.ts b/libraries/rush-lib/src/logic/operations/LegacySkipPlugin.ts index 638db6fcabf..cb4667469bf 100644 --- a/libraries/rush-lib/src/logic/operations/LegacySkipPlugin.ts +++ b/libraries/rush-lib/src/logic/operations/LegacySkipPlugin.ts @@ -260,12 +260,12 @@ export class LegacySkipPlugin implements IPhasedCommandPlugin { const { packageDeps, packageDepsPath } = skipRecord; if ( - (packageDeps && status === OperationStatus.Success) || + status === OperationStatus.NoOp || (packageDeps && - status === OperationStatus.SuccessWithWarning && - record.operation.runner!.warningsAreAllowed && - allowWarningsInSuccessfulBuild) || - status === OperationStatus.NoOp + (status === OperationStatus.Success || + (status === OperationStatus.SuccessWithWarning && + record.operation.runner!.warningsAreAllowed && + allowWarningsInSuccessfulBuild))) ) { // Write deps on success. await JsonFile.saveAsync(packageDeps, packageDepsPath, { From 0dac7f33e3afc3c542d7f11c58edda79d032ee0b Mon Sep 17 00:00:00 2001 From: Ze Cheng Date: Thu, 16 Nov 2023 01:02:37 -0800 Subject: [PATCH 4/5] Update libraries/rush-lib/src/logic/operations/LegacySkipPlugin.ts Co-authored-by: Ian Clanton-Thuon --- libraries/rush-lib/src/logic/operations/LegacySkipPlugin.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libraries/rush-lib/src/logic/operations/LegacySkipPlugin.ts b/libraries/rush-lib/src/logic/operations/LegacySkipPlugin.ts index cb4667469bf..f69438957a2 100644 --- a/libraries/rush-lib/src/logic/operations/LegacySkipPlugin.ts +++ b/libraries/rush-lib/src/logic/operations/LegacySkipPlugin.ts @@ -55,7 +55,7 @@ export interface ILegacySkipPluginOptions { terminal: ITerminal; changedProjectsOnly: boolean; isIncrementalBuildAllowed: boolean; - allowWarningsInSuccessfulBuild: boolean; + allowWarningsInSuccessfulBuild?: boolean; } /** From 2373889e2371515a13a2dae09bd320e7e1c9bae9 Mon Sep 17 00:00:00 2001 From: Ze Cheng Date: Thu, 16 Nov 2023 01:02:43 -0800 Subject: [PATCH 5/5] Update libraries/rush-lib/src/cli/scriptActions/PhasedScriptAction.ts Co-authored-by: Ian Clanton-Thuon --- libraries/rush-lib/src/cli/scriptActions/PhasedScriptAction.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libraries/rush-lib/src/cli/scriptActions/PhasedScriptAction.ts b/libraries/rush-lib/src/cli/scriptActions/PhasedScriptAction.ts index c0dffb75cd8..8401187841d 100644 --- a/libraries/rush-lib/src/cli/scriptActions/PhasedScriptAction.ts +++ b/libraries/rush-lib/src/cli/scriptActions/PhasedScriptAction.ts @@ -364,7 +364,7 @@ export class PhasedScriptAction extends BaseScriptAction { // Explicitly disabling the build cache also disables legacy skip detection. new LegacySkipPlugin({ allowWarningsInSuccessfulBuild: - !!this.rushConfiguration.experimentsConfiguration.configuration + this.rushConfiguration.experimentsConfiguration.configuration .buildSkipWithAllowWarningsInSuccessfulBuild, terminal, changedProjectsOnly,