Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[rush-lib] Add experiment flag to allow skipping build with warning #4341

Merged
Merged
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
@@ -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"
}
6 changes: 6 additions & 0 deletions common/config/rush/experiments.json
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
1 change: 1 addition & 0 deletions common/reviews/api/rush-lib.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -444,6 +444,7 @@ export interface IExecutionResult {
// @beta
export interface IExperimentsJson {
buildCacheWithAllowWarningsInSuccessfulBuild?: boolean;
buildSkipWithAllowWarningsInSuccessfulBuild?: boolean;
cleanInstallAfterNpmrcChanges?: boolean;
forbidPhantomResolvableNodeModulesFolders?: boolean;
noChmodFieldInTarHeaderNormalization?: boolean;
Expand Down
6 changes: 6 additions & 0 deletions libraries/rush-lib/src/api/ExperimentsConfiguration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -363,6 +363,9 @@ export class PhasedScriptAction extends BaseScriptAction<IPhasedCommandConfig> {
} 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
Expand Down
13 changes: 11 additions & 2 deletions libraries/rush-lib/src/logic/operations/LegacySkipPlugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ export interface ILegacySkipPluginOptions {
terminal: ITerminal;
changedProjectsOnly: boolean;
isIncrementalBuildAllowed: boolean;
allowWarningsInSuccessfulBuild?: boolean;
}

/**
Expand All @@ -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,
Expand Down Expand Up @@ -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
Expand Down
4 changes: 4 additions & 0 deletions libraries/rush-lib/src/schemas/experiments.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
Loading