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

feat(core): add parallelism to target configuration #26820

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
10 changes: 10 additions & 0 deletions docs/generated/devkit/TargetConfiguration.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ Target's configuration
- [metadata](../../devkit/documents/TargetConfiguration#metadata): TargetMetadata
- [options](../../devkit/documents/TargetConfiguration#options): T
- [outputs](../../devkit/documents/TargetConfiguration#outputs): string[]
- [parallelism](../../devkit/documents/TargetConfiguration#parallelism): boolean

## Properties

Expand Down Expand Up @@ -109,3 +110,12 @@ Target's options. They are passed in to the executor.

List of the target's outputs. The outputs will be cached by the Nx computation
caching engine.

---

### parallelism

`Optional` **parallelism**: `boolean`

Whether this target can be run in parallel with other tasks
Default is true
9 changes: 9 additions & 0 deletions docs/generated/devkit/Task.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ A representation of the invocation of an Executor
- [id](../../devkit/documents/Task#id): string
- [outputs](../../devkit/documents/Task#outputs): string[]
- [overrides](../../devkit/documents/Task#overrides): any
- [parallelism](../../devkit/documents/Task#parallelism): boolean
- [projectRoot](../../devkit/documents/Task#projectroot): string
- [startTime](../../devkit/documents/Task#starttime): number
- [target](../../devkit/documents/Task#target): Object
Expand Down Expand Up @@ -84,6 +85,14 @@ Overrides for the configured options of the target

---

### parallelism

**parallelism**: `boolean`

Determines if a given task should be parallelizable.

---

### projectRoot

`Optional` **projectRoot**: `string`
Expand Down
4 changes: 4 additions & 0 deletions packages/cypress/src/plugins/plugin.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@ describe('@nx/cypress/plugin', () => {
"{projectRoot}/dist/videos",
"{projectRoot}/dist/screenshots",
],
"parallelism": false,
},
"open-cypress": {
"command": "cypress open",
Expand Down Expand Up @@ -329,6 +330,7 @@ describe('@nx/cypress/plugin', () => {
"{projectRoot}/dist/videos",
"{projectRoot}/dist/screenshots",
],
"parallelism": false,
},
"e2e-ci": {
"cache": true,
Expand Down Expand Up @@ -369,6 +371,7 @@ describe('@nx/cypress/plugin', () => {
"{projectRoot}/dist/videos",
"{projectRoot}/dist/screenshots",
],
"parallelism": false,
},
"e2e-ci--src/test.cy.ts": {
"cache": true,
Expand Down Expand Up @@ -404,6 +407,7 @@ describe('@nx/cypress/plugin', () => {
"{projectRoot}/dist/videos",
"{projectRoot}/dist/screenshots",
],
"parallelism": false,
},
"open-cypress": {
"command": "cypress open",
Expand Down
3 changes: 3 additions & 0 deletions packages/cypress/src/plugins/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,7 @@ async function buildCypressTargets(
cache: true,
inputs: getInputs(namedInputs),
outputs: getOutputs(projectRoot, cypressConfig, 'e2e'),
parallelism: false,
metadata: {
technologies: ['cypress'],
description: 'Runs Cypress Tests',
Expand Down Expand Up @@ -276,6 +277,7 @@ async function buildCypressTargets(
options: {
cwd: projectRoot,
},
parallelism: false,
metadata: {
technologies: ['cypress'],
description: `Runs Cypress Tests in ${relativeSpecFilePath} in CI`,
Expand All @@ -300,6 +302,7 @@ async function buildCypressTargets(
inputs,
outputs,
dependsOn,
parallelism: false,
metadata: {
technologies: ['cypress'],
description: 'Runs Cypress Tests in CI',
Expand Down
13 changes: 13 additions & 0 deletions packages/js/src/utils/buildable-libs-utils.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -389,30 +389,35 @@ describe('calculateDependenciesFromTaskGraph', () => {
overrides: {},
target: { project: 'lib1', target: 'build' },
outputs: [],
parallelism: true,
},
'lib2:build': {
id: 'lib2:build',
overrides: {},
target: { project: 'lib2', target: 'build' },
outputs: [],
parallelism: true,
},
'lib2:build-base': {
id: 'lib2:build-base',
overrides: {},
target: { project: 'lib2', target: 'build-base' },
outputs: [],
parallelism: true,
},
'lib3:build': {
id: 'lib3:build',
overrides: {},
target: { project: 'lib3', target: 'build' },
outputs: [],
parallelism: true,
},
'lib4:build': {
id: 'lib4:build',
overrides: {},
target: { project: 'lib4', target: 'build' },
outputs: [],
parallelism: true,
},
},
};
Expand Down Expand Up @@ -559,48 +564,56 @@ describe('calculateDependenciesFromTaskGraph', () => {
overrides: {},
target: { project: 'lib1', target: 'build' },
outputs: [],
parallelism: true,
},
'lib1:build-base': {
id: 'lib1:build-base',
overrides: {},
target: { project: 'lib1', target: 'build-base' },
outputs: [],
parallelism: true,
},
'lib2:build': {
id: 'lib2:build',
overrides: {},
target: { project: 'lib2', target: 'build' },
outputs: [],
parallelism: true,
},
'lib2:build-base': {
id: 'lib2:build-base',
overrides: {},
target: { project: 'lib2', target: 'build-base' },
outputs: [],
parallelism: true,
},
'lib3:build': {
id: 'lib3:build',
overrides: {},
target: { project: 'lib3', target: 'build' },
outputs: [],
parallelism: true,
},
'lib3:build-base': {
id: 'lib3:build-base',
overrides: {},
target: { project: 'lib3', target: 'build-base' },
outputs: [],
parallelism: true,
},
'lib4:build': {
id: 'lib4:build',
overrides: {},
target: { project: 'lib4', target: 'build' },
outputs: [],
parallelism: true,
},
'lib4:build-base': {
id: 'lib4:build-base',
overrides: {},
target: { project: 'lib4', target: 'build-base' },
outputs: [],
parallelism: true,
},
},
};
Expand Down
26 changes: 26 additions & 0 deletions packages/nx/schemas/project-schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,27 @@
"title": "JSON schema for Nx projects",
"type": "object",
"properties": {
"name": {
"type": "string",
"description": "Project's name. Optional if specified in workspace.json"
},
"root": {
"type": "string",
"description": "Project's location relative to the root of the workspace"
},
"sourceRoot": {
"type": "string",
"description": "The location of project's sources relative to the root of the workspace"
},
"projectType": {
"type": "string",
"description": "Type of project supported",
"enum": ["library", "application"]
},
"generators": {
"type": "object",
"description": "List of default values used by generators"
},
"namedInputs": {
"type": "object",
"description": "Named inputs used by inputs defined in targets",
Expand Down Expand Up @@ -112,6 +133,11 @@
"cache": {
"type": "boolean",
"description": "Specifies if the given target should be cacheable"
},
"parallelism": {
"type": "boolean",
"default": true,
"description": "Whether this target can be run in parallel with other tasks"
}
}
}
Expand Down
5 changes: 5 additions & 0 deletions packages/nx/src/config/task-graph.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,11 @@ export interface Task {
* Determines if a given task should be cacheable.
*/
cache?: boolean;

/**
* Determines if a given task should be parallelizable.
*/
parallelism: boolean;
}

/**
Expand Down
1 change: 1 addition & 0 deletions packages/nx/src/config/to-project-name.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ describe('Workspaces', () => {
],
"executor": "@nx/js:release-publish",
"options": {},
"parallelism": true,
},
},
}
Expand Down
6 changes: 6 additions & 0 deletions packages/nx/src/config/workspace-json-project-json.ts
Original file line number Diff line number Diff line change
Expand Up @@ -230,4 +230,10 @@ export interface TargetConfiguration<T = any> {
* Metadata about the target
*/
metadata?: TargetMetadata;

/**
* Whether this target can be run in parallel with other tasks
* Default is true
*/
parallelism?: boolean;
}
Loading