Skip to content

Commit 05bc20e

Browse files
authored
Merge pull request microsoft#1272 from aboktor/fullParallel
[rush] Allow the option to ignore dependencies when running bulk commands
2 parents 64ee674 + 2ca71ca commit 05bc20e

7 files changed

Lines changed: 54 additions & 15 deletions

File tree

apps/rush-lib/assets/rush-init/common/config/rush/command-line.json

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,14 @@
6565
*/
6666
"enableParallelism": false,
6767

68+
/**
69+
* Normally projects will be processed according to their dependency order: a given project will not start
70+
* processing the command until all of its dependencies have completed. This restriction doesn't apply for
71+
* certain operations, for example a "clean" task that deletes output files. In this case
72+
* you can set "ignoreDependencyOrder" to true to increase parallelism.
73+
*/
74+
"ignoreDependencyOrder": false,
75+
6876
/**
6977
* Normally Rush requires that each project's package.json has a "scripts" entry matching
7078
* the custom command name. To disable this check, set "ignoreMissingScript" to true;

apps/rush-lib/src/api/CommandLineJson.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ export interface IBaseCommandJson {
2121
export interface IBulkCommandJson extends IBaseCommandJson {
2222
commandKind: 'bulk';
2323
enableParallelism: boolean;
24+
ignoreDependencyOrder?: boolean;
2425
ignoreMissingScript?: boolean;
2526
}
2627

apps/rush-lib/src/cli/RushCommandLineParser.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,8 @@ export class RushCommandLineParser extends CommandLineParser {
192192
commandLineConfiguration: commandLineConfiguration,
193193

194194
enableParallelism: true,
195-
ignoreMissingScript: false
195+
ignoreMissingScript: false,
196+
ignoreDependencyOrder: false
196197
}));
197198
}
198199

@@ -213,7 +214,8 @@ export class RushCommandLineParser extends CommandLineParser {
213214
commandLineConfiguration: commandLineConfiguration,
214215

215216
enableParallelism: true,
216-
ignoreMissingScript: false
217+
ignoreMissingScript: false,
218+
ignoreDependencyOrder: false
217219
}));
218220
}
219221
}
@@ -244,7 +246,8 @@ export class RushCommandLineParser extends CommandLineParser {
244246
commandLineConfiguration: commandLineConfiguration,
245247

246248
enableParallelism: command.enableParallelism,
247-
ignoreMissingScript: command.ignoreMissingScript || false
249+
ignoreMissingScript: command.ignoreMissingScript || false,
250+
ignoreDependencyOrder: command.ignoreDependencyOrder || false
248251
}));
249252
break;
250253
case 'global':

apps/rush-lib/src/cli/scriptActions/BulkScriptAction.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ import { FileSystem } from '@microsoft/node-core-library';
2828
export interface IBulkScriptActionOptions extends IBaseScriptActionOptions {
2929
enableParallelism: boolean;
3030
ignoreMissingScript: boolean;
31+
ignoreDependencyOrder: boolean;
3132

3233
/**
3334
* Optional command to run. Otherwise, use the `actionName` as the command to run.
@@ -55,6 +56,7 @@ export class BulkScriptAction extends BaseScriptAction {
5556
private _toVersionPolicy: CommandLineStringListParameter;
5657
private _verboseParameter: CommandLineFlagParameter;
5758
private _parallelismParameter: CommandLineStringParameter | undefined;
59+
private _ignoreDependencyOrder: boolean;
5860

5961
constructor(
6062
options: IBulkScriptActionOptions
@@ -63,6 +65,7 @@ export class BulkScriptAction extends BaseScriptAction {
6365
this._enableParallelism = options.enableParallelism;
6466
this._ignoreMissingScript = options.ignoreMissingScript;
6567
this._commandToRun = options.commandToRun || options.actionName;
68+
this._ignoreDependencyOrder = options.ignoreDependencyOrder;
6669
}
6770

6871
public run(): Promise<void> {
@@ -102,7 +105,8 @@ export class BulkScriptAction extends BaseScriptAction {
102105
parallelism,
103106
isIncrementalBuildAllowed: this.actionName === 'build',
104107
changedProjectsOnly,
105-
ignoreMissingScript: this._ignoreMissingScript
108+
ignoreMissingScript: this._ignoreMissingScript,
109+
ignoreDependencyOrder: this._ignoreDependencyOrder
106110
}
107111
);
108112

apps/rush-lib/src/logic/TaskSelector.ts

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ export interface ITaskSelectorConstructor {
2020
isIncrementalBuildAllowed: boolean;
2121
changedProjectsOnly: boolean;
2222
ignoreMissingScript: boolean;
23+
ignoreDependencyOrder: boolean;
2324
}
2425

2526
/**
@@ -81,8 +82,10 @@ export class TaskSelector {
8182
// Register any dependencies it may have
8283
deps.forEach(dep => this._registerTask(this._options.rushConfiguration.getProjectByName(dep)));
8384

84-
// Register the dependency graph to the TaskRunner
85-
deps.forEach(dep => this._taskRunner.addDependencies(dep, this._rushLinkJson.localLinks[dep] || []));
85+
if (!this._options.ignoreDependencyOrder) {
86+
// Add ordering relationships for each dependency
87+
deps.forEach(dep => this._taskRunner.addDependencies(dep, this._rushLinkJson.localLinks[dep] || []));
88+
}
8689
}
8790
}
8891

@@ -106,11 +109,13 @@ export class TaskSelector {
106109
this._registerTask(this._options.rushConfiguration.getProjectByName(dependent));
107110
});
108111

109-
// Only register dependencies graph for projects which have been registered
110-
// e.g. package C may depend on A & B, but if we are only building A's downstream, we will ignore B
111-
dependents.forEach(dependent =>
112-
this._taskRunner.addDependencies(dependent,
113-
(this._rushLinkJson.localLinks[dependent] || []).filter(dep => dependents.has(dep))));
112+
if (!this._options.ignoreDependencyOrder) {
113+
// Only add ordering relationships for projects which have been registered
114+
// e.g. package C may depend on A & B, but if we are only building A's downstream, we will ignore B
115+
dependents.forEach(dependent =>
116+
this._taskRunner.addDependencies(dependent,
117+
(this._rushLinkJson.localLinks[dependent] || []).filter(dep => dependents.has(dep))));
118+
}
114119
}
115120
}
116121

@@ -119,10 +124,11 @@ export class TaskSelector {
119124
for (const rushProject of this._options.rushConfiguration.projects) {
120125
this._registerTask(rushProject);
121126
}
122-
123-
// Add all dependencies
124-
for (const projectName of Object.keys(this._rushLinkJson.localLinks)) {
125-
this._taskRunner.addDependencies(projectName, this._rushLinkJson.localLinks[projectName]);
127+
if (!this._options.ignoreDependencyOrder) {
128+
// Add ordering relationships for each dependency
129+
for (const projectName of Object.keys(this._rushLinkJson.localLinks)) {
130+
this._taskRunner.addDependencies(projectName, this._rushLinkJson.localLinks[projectName]);
131+
}
126132
}
127133
}
128134

apps/rush-lib/src/schemas/command-line.schema.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,11 @@
6868
"description": "If true then this command can be run in parallel, i.e. executed simultaneously for multiple projects.",
6969
"type": "boolean"
7070
},
71+
"ignoreDependencyOrder": {
72+
"title": "ignoreDependencyOrder",
73+
"description": "Normally projects will be processed according to their dependency order: a given project will not start processing the command until all of its dependencies have completed. This restriction doesn't apply for certain operations, for example, a \"clean\" task that deletes output files. In this case you can set \"ignoreDependencyOrder\" to true to increase parallelism.",
74+
"type": "boolean"
75+
},
7176
"ignoreMissingScript": {
7277
"title": "Ignore Missing Script",
7378
"description": "Normally Rush requires that each project's package.json has a \"scripts\" entry matching the custom command name. To disable this check, set \"ignoreMissingScript\" to true.",
@@ -86,6 +91,7 @@
8691
"safeForSimultaneousRushProcesses": { "$ref": "#/definitions/anything" },
8792

8893
"enableParallelism": { "$ref": "#/definitions/anything" },
94+
"ignoreDependencyOrder": { "$ref": "#/definitions/anything" },
8995
"ignoreMissingScript": { "$ref": "#/definitions/anything" }
9096
}
9197
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"changes": [
3+
{
4+
"comment": "Add a new setting \"ignoreDependencyOrder\" in command-line.json",
5+
"packageName": "@microsoft/rush",
6+
"type": "none"
7+
}
8+
],
9+
"packageName": "@microsoft/rush",
10+
"email": "aboktor@users.noreply.github.com"
11+
}

0 commit comments

Comments
 (0)