@nrwl/nx-cloud 15.2.0 → 15.3.0-beta.2
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/lib/core/api/error-reporter.api.js +36 -1
- package/lib/core/api/run-group.api.d.ts +2 -2
- package/lib/core/api/run-group.api.js +73 -1
- package/lib/core/api/run-group.api.js.map +1 -1
- package/lib/core/commands/record-output.js +7 -2
- package/lib/core/commands/record-output.js.map +1 -1
- package/lib/core/commands/start-ci-run.js +5 -6
- package/lib/core/commands/start-ci-run.js.map +1 -1
- package/lib/core/commands/stop-all-agents.js +6 -3
- package/lib/core/commands/stop-all-agents.js.map +1 -1
- package/lib/core/commands/upload-and-show-run-details.js +6 -1
- package/lib/core/commands/upload-and-show-run-details.js.map +1 -1
- package/lib/core/error/print-run-group-error.d.ts +1 -0
- package/lib/core/error/print-run-group-error.js +9 -5
- package/lib/core/error/print-run-group-error.js.map +1 -1
- package/lib/core/models/cloud-task-runner-options.d.ts +0 -1
- package/lib/core/runners/cloud-enabled/cloud-enabled-life-cycle.js +93 -1
- package/lib/core/runners/cloud-enabled/cloud-enabled.runner.js +319 -1
- package/lib/core/runners/cloud-enabled/cloud-enabled.runner.js.map +1 -1
- package/lib/core/runners/cloud-enabled/cloud-remote-cache.js +133 -1
- package/lib/core/runners/cloud-enabled/cloud-run.api.d.ts +6 -1
- package/lib/core/runners/cloud-enabled/cloud-run.api.js +168 -1
- package/lib/core/runners/cloud-enabled/cloud-run.api.js.map +1 -1
- package/lib/core/runners/cloud-enabled/id-generator.js +16 -1
- package/lib/core/runners/distributed-agent/distributed-agent.api.d.ts +4 -1
- package/lib/core/runners/distributed-agent/distributed-agent.api.js +93 -1
- package/lib/core/runners/distributed-agent/distributed-agent.api.js.map +1 -1
- package/lib/core/runners/distributed-agent/distributed-agent.impl.js +157 -1
- package/lib/core/runners/distributed-agent/distributed-agent.impl.js.map +1 -1
- package/lib/core/runners/distributed-agent/execute-tasks.js +114 -1
- package/lib/core/runners/distributed-agent/invoke-tasks-using-nx-imperative-api.js +58 -1
- package/lib/core/runners/distributed-agent/invoke-tasks-using-run-many.js +97 -1
- package/lib/core/runners/distributed-execution/distributed-execution.api.d.ts +2 -2
- package/lib/core/runners/distributed-execution/distributed-execution.api.js +152 -1
- package/lib/core/runners/distributed-execution/distributed-execution.api.js.map +1 -1
- package/lib/core/runners/distributed-execution/distributed-execution.runner.js +118 -1
- package/lib/core/runners/distributed-execution/distributed-execution.runner.js.map +1 -1
- package/lib/core/runners/distributed-execution/process-task.js +45 -1
- package/lib/core/runners/distributed-execution/process-tasks.js +67 -1
- package/lib/core/runners/distributed-execution/split-task-graph-into-stages.js +37 -1
- package/lib/core/runners/distributed-execution/task-graph-creator.js +100 -1
- package/lib/utilities/environment.d.ts +3 -1
- package/lib/utilities/environment.js +23 -7
- package/lib/utilities/environment.js.map +1 -1
- package/package.json +1 -1
|
@@ -1 +1,114 @@
|
|
|
1
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.executeTasks = void 0;
|
|
13
|
+
const create_unchanged_value_timeout_1 = require("../../../utilities/create-unchanged-value-timeout");
|
|
14
|
+
const environment_1 = require("../../../utilities/environment");
|
|
15
|
+
const waiter_1 = require("../../../utilities/waiter");
|
|
16
|
+
const { output } = require('../../../utilities/nx-imports');
|
|
17
|
+
function executeTasks(agentName, api, dteArtifactStorage, invokeTasks, targets) {
|
|
18
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
19
|
+
let completedStatusCode = 0;
|
|
20
|
+
let apiResponse = null;
|
|
21
|
+
const failIfSameTasksAfterTimeout = (0, create_unchanged_value_timeout_1.createUnchangedValueTimeout)({
|
|
22
|
+
title: `No new messages received after ${environment_1.NO_MESSAGES_TIMEOUT / 1000} seconds`,
|
|
23
|
+
timeout: environment_1.NO_MESSAGES_TIMEOUT,
|
|
24
|
+
});
|
|
25
|
+
const waiter = new waiter_1.Waiter();
|
|
26
|
+
let completedTasks = [];
|
|
27
|
+
const startTime = new Date();
|
|
28
|
+
let executedAnyTasks = false;
|
|
29
|
+
const processedTasks = {};
|
|
30
|
+
while (true) {
|
|
31
|
+
if (environment_1.VERBOSE_LOGGING) {
|
|
32
|
+
output.note({
|
|
33
|
+
title: `${agentName} fetching tasks...`,
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
apiResponse = yield api.tasks(apiResponse ? apiResponse.executionId : null, completedStatusCode, completedTasks, targets);
|
|
37
|
+
if (environment_1.VERBOSE_LOGGING) {
|
|
38
|
+
output.note({
|
|
39
|
+
title: `${agentName} received an API Response`,
|
|
40
|
+
bodyLines: [
|
|
41
|
+
`completed: ${apiResponse.completed}`,
|
|
42
|
+
`status: ${apiResponse.status}`,
|
|
43
|
+
`retryDuring: ${apiResponse.retryDuring}`,
|
|
44
|
+
`executionId: ${apiResponse.executionId}`,
|
|
45
|
+
`number of tasks: ${apiResponse.tasks.length}`,
|
|
46
|
+
`error: ${apiResponse.criticalErrorMessage}`,
|
|
47
|
+
`maxParallel: ${apiResponse.maxParallel}`,
|
|
48
|
+
],
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
if (apiResponse.criticalErrorMessage) {
|
|
52
|
+
output.error({
|
|
53
|
+
title: 'Distributed Execution Terminated',
|
|
54
|
+
bodyLines: ['Error:', apiResponse.criticalErrorMessage],
|
|
55
|
+
});
|
|
56
|
+
process.exit(0);
|
|
57
|
+
}
|
|
58
|
+
// run group is completed but it might be a rerun
|
|
59
|
+
// we will try several times before going further and
|
|
60
|
+
// completed the response
|
|
61
|
+
// we only do it if we haven't executed any tasks
|
|
62
|
+
if ((apiResponse === null || apiResponse === void 0 ? void 0 : apiResponse.retryDuring) &&
|
|
63
|
+
(apiResponse === null || apiResponse === void 0 ? void 0 : apiResponse.retryDuring) !== 0 &&
|
|
64
|
+
!executedAnyTasks &&
|
|
65
|
+
new Date().getTime() - startTime.getTime() > apiResponse.retryDuring) {
|
|
66
|
+
yield waiter.wait();
|
|
67
|
+
continue;
|
|
68
|
+
}
|
|
69
|
+
if ((apiResponse === null || apiResponse === void 0 ? void 0 : apiResponse.status) !== undefined) {
|
|
70
|
+
if (apiResponse.status === 'RUN_GROUP_COMPLETED' ||
|
|
71
|
+
apiResponse.status === 'NO_FURTHER_TASKS_TO_RUN') {
|
|
72
|
+
return;
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
else if (apiResponse.completed) {
|
|
76
|
+
return;
|
|
77
|
+
}
|
|
78
|
+
// if status is present that use the status instead of completed, otherwise use completed
|
|
79
|
+
failIfSameTasksAfterTimeout(apiResponse.tasks.map((t) => t.taskId).join(''));
|
|
80
|
+
if (!apiResponse.executionId) {
|
|
81
|
+
if (environment_1.VERBOSE_LOGGING) {
|
|
82
|
+
output.note({
|
|
83
|
+
title: `${agentName} waiting...`,
|
|
84
|
+
});
|
|
85
|
+
}
|
|
86
|
+
yield waiter.wait();
|
|
87
|
+
completedStatusCode = 0;
|
|
88
|
+
completedTasks = [];
|
|
89
|
+
continue;
|
|
90
|
+
}
|
|
91
|
+
waiter.reset();
|
|
92
|
+
executedAnyTasks = true;
|
|
93
|
+
if (apiResponse.completedTasks) {
|
|
94
|
+
for (const t of apiResponse.completedTasks) {
|
|
95
|
+
if (processedTasks[t.taskId])
|
|
96
|
+
continue;
|
|
97
|
+
output.note({
|
|
98
|
+
title: `${agentName} downloading artifacts for ${t.taskId} Hash: ${t.hash} Url: ${t.url}`,
|
|
99
|
+
});
|
|
100
|
+
yield dteArtifactStorage.retrieveAndExtract(t.hash, t.url);
|
|
101
|
+
processedTasks[t.taskId] = true;
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
const r = yield invokeTasks(apiResponse.executionId, apiResponse.tasks, apiResponse.maxParallel);
|
|
105
|
+
for (const t of r.completedTasks) {
|
|
106
|
+
processedTasks[t.taskId] = true;
|
|
107
|
+
}
|
|
108
|
+
completedStatusCode = r.completedStatusCode;
|
|
109
|
+
completedTasks = r.completedTasks;
|
|
110
|
+
}
|
|
111
|
+
});
|
|
112
|
+
}
|
|
113
|
+
exports.executeTasks = executeTasks;
|
|
114
|
+
//# sourceMappingURL=execute-tasks.js.map
|
|
@@ -1 +1,58 @@
|
|
|
1
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.invokeTasksUsingNxImperativeApi = void 0;
|
|
13
|
+
const { initTasksRunner } = require('../../../utilities/nx-imports');
|
|
14
|
+
const parser = require("yargs-parser");
|
|
15
|
+
const serializer_overrides_1 = require("../../../utilities/serializer-overrides");
|
|
16
|
+
function invokeTasksUsingNxImperativeApi(options) {
|
|
17
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
18
|
+
const tasksRunner = yield initTasksRunner(options);
|
|
19
|
+
return (executionId, tasksToExecute, parallel) => __awaiter(this, void 0, void 0, function* () {
|
|
20
|
+
const tasks = tasksToExecute.map((t) => {
|
|
21
|
+
const params = parser(t.params, {
|
|
22
|
+
configuration: {
|
|
23
|
+
'camel-case-expansion': false,
|
|
24
|
+
'dot-notation': true,
|
|
25
|
+
},
|
|
26
|
+
});
|
|
27
|
+
const unparsed = (0, serializer_overrides_1.unparse)(params);
|
|
28
|
+
if (params._.length == 0) {
|
|
29
|
+
delete params._;
|
|
30
|
+
}
|
|
31
|
+
return {
|
|
32
|
+
id: t.taskId,
|
|
33
|
+
target: {
|
|
34
|
+
project: t.projectName,
|
|
35
|
+
target: t.target,
|
|
36
|
+
configuration: t.configuration,
|
|
37
|
+
},
|
|
38
|
+
overrides: Object.assign(Object.assign({}, params), { __overrides_unparsed__: unparsed }),
|
|
39
|
+
};
|
|
40
|
+
});
|
|
41
|
+
process.env.NX_CACHE_FAILURES = 'true'; // this is only requires because of how we do uploads
|
|
42
|
+
process.env.NX_CLOUD_DISTRIBUTED_EXECUTION_ID = executionId;
|
|
43
|
+
process.env.NX_STREAM_OUTPUT = 'true';
|
|
44
|
+
process.env.NX_PREFIX_OUTPUT = 'true';
|
|
45
|
+
const r = yield tasksRunner.invoke({ tasks, parallel });
|
|
46
|
+
const completedTasks = Object.values(r.taskGraph.tasks);
|
|
47
|
+
return {
|
|
48
|
+
completedTasks: completedTasks.map((t) => ({
|
|
49
|
+
taskId: t.id,
|
|
50
|
+
hash: t.hash,
|
|
51
|
+
})),
|
|
52
|
+
completedStatusCode: r.status,
|
|
53
|
+
};
|
|
54
|
+
});
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
exports.invokeTasksUsingNxImperativeApi = invokeTasksUsingNxImperativeApi;
|
|
58
|
+
//# sourceMappingURL=invoke-tasks-using-nx-imperative-api.js.map
|
|
@@ -1 +1,97 @@
|
|
|
1
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.invokeTasksUsingRunMany = void 0;
|
|
13
|
+
const environment_1 = require("../../../utilities/environment");
|
|
14
|
+
const child_process_1 = require("child_process");
|
|
15
|
+
const fs_1 = require("fs");
|
|
16
|
+
const { output } = require('../../../utilities/nx-imports');
|
|
17
|
+
function invokeTasksUsingRunMany(options) {
|
|
18
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
19
|
+
const readCompleted = completedTasksReader(options);
|
|
20
|
+
return function invokeTasksUsingRunMany(executionId, tasksToExecute, parallel) {
|
|
21
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
22
|
+
let completedStatusCode = 0;
|
|
23
|
+
const completedTasks = [];
|
|
24
|
+
for (const g of groupByTarget(tasksToExecute)) {
|
|
25
|
+
const config = g.configuration
|
|
26
|
+
? `--configuration=${g.configuration}`
|
|
27
|
+
: ``;
|
|
28
|
+
const parallelStr = parallel > 1 ? ` --parallel --max-parallel=${parallel}` : ``;
|
|
29
|
+
// TODO use pnpx or yarn when needed
|
|
30
|
+
const command = `npx nx run-many --target=${g.target} ${config} --projects=${g.projects.join(',')} ${g.params}${parallelStr}`;
|
|
31
|
+
if (environment_1.VERBOSE_LOGGING) {
|
|
32
|
+
output.note({
|
|
33
|
+
title: `Executing: '${command}'`,
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
try {
|
|
37
|
+
(0, child_process_1.execSync)(command, {
|
|
38
|
+
stdio: ['ignore', 'inherit', 'inherit'],
|
|
39
|
+
env: Object.assign(Object.assign({}, process.env), { NX_CACHE_FAILURES: 'true', NX_CLOUD_DISTRIBUTED_EXECUTION_ID: executionId, NX_STREAM_OUTPUT: 'true', NX_PREFIX_OUTPUT: 'true' }),
|
|
40
|
+
});
|
|
41
|
+
completedTasks.push(...readCompleted(executionId));
|
|
42
|
+
}
|
|
43
|
+
catch (e) {
|
|
44
|
+
if (e.status === environment_1.DISTRIBUTED_TASK_EXECUTION_INTERNAL_ERROR_STATUS_CODE) {
|
|
45
|
+
throw e;
|
|
46
|
+
}
|
|
47
|
+
else {
|
|
48
|
+
completedStatusCode = 1;
|
|
49
|
+
completedTasks.push(...readCompleted(executionId));
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
return { completedStatusCode, completedTasks };
|
|
54
|
+
});
|
|
55
|
+
};
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
exports.invokeTasksUsingRunMany = invokeTasksUsingRunMany;
|
|
59
|
+
function groupByTarget(tasks) {
|
|
60
|
+
const res = [];
|
|
61
|
+
tasks.forEach((t) => {
|
|
62
|
+
const r = res.find((rr) => rr.target === t.target && rr.configuration === t.configuration);
|
|
63
|
+
if (r) {
|
|
64
|
+
r.projects.push(t.projectName);
|
|
65
|
+
}
|
|
66
|
+
else {
|
|
67
|
+
res.push({
|
|
68
|
+
target: t.target,
|
|
69
|
+
projects: [t.projectName],
|
|
70
|
+
params: t.params,
|
|
71
|
+
configuration: t.configuration,
|
|
72
|
+
});
|
|
73
|
+
}
|
|
74
|
+
});
|
|
75
|
+
return res;
|
|
76
|
+
}
|
|
77
|
+
function completedTasksReader(options) {
|
|
78
|
+
const cacheDirectory = (0, environment_1.getNxCacheDirectory)(options);
|
|
79
|
+
return (distributedExecutionId) => {
|
|
80
|
+
const errorMessage = `Command execution failed (distributed task execution: ${distributedExecutionId}). Tasks hashes haven\'t been recorded.`;
|
|
81
|
+
let completedTasks;
|
|
82
|
+
try {
|
|
83
|
+
const taskHashesFile = `${cacheDirectory}/tasks-hashes-${distributedExecutionId}`;
|
|
84
|
+
completedTasks = JSON.parse((0, fs_1.readFileSync)(taskHashesFile).toString());
|
|
85
|
+
// remove it such that if the next command crashes we don't read an obsolete file
|
|
86
|
+
(0, fs_1.unlinkSync)(taskHashesFile);
|
|
87
|
+
}
|
|
88
|
+
catch (e) {
|
|
89
|
+
throw new Error(errorMessage);
|
|
90
|
+
}
|
|
91
|
+
if (completedTasks.length == 0) {
|
|
92
|
+
throw new Error(errorMessage);
|
|
93
|
+
}
|
|
94
|
+
return completedTasks;
|
|
95
|
+
};
|
|
96
|
+
}
|
|
97
|
+
//# sourceMappingURL=invoke-tasks-using-run-many.js.map
|
|
@@ -5,6 +5,6 @@ export declare class DistributedExecutionApi {
|
|
|
5
5
|
constructor(options: CloudTaskRunnerOptions);
|
|
6
6
|
start(params: any): Promise<string>;
|
|
7
7
|
status(id: string): Promise<any>;
|
|
8
|
-
completeRunGroupWithError(runGroup: string, error: string): Promise<void>;
|
|
8
|
+
completeRunGroupWithError(branch: string | null, runGroup: string, ciExecutionId: string | null, ciExecutionEnv: string, error: string): Promise<void>;
|
|
9
9
|
}
|
|
10
|
-
export declare function createStartRequest(runGroup: string, task: Task[][], options: CloudTaskRunnerOptions): any;
|
|
10
|
+
export declare function createStartRequest(branch: string | null, runGroup: string, ciExecutionId: string | null, ciExecutionEnv: string, task: Task[][], options: CloudTaskRunnerOptions): any;
|
|
@@ -1 +1,152 @@
|
|
|
1
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.createStartRequest = exports.DistributedExecutionApi = void 0;
|
|
13
|
+
const axios_1 = require("../../../utilities/axios");
|
|
14
|
+
const environment_1 = require("../../../utilities/environment");
|
|
15
|
+
const metric_logger_1 = require("../../../utilities/metric-logger");
|
|
16
|
+
const serializer_overrides_1 = require("../../../utilities/serializer-overrides");
|
|
17
|
+
const { output } = require('../../../utilities/nx-imports');
|
|
18
|
+
class DistributedExecutionApi {
|
|
19
|
+
constructor(options) {
|
|
20
|
+
this.apiAxiosInstance = (0, axios_1.createApiAxiosInstance)(options);
|
|
21
|
+
}
|
|
22
|
+
start(params) {
|
|
23
|
+
var _a;
|
|
24
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
25
|
+
const recorder = (0, metric_logger_1.createMetricRecorder)('dteStart');
|
|
26
|
+
let resp;
|
|
27
|
+
if (environment_1.VERBOSE_LOGGING) {
|
|
28
|
+
output.note({
|
|
29
|
+
title: 'Starting a distributed execution',
|
|
30
|
+
bodyLines: [JSON.stringify(params, null, 2)],
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
try {
|
|
34
|
+
resp = yield (0, axios_1.axiosMultipleTries)(() => this.apiAxiosInstance.post('/nx-cloud/executions/start', params));
|
|
35
|
+
recorder.recordMetric((0, metric_logger_1.mapRespToPerfEntry)(resp));
|
|
36
|
+
}
|
|
37
|
+
catch (e) {
|
|
38
|
+
recorder.recordMetric(((_a = e === null || e === void 0 ? void 0 : e.axiosException) === null || _a === void 0 ? void 0 : _a.response)
|
|
39
|
+
? (0, metric_logger_1.mapRespToPerfEntry)(e.axiosException.response)
|
|
40
|
+
: metric_logger_1.RUNNER_FAILURE_PERF_ENTRY);
|
|
41
|
+
throw e;
|
|
42
|
+
}
|
|
43
|
+
if (!resp.data.enabled) {
|
|
44
|
+
throw new Error(`Workspace is disabled. Cannot perform distributed task executions.`);
|
|
45
|
+
}
|
|
46
|
+
if (resp.data.error) {
|
|
47
|
+
throw new Error(resp.data.error);
|
|
48
|
+
}
|
|
49
|
+
return resp.data.id;
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
status(id) {
|
|
53
|
+
var _a;
|
|
54
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
55
|
+
const recorder = (0, metric_logger_1.createMetricRecorder)('dteStatus');
|
|
56
|
+
try {
|
|
57
|
+
const resp = yield (0, axios_1.axiosMultipleTries)(() => this.apiAxiosInstance.post('/nx-cloud/executions/status', {
|
|
58
|
+
id,
|
|
59
|
+
}));
|
|
60
|
+
recorder.recordMetric((0, metric_logger_1.mapRespToPerfEntry)(resp));
|
|
61
|
+
return resp.data;
|
|
62
|
+
}
|
|
63
|
+
catch (e) {
|
|
64
|
+
recorder.recordMetric(((_a = e === null || e === void 0 ? void 0 : e.axiosException) === null || _a === void 0 ? void 0 : _a.response)
|
|
65
|
+
? (0, metric_logger_1.mapRespToPerfEntry)(e.axiosException.response)
|
|
66
|
+
: metric_logger_1.RUNNER_FAILURE_PERF_ENTRY);
|
|
67
|
+
output.error({
|
|
68
|
+
title: e.message,
|
|
69
|
+
});
|
|
70
|
+
process.exit(1);
|
|
71
|
+
}
|
|
72
|
+
});
|
|
73
|
+
}
|
|
74
|
+
completeRunGroupWithError(branch, runGroup, ciExecutionId, ciExecutionEnv, error) {
|
|
75
|
+
var _a;
|
|
76
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
77
|
+
const recorder = (0, metric_logger_1.createMetricRecorder)('completeRunGroup');
|
|
78
|
+
if (environment_1.VERBOSE_LOGGING) {
|
|
79
|
+
output.note({
|
|
80
|
+
title: 'Completing with an error',
|
|
81
|
+
bodyLines: [
|
|
82
|
+
`ciExecutionId: ${ciExecutionId}`,
|
|
83
|
+
`ciExecutionEnv: ${ciExecutionEnv}`,
|
|
84
|
+
`runGroup: ${runGroup}`,
|
|
85
|
+
`error: ${error}`,
|
|
86
|
+
],
|
|
87
|
+
});
|
|
88
|
+
}
|
|
89
|
+
try {
|
|
90
|
+
const resp = yield (0, axios_1.axiosMultipleTries)(() => this.apiAxiosInstance.post('/nx-cloud/executions/complete-run-group', {
|
|
91
|
+
runGroup,
|
|
92
|
+
ciExecutionId,
|
|
93
|
+
ciExecutionEnv,
|
|
94
|
+
criticalErrorMessage: error,
|
|
95
|
+
}), 3);
|
|
96
|
+
recorder.recordMetric((0, metric_logger_1.mapRespToPerfEntry)(resp));
|
|
97
|
+
}
|
|
98
|
+
catch (e) {
|
|
99
|
+
recorder.recordMetric(((_a = e === null || e === void 0 ? void 0 : e.axiosException) === null || _a === void 0 ? void 0 : _a.response)
|
|
100
|
+
? (0, metric_logger_1.mapRespToPerfEntry)(e.axiosException.response)
|
|
101
|
+
: metric_logger_1.RUNNER_FAILURE_PERF_ENTRY);
|
|
102
|
+
}
|
|
103
|
+
});
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
exports.DistributedExecutionApi = DistributedExecutionApi;
|
|
107
|
+
function createStartRequest(branch, runGroup, ciExecutionId, ciExecutionEnv, task, options) {
|
|
108
|
+
const tasksToExecute = task.map((arr) => {
|
|
109
|
+
return arr.map((t) => {
|
|
110
|
+
return {
|
|
111
|
+
taskId: t.id,
|
|
112
|
+
hash: t.hash,
|
|
113
|
+
projectName: t.target.project,
|
|
114
|
+
target: t.target.target,
|
|
115
|
+
configuration: t.target.configuration || null,
|
|
116
|
+
params: (0, serializer_overrides_1.serializeOverrides)(t),
|
|
117
|
+
};
|
|
118
|
+
});
|
|
119
|
+
});
|
|
120
|
+
const request = {
|
|
121
|
+
command: (0, environment_1.parseCommand)(),
|
|
122
|
+
branch,
|
|
123
|
+
runGroup,
|
|
124
|
+
ciExecutionId,
|
|
125
|
+
ciExecutionEnv,
|
|
126
|
+
tasks: tasksToExecute,
|
|
127
|
+
maxParallel: calculateMaxParallel(options),
|
|
128
|
+
};
|
|
129
|
+
if (environment_1.NX_CLOUD_DISTRIBUTED_EXECUTION_AGENT_COUNT) {
|
|
130
|
+
request.agentCount = environment_1.NX_CLOUD_DISTRIBUTED_EXECUTION_AGENT_COUNT;
|
|
131
|
+
}
|
|
132
|
+
if (!environment_1.NX_CLOUD_DISTRIBUTED_EXECUTION_STOP_AGENTS_ON_FAILURE) {
|
|
133
|
+
request.stopAgentsOnFailure = false;
|
|
134
|
+
}
|
|
135
|
+
return request;
|
|
136
|
+
}
|
|
137
|
+
exports.createStartRequest = createStartRequest;
|
|
138
|
+
function calculateMaxParallel(options) {
|
|
139
|
+
if (options.parallel === 'false' || options.parallel === false) {
|
|
140
|
+
return 1;
|
|
141
|
+
}
|
|
142
|
+
else if (options.parallel === 'true' || options.parallel === true) {
|
|
143
|
+
return Number(options.maxParallel || 3);
|
|
144
|
+
}
|
|
145
|
+
else if (options.parallel === undefined) {
|
|
146
|
+
return options.maxParallel ? Number(options.maxParallel) : 3;
|
|
147
|
+
}
|
|
148
|
+
else {
|
|
149
|
+
return Number(options.parallel) || 3;
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
//# sourceMappingURL=distributed-execution.api.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"distributed-execution.api.js","sourceRoot":"","sources":["../../../../../../../../libs/nx-packages/nx-cloud/lib/core/runners/distributed-execution/distributed-execution.api.ts"],"names":[],"mappings":";;;;;;;;;;;;AACA,oDAGkC;AAClC,gEAMwC;AACxC,oEAI0C;AAE1C,kFAA6E;AAE7E,MAAM,EAAE,MAAM,EAAE,GAAG,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AC,IAAI,CAAC,EAAE,CAAC;;KACrB;IAEK,MAAM,CAAC,EAAU;;;YACrB,MAAM,QAAQ,GAAG,IAAA,oCAAoB,EAAC,WAAW,CAAC,CAAC;YAEnD,IAAI;gBACF,MAAM,IAAI,GAAG,MAAM,IAAA,0BAAkB,EAAC,GAAG,EAAE,CACzC,IAAI,CAAC,gBAAgB,CAAC,IAAI,CAAC,6BAA6B,EAAE;oBACxD,EAAE;iBACH,CAAC,CACH,CAAC;gBACF,QAAQ,CAAC,YAAY,CAAC,IAAA,kCAAkB,EAAC,IAAI,CAAC,CAAC,CAAC;gBAEhD,OAAO,IAAI,CAAC,IAAI,CAAC;aAClB;YAAC,OAAO,CAAM,EAAE;gBACf,QAAQ,CAAC,YAAY,CACnB,CAAA,MAAA,CAAC,aAAD,CAAC,uBAAD,CAAC,CAAE,cAAc,0CAAE,QAAQ;oBACzB,CAAC,CAAC,IAAA,kCAAkB,EAAC,CAAC,CAAC,cAAc,CAAC,QAAQ,CAAC;oBAC/C,CAAC,CAAC,yCAAyB,CAC9B,CAAC;gBAEF,MAAM,CAAC,KAAK,CAAC;oBACX,KAAK,EAAE,CAAC,CAAC,OAAO;iBACjB,CAAC,CAAC;gBACH,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;aACjB;;KACF;IAEK,yBAAyB,CAC7B,QAAgB,EAChB,KAAa;;;YAEb,MAAM,QAAQ,GAAG,IAAA,oCAAoB,EAAC,kBAAkB,CAAC,CAAC;YAE1D,IAAI,6BAAe,EAAE;gBACnB,MAAM,CAAC,IAAI,CAAC;oBACV,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"distributed-execution.api.js","sourceRoot":"","sources":["../../../../../../../../libs/nx-packages/nx-cloud/lib/core/runners/distributed-execution/distributed-execution.api.ts"],"names":[],"mappings":";;;;;;;;;;;;AACA,oDAGkC;AAClC,gEAMwC;AACxC,oEAI0C;AAE1C,kFAA6E;AAE7E,MAAM,EAAE,MAAM,EAAE,GAAG,O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