Skip to content

Commit 85e5186

Browse files
committed
feat(ci): add parallel option
1 parent 094797d commit 85e5186

File tree

4 files changed

+25
-1
lines changed

4 files changed

+25
-1
lines changed

packages/ci/README.md

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,7 @@ Optionally, you can override default options for further customization:
9797
| Property | Type | Default | Description |
9898
| :----------------- | :------------------------ | :------------------------------- | :------------------------------------------------------------------------------------------------------------------------------------------------------- |
9999
| `monorepo` | `boolean \| MonorepoTool` | `false` | Enables [monorepo mode](#monorepo-mode) |
100+
| `parallel` | `boolean \| number` | `false` | Enables parallel execution in [monorepo mode](#monorepo-mode) |
100101
| `projects` | `string[] \| null` | `null` | Custom projects configuration for [monorepo mode](#monorepo-mode) |
101102
| `task` | `string` | `'code-pushup'` | Name of command to run Code PushUp per project in [monorepo mode](#monorepo-mode) |
102103
| `nxProjectsFilter` | `string \| string[]` | `'--with-target={task}'` | Arguments passed to [`nx show projects`](https://nx.dev/nx-api/nx/documents/show#projects), only relevant for Nx in [monorepo mode](#monorepo-mode) [^2] |
@@ -193,6 +194,27 @@ await runInCI(refs, api, {
193194
});
194195
```
195196

197+
### Parallel tasks
198+
199+
By default, tasks are run sequentially for each project in the monorepo.
200+
The `parallel` option enables parallel execution for tools which support it (Nx, Turborepo, PNPM, Yarn 2+).
201+
202+
```ts
203+
await runInCI(refs, api, {
204+
monorepo: true,
205+
parallel: true,
206+
});
207+
```
208+
209+
The maximum number of concurrent tasks can be set by passing in a number instead of a boolean:
210+
211+
```ts
212+
await runInCI(refs, api, {
213+
monorepo: true,
214+
parallel: 3,
215+
});
216+
```
217+
196218
### Monorepo result
197219

198220
In monorepo mode, the resolved object includes the merged diff at the top-level, as well as a list of projects.

packages/ci/src/lib/constants.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import type { Settings } from './models.js';
22

33
export const DEFAULT_SETTINGS: Settings = {
44
monorepo: false,
5+
parallel: false, // TODO: default to true once battle-tested?
56
projects: null,
67
task: 'code-pushup',
78
bin: 'npx --no-install code-pushup',

packages/ci/src/lib/models.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import type { MonorepoTool } from './monorepo/index.js';
88
*/
99
export type Options = {
1010
monorepo?: boolean | MonorepoTool;
11+
parallel?: boolean | number;
1112
projects?: string[] | null;
1213
task?: string;
1314
nxProjectsFilter?: string | string[];

packages/ci/src/lib/monorepo/list-projects.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ function createMonorepoHandlerOptions(
8686
return {
8787
task: settings.task,
8888
cwd: settings.directory,
89-
parallel: false, // TODO: add to settings
89+
parallel: settings.parallel,
9090
nxProjectsFilter: settings.nxProjectsFilter,
9191
...(!settings.silent && {
9292
observer: {

0 commit comments

Comments
 (0)