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] Add suppressedWarnings option #1224

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
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
4 changes: 4 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,9 @@
"temp": true,
"**/test/**/temp": false,
"coverage": true
},
"files.associations": {
"rush.json": "jsonc",
"**/common/config/rush/*.json": "jsonc"
}
}
12 changes: 12 additions & 0 deletions apps/rush-lib/assets/rush-init/rush.json
Original file line number Diff line number Diff line change
Expand Up @@ -270,6 +270,18 @@
*/
/*[LINE "HYPOTHETICAL"]*/ "hotfixChangeEnabled": false,

/**
* If a warning message includes any substrings listed here, it should be treated as a standard
Copy link
Member

Choose a reason for hiding this comment

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

I think these should be regular expressions instead of simple substrings.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Also the regex's should be anchored to match the whole "message". But see my note below...

* log message rather than a warning. This prevents inconsequential warning messages caused by
* external packages from breaking incremental builds (packages marked as "success with warnings"
* will be rebuilt on each rush build).
*
* For example, certain npm packages with C++ bindings intermittently cause Node to display a warning
Copy link
Member

Choose a reason for hiding this comment

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

I'd remove this second paragraph.

* starting with "Using a domain property in MakeCallback is deprecated." The source of this warning
* has been hard to track down, so it can be added to this list to make incremental builds work.
*/
/*[LINE "HYPOTHETICAL"]*/ "suppressedWarnings": [],

/**
* (Required) This is the inventory of projects to be managed by Rush.
*
Expand Down
12 changes: 12 additions & 0 deletions apps/rush-lib/src/api/RushConfiguration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,7 @@ export interface IRushConfigurationJson {
yarnOptions?: IYarnOptionsJson;
ensureConsistentVersions?: boolean;
variants?: IRushVariantOptionsJson[];
suppressedWarnings?: string[];
}

/**
Expand Down Expand Up @@ -246,6 +247,7 @@ export class RushConfiguration {
private _variants: {
[variantName: string]: boolean;
};
private _suppressedWarnings: string[];

// "approvedPackagesPolicy" feature
private _approvedPackagesPolicy: ApprovedPackagesPolicy;
Expand Down Expand Up @@ -734,6 +736,14 @@ export class RushConfiguration {
return this._ensureConsistentVersions;
}

/**
* Gets the list of warning message substrings which should be suppressed (treated as standard
* log messages rather than warnings).
*/
public get suppressedWarnings(): string[] {
return this._suppressedWarnings;
}

/**
* Indicates whether telemetry collection is enabled for Rush runs.
* @beta
Expand Down Expand Up @@ -974,6 +984,8 @@ export class RushConfiguration {

this._ensureConsistentVersions = !!rushConfigurationJson.ensureConsistentVersions;

this._suppressedWarnings = rushConfigurationJson.suppressedWarnings || [];

this._pnpmOptions = new PnpmOptionsConfiguration(rushConfigurationJson.pnpmOptions || {});
this._yarnOptions = new YarnOptionsConfiguration(rushConfigurationJson.yarnOptions || { });

Expand Down
10 changes: 8 additions & 2 deletions apps/rush-lib/src/logic/taskRunner/ProjectTask.ts
Original file line number Diff line number Diff line change
Expand Up @@ -160,8 +160,14 @@ export class ProjectTask implements ITaskDefinition {
});

task.stderr.on('data', (data: string) => {
writer.writeError(data);
this._hasWarningOrError = true;
// If this error matches any of the suppressed warnings from the config, write it to
// stdout instead of stderr and don't treat the task as having a warning/error.
if (this._rushConfiguration.suppressedWarnings.some((warning: string) => data.indexOf(warning) !== -1)) {
writer.write(data);
} else {
writer.writeError(data);
this._hasWarningOrError = true;
}
});

return new Promise((resolve: (status: TaskStatus) => void, reject: (error: TaskError) => void) => {
Expand Down
9 changes: 8 additions & 1 deletion apps/rush-lib/src/schemas/rush.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,14 @@
}
},
"additionalProperties": false
}
},
"suppressedWarnings": {
"description": "A list of warning messages which should be treated as standard log messages instead of warnings.",
"type": "array",
"items": {
"type": "string"
}
}
},
"additionalProperties": false,
"required": [
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"changes": [
{
"comment": "Add suppressedWarnings option",
"packageName": "@microsoft/rush",
"type": "none"
}
],
"packageName": "@microsoft/rush",
"email": "[email protected]"
}
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 @@ -259,6 +259,7 @@ export class RushConfiguration {
readonly rushJsonFolder: string;
readonly rushLinkJsonFilename: string;
readonly shrinkwrapFilePhrase: string;
readonly suppressedWarnings: string[];
// @beta
readonly telemetryEnabled: boolean;
readonly tempShrinkwrapFilename: string;
Expand Down
12 changes: 12 additions & 0 deletions rush.json
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,18 @@
*/
// "hotfixChangeEnabled": false,

/**
* If a warning message includes any substrings listed here, it should be treated as a standard
* log message rather than a warning. This prevents inconsequential warning messages caused by
* external packages from breaking incremental builds (packages marked as "success with warnings"
* will be rebuilt on each rush build).
*
* For example, certain npm packages with C++ bindings intermittently cause Node to display a warning
* starting with "Using a domain property in MakeCallback is deprecated." The source of this warning
* has been hard to track down, so it can be added to this list to make incremental builds work.
*/
// "suppressedWarnings": [],

/**
* (Required) This is the inventory of projects to be managed by Rush.
*
Expand Down