@teambit/builder 1.0.1019 → 1.0.1021
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/build-pipe.d.ts +6 -0
- package/dist/build-pipe.js +19 -4
- package/dist/build-pipe.js.map +1 -1
- package/dist/builder.service.d.ts +7 -0
- package/dist/builder.service.js +14 -1
- package/dist/builder.service.js.map +1 -1
- package/dist/{preview-1781551713034.js → preview-1781818990778.js} +2 -2
- package/dist/tasks-parallel-scheduler.d.ts +64 -0
- package/dist/tasks-parallel-scheduler.js +169 -0
- package/dist/tasks-parallel-scheduler.js.map +1 -0
- package/dist/tasks-parallel-scheduler.spec.d.ts +1 -0
- package/dist/tasks-parallel-scheduler.spec.js +160 -0
- package/dist/tasks-parallel-scheduler.spec.js.map +1 -0
- package/package.json +23 -21
package/dist/build-pipe.d.ts
CHANGED
|
@@ -38,6 +38,12 @@ type PipeOptions = {
|
|
|
38
38
|
exitOnFirstFailedTask?: boolean;
|
|
39
39
|
showEnvNameInOutput?: boolean;
|
|
40
40
|
showEnvVersionInOutput?: boolean;
|
|
41
|
+
/**
|
|
42
|
+
* number of environments whose task-chains may run concurrently. 1 (default) keeps the original
|
|
43
|
+
* fully-serial behavior. when > 1, environments are built in parallel (see
|
|
44
|
+
* `executeTasksByLocationAndEnv`).
|
|
45
|
+
*/
|
|
46
|
+
concurrency?: number;
|
|
41
47
|
};
|
|
42
48
|
export declare class BuildPipe {
|
|
43
49
|
/**
|
package/dist/build-pipe.js
CHANGED
|
@@ -53,6 +53,13 @@ function _taskResultsList() {
|
|
|
53
53
|
};
|
|
54
54
|
return data;
|
|
55
55
|
}
|
|
56
|
+
function _tasksParallelScheduler() {
|
|
57
|
+
const data = require("./tasks-parallel-scheduler");
|
|
58
|
+
_tasksParallelScheduler = function () {
|
|
59
|
+
return data;
|
|
60
|
+
};
|
|
61
|
+
return data;
|
|
62
|
+
}
|
|
56
63
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
57
64
|
function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
|
|
58
65
|
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
|
|
@@ -84,10 +91,18 @@ class BuildPipe {
|
|
|
84
91
|
async execute() {
|
|
85
92
|
await this.executePreBuild();
|
|
86
93
|
this.longProcessLogger = this.logger.createLongProcessLogger('running tasks', this.tasksQueue.length);
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
94
|
+
const concurrency = this.options?.concurrency ?? 1;
|
|
95
|
+
if (concurrency > 1) {
|
|
96
|
+
await (0, _tasksParallelScheduler().executeTasksByLocationAndEnv)(this.tasksQueue, concurrency, ({
|
|
97
|
+
task,
|
|
98
|
+
env
|
|
99
|
+
}) => this.executeTask(task, env));
|
|
100
|
+
} else {
|
|
101
|
+
await (0, _pMapSeries().default)(this.tasksQueue, async ({
|
|
102
|
+
task,
|
|
103
|
+
env
|
|
104
|
+
}) => this.executeTask(task, env));
|
|
105
|
+
}
|
|
91
106
|
this.longProcessLogger.end();
|
|
92
107
|
const capsuleRootDir = Object.values(this.envsBuildContext)[0]?.capsuleNetwork.capsulesRootDir;
|
|
93
108
|
const tasksResultsList = new (_taskResultsList().TaskResultsList)(this.tasksQueue, this.taskResults, capsuleRootDir, this.logger);
|
package/dist/build-pipe.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_component","data","require","_pMapSeries","_interopRequireDefault","_prettyTime","_toolboxString","_chalk","_buildTask","_taskResultsList","e","__esModule","default","_defineProperty","r","t","_toPropertyKey","Object","defineProperty","value","enumerable","configurable","writable","i","_toPrimitive","Symbol","toPrimitive","call","TypeError","String","Number","BuildPipe","constructor","tasksQueue","envsBuildContext","logger","artifactFactory","previousTaskResults","options","allTasksResults","taskResults","execute","executePreBuild","longProcessLogger","createLongProcessLogger","length","mapSeries","task","env","executeTask","end","capsuleRootDir","values","capsuleNetwork","capsulesRootDir","tasksResultsList","TaskResultsList","executePostBuild","setStatusLine","preBuild","getBuildContext","id","taskId","BuildTaskHelper","serializeId","envName","showEnvNameInOutput","getPrettyEnvName","buildContext","hasOriginalSeeders","Boolean","_originalSeeders","dependencyStr","taskLogPrefix","getPrettyAspectName","aspectId","name","logProgress","description","updateFailedDependencyTask","shouldSkipTask","components","seedersCapsules","getAllComponents","componentsResults","map","component","status","artifacts","undefined","startTime","Date","now","endTime","push","startTask","process","hrtime","taskStartTime","buildTaskResult","debug","Math","round","memoryUsage","heapUsed","err","consoleFailure","compsWithErrors","filter","c","errors","duration","prettyTime","chalk","red","getProgress","failedTasks","color","green","dim","consoleSuccess","defs","generate","resolvedId","ComponentID","fromString","tokens","split","token","capitalize","join","envId","ver","showEnvVersionInOutput","version","fullName","tasksResults","postBuild","failedDependencyTask","dependencies","forEach","dependency","deserializeIdAllowEmptyName","find","failedTask","exitOnFirstFailedTask","failedTaskId","consoleWarning","Error","previousTasksResults","exports"],"sources":["build-pipe.ts"],"sourcesContent":["import type { EnvDefinition } from '@teambit/envs';\nimport type { ComponentMap } from '@teambit/component';\nimport { ComponentID } from '@teambit/component';\nimport type { Logger, LongProcessLogger } from '@teambit/logger';\nimport mapSeries from 'p-map-series';\nimport prettyTime from 'pretty-time';\nimport { capitalize } from '@teambit/toolbox.string.capitalize';\nimport chalk from 'chalk';\nimport type { ArtifactFactory, ArtifactList, FsArtifact } from './artifact';\nimport type { BuildContext, BuildTask, BuiltTaskResult } from './build-task';\nimport { BuildTaskHelper } from './build-task';\nimport type { ComponentResult } from './types';\nimport type { TasksQueue } from './tasks-queue';\nimport type { EnvsBuildContext } from './builder.service';\nimport { TaskResultsList } from './task-results-list';\n\nexport type TaskResults = {\n /**\n * task itself. useful for getting its id/description later on.\n */\n task: BuildTask;\n\n /**\n * environment were the task was running\n */\n env: EnvDefinition;\n\n /**\n * component build results.\n */\n componentsResults: ComponentResult[];\n\n /**\n * artifacts generated by the build pipeline.\n * in case the task finished with errors, this prop is undefined.\n */\n artifacts: ComponentMap<ArtifactList<FsArtifact>> | undefined;\n\n /**\n * timestamp of start initiation.\n */\n startTime: number;\n\n /**\n * timestamp of task completion.\n */\n endTime: number;\n};\n\ntype PipeOptions = {\n exitOnFirstFailedTask?: boolean; // by default it skips only when a dependent failed.\n showEnvNameInOutput?: boolean;\n showEnvVersionInOutput?: boolean; // in case it shows the env-name, whether should show also the version\n};\n\nexport class BuildPipe {\n private failedTasks: BuildTask[] = [];\n private failedDependencyTask: BuildTask | undefined;\n private longProcessLogger: LongProcessLogger;\n private taskResults: TaskResults[] = [];\n constructor(\n /**\n * array of services to apply on the components.\n */\n readonly tasksQueue: TasksQueue,\n readonly envsBuildContext: EnvsBuildContext,\n readonly logger: Logger,\n readonly artifactFactory: ArtifactFactory,\n private previousTaskResults?: TaskResults[],\n private options?: PipeOptions\n ) {}\n\n get allTasksResults(): TaskResults[] {\n return [...(this.previousTaskResults || []), ...(this.taskResults || [])];\n }\n\n /**\n * execute a pipeline of build tasks.\n */\n async execute(): Promise<TaskResultsList> {\n await this.executePreBuild();\n this.longProcessLogger = this.logger.createLongProcessLogger('running tasks', this.tasksQueue.length);\n await mapSeries(this.tasksQueue, async ({ task, env }) => this.executeTask(task, env));\n this.longProcessLogger.end();\n const capsuleRootDir = Object.values(this.envsBuildContext)[0]?.capsuleNetwork.capsulesRootDir;\n const tasksResultsList = new TaskResultsList(this.tasksQueue, this.taskResults, capsuleRootDir, this.logger);\n await this.executePostBuild(tasksResultsList);\n\n return tasksResultsList;\n }\n\n private async executePreBuild() {\n this.logger.setStatusLine('executing pre-build for all tasks');\n const longProcessLogger = this.logger.createLongProcessLogger('running pre-build for all tasks');\n await mapSeries(this.tasksQueue, async ({ task, env }) => {\n if (!task.preBuild) return;\n await task.preBuild(this.getBuildContext(env.id));\n });\n longProcessLogger.end();\n }\n\n private async executeTask(task: BuildTask, env: EnvDefinition): Promise<void> {\n const taskId = BuildTaskHelper.serializeId(task);\n const envName = this.options?.showEnvNameInOutput ? `(${this.getPrettyEnvName(env.id)}) ` : '';\n const buildContext = this.getBuildContext(env.id);\n const hasOriginalSeeders = Boolean(buildContext.capsuleNetwork._originalSeeders?.length);\n const dependencyStr = hasOriginalSeeders ? '' : `[dependency] `;\n const taskLogPrefix = `${dependencyStr}${envName}[${this.getPrettyAspectName(task.aspectId)}: ${task.name}]`;\n this.longProcessLogger.logProgress(`${taskLogPrefix}${task.description ? ` ${task.description}` : ''}`, false);\n this.updateFailedDependencyTask(task);\n if (this.shouldSkipTask(taskId, env.id)) {\n // Save skipped tasks with pending status so they appear in the UI\n const components = buildContext.capsuleNetwork.seedersCapsules.getAllComponents();\n const componentsResults: ComponentResult[] = components.map((component) => ({\n component,\n status: 'pending',\n }));\n const taskResults: TaskResults = {\n task,\n env,\n componentsResults,\n artifacts: undefined,\n startTime: Date.now(),\n endTime: Date.now(),\n };\n this.taskResults.push(taskResults);\n return;\n }\n const startTask = process.hrtime();\n const taskStartTime = Date.now();\n let buildTaskResult: BuiltTaskResult;\n this.logger.debug(\n `${taskLogPrefix} memory usage: ${Math.round((process.memoryUsage().heapUsed / 1024 / 1024 / 1024) * 100) / 100} GB`\n );\n try {\n buildTaskResult = await task.execute(buildContext);\n } catch (err) {\n this.logger.consoleFailure(`env: ${env.id}, task \"${taskId}\" threw an error`);\n throw err;\n }\n\n const endTime = Date.now();\n const compsWithErrors = buildTaskResult.componentsResults.filter((c) => c.errors?.length);\n let artifacts: ComponentMap<ArtifactList<FsArtifact>> | undefined;\n const duration = prettyTime(process.hrtime(startTask));\n if (compsWithErrors.length) {\n this.logger.consoleFailure(`env: ${env.id}, task \"${taskId}\" has failed`);\n this.logger.consoleFailure(\n chalk.red(`${this.longProcessLogger.getProgress()} env: ${env.id}, task \"${taskId}\" has failed in ${duration}`)\n );\n this.failedTasks.push(task);\n } else {\n const color = hasOriginalSeeders ? chalk.green : chalk.green.dim;\n this.logger.consoleSuccess(\n color(`${this.longProcessLogger.getProgress()} ${taskLogPrefix} Completed successfully in ${duration}`)\n );\n const defs = buildTaskResult.artifacts || [];\n artifacts = this.artifactFactory.generate(buildContext, defs, task);\n }\n\n // For tasks that run on a single component (e.g., test/lint in single-component builds),\n // add the task-level timing to the component result if it doesn't already have timing\n const componentsResults = buildTaskResult.componentsResults;\n if (componentsResults.length === 1 && !componentsResults[0].startTime && !componentsResults[0].endTime) {\n componentsResults[0].startTime = taskStartTime;\n componentsResults[0].endTime = endTime;\n }\n\n const taskResults: TaskResults = {\n task,\n env,\n componentsResults,\n artifacts,\n startTime: taskStartTime,\n endTime,\n };\n\n this.taskResults.push(taskResults);\n }\n\n private getPrettyAspectName(aspectId: string): string {\n const resolvedId = ComponentID.fromString(aspectId);\n const tokens = resolvedId.name.split('-').map((token) => capitalize(token));\n return tokens.join(' ');\n }\n\n private getPrettyEnvName(envId: string) {\n const resolvedId = ComponentID.fromString(envId);\n const ver = this.options?.showEnvVersionInOutput ? `@${resolvedId.version}` : '';\n return `${resolvedId.fullName}${ver}`;\n }\n\n private async executePostBuild(tasksResults: TaskResultsList) {\n const longProcessLogger = this.logger.createLongProcessLogger('running post-build for all tasks');\n this.logger.setStatusLine('executing post-build for all tasks');\n await mapSeries(this.tasksQueue, async ({ task, env }) => {\n if (!task.postBuild) return;\n await task.postBuild(this.getBuildContext(env.id), tasksResults);\n });\n longProcessLogger.end();\n }\n\n private updateFailedDependencyTask(task: BuildTask) {\n if (!this.failedDependencyTask && this.failedTasks.length && task.dependencies) {\n task.dependencies.forEach((dependency) => {\n const { aspectId, name } = BuildTaskHelper.deserializeIdAllowEmptyName(dependency);\n this.failedDependencyTask = this.failedTasks.find((failedTask) => {\n if (name && name !== failedTask.name) return false;\n return aspectId === failedTask.aspectId;\n });\n });\n }\n }\n\n private shouldSkipTask(taskId: string, envId: string): boolean {\n if (this.options?.exitOnFirstFailedTask && this.failedTasks.length) {\n const failedTaskId = BuildTaskHelper.serializeId(this.failedTasks[0]);\n this.logger.consoleWarning(`env: ${envId}, task \"${taskId}\" has skipped due to \"${failedTaskId}\" failure`);\n return true;\n }\n if (!this.failedDependencyTask) return false;\n const failedTaskId = BuildTaskHelper.serializeId(this.failedDependencyTask);\n this.logger.consoleWarning(`env: ${envId}, task \"${taskId}\" has skipped due to \"${failedTaskId}\" failure`);\n return true;\n }\n\n private getBuildContext(envId: string): BuildContext {\n const buildContext = this.envsBuildContext[envId];\n if (!buildContext) throw new Error(`unable to find buildContext for ${envId}`);\n buildContext.previousTasksResults = this.allTasksResults;\n return buildContext;\n }\n}\n"],"mappings":";;;;;;AAEA,SAAAA,WAAA;EAAA,MAAAC,IAAA,GAAAC,OAAA;EAAAF,UAAA,YAAAA,CAAA;IAAA,OAAAC,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AAEA,SAAAE,YAAA;EAAA,MAAAF,IAAA,GAAAG,sBAAA,CAAAF,OAAA;EAAAC,WAAA,YAAAA,CAAA;IAAA,OAAAF,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAI,YAAA;EAAA,MAAAJ,IAAA,GAAAG,sBAAA,CAAAF,OAAA;EAAAG,WAAA,YAAAA,CAAA;IAAA,OAAAJ,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAK,eAAA;EAAA,MAAAL,IAAA,GAAAC,OAAA;EAAAI,cAAA,YAAAA,CAAA;IAAA,OAAAL,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAM,OAAA;EAAA,MAAAN,IAAA,GAAAG,sBAAA,CAAAF,OAAA;EAAAK,MAAA,YAAAA,CAAA;IAAA,OAAAN,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AAGA,SAAAO,WAAA;EAAA,MAAAP,IAAA,GAAAC,OAAA;EAAAM,UAAA,YAAAA,CAAA;IAAA,OAAAP,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;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ACC,WAAW,CAAC,IAAI,CAAC0E,oBAAoB,CAAC;IAC3E,IAAI,CAACvG,MAAM,CAACgH,cAAc,CAAC,QAAQhB,KAAK,WAAWrE,MAAM,yBAAyBoF,YAAY,WAAW,CAAC;IAC1G,OAAO,IAAI;EACb;EAEQtF,eAAeA,CAACuE,KAAa,EAAgB;IACnD,MAAM/D,YAAY,GAAG,IAAI,CAAClC,gBAAgB,CAACiG,KAAK,CAAC;IACjD,IAAI,CAAC/D,YAAY,EAAE,MAAM,IAAIgF,KAAK,CAAC,mCAAmCjB,KAAK,EAAE,CAAC;IAC9E/D,YAAY,CAACiF,oBAAoB,GAAG,IAAI,CAAC9G,eAAe;IACxD,OAAO6B,YAAY;EACrB;AACF;AAACkF,OAAA,CAAAvH,SAAA,GAAAA,SAAA","ignoreList":[]}
|
|
1
|
+
{"version":3,"names":["_component","data","require","_pMapSeries","_interopRequireDefault","_prettyTime","_toolboxString","_chalk","_buildTask","_taskResultsList","_tasksParallelScheduler","e","__esModule","default","_defineProperty","r","t","_toPropertyKey","Object","defineProperty","value","enumerable","configurable","writable","i","_toPrimitive","Symbol","toPrimitive","call","TypeError","String","Number","BuildPipe","constructor","tasksQueue","envsBuildContext","logger","artifactFactory","previousTaskResults","options","allTasksResults","taskResults","execute","executePreBuild","longProcessLogger","createLongProcessLogger","length","concurrency","executeTasksByLocationAndEnv","task","env","executeTask","mapSeries","end","capsuleRootDir","values","capsuleNetwork","capsulesRootDir","tasksResultsList","TaskResultsList","executePostBuild","setStatusLine","preBuild","getBuildContext","id","taskId","BuildTaskHelper","serializeId","envName","showEnvNameInOutput","getPrettyEnvName","buildContext","hasOriginalSeeders","Boolean","_originalSeeders","dependencyStr","taskLogPrefix","getPrettyAspectName","aspectId","name","logProgress","description","updateFailedDependencyTask","shouldSkipTask","components","seedersCapsules","getAllComponents","componentsResults","map","component","status","artifacts","undefined","startTime","Date","now","endTime","push","startTask","process","hrtime","taskStartTime","buildTaskResult","debug","Math","round","memoryUsage","heapUsed","err","consoleFailure","compsWithErrors","filter","c","errors","duration","prettyTime","chalk","red","getProgress","failedTasks","color","green","dim","consoleSuccess","defs","generate","resolvedId","ComponentID","fromString","tokens","split","token","capitalize","join","envId","ver","showEnvVersionInOutput","version","fullName","tasksResults","postBuild","failedDependencyTask","dependencies","forEach","dependency","deserializeIdAllowEmptyName","find","failedTask","exitOnFirstFailedTask","failedTaskId","consoleWarning","Error","previousTasksResults","exports"],"sources":["build-pipe.ts"],"sourcesContent":["import type { EnvDefinition } from '@teambit/envs';\nimport type { ComponentMap } from '@teambit/component';\nimport { ComponentID } from '@teambit/component';\nimport type { Logger, LongProcessLogger } from '@teambit/logger';\nimport mapSeries from 'p-map-series';\nimport prettyTime from 'pretty-time';\nimport { capitalize } from '@teambit/toolbox.string.capitalize';\nimport chalk from 'chalk';\nimport type { ArtifactFactory, ArtifactList, FsArtifact } from './artifact';\nimport type { BuildContext, BuildTask, BuiltTaskResult } from './build-task';\nimport { BuildTaskHelper } from './build-task';\nimport type { ComponentResult } from './types';\nimport type { TasksQueue } from './tasks-queue';\nimport type { EnvsBuildContext } from './builder.service';\nimport { TaskResultsList } from './task-results-list';\nimport { executeTasksByLocationAndEnv } from './tasks-parallel-scheduler';\n\nexport type TaskResults = {\n /**\n * task itself. useful for getting its id/description later on.\n */\n task: BuildTask;\n\n /**\n * environment were the task was running\n */\n env: EnvDefinition;\n\n /**\n * component build results.\n */\n componentsResults: ComponentResult[];\n\n /**\n * artifacts generated by the build pipeline.\n * in case the task finished with errors, this prop is undefined.\n */\n artifacts: ComponentMap<ArtifactList<FsArtifact>> | undefined;\n\n /**\n * timestamp of start initiation.\n */\n startTime: number;\n\n /**\n * timestamp of task completion.\n */\n endTime: number;\n};\n\ntype PipeOptions = {\n exitOnFirstFailedTask?: boolean; // by default it skips only when a dependent failed.\n showEnvNameInOutput?: boolean;\n showEnvVersionInOutput?: boolean; // in case it shows the env-name, whether should show also the version\n /**\n * number of environments whose task-chains may run concurrently. 1 (default) keeps the original\n * fully-serial behavior. when > 1, environments are built in parallel (see\n * `executeTasksByLocationAndEnv`).\n */\n concurrency?: number;\n};\n\nexport class BuildPipe {\n private failedTasks: BuildTask[] = [];\n private failedDependencyTask: BuildTask | undefined;\n private longProcessLogger: LongProcessLogger;\n private taskResults: TaskResults[] = [];\n constructor(\n /**\n * array of services to apply on the components.\n */\n readonly tasksQueue: TasksQueue,\n readonly envsBuildContext: EnvsBuildContext,\n readonly logger: Logger,\n readonly artifactFactory: ArtifactFactory,\n private previousTaskResults?: TaskResults[],\n private options?: PipeOptions\n ) {}\n\n get allTasksResults(): TaskResults[] {\n return [...(this.previousTaskResults || []), ...(this.taskResults || [])];\n }\n\n /**\n * execute a pipeline of build tasks.\n */\n async execute(): Promise<TaskResultsList> {\n await this.executePreBuild();\n this.longProcessLogger = this.logger.createLongProcessLogger('running tasks', this.tasksQueue.length);\n const concurrency = this.options?.concurrency ?? 1;\n if (concurrency > 1) {\n await executeTasksByLocationAndEnv(this.tasksQueue, concurrency, ({ task, env }) => this.executeTask(task, env));\n } else {\n await mapSeries(this.tasksQueue, async ({ task, env }) => this.executeTask(task, env));\n }\n this.longProcessLogger.end();\n const capsuleRootDir = Object.values(this.envsBuildContext)[0]?.capsuleNetwork.capsulesRootDir;\n const tasksResultsList = new TaskResultsList(this.tasksQueue, this.taskResults, capsuleRootDir, this.logger);\n await this.executePostBuild(tasksResultsList);\n\n return tasksResultsList;\n }\n\n private async executePreBuild() {\n this.logger.setStatusLine('executing pre-build for all tasks');\n const longProcessLogger = this.logger.createLongProcessLogger('running pre-build for all tasks');\n await mapSeries(this.tasksQueue, async ({ task, env }) => {\n if (!task.preBuild) return;\n await task.preBuild(this.getBuildContext(env.id));\n });\n longProcessLogger.end();\n }\n\n private async executeTask(task: BuildTask, env: EnvDefinition): Promise<void> {\n const taskId = BuildTaskHelper.serializeId(task);\n const envName = this.options?.showEnvNameInOutput ? `(${this.getPrettyEnvName(env.id)}) ` : '';\n const buildContext = this.getBuildContext(env.id);\n const hasOriginalSeeders = Boolean(buildContext.capsuleNetwork._originalSeeders?.length);\n const dependencyStr = hasOriginalSeeders ? '' : `[dependency] `;\n const taskLogPrefix = `${dependencyStr}${envName}[${this.getPrettyAspectName(task.aspectId)}: ${task.name}]`;\n this.longProcessLogger.logProgress(`${taskLogPrefix}${task.description ? ` ${task.description}` : ''}`, false);\n this.updateFailedDependencyTask(task);\n if (this.shouldSkipTask(taskId, env.id)) {\n // Save skipped tasks with pending status so they appear in the UI\n const components = buildContext.capsuleNetwork.seedersCapsules.getAllComponents();\n const componentsResults: ComponentResult[] = components.map((component) => ({\n component,\n status: 'pending',\n }));\n const taskResults: TaskResults = {\n task,\n env,\n componentsResults,\n artifacts: undefined,\n startTime: Date.now(),\n endTime: Date.now(),\n };\n this.taskResults.push(taskResults);\n return;\n }\n const startTask = process.hrtime();\n const taskStartTime = Date.now();\n let buildTaskResult: BuiltTaskResult;\n this.logger.debug(\n `${taskLogPrefix} memory usage: ${Math.round((process.memoryUsage().heapUsed / 1024 / 1024 / 1024) * 100) / 100} GB`\n );\n try {\n buildTaskResult = await task.execute(buildContext);\n } catch (err) {\n this.logger.consoleFailure(`env: ${env.id}, task \"${taskId}\" threw an error`);\n throw err;\n }\n\n const endTime = Date.now();\n const compsWithErrors = buildTaskResult.componentsResults.filter((c) => c.errors?.length);\n let artifacts: ComponentMap<ArtifactList<FsArtifact>> | undefined;\n const duration = prettyTime(process.hrtime(startTask));\n if (compsWithErrors.length) {\n this.logger.consoleFailure(`env: ${env.id}, task \"${taskId}\" has failed`);\n this.logger.consoleFailure(\n chalk.red(`${this.longProcessLogger.getProgress()} env: ${env.id}, task \"${taskId}\" has failed in ${duration}`)\n );\n this.failedTasks.push(task);\n } else {\n const color = hasOriginalSeeders ? chalk.green : chalk.green.dim;\n this.logger.consoleSuccess(\n color(`${this.longProcessLogger.getProgress()} ${taskLogPrefix} Completed successfully in ${duration}`)\n );\n const defs = buildTaskResult.artifacts || [];\n artifacts = this.artifactFactory.generate(buildContext, defs, task);\n }\n\n // For tasks that run on a single component (e.g., test/lint in single-component builds),\n // add the task-level timing to the component result if it doesn't already have timing\n const componentsResults = buildTaskResult.componentsResults;\n if (componentsResults.length === 1 && !componentsResults[0].startTime && !componentsResults[0].endTime) {\n componentsResults[0].startTime = taskStartTime;\n componentsResults[0].endTime = endTime;\n }\n\n const taskResults: TaskResults = {\n task,\n env,\n componentsResults,\n artifacts,\n startTime: taskStartTime,\n endTime,\n };\n\n this.taskResults.push(taskResults);\n }\n\n private getPrettyAspectName(aspectId: string): string {\n const resolvedId = ComponentID.fromString(aspectId);\n const tokens = resolvedId.name.split('-').map((token) => capitalize(token));\n return tokens.join(' ');\n }\n\n private getPrettyEnvName(envId: string) {\n const resolvedId = ComponentID.fromString(envId);\n const ver = this.options?.showEnvVersionInOutput ? `@${resolvedId.version}` : '';\n return `${resolvedId.fullName}${ver}`;\n }\n\n private async executePostBuild(tasksResults: TaskResultsList) {\n const longProcessLogger = this.logger.createLongProcessLogger('running post-build for all tasks');\n this.logger.setStatusLine('executing post-build for all tasks');\n await mapSeries(this.tasksQueue, async ({ task, env }) => {\n if (!task.postBuild) return;\n await task.postBuild(this.getBuildContext(env.id), tasksResults);\n });\n longProcessLogger.end();\n }\n\n private updateFailedDependencyTask(task: BuildTask) {\n if (!this.failedDependencyTask && this.failedTasks.length && task.dependencies) {\n task.dependencies.forEach((dependency) => {\n const { aspectId, name } = BuildTaskHelper.deserializeIdAllowEmptyName(dependency);\n this.failedDependencyTask = this.failedTasks.find((failedTask) => {\n if (name && name !== failedTask.name) return false;\n return aspectId === failedTask.aspectId;\n });\n });\n }\n }\n\n private shouldSkipTask(taskId: string, envId: string): boolean {\n if (this.options?.exitOnFirstFailedTask && this.failedTasks.length) {\n const failedTaskId = BuildTaskHelper.serializeId(this.failedTasks[0]);\n this.logger.consoleWarning(`env: ${envId}, task \"${taskId}\" has skipped due to \"${failedTaskId}\" failure`);\n return true;\n }\n if (!this.failedDependencyTask) return false;\n const failedTaskId = BuildTaskHelper.serializeId(this.failedDependencyTask);\n this.logger.consoleWarning(`env: ${envId}, task \"${taskId}\" has skipped due to \"${failedTaskId}\" failure`);\n return true;\n }\n\n private getBuildContext(envId: string): BuildContext {\n const buildContext = this.envsBuildContext[envId];\n if (!buildContext) throw new Error(`unable to find buildContext for ${envId}`);\n buildContext.previousTasksResults = this.allTasksResults;\n return buildContext;\n }\n}\n"],"mappings":";;;;;;AAEA,SAAAA,WAAA;EAAA,MAAAC,IAAA,GAAAC,OAAA;EAAAF,UAAA,YAAAA,CAAA;IAAA,OAAAC,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AAEA,SAAAE,YAAA;EAAA,MAAAF,IAAA,GAAAG,sBAAA,CAAAF,OAAA;EAAAC,WAAA,YAAAA,CAAA;IAAA,OAAAF,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAI,YAAA;EAAA,MAAAJ,IAAA,GAAAG,sBAAA,CAAAF,OAAA;EAAAG,WAAA,YAAAA,CAAA;IAAA,OAAAJ,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAK,eAAA;EAAA,MAAAL,IAAA,GAAAC,OAAA;EAAAI,cAAA,YAAAA,CAAA;IAAA,OAAAL,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAM,OAAA;EAAA,MAAAN,IAAA,GAAAG,sBAAA,CAAAF,OAAA;EAAAK,MAAA,YAAAA,CAAA;IAAA,OAAAN,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AAGA,SAAAO,WAAA;EAAA,MAAAP,IAAA,GAAAC,OAAA;EAAAM,UAAA,YAAAA,CAAA;IAAA,OAAAP,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AAIA,SAAAQ,iBAAA;EAAA,MAAAR,IAAA,GAAAC,OAAA;EAAAO,gBAAA,YAAAA,CAAA;IAAA,OAAAR,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAS,wB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AACC,WAAW,CAAC,IAAI,CAACoD,WAAW,CAAC,CAAC,CAAC,CAAC;MACrE,IAAI,CAACnF,MAAM,CAACkH,cAAc,CAAC,QAAQhB,KAAK,WAAWrE,MAAM,yBAAyBoF,YAAY,WAAW,CAAC;MAC1G,OAAO,IAAI;IACb;IACA,IAAI,CAAC,IAAI,CAACR,oBAAoB,EAAE,OAAO,KAAK;IAC5C,MAAMQ,YAAY,GAAGnF,4BAAe,CAACC,WAAW,CAAC,IAAI,CAAC0E,oBAAoB,CAAC;IAC3E,IAAI,CAACzG,MAAM,CAACkH,cAAc,CAAC,QAAQhB,KAAK,WAAWrE,MAAM,yBAAyBoF,YAAY,WAAW,CAAC;IAC1G,OAAO,IAAI;EACb;EAEQtF,eAAeA,CAACuE,KAAa,EAAgB;IACnD,MAAM/D,YAAY,GAAG,IAAI,CAACpC,gBAAgB,CAACmG,KAAK,CAAC;IACjD,IAAI,CAAC/D,YAAY,EAAE,MAAM,IAAIgF,KAAK,CAAC,mCAAmCjB,KAAK,EAAE,CAAC;IAC9E/D,YAAY,CAACiF,oBAAoB,GAAG,IAAI,CAAChH,eAAe;IACxD,OAAO+B,YAAY;EACrB;AACF;AAACkF,OAAA,CAAAzH,SAAA,GAAAA,SAAA","ignoreList":[]}
|
|
@@ -97,6 +97,13 @@ export declare class BuilderService implements EnvService<BuildServiceResults, s
|
|
|
97
97
|
*/
|
|
98
98
|
runOnce(envsExecutionContext: ExecutionContext[], options: BuilderServiceOptions): Promise<TaskResultsList>;
|
|
99
99
|
getComponentsCapsulesBaseDir(): string | undefined;
|
|
100
|
+
/**
|
|
101
|
+
* Number of environments whose build task-chains may run concurrently. Defaults to 1 (fully
|
|
102
|
+
* serial — the original behavior). Opt into parallelism with the `BIT_BUILD_CONCURRENCY` env var
|
|
103
|
+
* (handy for CI) or the `build.concurrency` config. In parallel mode each env's tasks still run
|
|
104
|
+
* sequentially; only different envs run concurrently — see `BuildPipe.executeTasksInParallel`.
|
|
105
|
+
*/
|
|
106
|
+
getBuildConcurrency(): number;
|
|
100
107
|
render(): string;
|
|
101
108
|
transform(env: Env, envContext: EnvContext): BuilderTransformationMap | undefined;
|
|
102
109
|
getDescriptor(): string;
|
package/dist/builder.service.js
CHANGED
|
@@ -140,7 +140,8 @@ class BuilderService {
|
|
|
140
140
|
const buildPipe = new (_buildPipe().BuildPipe)(tasksQueue, envsBuildContext, this.logger, this.artifactFactory, options.previousTasksResults, {
|
|
141
141
|
exitOnFirstFailedTask: options.exitOnFirstFailedTask,
|
|
142
142
|
showEnvNameInOutput: envs.length > 1,
|
|
143
|
-
showEnvVersionInOutput: envIdsWithoutVersion.length > (0, _lodash().uniq)(envIdsWithoutVersion).length
|
|
143
|
+
showEnvVersionInOutput: envIdsWithoutVersion.length > (0, _lodash().uniq)(envIdsWithoutVersion).length,
|
|
144
|
+
concurrency: this.getBuildConcurrency()
|
|
144
145
|
});
|
|
145
146
|
const buildResults = await buildPipe.execute();
|
|
146
147
|
longProcessLogger.end(buildResults.hasErrors() ? 'error' : 'success');
|
|
@@ -149,6 +150,18 @@ class BuilderService {
|
|
|
149
150
|
getComponentsCapsulesBaseDir() {
|
|
150
151
|
return this.configStore.getConfig(_legacy().CFG_CAPSULES_BUILD_COMPONENTS_BASE_DIR);
|
|
151
152
|
}
|
|
153
|
+
|
|
154
|
+
/**
|
|
155
|
+
* Number of environments whose build task-chains may run concurrently. Defaults to 1 (fully
|
|
156
|
+
* serial — the original behavior). Opt into parallelism with the `BIT_BUILD_CONCURRENCY` env var
|
|
157
|
+
* (handy for CI) or the `build.concurrency` config. In parallel mode each env's tasks still run
|
|
158
|
+
* sequentially; only different envs run concurrently — see `BuildPipe.executeTasksInParallel`.
|
|
159
|
+
*/
|
|
160
|
+
getBuildConcurrency() {
|
|
161
|
+
const raw = process.env.BIT_BUILD_CONCURRENCY ?? this.configStore.getConfig('build.concurrency');
|
|
162
|
+
const parsed = raw ? parseInt(raw, 10) : NaN;
|
|
163
|
+
return Number.isNaN(parsed) || parsed < 1 ? 1 : parsed;
|
|
164
|
+
}
|
|
152
165
|
render() {
|
|
153
166
|
const descriptor = this.getDescriptor();
|
|
154
167
|
return descriptor;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_legacy","data","require","_chalk","_interopRequireDefault","_lodash","_pMapSeries","_buildPipe","_buildTask","_buildPipelineOrder","e","__esModule","default","_defineProperty","r","t","_toPropertyKey","Object","defineProperty","value","enumerable","configurable","writable","i","_toPrimitive","Symbol","toPrimitive","call","TypeError","String","Number","pipeNames","getBuildPipe","getTagPipe","getSnapPipe","BuilderService","constructor","isolator","logger","taskSlot","pipeNameOnEnv","displayPipeName","artifactFactory","scope","configStore","runOnce","envsExecutionContext","options","envs","map","executionContext","envDefinition","tasksQueue","calculatePipelineOrder","tasks","skipTests","skipTasks","validate","info","toString","console","title","length","longProcessLogger","createLongProcessLogger","undefined","envsBuildContext","capsulesBaseDir","getComponentsCapsulesBaseDir","baseDir","useHash","isolateOptions","getExistingAsIs","seedersOnly","pMapSeries","componentIds","components","component","id","originalSeeders","originalSeedersOfThisEnv","filter","compId","find","seeder","isEqual","capsuleNetwork","isolateComponents","_originalSeeders","msg","chalk","cyan","extraDetails","seedersCapsules","graphCapsules","dim","buildContext","assign","previousTasksResults","pipeName","dev","laneId","legacyScope","getCurrentLaneId","envIdsWithoutVersion","env","split","buildPipe","BuildPipe","exitOnFirstFailedTask","showEnvNameInOutput","showEnvVersionInOutput","uniq","buildResults","execute","end","hasErrors","getConfig","CFG_CAPSULES_BUILD_COMPONENTS_BASE_DIR","render","descriptor","getDescriptor","transform","envContext","build","pipeline","compute","tag","snap","getTasksNamesByPipeFunc","pipeFuncName","task","BuildTaskHelper","serializeId","getCurrentPipeTasks","exports"],"sources":["builder.service.ts"],"sourcesContent":["import { CFG_CAPSULES_BUILD_COMPONENTS_BASE_DIR } from '@teambit/legacy.constants';\nimport type {\n EnvService,\n ExecutionContext,\n EnvDefinition,\n Env,\n EnvContext,\n ServiceTransformationMap,\n} from '@teambit/envs';\nimport chalk from 'chalk';\nimport { uniq } from 'lodash';\nimport type { ScopeMain } from '@teambit/scope';\nimport pMapSeries from 'p-map-series';\nimport type { Logger } from '@teambit/logger';\nimport type { IsolatorMain } from '@teambit/isolator';\nimport type { Component, ComponentID } from '@teambit/component';\nimport type { TaskResults } from './build-pipe';\nimport { BuildPipe } from './build-pipe';\nimport type { TaskResultsList } from './task-results-list';\nimport type { TaskSlot } from './builder.main.runtime';\nimport type { BuildContext, BuildTask } from './build-task';\nimport { BuildTaskHelper } from './build-task';\nimport type { ArtifactFactory } from './artifact';\nimport { calculatePipelineOrder } from './build-pipeline-order';\nimport type { ConfigStoreMain } from '@teambit/config-store';\n\nexport type BuildServiceResults = {\n id: string;\n buildResults: TaskResultsList;\n components: Component[];\n errors?: [];\n};\n\nexport type BuilderServiceOptions = {\n seedersOnly?: boolean;\n originalSeeders?: ComponentID[];\n tasks?: string[];\n skipTests?: boolean;\n skipTasks?: string[];\n previousTasksResults?: TaskResults[];\n dev?: boolean;\n exitOnFirstFailedTask?: boolean;\n capsulesBaseDir?: string;\n loose?: boolean; // avoid throwing errors if tasks like tests or lint fail\n};\n\ntype BuilderTransformationMap = ServiceTransformationMap & {\n getBuildPipe: () => BuildTask[];\n getTagPipe: () => BuildTask[];\n getSnapPipe: () => BuildTask[];\n};\n\nexport type EnvsBuildContext = { [envId: string]: BuildContext };\n\nconst pipeNames = {\n getBuildPipe: 'build',\n getTagPipe: 'tag',\n getSnapPipe: 'snap',\n};\n\nexport type PipeName = 'build' | 'tag' | 'snap';\n\nexport type BuilderDescriptor = Array<{ pipeName: PipeName; tasks: string[] }>;\n\nexport type PipeFunctionNames = keyof typeof pipeNames;\nexport class BuilderService implements EnvService<BuildServiceResults, string> {\n name = 'builder';\n\n constructor(\n /**\n * isolator extension.\n */\n private isolator: IsolatorMain,\n\n /**\n * logger extension.\n */\n private logger: Logger,\n\n /**\n * task slot (e.g tasks registered by other extensions.).\n */\n private taskSlot: TaskSlot,\n\n /**\n * a method with such name should be implemented on the env in order to run the pipe tasks.\n */\n private pipeNameOnEnv: PipeFunctionNames,\n\n /**\n * pipe name to display on the console during the execution\n */\n private displayPipeName: PipeName,\n private artifactFactory: ArtifactFactory,\n private scope: ScopeMain,\n private configStore: ConfigStoreMain\n ) {}\n\n /**\n * runs all tasks for all envs\n */\n async runOnce(envsExecutionContext: ExecutionContext[], options: BuilderServiceOptions): Promise<TaskResultsList> {\n const envs = envsExecutionContext.map((executionContext) => executionContext.envDefinition);\n const tasksQueue = calculatePipelineOrder(\n this.taskSlot,\n envs,\n this.pipeNameOnEnv,\n options.tasks,\n options.skipTests,\n options.skipTasks\n );\n tasksQueue.validate();\n this.logger.info(`going to run tasks in the following order:\\n${tasksQueue.toString()}`);\n this.logger.console('\\n'); // this is to make is clear separation between the various pipelines (build/snap/tag)\n const title = `Running ${this.displayPipeName} pipeline using ${envs.length} environment(s), total ${tasksQueue.length} tasks`;\n const longProcessLogger = this.logger.createLongProcessLogger(title, undefined, 'title');\n const envsBuildContext: EnvsBuildContext = {};\n const capsulesBaseDir = this.getComponentsCapsulesBaseDir();\n\n const baseDir = options.capsulesBaseDir || capsulesBaseDir;\n const useHash = !baseDir;\n const isolateOptions = {\n baseDir,\n useHash,\n getExistingAsIs: true,\n seedersOnly: options.seedersOnly,\n };\n\n await pMapSeries(envsExecutionContext, async (executionContext) => {\n const componentIds = executionContext.components.map((component) => component.id);\n const { originalSeeders } = options;\n const originalSeedersOfThisEnv = componentIds.filter((compId) =>\n originalSeeders ? originalSeeders.find((seeder) => compId.isEqual(seeder)) : true\n );\n const capsuleNetwork = await this.isolator.isolateComponents(componentIds, isolateOptions);\n capsuleNetwork._originalSeeders = originalSeedersOfThisEnv;\n const msg = `building ${chalk.cyan(originalSeedersOfThisEnv.length.toString())} components of env ${chalk.cyan(executionContext.id)}`;\n const extraDetails = `original seeders of this env: ${originalSeedersOfThisEnv.length}, graph of this env: ${capsuleNetwork.seedersCapsules.length}, graph total (include other envs): ${capsuleNetwork.graphCapsules.length}`;\n this.logger.console(`${msg}. ${chalk.dim(extraDetails)}`);\n const buildContext = Object.assign(executionContext, {\n capsuleNetwork,\n previousTasksResults: [],\n pipeName: this.displayPipeName,\n dev: options.dev,\n laneId: this.scope.legacyScope.getCurrentLaneId(),\n });\n envsBuildContext[executionContext.id] = buildContext;\n });\n const envIdsWithoutVersion = envs.map((env) => env.id.split('@')[0]);\n const buildPipe = new BuildPipe(\n tasksQueue,\n envsBuildContext,\n this.logger,\n this.artifactFactory,\n options.previousTasksResults,\n {\n exitOnFirstFailedTask: options.exitOnFirstFailedTask,\n showEnvNameInOutput: envs.length > 1,\n showEnvVersionInOutput: envIdsWithoutVersion.length > uniq(envIdsWithoutVersion).length,\n }\n );\n const buildResults = await buildPipe.execute();\n longProcessLogger.end(buildResults.hasErrors() ? 'error' : 'success');\n\n return buildResults;\n }\n\n getComponentsCapsulesBaseDir(): string | undefined {\n return this.configStore.getConfig(CFG_CAPSULES_BUILD_COMPONENTS_BASE_DIR);\n }\n\n render() {\n const descriptor = this.getDescriptor();\n return descriptor;\n }\n\n transform(env: Env, envContext: EnvContext): BuilderTransformationMap | undefined {\n if (!env?.build) return undefined;\n return {\n getBuildPipe: () => {\n // TODO: refactor after defining for an env property\n const pipeline = env.build?.();\n if (!pipeline || !pipeline.compute) return [];\n return pipeline?.compute(envContext);\n },\n getTagPipe: () => {\n // TODO: refactor after defining for an env property\n const pipeline = env.tag?.();\n if (!pipeline || !pipeline.compute) return [];\n return pipeline?.compute(envContext);\n },\n getSnapPipe: () => {\n const pipeline = env.snap?.();\n if (!pipeline || !pipeline.compute) return [];\n return pipeline?.compute(envContext);\n },\n };\n }\n\n getDescriptor() {\n return 'run `bit build --list-tasks <component-id>` to see the tasks list for the pipelines: build, tag and snap';\n }\n\n private getTasksNamesByPipeFunc(env: EnvDefinition, pipeFuncName: PipeFunctionNames): string[] {\n const tasksQueue = calculatePipelineOrder(this.taskSlot, [env], pipeFuncName).map(({ task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pMapSeries","_buildPipe","_buildTask","_buildPipelineOrder","e","__esModule","default","_defineProperty","r","t","_toPropertyKey","Object","defineProperty","value","enumerable","configurable","writable","i","_toPrimitive","Symbol","toPrimitive","call","TypeError","String","Number","pipeNames","getBuildPipe","getTagPipe","getSnapPipe","BuilderService","constructor","isolator","logger","taskSlot","pipeNameOnEnv","displayPipeName","artifactFactory","scope","configStore","runOnce","envsExecutionContext","options","envs","map","executionContext","envDefinition","tasksQueue","calculatePipelineOrder","tasks","skipTests","skipTasks","validate","info","toString","console","title","length","longProcessLogger","createLongProcessLogger","undefined","envsBuildContext","capsulesBaseDir","getComponentsCapsulesBaseDir","baseDir","useHash","isolateOptions","getExistingAsIs","seedersOnly","pMapSeries","componentIds","components","component","id","originalSeeders","originalSeedersOfThisEnv","filter","compId","find","seeder","isEqual","capsuleNetwork","isolateComponents","_originalSeeders","msg","chalk","cyan","extraDetails","seedersCapsules","graphCapsules","dim","buildContext","assign","previousTasksResults","pipeName","dev","laneId","legacyScope","getCurrentLaneId","envIdsWithoutVersion","env","split","buildPipe","BuildPipe","exitOnFirstFailedTask","showEnvNameInOutput","showEnvVersionInOutput","uniq","concurrency","getBuildConcurrency","buildResults","execute","end","hasErrors","getConfig","CFG_CAPSULES_BUILD_COMPONENTS_BASE_DIR","raw","process","BIT_BUILD_CONCURRENCY","parsed","parseInt","NaN","isNaN","render","descriptor","getDescriptor","transform","envContext","build","pipeline","compute","tag","snap","getTasksNamesByPipeFunc","pipeFuncName","task","BuildTaskHelper","serializeId","getCurrentPipeTasks","exports"],"sources":["builder.service.ts"],"sourcesContent":["import { CFG_CAPSULES_BUILD_COMPONENTS_BASE_DIR } from '@teambit/legacy.constants';\nimport type {\n EnvService,\n ExecutionContext,\n EnvDefinition,\n Env,\n EnvContext,\n ServiceTransformationMap,\n} from '@teambit/envs';\nimport chalk from 'chalk';\nimport { uniq } from 'lodash';\nimport type { ScopeMain } from '@teambit/scope';\nimport pMapSeries from 'p-map-series';\nimport type { Logger } from '@teambit/logger';\nimport type { IsolatorMain } from '@teambit/isolator';\nimport type { Component, ComponentID } from '@teambit/component';\nimport type { TaskResults } from './build-pipe';\nimport { BuildPipe } from './build-pipe';\nimport type { TaskResultsList } from './task-results-list';\nimport type { TaskSlot } from './builder.main.runtime';\nimport type { BuildContext, BuildTask } from './build-task';\nimport { BuildTaskHelper } from './build-task';\nimport type { ArtifactFactory } from './artifact';\nimport { calculatePipelineOrder } from './build-pipeline-order';\nimport type { ConfigStoreMain } from '@teambit/config-store';\n\nexport type BuildServiceResults = {\n id: string;\n buildResults: TaskResultsList;\n components: Component[];\n errors?: [];\n};\n\nexport type BuilderServiceOptions = {\n seedersOnly?: boolean;\n originalSeeders?: ComponentID[];\n tasks?: string[];\n skipTests?: boolean;\n skipTasks?: string[];\n previousTasksResults?: TaskResults[];\n dev?: boolean;\n exitOnFirstFailedTask?: boolean;\n capsulesBaseDir?: string;\n loose?: boolean; // avoid throwing errors if tasks like tests or lint fail\n};\n\ntype BuilderTransformationMap = ServiceTransformationMap & {\n getBuildPipe: () => BuildTask[];\n getTagPipe: () => BuildTask[];\n getSnapPipe: () => BuildTask[];\n};\n\nexport type EnvsBuildContext = { [envId: string]: BuildContext };\n\nconst pipeNames = {\n getBuildPipe: 'build',\n getTagPipe: 'tag',\n getSnapPipe: 'snap',\n};\n\nexport type PipeName = 'build' | 'tag' | 'snap';\n\nexport type BuilderDescriptor = Array<{ pipeName: PipeName; tasks: string[] }>;\n\nexport type PipeFunctionNames = keyof typeof pipeNames;\nexport class BuilderService implements EnvService<BuildServiceResults, string> {\n name = 'builder';\n\n constructor(\n /**\n * isolator extension.\n */\n private isolator: IsolatorMain,\n\n /**\n * logger extension.\n */\n private logger: Logger,\n\n /**\n * task slot (e.g tasks registered by other extensions.).\n */\n private taskSlot: TaskSlot,\n\n /**\n * a method with such name should be implemented on the env in order to run the pipe tasks.\n */\n private pipeNameOnEnv: PipeFunctionNames,\n\n /**\n * pipe name to display on the console during the execution\n */\n private displayPipeName: PipeName,\n private artifactFactory: ArtifactFactory,\n private scope: ScopeMain,\n private configStore: ConfigStoreMain\n ) {}\n\n /**\n * runs all tasks for all envs\n */\n async runOnce(envsExecutionContext: ExecutionContext[], options: BuilderServiceOptions): Promise<TaskResultsList> {\n const envs = envsExecutionContext.map((executionContext) => executionContext.envDefinition);\n const tasksQueue = calculatePipelineOrder(\n this.taskSlot,\n envs,\n this.pipeNameOnEnv,\n options.tasks,\n options.skipTests,\n options.skipTasks\n );\n tasksQueue.validate();\n this.logger.info(`going to run tasks in the following order:\\n${tasksQueue.toString()}`);\n this.logger.console('\\n'); // this is to make is clear separation between the various pipelines (build/snap/tag)\n const title = `Running ${this.displayPipeName} pipeline using ${envs.length} environment(s), total ${tasksQueue.length} tasks`;\n const longProcessLogger = this.logger.createLongProcessLogger(title, undefined, 'title');\n const envsBuildContext: EnvsBuildContext = {};\n const capsulesBaseDir = this.getComponentsCapsulesBaseDir();\n\n const baseDir = options.capsulesBaseDir || capsulesBaseDir;\n const useHash = !baseDir;\n const isolateOptions = {\n baseDir,\n useHash,\n getExistingAsIs: true,\n seedersOnly: options.seedersOnly,\n };\n\n await pMapSeries(envsExecutionContext, async (executionContext) => {\n const componentIds = executionContext.components.map((component) => component.id);\n const { originalSeeders } = options;\n const originalSeedersOfThisEnv = componentIds.filter((compId) =>\n originalSeeders ? originalSeeders.find((seeder) => compId.isEqual(seeder)) : true\n );\n const capsuleNetwork = await this.isolator.isolateComponents(componentIds, isolateOptions);\n capsuleNetwork._originalSeeders = originalSeedersOfThisEnv;\n const msg = `building ${chalk.cyan(originalSeedersOfThisEnv.length.toString())} components of env ${chalk.cyan(executionContext.id)}`;\n const extraDetails = `original seeders of this env: ${originalSeedersOfThisEnv.length}, graph of this env: ${capsuleNetwork.seedersCapsules.length}, graph total (include other envs): ${capsuleNetwork.graphCapsules.length}`;\n this.logger.console(`${msg}. ${chalk.dim(extraDetails)}`);\n const buildContext = Object.assign(executionContext, {\n capsuleNetwork,\n previousTasksResults: [],\n pipeName: this.displayPipeName,\n dev: options.dev,\n laneId: this.scope.legacyScope.getCurrentLaneId(),\n });\n envsBuildContext[executionContext.id] = buildContext;\n });\n const envIdsWithoutVersion = envs.map((env) => env.id.split('@')[0]);\n const buildPipe = new BuildPipe(\n tasksQueue,\n envsBuildContext,\n this.logger,\n this.artifactFactory,\n options.previousTasksResults,\n {\n exitOnFirstFailedTask: options.exitOnFirstFailedTask,\n showEnvNameInOutput: envs.length > 1,\n showEnvVersionInOutput: envIdsWithoutVersion.length > uniq(envIdsWithoutVersion).length,\n concurrency: this.getBuildConcurrency(),\n }\n );\n const buildResults = await buildPipe.execute();\n longProcessLogger.end(buildResults.hasErrors() ? 'error' : 'success');\n\n return buildResults;\n }\n\n getComponentsCapsulesBaseDir(): string | undefined {\n return this.configStore.getConfig(CFG_CAPSULES_BUILD_COMPONENTS_BASE_DIR);\n }\n\n /**\n * Number of environments whose build task-chains may run concurrently. Defaults to 1 (fully\n * serial — the original behavior). Opt into parallelism with the `BIT_BUILD_CONCURRENCY` env var\n * (handy for CI) or the `build.concurrency` config. In parallel mode each env's tasks still run\n * sequentially; only different envs run concurrently — see `BuildPipe.executeTasksInParallel`.\n */\n getBuildConcurrency(): number {\n const raw = process.env.BIT_BUILD_CONCURRENCY ?? this.configStore.getConfig('build.concurrency');\n const parsed = raw ? parseInt(raw, 10) : NaN;\n return Number.isNaN(parsed) || parsed < 1 ? 1 : parsed;\n }\n\n render() {\n const descriptor = this.getDescriptor();\n return descriptor;\n }\n\n transform(env: Env, envContext: EnvContext): BuilderTransformationMap | undefined {\n if (!env?.build) return undefined;\n return {\n getBuildPipe: () => {\n // TODO: refactor after defining for an env property\n const pipeline = env.build?.();\n if (!pipeline || !pipeline.compute) return [];\n return pipeline?.compute(envContext);\n },\n getTagPipe: () => {\n // TODO: refactor after defining for an env property\n const pipeline = env.tag?.();\n if (!pipeline || !pipeline.compute) return [];\n return pipeline?.compute(envContext);\n },\n getSnapPipe: () => {\n const pipeline = env.snap?.();\n if (!pipeline || !pipeline.compute) return [];\n return pipeline?.compute(envContext);\n },\n };\n }\n\n getDescriptor() {\n return 'run `bit build --list-tasks <component-id>` to see the tasks list for the pipelines: build, tag and snap';\n }\n\n private getTasksNamesByPipeFunc(env: EnvDefinition, pipeFuncName: PipeFunctionNames): string[] {\n const tasksQueue = calculatePipelineOrder(this.taskSlot, [env], pipeFuncName).map(({ task }) =>\n BuildTaskHelper.serializeId(task)\n );\n return tasksQueue;\n }\n\n getCurrentPipeTasks(env: EnvDefinition) {\n return this.getTasksNamesByPipeFunc(env, this.pipeNameOnEnv);\n }\n}\n"],"mappings":";;;;;;AAAA,SAAAA,QAAA;EAAA,MAAAC,IAAA,GAAAC,OAAA;EAAAF,OAAA,YAAAA,CAAA;IAAA,OAAAC,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AASA,SAAAE,OAAA;EAAA,MAAAF,IAAA,GAAAG,sBAAA,CAAAF,OAAA;EAAAC,MAAA,YAAAA,CAAA;IAAA,OAAAF,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAI,QAAA;EAAA,MAAAJ,IAAA,GAAAC,OAAA;EAAAG,OAAA,YAAAA,CAAA;IAAA,OAAAJ,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AAEA,SAAAK,YAAA;EAAA,MAAAL,IAAA,GAAAG,sBAAA,CAAAF,OAAA;EAAAI,WAAA,YAAAA,CAAA;IAAA,OAAAL,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AAKA,SAAAM,WAAA;EAAA,MAAAN,IAAA,GAAAC,OAAA;EAAAK,UAAA,YAAAA,CAAA;IAAA,OAAAN,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AAIA,SAAAO,WAAA;EAAA,MAAAP,IAAA,GAAAC,OAAA;EAAAM,UAAA,YAAAA,CAAA;IAAA,OAAAP,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AAEA,SAAAQ,oBAAA;EAAA,MAAAR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,CAACC,OAAO,EAAE,OAAO,EAAE;QAC7C,OAAOD,QAAQ,EAAEC,OAAO,CAACH,UAAU,CAAC;MACtC;IACF,CAAC;EACH;EAEAF,aAAaA,CAAA,EAAG;IACd,OAAO,0GAA0G;EACnH;EAEQQ,uBAAuBA,CAACjC,GAAkB,EAAEkC,YAA+B,EAAY;IAC7F,MAAMvF,UAAU,GAAG,IAAAC,4CAAsB,EAAC,IAAI,CAACd,QAAQ,EAAE,CAACkE,GAAG,CAAC,EAAEkC,YAAY,CAAC,CAAC1F,GAAG,CAAC,CAAC;MAAE2F;IAAK,CAAC,KACzFC,4BAAe,CAACC,WAAW,CAACF,IAAI,CAClC,CAAC;IACD,OAAOxF,UAAU;EACnB;EAEA2F,mBAAmBA,CAACtC,GAAkB,EAAE;IACtC,OAAO,IAAI,CAACiC,uBAAuB,CAACjC,GAAG,EAAE,IAAI,CAACjE,aAAa,CAAC;EAC9D;AACF;AAACwG,OAAA,CAAA7G,cAAA,GAAAA,cAAA","ignoreList":[]}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import * as compositions_0 from '/home/circleci/Library/Caches/Bit/capsules/8891be5ad/teambit.pipelines_builder@1.0.
|
|
2
|
-
import * as overview_0 from '/home/circleci/Library/Caches/Bit/capsules/8891be5ad/teambit.pipelines_builder@1.0.
|
|
1
|
+
import * as compositions_0 from '/home/circleci/Library/Caches/Bit/capsules/8891be5ad/teambit.pipelines_builder@1.0.1021/dist/builder.composition.js';
|
|
2
|
+
import * as overview_0 from '/home/circleci/Library/Caches/Bit/capsules/8891be5ad/teambit.pipelines_builder@1.0.1021/dist/builder.docs.mdx';
|
|
3
3
|
|
|
4
4
|
export const compositions = [compositions_0];
|
|
5
5
|
export const overview = [overview_0];
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Opt-in parallel build scheduler (enabled with `BIT_BUILD_CONCURRENCY` / the `build.concurrency`
|
|
3
|
+
* config; default 1 = the original serial `mapSeries` path). It runs environments concurrently while
|
|
4
|
+
* keeping each env's tasks sequential and honoring cross-env task dependencies + location barriers.
|
|
5
|
+
*
|
|
6
|
+
* WHY IT'S OFF BY DEFAULT — it did NOT help Bit's own build. Measured A/B on `bit_pr`, identical
|
|
7
|
+
* 97-component workload (CircleCI 2xlarge, 8 vCPU): serial build-pipeline wall ≈ 17m vs parallel
|
|
8
|
+
* (concurrency=3) ≈ 16m — a ~1m wash, with total `bit ci pr` essentially unchanged. The envs did
|
|
9
|
+
* overlap (parallel wall 16m vs its own task-time sum of 24m), but two effects cancelled the gain:
|
|
10
|
+
* 1. CPU contention. The tasks (tsc/webpack/babel) already saturate all cores on their own, so
|
|
11
|
+
* running several at once just oversubscribes — per-task times ballooned (one BabelCompile went
|
|
12
|
+
* 19s → 300s) and the heaviest env's chain grew from ~9.7m to ~15.5m, giving back what the
|
|
13
|
+
* overlap saved.
|
|
14
|
+
* 2. Single-env dominance. ~80% of the work is one env (`core-aspect-env`), a sequential chain
|
|
15
|
+
* cross-env parallelism can't split — so even with zero contention the floor is ~its own length.
|
|
16
|
+
*
|
|
17
|
+
* It CAN help a workspace whose build is spread across several similarly-sized envs, or a machine
|
|
18
|
+
* with spare cores beyond what one task uses. For a CPU-bound, one-env-dominated build like Bit's,
|
|
19
|
+
* reducing work (e.g. skipping preview/schema on PR builds) beats adding concurrency.
|
|
20
|
+
*/
|
|
21
|
+
import type { EnvDefinition } from '@teambit/envs';
|
|
22
|
+
import type { BuildTask } from './build-task';
|
|
23
|
+
export type SchedulerEntry = {
|
|
24
|
+
env: EnvDefinition;
|
|
25
|
+
task: BuildTask;
|
|
26
|
+
};
|
|
27
|
+
/**
|
|
28
|
+
* Split an already location-ordered queue (the queue `calculatePipelineOrder` produces is contiguous
|
|
29
|
+
* by location, in the order start → middle → end) into one segment per location group, preserving
|
|
30
|
+
* order. A new segment starts whenever the location changes from the previous entry.
|
|
31
|
+
*/
|
|
32
|
+
export declare function splitByLocation(queue: SchedulerEntry[]): SchedulerEntry[][];
|
|
33
|
+
/**
|
|
34
|
+
* Indices of the entries (within the same location segment) that `entry` must wait for:
|
|
35
|
+
* - its **per-env predecessor** — the previous entry of the same env. Keeping each env a sequential
|
|
36
|
+
* chain preserves the `getBuildPipe()` array order (most tasks rely on it, not on `dependencies`)
|
|
37
|
+
* and means two tasks of the same env never run concurrently (they share a capsule).
|
|
38
|
+
* - every entry whose task type matches one of `entry.task.dependencies` — for **all envs**. This is
|
|
39
|
+
* the documented "the dependency must be completed for all envs before this task starts" rule, e.g.
|
|
40
|
+
* the tester depends on the compiler, so tests wait for *every* env's compile, not just their own.
|
|
41
|
+
*
|
|
42
|
+
* Cross-location dependencies (e.g. pkg → typescript) need no handling here: locations run in order
|
|
43
|
+
* with a barrier between them, so an earlier-location dependency is always already done.
|
|
44
|
+
*/
|
|
45
|
+
export declare function computeBlockers(entries: SchedulerEntry[]): number[][];
|
|
46
|
+
/**
|
|
47
|
+
* Execute a build-task queue with environments running concurrently.
|
|
48
|
+
*
|
|
49
|
+
* Correctness model — matches the serial `mapSeries` path's guarantees:
|
|
50
|
+
* - **Barrier between location groups** (start → middle → end): a location fully completes before the
|
|
51
|
+
* next starts. Preserves the start/middle/end ordering (so e.g. preview/pkg in 'end' run after every
|
|
52
|
+
* compile in 'middle', even though the preview tasks don't declare a compiler dependency) and the
|
|
53
|
+
* completeness of `previousTasksResults` for later locations.
|
|
54
|
+
* - **Sequential within an env**: each env's tasks run in their original queue order and never overlap
|
|
55
|
+
* each other (they share a capsule).
|
|
56
|
+
* - **Cross-env declared dependencies honored**: a task waits for its `dependencies` task types across
|
|
57
|
+
* *all* envs (e.g. tests wait for every env's compile).
|
|
58
|
+
*
|
|
59
|
+
* Note: all envs share one capsule root dir, but this is still safe — every capsule file has a single
|
|
60
|
+
* writer env (a component's `dist` is produced only by its own env; a component's hard-linked
|
|
61
|
+
* artifacts only by the source component's env), and the TS compiler resolves cross-component types
|
|
62
|
+
* from source, so an env's compiled output never depends on a sibling env's build running first.
|
|
63
|
+
*/
|
|
64
|
+
export declare function executeTasksByLocationAndEnv(queue: SchedulerEntry[], concurrency: number, executor: (entry: SchedulerEntry) => Promise<void>): Promise<void>;
|
|
@@ -0,0 +1,169 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.computeBlockers = computeBlockers;
|
|
7
|
+
exports.executeTasksByLocationAndEnv = executeTasksByLocationAndEnv;
|
|
8
|
+
exports.splitByLocation = splitByLocation;
|
|
9
|
+
function _buildTask() {
|
|
10
|
+
const data = require("./build-task");
|
|
11
|
+
_buildTask = function () {
|
|
12
|
+
return data;
|
|
13
|
+
};
|
|
14
|
+
return data;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Opt-in parallel build scheduler (enabled with `BIT_BUILD_CONCURRENCY` / the `build.concurrency`
|
|
18
|
+
* config; default 1 = the original serial `mapSeries` path). It runs environments concurrently while
|
|
19
|
+
* keeping each env's tasks sequential and honoring cross-env task dependencies + location barriers.
|
|
20
|
+
*
|
|
21
|
+
* WHY IT'S OFF BY DEFAULT — it did NOT help Bit's own build. Measured A/B on `bit_pr`, identical
|
|
22
|
+
* 97-component workload (CircleCI 2xlarge, 8 vCPU): serial build-pipeline wall ≈ 17m vs parallel
|
|
23
|
+
* (concurrency=3) ≈ 16m — a ~1m wash, with total `bit ci pr` essentially unchanged. The envs did
|
|
24
|
+
* overlap (parallel wall 16m vs its own task-time sum of 24m), but two effects cancelled the gain:
|
|
25
|
+
* 1. CPU contention. The tasks (tsc/webpack/babel) already saturate all cores on their own, so
|
|
26
|
+
* running several at once just oversubscribes — per-task times ballooned (one BabelCompile went
|
|
27
|
+
* 19s → 300s) and the heaviest env's chain grew from ~9.7m to ~15.5m, giving back what the
|
|
28
|
+
* overlap saved.
|
|
29
|
+
* 2. Single-env dominance. ~80% of the work is one env (`core-aspect-env`), a sequential chain
|
|
30
|
+
* cross-env parallelism can't split — so even with zero contention the floor is ~its own length.
|
|
31
|
+
*
|
|
32
|
+
* It CAN help a workspace whose build is spread across several similarly-sized envs, or a machine
|
|
33
|
+
* with spare cores beyond what one task uses. For a CPU-bound, one-env-dominated build like Bit's,
|
|
34
|
+
* reducing work (e.g. skipping preview/schema on PR builds) beats adding concurrency.
|
|
35
|
+
*/
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* Split an already location-ordered queue (the queue `calculatePipelineOrder` produces is contiguous
|
|
39
|
+
* by location, in the order start → middle → end) into one segment per location group, preserving
|
|
40
|
+
* order. A new segment starts whenever the location changes from the previous entry.
|
|
41
|
+
*/
|
|
42
|
+
function splitByLocation(queue) {
|
|
43
|
+
const segments = [];
|
|
44
|
+
let currentLocation;
|
|
45
|
+
let current;
|
|
46
|
+
queue.forEach(entry => {
|
|
47
|
+
const location = entry.task.location || 'middle';
|
|
48
|
+
if (!current || location !== currentLocation) {
|
|
49
|
+
current = [];
|
|
50
|
+
segments.push(current);
|
|
51
|
+
currentLocation = location;
|
|
52
|
+
}
|
|
53
|
+
current.push(entry);
|
|
54
|
+
});
|
|
55
|
+
return segments;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* Indices of the entries (within the same location segment) that `entry` must wait for:
|
|
60
|
+
* - its **per-env predecessor** — the previous entry of the same env. Keeping each env a sequential
|
|
61
|
+
* chain preserves the `getBuildPipe()` array order (most tasks rely on it, not on `dependencies`)
|
|
62
|
+
* and means two tasks of the same env never run concurrently (they share a capsule).
|
|
63
|
+
* - every entry whose task type matches one of `entry.task.dependencies` — for **all envs**. This is
|
|
64
|
+
* the documented "the dependency must be completed for all envs before this task starts" rule, e.g.
|
|
65
|
+
* the tester depends on the compiler, so tests wait for *every* env's compile, not just their own.
|
|
66
|
+
*
|
|
67
|
+
* Cross-location dependencies (e.g. pkg → typescript) need no handling here: locations run in order
|
|
68
|
+
* with a barrier between them, so an earlier-location dependency is always already done.
|
|
69
|
+
*/
|
|
70
|
+
function computeBlockers(entries) {
|
|
71
|
+
const parsedDeps = entries.map(entry => (entry.task.dependencies || []).map(dep => _buildTask().BuildTaskHelper.deserializeIdAllowEmptyName(dep)));
|
|
72
|
+
return entries.map((entry, i) => {
|
|
73
|
+
const blockers = new Set();
|
|
74
|
+
// per-env predecessor (nearest earlier entry of the same env)
|
|
75
|
+
for (let j = i - 1; j >= 0; j -= 1) {
|
|
76
|
+
if (entries[j].env.id === entry.env.id) {
|
|
77
|
+
blockers.add(j);
|
|
78
|
+
break;
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
// declared dependencies, matched across all envs in this location
|
|
82
|
+
const deps = parsedDeps[i];
|
|
83
|
+
if (deps.length) {
|
|
84
|
+
entries.forEach((other, k) => {
|
|
85
|
+
if (k === i) return;
|
|
86
|
+
const matches = deps.some(({
|
|
87
|
+
aspectId,
|
|
88
|
+
name
|
|
89
|
+
}) => other.task.aspectId === aspectId && (name === undefined || other.task.name === name));
|
|
90
|
+
if (matches) blockers.add(k);
|
|
91
|
+
});
|
|
92
|
+
}
|
|
93
|
+
return [...blockers];
|
|
94
|
+
});
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
/**
|
|
98
|
+
* Run one location segment: every entry starts as soon as its blockers are done, up to `concurrency`
|
|
99
|
+
* at a time. Blockers form a DAG whose edges always point to earlier indices (per-env predecessors
|
|
100
|
+
* are earlier; declared-dependency task types are toposorted earlier by `calculatePipelineOrder`), so
|
|
101
|
+
* there is always a runnable entry and no deadlock. The first executor rejection aborts the segment.
|
|
102
|
+
*/
|
|
103
|
+
function runLocation(entries, concurrency, executor) {
|
|
104
|
+
const n = entries.length;
|
|
105
|
+
if (n === 0) return Promise.resolve();
|
|
106
|
+
const blockers = computeBlockers(entries);
|
|
107
|
+
const done = Array.from({
|
|
108
|
+
length: n
|
|
109
|
+
}, () => false);
|
|
110
|
+
const started = Array.from({
|
|
111
|
+
length: n
|
|
112
|
+
}, () => false);
|
|
113
|
+
return new Promise((resolve, reject) => {
|
|
114
|
+
let inFlight = 0;
|
|
115
|
+
let completed = 0;
|
|
116
|
+
let aborted = false;
|
|
117
|
+
const launchReady = () => {
|
|
118
|
+
if (aborted) return;
|
|
119
|
+
if (completed === n) {
|
|
120
|
+
resolve();
|
|
121
|
+
return;
|
|
122
|
+
}
|
|
123
|
+
for (let i = 0; i < n && inFlight < concurrency; i += 1) {
|
|
124
|
+
if (started[i] || !blockers[i].every(b => done[b])) continue;
|
|
125
|
+
started[i] = true;
|
|
126
|
+
inFlight += 1;
|
|
127
|
+
Promise.resolve().then(() => executor(entries[i])).then(() => {
|
|
128
|
+
done[i] = true;
|
|
129
|
+
inFlight -= 1;
|
|
130
|
+
completed += 1;
|
|
131
|
+
launchReady();
|
|
132
|
+
}).catch(err => {
|
|
133
|
+
aborted = true;
|
|
134
|
+
reject(err);
|
|
135
|
+
});
|
|
136
|
+
}
|
|
137
|
+
};
|
|
138
|
+
launchReady();
|
|
139
|
+
});
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
/**
|
|
143
|
+
* Execute a build-task queue with environments running concurrently.
|
|
144
|
+
*
|
|
145
|
+
* Correctness model — matches the serial `mapSeries` path's guarantees:
|
|
146
|
+
* - **Barrier between location groups** (start → middle → end): a location fully completes before the
|
|
147
|
+
* next starts. Preserves the start/middle/end ordering (so e.g. preview/pkg in 'end' run after every
|
|
148
|
+
* compile in 'middle', even though the preview tasks don't declare a compiler dependency) and the
|
|
149
|
+
* completeness of `previousTasksResults` for later locations.
|
|
150
|
+
* - **Sequential within an env**: each env's tasks run in their original queue order and never overlap
|
|
151
|
+
* each other (they share a capsule).
|
|
152
|
+
* - **Cross-env declared dependencies honored**: a task waits for its `dependencies` task types across
|
|
153
|
+
* *all* envs (e.g. tests wait for every env's compile).
|
|
154
|
+
*
|
|
155
|
+
* Note: all envs share one capsule root dir, but this is still safe — every capsule file has a single
|
|
156
|
+
* writer env (a component's `dist` is produced only by its own env; a component's hard-linked
|
|
157
|
+
* artifacts only by the source component's env), and the TS compiler resolves cross-component types
|
|
158
|
+
* from source, so an env's compiled output never depends on a sibling env's build running first.
|
|
159
|
+
*/
|
|
160
|
+
async function executeTasksByLocationAndEnv(queue, concurrency, executor) {
|
|
161
|
+
const limit = Math.max(concurrency, 1);
|
|
162
|
+
const segments = splitByLocation(queue);
|
|
163
|
+
// sequential `for` (not Promise.all) is the location barrier — each segment fully resolves first.
|
|
164
|
+
for (const segment of segments) {
|
|
165
|
+
await runLocation(segment, limit, executor);
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
//# sourceMappingURL=tasks-parallel-scheduler.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_buildTask","data","require","splitByLocation","queue","segments","currentLocation","current","forEach","entry","location","task","push","computeBlockers","entries","parsedDeps","map","dependencies","dep","BuildTaskHelper","deserializeIdAllowEmptyName","i","blockers","Set","j","env","id","add","deps","length","other","k","matches","some","aspectId","name","undefined","runLocation","concurrency","executor","n","Promise","resolve","done","Array","from","started","reject","inFlight","completed","aborted","launchReady","every","b","then","catch","err","executeTasksByLocationAndEnv","limit","Math","max","segment"],"sources":["tasks-parallel-scheduler.ts"],"sourcesContent":["/**\n * Opt-in parallel build scheduler (enabled with `BIT_BUILD_CONCURRENCY` / the `build.concurrency`\n * config; default 1 = the original serial `mapSeries` path). It runs environments concurrently while\n * keeping each env's tasks sequential and honoring cross-env task dependencies + location barriers.\n *\n * WHY IT'S OFF BY DEFAULT — it did NOT help Bit's own build. Measured A/B on `bit_pr`, identical\n * 97-component workload (CircleCI 2xlarge, 8 vCPU): serial build-pipeline wall ≈ 17m vs parallel\n * (concurrency=3) ≈ 16m — a ~1m wash, with total `bit ci pr` essentially unchanged. The envs did\n * overlap (parallel wall 16m vs its own task-time sum of 24m), but two effects cancelled the gain:\n * 1. CPU contention. The tasks (tsc/webpack/babel) already saturate all cores on their own, so\n * running several at once just oversubscribes — per-task times ballooned (one BabelCompile went\n * 19s → 300s) and the heaviest env's chain grew from ~9.7m to ~15.5m, giving back what the\n * overlap saved.\n * 2. Single-env dominance. ~80% of the work is one env (`core-aspect-env`), a sequential chain\n * cross-env parallelism can't split — so even with zero contention the floor is ~its own length.\n *\n * It CAN help a workspace whose build is spread across several similarly-sized envs, or a machine\n * with spare cores beyond what one task uses. For a CPU-bound, one-env-dominated build like Bit's,\n * reducing work (e.g. skipping preview/schema on PR builds) beats adding concurrency.\n */\nimport type { EnvDefinition } from '@teambit/envs';\nimport type { BuildTask } from './build-task';\nimport { BuildTaskHelper } from './build-task';\n\nexport type SchedulerEntry = { env: EnvDefinition; task: BuildTask };\n\n/**\n * Split an already location-ordered queue (the queue `calculatePipelineOrder` produces is contiguous\n * by location, in the order start → middle → end) into one segment per location group, preserving\n * order. A new segment starts whenever the location changes from the previous entry.\n */\nexport function splitByLocation(queue: SchedulerEntry[]): SchedulerEntry[][] {\n const segments: SchedulerEntry[][] = [];\n let currentLocation: string | undefined;\n let current: SchedulerEntry[] | undefined;\n queue.forEach((entry) => {\n const location = entry.task.location || 'middle';\n if (!current || location !== currentLocation) {\n current = [];\n segments.push(current);\n currentLocation = location;\n }\n current.push(entry);\n });\n return segments;\n}\n\n/**\n * Indices of the entries (within the same location segment) that `entry` must wait for:\n * - its **per-env predecessor** — the previous entry of the same env. Keeping each env a sequential\n * chain preserves the `getBuildPipe()` array order (most tasks rely on it, not on `dependencies`)\n * and means two tasks of the same env never run concurrently (they share a capsule).\n * - every entry whose task type matches one of `entry.task.dependencies` — for **all envs**. This is\n * the documented \"the dependency must be completed for all envs before this task starts\" rule, e.g.\n * the tester depends on the compiler, so tests wait for *every* env's compile, not just their own.\n *\n * Cross-location dependencies (e.g. pkg → typescript) need no handling here: locations run in order\n * with a barrier between them, so an earlier-location dependency is always already done.\n */\nexport function computeBlockers(entries: SchedulerEntry[]): number[][] {\n const parsedDeps = entries.map((entry) =>\n (entry.task.dependencies || []).map((dep) => BuildTaskHelper.deserializeIdAllowEmptyName(dep))\n );\n return entries.map((entry, i) => {\n const blockers = new Set<number>();\n // per-env predecessor (nearest earlier entry of the same env)\n for (let j = i - 1; j >= 0; j -= 1) {\n if (entries[j].env.id === entry.env.id) {\n blockers.add(j);\n break;\n }\n }\n // declared dependencies, matched across all envs in this location\n const deps = parsedDeps[i];\n if (deps.length) {\n entries.forEach((other, k) => {\n if (k === i) return;\n const matches = deps.some(\n ({ aspectId, name }) => other.task.aspectId === aspectId && (name === undefined || other.task.name === name)\n );\n if (matches) blockers.add(k);\n });\n }\n return [...blockers];\n });\n}\n\n/**\n * Run one location segment: every entry starts as soon as its blockers are done, up to `concurrency`\n * at a time. Blockers form a DAG whose edges always point to earlier indices (per-env predecessors\n * are earlier; declared-dependency task types are toposorted earlier by `calculatePipelineOrder`), so\n * there is always a runnable entry and no deadlock. The first executor rejection aborts the segment.\n */\nfunction runLocation(\n entries: SchedulerEntry[],\n concurrency: number,\n executor: (entry: SchedulerEntry) => Promise<void>\n): Promise<void> {\n const n = entries.length;\n if (n === 0) return Promise.resolve();\n const blockers = computeBlockers(entries);\n const done: boolean[] = Array.from({ length: n }, () => false);\n const started: boolean[] = Array.from({ length: n }, () => false);\n\n return new Promise<void>((resolve, reject) => {\n let inFlight = 0;\n let completed = 0;\n let aborted = false;\n\n const launchReady = () => {\n if (aborted) return;\n if (completed === n) {\n resolve();\n return;\n }\n for (let i = 0; i < n && inFlight < concurrency; i += 1) {\n if (started[i] || !blockers[i].every((b) => done[b])) continue;\n started[i] = true;\n inFlight += 1;\n Promise.resolve()\n .then(() => executor(entries[i]))\n .then(() => {\n done[i] = true;\n inFlight -= 1;\n completed += 1;\n launchReady();\n })\n .catch((err) => {\n aborted = true;\n reject(err);\n });\n }\n };\n\n launchReady();\n });\n}\n\n/**\n * Execute a build-task queue with environments running concurrently.\n *\n * Correctness model — matches the serial `mapSeries` path's guarantees:\n * - **Barrier between location groups** (start → middle → end): a location fully completes before the\n * next starts. Preserves the start/middle/end ordering (so e.g. preview/pkg in 'end' run after every\n * compile in 'middle', even though the preview tasks don't declare a compiler dependency) and the\n * completeness of `previousTasksResults` for later locations.\n * - **Sequential within an env**: each env's tasks run in their original queue order and never overlap\n * each other (they share a capsule).\n * - **Cross-env declared dependencies honored**: a task waits for its `dependencies` task types across\n * *all* envs (e.g. tests wait for every env's compile).\n *\n * Note: all envs share one capsule root dir, but this is still safe — every capsule file has a single\n * writer env (a component's `dist` is produced only by its own env; a component's hard-linked\n * artifacts only by the source component's env), and the TS compiler resolves cross-component types\n * from source, so an env's compiled output never depends on a sibling env's build running first.\n */\nexport async function executeTasksByLocationAndEnv(\n queue: SchedulerEntry[],\n concurrency: number,\n executor: (entry: SchedulerEntry) => Promise<void>\n): Promise<void> {\n const limit = Math.max(concurrency, 1);\n const segments = splitByLocation(queue);\n // sequential `for` (not Promise.all) is the location barrier — each segment fully resolves first.\n for (const segment of segments) {\n await runLocation(segment, limit, executor);\n }\n}\n"],"mappings":";;;;;;;;AAsBA,SAAAA,WAAA;EAAA,MAAAC,IAAA,GAAAC,OAAA;EAAAF,UAAA,YAAAA,CAAA;IAAA,OAAAC,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AAtBA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAOA;AACA;AACA;AACA;AACA;AACO,SAASE,eAAeA,CAACC,KAAuB,EAAsB;EAC3E,MAAMC,QAA4B,GAAG,EAAE;EACvC,IAAIC,eAAmC;EACvC,IAAIC,OAAqC;EACzCH,KAAK,CAACI,OAAO,CAAEC,KAAK,IAAK;IACvB,MAAMC,QAAQ,GAAGD,KAAK,CAACE,IAAI,CAACD,QAAQ,IAAI,QAAQ;IAChD,IAAI,CAACH,OAAO,IAAIG,QAAQ,KAAKJ,eAAe,EAAE;MAC5CC,OAAO,GAAG,EAAE;MACZF,QAAQ,CAACO,IAAI,CAACL,OAAO,CAAC;MACtBD,eAAe,G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zB,CAAC,CAAC,GAAG,IAAI;QACjB2B,QAAQ,IAAI,CAAC;QACbP,OAAO,CAACC,OAAO,CAAC,CAAC,CACdY,IAAI,CAAC,MAAMf,QAAQ,CAACzB,OAAO,CAACO,CAAC,CAAC,CAAC,CAAC,CAChCiC,IAAI,CAAC,MAAM;UACVX,IAAI,CAACtB,CAAC,CAAC,GAAG,IAAI;UACd2B,QAAQ,IAAI,CAAC;UACbC,SAAS,IAAI,CAAC;UACdE,WAAW,CAAC,CAAC;QACf,CAAC,CAAC,CACDI,KAAK,CAAEC,GAAG,IAAK;UACdN,OAAO,GAAG,IAAI;UACdH,MAAM,CAACS,GAAG,CAAC;QACb,CAAC,CAAC;MACN;IACF,CAAC;IAEDL,WAAW,CAAC,CAAC;EACf,CAAC,CAAC;AACJ;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,eAAeM,4BAA4BA,CAChDrD,KAAuB,EACvBkC,WAAmB,EACnBC,QAAkD,EACnC;EACf,MAAMmB,KAAK,GAAGC,IAAI,CAACC,GAAG,CAACtB,WAAW,EAAE,CAAC,CAAC;EACtC,MAAMjC,QAAQ,GAAGF,eAAe,CAACC,KAAK,CAAC;EACvC;EACA,KAAK,MAAMyD,OAAO,IAAIxD,QAAQ,EAAE;IAC9B,MAAMgC,WAAW,CAACwB,OAAO,EAAEH,KAAK,EAAEnB,QAAQ,CAAC;EAC7C;AACF","ignoreList":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,160 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
function _chai() {
|
|
4
|
+
const data = require("chai");
|
|
5
|
+
_chai = function () {
|
|
6
|
+
return data;
|
|
7
|
+
};
|
|
8
|
+
return data;
|
|
9
|
+
}
|
|
10
|
+
function _tasksParallelScheduler() {
|
|
11
|
+
const data = require("./tasks-parallel-scheduler");
|
|
12
|
+
_tasksParallelScheduler = function () {
|
|
13
|
+
return data;
|
|
14
|
+
};
|
|
15
|
+
return data;
|
|
16
|
+
}
|
|
17
|
+
// Minimal fakes — the scheduler only reads `env.id` and the task's `aspectId`, `name`, `location`,
|
|
18
|
+
// `dependencies`. `aspectId` defaults to `name` so a dep referencing `name` matches by aspect id
|
|
19
|
+
// (mirrors how real tasks like the tester depend on `CompilerAspect.id`).
|
|
20
|
+
function entry(envId, name, opts = {}) {
|
|
21
|
+
return {
|
|
22
|
+
env: {
|
|
23
|
+
id: envId
|
|
24
|
+
},
|
|
25
|
+
task: {
|
|
26
|
+
aspectId: opts.aspectId ?? name,
|
|
27
|
+
name,
|
|
28
|
+
location: opts.location,
|
|
29
|
+
dependencies: opts.deps
|
|
30
|
+
}
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
const delay = ms => new Promise(resolve => setTimeout(resolve, ms));
|
|
34
|
+
describe('tasks-parallel-scheduler', () => {
|
|
35
|
+
describe('splitByLocation', () => {
|
|
36
|
+
it('splits a contiguous start→middle→end queue into one segment per location', () => {
|
|
37
|
+
const queue = [entry('envA', 'exporter', {
|
|
38
|
+
location: 'start'
|
|
39
|
+
}), entry('envA', 'compile'), entry('envB', 'compile'), entry('envA', 'schema', {
|
|
40
|
+
location: 'end'
|
|
41
|
+
}), entry('envB', 'schema', {
|
|
42
|
+
location: 'end'
|
|
43
|
+
})];
|
|
44
|
+
const segments = (0, _tasksParallelScheduler().splitByLocation)(queue);
|
|
45
|
+
(0, _chai().expect)(segments.map(s => s.length)).to.deep.equal([1, 2, 2]);
|
|
46
|
+
});
|
|
47
|
+
it('treats undeclared location as middle', () => {
|
|
48
|
+
(0, _chai().expect)((0, _tasksParallelScheduler().splitByLocation)([entry('envA', 'a'), entry('envA', 'b')])).to.have.lengthOf(1);
|
|
49
|
+
});
|
|
50
|
+
});
|
|
51
|
+
describe('computeBlockers', () => {
|
|
52
|
+
it('blocks each task on its per-env predecessor and on its declared deps across ALL envs', () => {
|
|
53
|
+
const entries = [entry('envA', 'compile', {
|
|
54
|
+
aspectId: 'compiler'
|
|
55
|
+
}),
|
|
56
|
+
// 0
|
|
57
|
+
entry('envB', 'compile', {
|
|
58
|
+
aspectId: 'compiler'
|
|
59
|
+
}),
|
|
60
|
+
// 1
|
|
61
|
+
entry('envA', 'test', {
|
|
62
|
+
aspectId: 'tester',
|
|
63
|
+
deps: ['compiler']
|
|
64
|
+
}),
|
|
65
|
+
// 2
|
|
66
|
+
entry('envB', 'test', {
|
|
67
|
+
aspectId: 'tester',
|
|
68
|
+
deps: ['compiler']
|
|
69
|
+
}) // 3
|
|
70
|
+
];
|
|
71
|
+
const blockers = (0, _tasksParallelScheduler().computeBlockers)(entries).map(b => b.slice().sort((x, y) => x - y));
|
|
72
|
+
(0, _chai().expect)(blockers[0]).to.deep.equal([]); // first compile — nothing
|
|
73
|
+
(0, _chai().expect)(blockers[1]).to.deep.equal([]); // envB compile — no envB predecessor, no deps
|
|
74
|
+
(0, _chai().expect)(blockers[2]).to.deep.equal([0, 1]); // envA test — its compile (0) + ALL compiles (0,1)
|
|
75
|
+
(0, _chai().expect)(blockers[3]).to.deep.equal([0, 1]); // envB test — its compile (1) + ALL compiles (0,1)
|
|
76
|
+
});
|
|
77
|
+
});
|
|
78
|
+
describe('executeTasksByLocationAndEnv', () => {
|
|
79
|
+
it('runs every entry exactly once', async () => {
|
|
80
|
+
const queue = [entry('envA', 'compile'), entry('envB', 'compile'), entry('envA', 'schema', {
|
|
81
|
+
location: 'end'
|
|
82
|
+
})];
|
|
83
|
+
const seen = [];
|
|
84
|
+
await (0, _tasksParallelScheduler().executeTasksByLocationAndEnv)(queue, 4, async e => {
|
|
85
|
+
seen.push(`${e.env.id}:${e.task.name}`);
|
|
86
|
+
});
|
|
87
|
+
(0, _chai().expect)(seen.sort()).to.deep.equal(['envA:compile', 'envA:schema', 'envB:compile']);
|
|
88
|
+
});
|
|
89
|
+
it('preserves task order within an env (never reorders or overlaps an env chain)', async () => {
|
|
90
|
+
const events = [];
|
|
91
|
+
const queue = [entry('envA', 'compile'), entry('envA', 'test')];
|
|
92
|
+
await (0, _tasksParallelScheduler().executeTasksByLocationAndEnv)(queue, 4, async e => {
|
|
93
|
+
events.push(`start:${e.task.name}`);
|
|
94
|
+
await delay(e.task.name === 'compile' ? 30 : 0);
|
|
95
|
+
events.push(`end:${e.task.name}`);
|
|
96
|
+
});
|
|
97
|
+
(0, _chai().expect)(events).to.deep.equal(['start:compile', 'end:compile', 'start:test', 'end:test']);
|
|
98
|
+
});
|
|
99
|
+
it('runs different envs concurrently within a location', async () => {
|
|
100
|
+
const events = [];
|
|
101
|
+
const queue = [entry('envA', 'compile'), entry('envB', 'compile')];
|
|
102
|
+
await (0, _tasksParallelScheduler().executeTasksByLocationAndEnv)(queue, 4, async e => {
|
|
103
|
+
events.push(`start:${e.env.id}`);
|
|
104
|
+
await delay(e.env.id === 'envA' ? 40 : 5);
|
|
105
|
+
events.push(`end:${e.env.id}`);
|
|
106
|
+
});
|
|
107
|
+
// envB starts before envA ends → proves concurrency.
|
|
108
|
+
(0, _chai().expect)(events.indexOf('start:envB')).to.be.lessThan(events.indexOf('end:envA'));
|
|
109
|
+
});
|
|
110
|
+
it("honors a cross-env declared dependency: a task waits for ALL envs' dep, not just its own", async () => {
|
|
111
|
+
// envA's compile is fast, envB's compile is slow. envA's test depends on the compiler, so it
|
|
112
|
+
// must wait for envB's compile too — not start right after its own (fast) compile.
|
|
113
|
+
const events = [];
|
|
114
|
+
const queue = [entry('envA', 'compile', {
|
|
115
|
+
aspectId: 'compiler'
|
|
116
|
+
}), entry('envB', 'compile', {
|
|
117
|
+
aspectId: 'compiler'
|
|
118
|
+
}), entry('envA', 'test', {
|
|
119
|
+
aspectId: 'tester',
|
|
120
|
+
deps: ['compiler']
|
|
121
|
+
})];
|
|
122
|
+
await (0, _tasksParallelScheduler().executeTasksByLocationAndEnv)(queue, 4, async e => {
|
|
123
|
+
events.push(`start:${e.env.id}:${e.task.name}`);
|
|
124
|
+
await delay(e.env.id === 'envB' && e.task.name === 'compile' ? 40 : 2);
|
|
125
|
+
events.push(`end:${e.env.id}:${e.task.name}`);
|
|
126
|
+
});
|
|
127
|
+
(0, _chai().expect)(events.indexOf('start:envA:test')).to.be.greaterThan(events.indexOf('end:envB:compile'));
|
|
128
|
+
});
|
|
129
|
+
it('enforces a barrier between locations: no end task starts before all middle tasks finish', async () => {
|
|
130
|
+
const events = [];
|
|
131
|
+
const queue = [entry('envA', 'compile'), entry('envB', 'compile'), entry('envA', 'preview', {
|
|
132
|
+
location: 'end'
|
|
133
|
+
}), entry('envB', 'preview', {
|
|
134
|
+
location: 'end'
|
|
135
|
+
})];
|
|
136
|
+
await (0, _tasksParallelScheduler().executeTasksByLocationAndEnv)(queue, 4, async e => {
|
|
137
|
+
events.push(`start:${e.task.name}:${e.env.id}`);
|
|
138
|
+
await delay(e.task.name === 'compile' && e.env.id === 'envA' ? 40 : 2);
|
|
139
|
+
events.push(`end:${e.task.name}:${e.env.id}`);
|
|
140
|
+
});
|
|
141
|
+
const lastMiddleEnd = Math.max(events.indexOf('end:compile:envA'), events.indexOf('end:compile:envB'));
|
|
142
|
+
const firstEndStart = Math.min(events.indexOf('start:preview:envA'), events.indexOf('start:preview:envB'));
|
|
143
|
+
(0, _chai().expect)(firstEndStart).to.be.greaterThan(lastMiddleEnd);
|
|
144
|
+
});
|
|
145
|
+
it('bounds concurrency to the given limit', async () => {
|
|
146
|
+
let inFlight = 0;
|
|
147
|
+
let maxInFlight = 0;
|
|
148
|
+
const queue = ['e1', 'e2', 'e3', 'e4', 'e5'].map(id => entry(id, 'compile'));
|
|
149
|
+
await (0, _tasksParallelScheduler().executeTasksByLocationAndEnv)(queue, 2, async () => {
|
|
150
|
+
inFlight += 1;
|
|
151
|
+
maxInFlight = Math.max(maxInFlight, inFlight);
|
|
152
|
+
await delay(10);
|
|
153
|
+
inFlight -= 1;
|
|
154
|
+
});
|
|
155
|
+
(0, _chai().expect)(maxInFlight).to.equal(2);
|
|
156
|
+
});
|
|
157
|
+
});
|
|
158
|
+
});
|
|
159
|
+
|
|
160
|
+
//# sourceMappingURL=tasks-parallel-scheduler.spec.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_chai","data","require","_tasksParallelScheduler","entry","envId","name","opts","env","id","task","aspectId","location","dependencies","deps","delay","ms","Promise","resolve","setTimeout","describe","it","queue","segments","splitByLocation","expect","map","s","length","to","deep","equal","have","lengthOf","entries","blockers","computeBlockers","b","slice","sort","x","y","seen","executeTasksByLocationAndEnv","e","push","events","indexOf","be","lessThan","greaterThan","lastMiddleEnd","Math","max","firstEndStart","min","inFlight","maxInFlight"],"sources":["tasks-parallel-scheduler.spec.ts"],"sourcesContent":["import { expect } from 'chai';\nimport type { SchedulerEntry } from './tasks-parallel-scheduler';\nimport { splitByLocation, computeBlockers, executeTasksByLocationAndEnv } from './tasks-parallel-scheduler';\n\ntype EntryOpts = { aspectId?: string; location?: 'start' | 'end'; deps?: string[] };\n\n// Minimal fakes — the scheduler only reads `env.id` and the task's `aspectId`, `name`, `location`,\n// `dependencies`. `aspectId` defaults to `name` so a dep referencing `name` matches by aspect id\n// (mirrors how real tasks like the tester depend on `CompilerAspect.id`).\nfunction entry(envId: string, name: string, opts: EntryOpts = {}): SchedulerEntry {\n return {\n env: { id: envId } as any,\n task: { aspectId: opts.aspectId ?? name, name, location: opts.location, dependencies: opts.deps } as any,\n };\n}\n\nconst delay = (ms: number) => new Promise((resolve) => setTimeout(resolve, ms));\n\ndescribe('tasks-parallel-scheduler', () => {\n describe('splitByLocation', () => {\n it('splits a contiguous start→middle→end queue into one segment per location', () => {\n const queue = [\n entry('envA', 'exporter', { location: 'start' }),\n entry('envA', 'compile'),\n entry('envB', 'compile'),\n entry('envA', 'schema', { location: 'end' }),\n entry('envB', 'schema', { location: 'end' }),\n ];\n const segments = splitByLocation(queue);\n expect(segments.map((s) => s.length)).to.deep.equal([1, 2, 2]);\n });\n\n it('treats undeclared location as middle', () => {\n expect(splitByLocation([entry('envA', 'a'), entry('envA', 'b')])).to.have.lengthOf(1);\n });\n });\n\n describe('computeBlockers', () => {\n it('blocks each task on its per-env predecessor and on its declared deps across ALL envs', () => {\n const entries = [\n entry('envA', 'compile', { aspectId: 'compiler' }), // 0\n entry('envB', 'compile', { aspectId: 'compiler' }), // 1\n entry('envA', 'test', { aspectId: 'tester', deps: ['compiler'] }), // 2\n entry('envB', 'test', { aspectId: 'tester', deps: ['compiler'] }), // 3\n ];\n const blockers = computeBlockers(entries).map((b) => b.slice().sort((x, y) => x - y));\n expect(blockers[0]).to.deep.equal([]); // first compile — nothing\n expect(blockers[1]).to.deep.equal([]); // envB compile — no envB predecessor, no deps\n expect(blockers[2]).to.deep.equal([0, 1]); // envA test — its compile (0) + ALL compiles (0,1)\n expect(blockers[3]).to.deep.equal([0, 1]); // envB test — its compile (1) + ALL compiles (0,1)\n });\n });\n\n describe('executeTasksByLocationAndEnv', () => {\n it('runs every entry exactly once', async () => {\n const queue = [entry('envA', 'compile'), entry('envB', 'compile'), entry('envA', 'schema', { location: 'end' })];\n const seen: string[] = [];\n await executeTasksByLocationAndEnv(queue, 4, async (e) => {\n seen.push(`${e.env.id}:${e.task.name}`);\n });\n expect(seen.sort()).to.deep.equal(['envA:compile', 'envA:schema', 'envB:compile']);\n });\n\n it('preserves task order within an env (never reorders or overlaps an env chain)', async () => {\n const events: string[] = [];\n const queue = [entry('envA', 'compile'), entry('envA', 'test')];\n await executeTasksByLocationAndEnv(queue, 4, async (e) => {\n events.push(`start:${e.task.name}`);\n await delay(e.task.name === 'compile' ? 30 : 0);\n events.push(`end:${e.task.name}`);\n });\n expect(events).to.deep.equal(['start:compile', 'end:compile', 'start:test', 'end:test']);\n });\n\n it('runs different envs concurrently within a location', async () => {\n const events: string[] = [];\n const queue = [entry('envA', 'compile'), entry('envB', 'compile')];\n await executeTasksByLocationAndEnv(queue, 4, async (e) => {\n events.push(`start:${e.env.id}`);\n await delay(e.env.id === 'envA' ? 40 : 5);\n events.push(`end:${e.env.id}`);\n });\n // envB starts before envA ends → proves concurrency.\n expect(events.indexOf('start:envB')).to.be.lessThan(events.indexOf('end:envA'));\n });\n\n it(\"honors a cross-env declared dependency: a task waits for ALL envs' dep, not just its own\", async () => {\n // envA's compile is fast, envB's compile is slow. envA's test depends on the compiler, so it\n // must wait for envB's compile too — not start right after its own (fast) compile.\n const events: string[] = [];\n const queue = [\n entry('envA', 'compile', { aspectId: 'compiler' }),\n entry('envB', 'compile', { aspectId: 'compiler' }),\n entry('envA', 'test', { aspectId: 'tester', deps: ['compiler'] }),\n ];\n await executeTasksByLocationAndEnv(queue, 4, async (e) => {\n events.push(`start:${e.env.id}:${e.task.name}`);\n await delay(e.env.id === 'envB' && e.task.name === 'compile' ? 40 : 2);\n events.push(`end:${e.env.id}:${e.task.name}`);\n });\n expect(events.indexOf('start:envA:test')).to.be.greaterThan(events.indexOf('end:envB:compile'));\n });\n\n it('enforces a barrier between locations: no end task starts before all middle tasks finish', async () => {\n const events: string[] = [];\n const queue = [\n entry('envA', 'compile'),\n entry('envB', 'compile'),\n entry('envA', 'preview', { location: 'end' }),\n entry('envB', 'preview', { location: 'end' }),\n ];\n await executeTasksByLocationAndEnv(queue, 4, async (e) => {\n events.push(`start:${e.task.name}:${e.env.id}`);\n await delay(e.task.name === 'compile' && e.env.id === 'envA' ? 40 : 2);\n events.push(`end:${e.task.name}:${e.env.id}`);\n });\n const lastMiddleEnd = Math.max(events.indexOf('end:compile:envA'), events.indexOf('end:compile:envB'));\n const firstEndStart = Math.min(events.indexOf('start:preview:envA'), events.indexOf('start:preview:envB'));\n expect(firstEndStart).to.be.greaterThan(lastMiddleEnd);\n });\n\n it('bounds concurrency to the given limit', async () => {\n let inFlight = 0;\n let maxInFlight = 0;\n const queue = ['e1', 'e2', 'e3', 'e4', 'e5'].map((id) => entry(id, 'compile'));\n await executeTasksByLocationAndEnv(queue, 2, async () => {\n inFlight += 1;\n maxInFlight = Math.max(maxInF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AAO,CAAC,kBAAkB,CAAC,CAAC;MACtG,MAAMO,aAAa,GAAGF,IAAI,CAACG,GAAG,CAACT,MAAM,CAACC,OAAO,CAAC,oBAAoB,CAAC,EAAED,MAAM,CAACC,OAAO,CAAC,oBAAoB,CAAC,CAAC;MAC1G,IAAAtB,cAAM,EAAC6B,aAAa,CAAC,CAACzB,EAAE,CAACmB,EAAE,CAACE,WAAW,CAACC,aAAa,CAAC;IACxD,CAAC,CAAC;IAEF9B,EAAE,CAAC,uCAAuC,EAAE,YAAY;MACtD,IAAImC,QAAQ,GAAG,CAAC;MAChB,IAAIC,WAAW,GAAG,CAAC;MACnB,MAAMnC,KAAK,GAAG,CAAC,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,CAAC,CAACI,GAAG,CAAEjB,EAAE,IAAKL,KAAK,CAACK,EAAE,EAAE,SAAS,CAAC,CAAC;MAC9E,MAAM,IAAAkC,sDAA4B,EAACrB,KAAK,EAAE,CAAC,EAAE,YAAY;QACvDkC,QAAQ,IAAI,CAAC;QACbC,WAAW,GAAGL,IAAI,CAACC,GAAG,CAACI,WAAW,EAAED,QAAQ,CAAC;QAC7C,MAAMzC,KAAK,CAAC,EAAE,CAAC;QACfyC,QAAQ,IAAI,CAAC;MACf,CAAC,CAAC;MACF,IAAA/B,cAAM,EAACgC,WAAW,CAAC,CAAC5B,EAAE,CAACE,KAAK,CAAC,CAAC,CAAC;IACjC,CAAC,CAAC;EACJ,CAAC,CAAC;AACJ,CAAC,CAAC","ignoreList":[]}
|
package/package.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@teambit/builder",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.1021",
|
|
4
4
|
"homepage": "https://bit.cloud/teambit/pipelines/builder",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"componentId": {
|
|
7
7
|
"scope": "teambit.pipelines",
|
|
8
8
|
"name": "builder",
|
|
9
|
-
"version": "1.0.
|
|
9
|
+
"version": "1.0.1021"
|
|
10
10
|
},
|
|
11
11
|
"dependencies": {
|
|
12
12
|
"chalk": "4.1.2",
|
|
@@ -21,35 +21,35 @@
|
|
|
21
21
|
"fs-extra": "10.0.0",
|
|
22
22
|
"minimatch": "3.0.5",
|
|
23
23
|
"globby": "11.0.1",
|
|
24
|
+
"@teambit/logger": "0.0.1432",
|
|
24
25
|
"@teambit/toolbox.string.capitalize": "0.0.509",
|
|
25
26
|
"@teambit/graph.cleargraph": "0.0.11",
|
|
26
27
|
"@teambit/legacy.constants": "0.0.30",
|
|
28
|
+
"@teambit/component.sources": "0.0.179",
|
|
27
29
|
"@teambit/lane-id": "0.0.312",
|
|
30
|
+
"@teambit/cli": "0.0.1339",
|
|
31
|
+
"@teambit/component-issues": "0.0.173",
|
|
28
32
|
"@teambit/harmony": "0.4.7",
|
|
29
33
|
"@teambit/bit-error": "0.0.404",
|
|
30
34
|
"@teambit/bit.get-bit-version": "0.0.16",
|
|
31
|
-
"@teambit/toolbox.array.duplications-finder": "0.0.3",
|
|
32
|
-
"@teambit/component-id": "1.2.4",
|
|
33
|
-
"@teambit/legacy.utils": "0.0.38",
|
|
34
|
-
"@teambit/component": "1.0.1019",
|
|
35
|
-
"@teambit/envs": "1.0.1019",
|
|
36
|
-
"@teambit/logger": "0.0.1432",
|
|
37
|
-
"@teambit/component.sources": "0.0.179",
|
|
38
|
-
"@teambit/isolator": "1.0.1019",
|
|
39
|
-
"@teambit/cli": "0.0.1339",
|
|
40
|
-
"@teambit/component-issues": "0.0.173",
|
|
41
|
-
"@teambit/workspace": "1.0.1019",
|
|
42
|
-
"@teambit/aspect-loader": "1.0.1019",
|
|
43
35
|
"@teambit/config-store": "0.0.220",
|
|
44
|
-
"@teambit/generator": "1.0.1020",
|
|
45
|
-
"@teambit/graphql": "1.0.1019",
|
|
46
|
-
"@teambit/issues": "1.0.1019",
|
|
47
36
|
"@teambit/legacy.consumer-component": "0.0.128",
|
|
48
37
|
"@teambit/legacy.extension-data": "0.0.129",
|
|
49
|
-
"@teambit/
|
|
50
|
-
"@teambit/ui": "1.0.1019",
|
|
38
|
+
"@teambit/toolbox.array.duplications-finder": "0.0.3",
|
|
51
39
|
"@teambit/express": "0.0.1438",
|
|
52
|
-
"@teambit/
|
|
40
|
+
"@teambit/component-id": "1.2.4",
|
|
41
|
+
"@teambit/legacy.utils": "0.0.38",
|
|
42
|
+
"@teambit/legacy.scope": "0.0.127",
|
|
43
|
+
"@teambit/component": "1.0.1021",
|
|
44
|
+
"@teambit/envs": "1.0.1021",
|
|
45
|
+
"@teambit/isolator": "1.0.1021",
|
|
46
|
+
"@teambit/workspace": "1.0.1021",
|
|
47
|
+
"@teambit/aspect-loader": "1.0.1021",
|
|
48
|
+
"@teambit/generator": "1.0.1022",
|
|
49
|
+
"@teambit/graphql": "1.0.1021",
|
|
50
|
+
"@teambit/issues": "1.0.1021",
|
|
51
|
+
"@teambit/scope": "1.0.1021",
|
|
52
|
+
"@teambit/ui": "1.0.1021"
|
|
53
53
|
},
|
|
54
54
|
"devDependencies": {
|
|
55
55
|
"@types/pretty-time": "^1.1.5",
|
|
@@ -64,7 +64,9 @@
|
|
|
64
64
|
},
|
|
65
65
|
"peerDependencies": {
|
|
66
66
|
"react": "^17.0.0 || ^18.0.0 || ^19.0.0",
|
|
67
|
-
"
|
|
67
|
+
"chai": "5.2.1",
|
|
68
|
+
"@types/react": "^19.0.0",
|
|
69
|
+
"@types/chai": "5.2.2"
|
|
68
70
|
},
|
|
69
71
|
"license": "Apache-2.0",
|
|
70
72
|
"optionalDependencies": {},
|