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 diff --git a/common/config/rush/experiments.json b/common/config/rush/experiments.json index b3a138a7d3e..678d6aff03b 100644 --- a/common/config/rush/experiments.json +++ b/common/config/rush/experiments.json @@ -43,6 +43,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 a5e578d26cf..933d6dfa19c 100644 --- a/common/reviews/api/rush-lib.api.md +++ b/common/reviews/api/rush-lib.api.md @@ -448,6 +448,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 e4525583459..8ad6e69dd76 100644 --- a/libraries/rush-lib/src/cli/scriptActions/PhasedScriptAction.ts +++ b/libraries/rush-lib/src/cli/scriptActions/PhasedScriptAction.ts @@ -365,6 +365,9 @@ export class PhasedScriptAction extends BaseScriptAction { terminal.writeVerboseLine(`Incremental strategy: output preservation`); // 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 656fe20760d..4b77efc7222 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 ( + status === OperationStatus.NoOp || + (packageDeps && + (status === OperationStatus.Success || + (status === OperationStatus.SuccessWithWarning && + record.operation.runner!.warningsAreAllowed && + allowWarningsInSuccessfulBuild))) + ) { // 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"