@nrwl/nx-cloud 15.1.0-beta.3 → 15.1.0
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 +1 -36
- package/lib/core/api/run-group.api.js +1 -68
- package/lib/core/runners/cloud-enabled/cloud-enabled-life-cycle.js +1 -92
- package/lib/core/runners/cloud-enabled/cloud-enabled.runner.js +1 -305
- package/lib/core/runners/cloud-enabled/cloud-remote-cache.js +1 -117
- package/lib/core/runners/cloud-enabled/cloud-run.api.js +1 -167
- package/lib/core/runners/cloud-enabled/id-generator.js +1 -16
- package/lib/core/runners/distributed-agent/distributed-agent.api.js +1 -80
- package/lib/core/runners/distributed-agent/distributed-agent.impl.js +1 -293
- package/lib/core/runners/distributed-execution/distributed-execution.api.js +1 -143
- package/lib/core/runners/distributed-execution/distributed-execution.runner.js +1 -241
- package/lib/core/runners/distributed-execution/split-task-graph-into-stages.js +1 -37
- package/lib/core/runners/distributed-execution/task-graph-creator.js +1 -77
- package/package.json +1 -1
|
@@ -1,293 +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.startAgent = void 0;
|
|
13
|
-
const child_process_1 = require("child_process");
|
|
14
|
-
const fs_1 = require("fs");
|
|
15
|
-
const stripJsonComments = require("strip-json-comments");
|
|
16
|
-
const yargsParser = require("yargs-parser");
|
|
17
|
-
const create_unchanged_value_timeout_1 = require("../../../utilities/create-unchanged-value-timeout");
|
|
18
|
-
const environment_1 = require("../../../utilities/environment");
|
|
19
|
-
const metric_logger_1 = require("../../../utilities/metric-logger");
|
|
20
|
-
const waiter_1 = require("../../../utilities/waiter");
|
|
21
|
-
const print_cacheable_targets_error_1 = require("../../error/print-cacheable-targets-error");
|
|
22
|
-
const print_invalid_runner_error_1 = require("../../error/print-invalid-runner-error");
|
|
23
|
-
const print_run_group_error_1 = require("../../error/print-run-group-error");
|
|
24
|
-
const distributed_agent_api_1 = require("./distributed-agent.api");
|
|
25
|
-
const { output, workspaceRoot } = require('../../../utilities/nx-imports');
|
|
26
|
-
const args = yargsParser(process.argv, {
|
|
27
|
-
array: ['targets'],
|
|
28
|
-
default: {},
|
|
29
|
-
});
|
|
30
|
-
// just in case someone passes the args with commas
|
|
31
|
-
// cf. https://github.com/yargs/yargs/issues/846
|
|
32
|
-
if (args.targets && args.targets.length === 1) {
|
|
33
|
-
args.targets = args.targets[0].split(',').map((x) => x.trim());
|
|
34
|
-
}
|
|
35
|
-
function executeTasks(options, api) {
|
|
36
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
37
|
-
let completedStatusCode = 0;
|
|
38
|
-
let apiResponse = null;
|
|
39
|
-
const failIfSameTasksAfterTimeout = (0, create_unchanged_value_timeout_1.createUnchangedValueTimeout)({
|
|
40
|
-
title: `No new messages received after ${environment_1.NO_MESSAGES_TIMEOUT / 1000} seconds`,
|
|
41
|
-
timeout: environment_1.NO_MESSAGES_TIMEOUT,
|
|
42
|
-
});
|
|
43
|
-
const waiter = new waiter_1.Waiter();
|
|
44
|
-
let completedTasks = [];
|
|
45
|
-
const startTime = new Date();
|
|
46
|
-
let executedAnyTasks = false;
|
|
47
|
-
while (true) {
|
|
48
|
-
if (environment_1.VERBOSE_LOGGING) {
|
|
49
|
-
output.note({
|
|
50
|
-
title: 'Fetching tasks...',
|
|
51
|
-
});
|
|
52
|
-
}
|
|
53
|
-
apiResponse = yield api.tasks(apiResponse ? apiResponse.executionId : null, completedStatusCode, completedTasks, args.targets);
|
|
54
|
-
if (environment_1.VERBOSE_LOGGING) {
|
|
55
|
-
output.note({
|
|
56
|
-
title: 'API Response',
|
|
57
|
-
bodyLines: [
|
|
58
|
-
`completed: ${apiResponse.completed}`,
|
|
59
|
-
`status: ${apiResponse.status}`,
|
|
60
|
-
`retryDuring: ${apiResponse.retryDuring}`,
|
|
61
|
-
`executionId: ${apiResponse.executionId}`,
|
|
62
|
-
`number of tasks: ${apiResponse.tasks.length}`,
|
|
63
|
-
`error: ${apiResponse.criticalErrorMessage}`,
|
|
64
|
-
`maxParallel: ${apiResponse.maxParallel}`,
|
|
65
|
-
],
|
|
66
|
-
});
|
|
67
|
-
}
|
|
68
|
-
if (apiResponse.criticalErrorMessage) {
|
|
69
|
-
output.error({
|
|
70
|
-
title: 'Distributed Execution Terminated',
|
|
71
|
-
bodyLines: ['Error:', apiResponse.criticalErrorMessage],
|
|
72
|
-
});
|
|
73
|
-
process.exit(0);
|
|
74
|
-
}
|
|
75
|
-
// run group is completed but it might be a rerun
|
|
76
|
-
// we will try several times before going further and
|
|
77
|
-
// completed the response
|
|
78
|
-
// we only do it if we haven't executed any tasks
|
|
79
|
-
if ((apiResponse === null || apiResponse === void 0 ? void 0 : apiResponse.retryDuring) &&
|
|
80
|
-
(apiResponse === null || apiResponse === void 0 ? void 0 : apiResponse.retryDuring) !== 0 &&
|
|
81
|
-
!executedAnyTasks &&
|
|
82
|
-
new Date().getTime() - startTime.getTime() > apiResponse.retryDuring) {
|
|
83
|
-
yield waiter.wait();
|
|
84
|
-
continue;
|
|
85
|
-
}
|
|
86
|
-
if ((apiResponse === null || apiResponse === void 0 ? void 0 : apiResponse.status) !== undefined) {
|
|
87
|
-
if (apiResponse.status === 'RUN_GROUP_COMPLETED' ||
|
|
88
|
-
apiResponse.status === 'NO_FURTHER_TASKS_TO_RUN') {
|
|
89
|
-
return;
|
|
90
|
-
}
|
|
91
|
-
}
|
|
92
|
-
else if (apiResponse.completed) {
|
|
93
|
-
return;
|
|
94
|
-
}
|
|
95
|
-
// if status is present that use the status instead of completed, otherwise use completed
|
|
96
|
-
failIfSameTasksAfterTimeout(apiResponse.tasks.map((t) => t.taskId).join(''));
|
|
97
|
-
if (!apiResponse.executionId) {
|
|
98
|
-
if (environment_1.VERBOSE_LOGGING) {
|
|
99
|
-
output.note({
|
|
100
|
-
title: 'Waiting...',
|
|
101
|
-
});
|
|
102
|
-
}
|
|
103
|
-
yield waiter.wait();
|
|
104
|
-
completedStatusCode = 0;
|
|
105
|
-
completedTasks = [];
|
|
106
|
-
continue;
|
|
107
|
-
}
|
|
108
|
-
waiter.reset();
|
|
109
|
-
executedAnyTasks = true;
|
|
110
|
-
const r = invokeTasksUsingRunMany(options, apiResponse.executionId, apiResponse.tasks, apiResponse.maxParallel);
|
|
111
|
-
completedStatusCode = r.completedStatusCode;
|
|
112
|
-
completedTasks = r.completedTasks;
|
|
113
|
-
}
|
|
114
|
-
});
|
|
115
|
-
}
|
|
116
|
-
function readCompletedTasks(options, distributedExecutionId) {
|
|
117
|
-
const errorMessage = `Command execution failed (distributed task execution: ${distributedExecutionId}). Tasks hashes haven\'t been recorded.`;
|
|
118
|
-
let completedTasks;
|
|
119
|
-
try {
|
|
120
|
-
const cacheDirectory = (0, environment_1.getNxCacheDirectory)(options);
|
|
121
|
-
const taskHashesFile = `${cacheDirectory}/tasks-hashes-${distributedExecutionId}`;
|
|
122
|
-
completedTasks = JSON.parse((0, fs_1.readFileSync)(taskHashesFile).toString());
|
|
123
|
-
// remove it such that if the next command crashes we don't read an obsolete file
|
|
124
|
-
(0, fs_1.unlinkSync)(taskHashesFile);
|
|
125
|
-
}
|
|
126
|
-
catch (e) {
|
|
127
|
-
throw new Error(errorMessage);
|
|
128
|
-
}
|
|
129
|
-
if (completedTasks.length == 0) {
|
|
130
|
-
throw new Error(errorMessage);
|
|
131
|
-
}
|
|
132
|
-
return completedTasks;
|
|
133
|
-
}
|
|
134
|
-
function invokeTasksUsingRunMany(options, executionId, tasks, maxParallel) {
|
|
135
|
-
let completedStatusCode = 0;
|
|
136
|
-
const completedTasks = [];
|
|
137
|
-
for (const g of groupByTarget(tasks)) {
|
|
138
|
-
const config = g.configuration ? `--configuration=${g.configuration}` : ``;
|
|
139
|
-
const parallel = maxParallel > 1 ? ` --parallel --max-parallel=${maxParallel}` : ``;
|
|
140
|
-
// TODO use pnpx or yarn when needed
|
|
141
|
-
const command = `npx nx run-many --target=${g.target} ${config} --projects=${g.projects.join(',')} ${g.params}${parallel}`;
|
|
142
|
-
if (environment_1.VERBOSE_LOGGING) {
|
|
143
|
-
output.note({
|
|
144
|
-
title: `Executing: '${command}'`,
|
|
145
|
-
});
|
|
146
|
-
}
|
|
147
|
-
try {
|
|
148
|
-
(0, child_process_1.execSync)(command, {
|
|
149
|
-
stdio: ['ignore', 'inherit', 'inherit'],
|
|
150
|
-
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' }),
|
|
151
|
-
});
|
|
152
|
-
completedTasks.push(...readCompletedTasks(options, executionId));
|
|
153
|
-
}
|
|
154
|
-
catch (e) {
|
|
155
|
-
if (e.status === environment_1.DISTRIBUTED_TASK_EXECUTION_INTERNAL_ERROR_STATUS_CODE) {
|
|
156
|
-
throw e;
|
|
157
|
-
}
|
|
158
|
-
else {
|
|
159
|
-
completedStatusCode = 1;
|
|
160
|
-
completedTasks.push(...readCompletedTasks(options, executionId));
|
|
161
|
-
}
|
|
162
|
-
}
|
|
163
|
-
}
|
|
164
|
-
return { completedStatusCode, completedTasks };
|
|
165
|
-
}
|
|
166
|
-
function groupByTarget(tasks) {
|
|
167
|
-
const res = [];
|
|
168
|
-
tasks.forEach((t) => {
|
|
169
|
-
const r = res.find((rr) => rr.target === t.target && rr.configuration === t.configuration);
|
|
170
|
-
if (r) {
|
|
171
|
-
r.projects.push(t.projectName);
|
|
172
|
-
}
|
|
173
|
-
else {
|
|
174
|
-
res.push({
|
|
175
|
-
target: t.target,
|
|
176
|
-
projects: [t.projectName],
|
|
177
|
-
params: t.params,
|
|
178
|
-
configuration: t.configuration,
|
|
179
|
-
});
|
|
180
|
-
}
|
|
181
|
-
});
|
|
182
|
-
return res;
|
|
183
|
-
}
|
|
184
|
-
function getAgentName() {
|
|
185
|
-
if (process.env.NX_AGENT_NAME !== undefined) {
|
|
186
|
-
return process.env.NX_AGENT_NAME;
|
|
187
|
-
}
|
|
188
|
-
else if (process.env.CIRCLECI !== undefined && process.env.CIRCLE_STAGE) {
|
|
189
|
-
return process.env.CIRCLE_STAGE;
|
|
190
|
-
}
|
|
191
|
-
else if (process.env.CIRCLECI !== undefined && process.env.CIRCLE_JOB) {
|
|
192
|
-
return process.env.CIRCLE_JOB;
|
|
193
|
-
}
|
|
194
|
-
else {
|
|
195
|
-
return `Agent ${Math.floor(Math.random() * 100000)}`;
|
|
196
|
-
}
|
|
197
|
-
}
|
|
198
|
-
function createAgentLockfileAndSetUpListeners(api, options, agentName) {
|
|
199
|
-
const cacheDirectory = (0, environment_1.getNxCacheDirectory)(options);
|
|
200
|
-
const lockFileDirectory = `${cacheDirectory}/lockfiles`;
|
|
201
|
-
const lockFilePath = `${lockFileDirectory}/${agentName}.lock`;
|
|
202
|
-
if (!(0, fs_1.existsSync)(lockFileDirectory)) {
|
|
203
|
-
(0, fs_1.mkdirSync)(lockFileDirectory, { recursive: true });
|
|
204
|
-
}
|
|
205
|
-
// Check for other agents' lockfiles and warn if exist
|
|
206
|
-
const lockFiles = (0, fs_1.readdirSync)(lockFileDirectory);
|
|
207
|
-
if (lockFiles.length) {
|
|
208
|
-
// Check to make sure the current agent name is not in use (only 1/100000 ^ 2 chance of this)
|
|
209
|
-
if (lockFiles.includes(`${agentName}.lock`)) {
|
|
210
|
-
output.error({
|
|
211
|
-
title: 'Duplicate Agent ID Detected',
|
|
212
|
-
bodyLines: [
|
|
213
|
-
'We have detected another agent with this ID running in this workspace. This should not happen.',
|
|
214
|
-
'',
|
|
215
|
-
'End all currently running agents, run "npx nx-cloud clean-up-agents", and try again.',
|
|
216
|
-
],
|
|
217
|
-
});
|
|
218
|
-
process.exit(1);
|
|
219
|
-
}
|
|
220
|
-
output.warn({
|
|
221
|
-
title: 'Other Nx Cloud Agents Detected',
|
|
222
|
-
bodyLines: [
|
|
223
|
-
'We have detected other agents running in this workspace. This can cause unexpected behavior.',
|
|
224
|
-
'',
|
|
225
|
-
'This can also be a false positive caused by agents that did not shut down correctly.',
|
|
226
|
-
'If you believe this is the case, run "npx nx-cloud clean-up-agents".',
|
|
227
|
-
],
|
|
228
|
-
});
|
|
229
|
-
}
|
|
230
|
-
(0, fs_1.writeFileSync)(lockFilePath, '');
|
|
231
|
-
process.on('exit', (code) => {
|
|
232
|
-
cleanupAgentLockfile(lockFilePath, code);
|
|
233
|
-
});
|
|
234
|
-
process.on('SIGTERM', () => __awaiter(this, void 0, void 0, function* () {
|
|
235
|
-
yield api.completeRunGroupWithError('Agent was terminated via SIGTERM');
|
|
236
|
-
cleanupAgentLockfile(lockFilePath, 1);
|
|
237
|
-
}));
|
|
238
|
-
process.on('SIGINT', () => __awaiter(this, void 0, void 0, function* () {
|
|
239
|
-
yield api.completeRunGroupWithError('Agent was terminated via SIGINT');
|
|
240
|
-
cleanupAgentLockfile(lockFilePath, 1);
|
|
241
|
-
}));
|
|
242
|
-
}
|
|
243
|
-
function cleanupAgentLockfile(lockFilePath, code) {
|
|
244
|
-
if ((0, fs_1.existsSync)(lockFilePath)) {
|
|
245
|
-
(0, fs_1.unlinkSync)(lockFilePath);
|
|
246
|
-
process.exit(code);
|
|
247
|
-
}
|
|
248
|
-
}
|
|
249
|
-
function startAgent() {
|
|
250
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
251
|
-
const runGroup = (0, environment_1.getRunGroup)();
|
|
252
|
-
if (!runGroup) {
|
|
253
|
-
(0, print_run_group_error_1.printRunGroupError)();
|
|
254
|
-
return process.exit(1);
|
|
255
|
-
}
|
|
256
|
-
if (args.targets && args.targets.length) {
|
|
257
|
-
output.note({
|
|
258
|
-
title: `Starting an agent for running Nx target(s) [${args.targets.join(', ')}]`,
|
|
259
|
-
});
|
|
260
|
-
}
|
|
261
|
-
else {
|
|
262
|
-
output.note({
|
|
263
|
-
title: 'Starting an agent for running Nx tasks',
|
|
264
|
-
});
|
|
265
|
-
}
|
|
266
|
-
const defaultRunnerConfig = JSON.parse(stripJsonComments((0, fs_1.readFileSync)(`${workspaceRoot}/nx.json`).toString())).tasksRunnerOptions.default;
|
|
267
|
-
if (defaultRunnerConfig.runner !== '@nrwl/nx-cloud') {
|
|
268
|
-
(0, print_invalid_runner_error_1.printInvalidRunnerError)();
|
|
269
|
-
return process.exit(1);
|
|
270
|
-
}
|
|
271
|
-
const options = defaultRunnerConfig.options;
|
|
272
|
-
if (args.targets &&
|
|
273
|
-
args.targets.some((target) => { var _a; return !((_a = options.cacheableOperations) === null || _a === void 0 ? void 0 : _a.includes(target)); })) {
|
|
274
|
-
const wrongTargets = args.targets.filter((target) => { var _a; return !((_a = options.cacheableOperations) === null || _a === void 0 ? void 0 : _a.includes(target)); });
|
|
275
|
-
(0, print_cacheable_targets_error_1.printCacheableTargetsError)(wrongTargets);
|
|
276
|
-
return process.exit(1);
|
|
277
|
-
}
|
|
278
|
-
const agentName = getAgentName();
|
|
279
|
-
const api = new distributed_agent_api_1.DistributedAgentApi(options, runGroup, agentName);
|
|
280
|
-
createAgentLockfileAndSetUpListeners(api, options, agentName);
|
|
281
|
-
return executeTasks(options, api)
|
|
282
|
-
.then((res) => __awaiter(this, void 0, void 0, function* () {
|
|
283
|
-
yield (0, metric_logger_1.submitRunMetrics)(options);
|
|
284
|
-
return res;
|
|
285
|
-
}))
|
|
286
|
-
.catch((e) => __awaiter(this, void 0, void 0, function* () {
|
|
287
|
-
yield api.completeRunGroupWithError(`Critical Error in Agent: "${e.message}"`);
|
|
288
|
-
throw e;
|
|
289
|
-
}));
|
|
290
|
-
});
|
|
291
|
-
}
|
|
292
|
-
exports.startAgent = startAgent;
|
|
293
|
-
//# sourceMappingURL=distributed-agent.impl.js.map
|
|
1
|
+
const a6_0x104a=['reset','status','../../error/print-run-group-error','\x20seconds','CIRCLE_JOB','DistributedAgentApi','executionId','execSync','printRunGroupError','push','SIGINT','join','--configuration=','RUN_GROUP_COMPLETED','criticalErrorMessage','params','runner','cacheableOperations','Agent\x20was\x20terminated\x20via\x20SIGINT','/nx.json','VERBOSE_LOGGING','unlinkSync','../../error/print-cacheable-targets-error','Duplicate\x20Agent\x20ID\x20Detected','map','startAgent','Executing:\x20\x27','done','existsSync','target','NX_AGENT_NAME','forEach','targets','parse','./distributed-agent.api','__awaiter','completeRunGroupWithError','wait','trim','CIRCLE_STAGE','@nrwl/nx-cloud','printCacheableTargetsError','../../error/print-invalid-runner-error','projects','then','Command\x20execution\x20failed\x20(distributed\x20task\x20execution:\x20','configuration','next','completedStatusCode','error','retryDuring','We\x20have\x20detected\x20other\x20agents\x20running\x20in\x20this\x20workspace.\x20This\x20can\x20cause\x20unexpected\x20behavior.','message','tasksRunnerOptions','Starting\x20an\x20agent\x20for\x20running\x20Nx\x20tasks','toString','default','.lock','../../../utilities/nx-imports','../../../utilities/metric-logger','End\x20all\x20currently\x20running\x20agents,\x20run\x20\x22npx\x20nx-cloud\x20clean-up-agents\x22,\x20and\x20try\x20again.','No\x20new\x20messages\x20received\x20after\x20','../../../utilities/environment','getTime','getRunGroup','options','This\x20can\x20also\x20be\x20a\x20false\x20positive\x20caused\x20by\x20agents\x20that\x20did\x20not\x20shut\x20down\x20correctly.','note','NO_FURTHER_TASKS_TO_RUN','split','random','NO_MESSAGES_TIMEOUT','completed','../../../utilities/create-unchanged-value-timeout','value','readFileSync','defineProperty','number\x20of\x20tasks:\x20','createUnchangedValueTimeout','tasks','API\x20Response','some','executionId:\x20','env','If\x20you\x20believe\x20this\x20is\x20the\x20case,\x20run\x20\x22npx\x20nx-cloud\x20clean-up-agents\x22.','true','length','projectName','Distributed\x20Execution\x20Terminated','\x20--projects=','DISTRIBUTED_TASK_EXECUTION_INTERNAL_ERROR_STATUS_CODE',').\x20Tasks\x20hashes\x20haven\x27t\x20been\x20recorded.','includes','inherit','writeFileSync','exit','completed:\x20','readdirSync','getNxCacheDirectory','strip-json-comments','\x20--parallel\x20--max-parallel=','status:\x20','yargs-parser','Agent\x20','ignore','printInvalidRunnerError','taskId','mkdirSync','error:\x20','apply','SIGTERM','CIRCLECI'];(function(_0x12934b,_0x104ad0){const _0x2d1746=function(_0x43d342){while(--_0x43d342){_0x12934b['push'](_0x12934b['shift']());}};_0x2d1746(++_0x104ad0);}(a6_0x104a,0xb2));const a6_0x2d17=function(_0x12934b,_0x104ad0){_0x12934b=_0x12934b-0x0;let _0x2d1746=a6_0x104a[_0x12934b];return _0x2d1746;};'use strict';var __awaiter=this&&this[a6_0x2d17('0x51')]||function(_0x420326,_0x41393f,_0x2e86e3,_0x28e1d3){function _0xaf36b2(_0xdd13e0){return _0xdd13e0 instanceof _0x2e86e3?_0xdd13e0:new _0x2e86e3(function(_0xb2cf29){_0xb2cf29(_0xdd13e0);});}return new(_0x2e86e3||(_0x2e86e3=Promise))(function(_0x44906a,_0x440438){function _0x2f71d2(_0x17147b){try{_0x2b2eae(_0x28e1d3[a6_0x2d17('0x5d')](_0x17147b));}catch(_0x568e8d){_0x440438(_0x568e8d);}}function _0x235a2a(_0x14deee){try{_0x2b2eae(_0x28e1d3['throw'](_0x14deee));}catch(_0x569bf4){_0x440438(_0x569bf4);}}function _0x2b2eae(_0x248dbb){_0x248dbb[a6_0x2d17('0x49')]?_0x44906a(_0x248dbb[a6_0x2d17('0x8')]):_0xaf36b2(_0x248dbb[a6_0x2d17('0x8')])[a6_0x2d17('0x5a')](_0x2f71d2,_0x235a2a);}_0x2b2eae((_0x28e1d3=_0x28e1d3[a6_0x2d17('0x2b')](_0x420326,_0x41393f||[]))['next']());});};Object[a6_0x2d17('0xa')](exports,'__esModule',{'value':!![]});exports[a6_0x2d17('0x47')]=void 0x0;const child_process_1=require('child_process');const fs_1=require('fs');const stripJsonComments=require(a6_0x2d17('0x21'));const yargsParser=require(a6_0x2d17('0x24'));const create_unchanged_value_timeout_1=require(a6_0x2d17('0x7'));const environment_1=require(a6_0x2d17('0x6c'));const metric_logger_1=require(a6_0x2d17('0x69'));const waiter_1=require('../../../utilities/waiter');const print_cacheable_targets_error_1=require(a6_0x2d17('0x44'));const print_invalid_runner_error_1=require(a6_0x2d17('0x58'));const print_run_group_error_1=require(a6_0x2d17('0x30'));const distributed_agent_api_1=require(a6_0x2d17('0x50'));const {output,workspaceRoot}=require(a6_0x2d17('0x68'));const args=yargsParser(process['argv'],{'array':[a6_0x2d17('0x4e')],'default':{}});if(args[a6_0x2d17('0x4e')]&&args[a6_0x2d17('0x4e')][a6_0x2d17('0x14')]===0x1){args[a6_0x2d17('0x4e')]=args[a6_0x2d17('0x4e')][0x0][a6_0x2d17('0x3')](',')[a6_0x2d17('0x46')](_0x5214c0=>_0x5214c0[a6_0x2d17('0x54')]());}function executeTasks(_0x493552,_0x112fed){return __awaiter(this,void 0x0,void 0x0,function*(){let _0x4c3925=0x0;let _0x1f55ef=null;const _0x2a5b85=(0x0,create_unchanged_value_timeout_1[a6_0x2d17('0xc')])({'title':a6_0x2d17('0x6b')+environment_1[a6_0x2d17('0x5')]/0x3e8+a6_0x2d17('0x31'),'timeout':environment_1['NO_MESSAGES_TIMEOUT']});const _0x3efb49=new waiter_1['Waiter']();let _0x100005=[];const _0x5eb32f=new Date();let _0x42734a=![];while(!![]){if(environment_1['VERBOSE_LOGGING']){output[a6_0x2d17('0x1')]({'title':'Fetching\x20tasks...'});}_0x1f55ef=yield _0x112fed[a6_0x2d17('0xd')](_0x1f55ef?_0x1f55ef[a6_0x2d17('0x34')]:null,_0x4c3925,_0x100005,args[a6_0x2d17('0x4e')]);if(environment_1['VERBOSE_LOGGING']){output[a6_0x2d17('0x1')]({'title':a6_0x2d17('0xe'),'bodyLines':[a6_0x2d17('0x1e')+_0x1f55ef[a6_0x2d17('0x6')],a6_0x2d17('0x23')+_0x1f55ef['status'],'retryDuring:\x20'+_0x1f55ef['retryDuring'],a6_0x2d17('0x10')+_0x1f55ef['executionId'],a6_0x2d17('0xb')+_0x1f55ef[a6_0x2d17('0xd')][a6_0x2d17('0x14')],a6_0x2d17('0x2a')+_0x1f55ef['criticalErrorMessage'],'maxParallel:\x20'+_0x1f55ef['maxParallel']]});}if(_0x1f55ef[a6_0x2d17('0x3c')]){output[a6_0x2d17('0x5f')]({'title':a6_0x2d17('0x16'),'bodyLines':['Error:',_0x1f55ef[a6_0x2d17('0x3c')]]});process[a6_0x2d17('0x1d')](0x0);}if((_0x1f55ef===null||_0x1f55ef===void 0x0?void 0x0:_0x1f55ef[a6_0x2d17('0x60')])&&(_0x1f55ef===null||_0x1f55ef===void 0x0?void 0x0:_0x1f55ef[a6_0x2d17('0x60')])!==0x0&&!_0x42734a&&new Date()[a6_0x2d17('0x6d')]()-_0x5eb32f['getTime']()>_0x1f55ef['retryDuring']){yield _0x3efb49[a6_0x2d17('0x53')]();continue;}if((_0x1f55ef===null||_0x1f55ef===void 0x0?void 0x0:_0x1f55ef[a6_0x2d17('0x2f')])!==undefined){if(_0x1f55ef[a6_0x2d17('0x2f')]===a6_0x2d17('0x3b')||_0x1f55ef[a6_0x2d17('0x2f')]===a6_0x2d17('0x2')){return;}}else if(_0x1f55ef['completed']){return;}_0x2a5b85(_0x1f55ef[a6_0x2d17('0xd')][a6_0x2d17('0x46')](_0x56ff40=>_0x56ff40[a6_0x2d17('0x28')])[a6_0x2d17('0x39')](''));if(!_0x1f55ef[a6_0x2d17('0x34')]){if(environment_1['VERBOSE_LOGGING']){output[a6_0x2d17('0x1')]({'title':'Waiting...'});}yield _0x3efb49[a6_0x2d17('0x53')]();_0x4c3925=0x0;_0x100005=[];continue;}_0x3efb49[a6_0x2d17('0x2e')]();_0x42734a=!![];const _0x11f75f=invokeTasksUsingRunMany(_0x493552,_0x1f55ef['executionId'],_0x1f55ef[a6_0x2d17('0xd')],_0x1f55ef['maxParallel']);_0x4c3925=_0x11f75f[a6_0x2d17('0x5e')];_0x100005=_0x11f75f['completedTasks'];}});}function readCompletedTasks(_0x1ada34,_0x51841d){const _0x11b2f7=a6_0x2d17('0x5b')+_0x51841d+a6_0x2d17('0x19');let _0x1ec9ff;try{const _0x7c3a45=(0x0,environment_1[a6_0x2d17('0x20')])(_0x1ada34);const _0x3858ca=_0x7c3a45+'/tasks-hashes-'+_0x51841d;_0x1ec9ff=JSON[a6_0x2d17('0x4f')]((0x0,fs_1[a6_0x2d17('0x9')])(_0x3858ca)[a6_0x2d17('0x65')]());(0x0,fs_1[a6_0x2d17('0x43')])(_0x3858ca);}catch(_0x5181e6){throw new Error(_0x11b2f7);}if(_0x1ec9ff[a6_0x2d17('0x14')]==0x0){throw new Error(_0x11b2f7);}return _0x1ec9ff;}function invokeTasksUsingRunMany(_0x1b2431,_0x586648,_0xaf73c3,_0x341574){let _0x2f49ab=0x0;const _0x534907=[];for(const _0x5e54ca of groupByTarget(_0xaf73c3)){const _0x3daaad=_0x5e54ca[a6_0x2d17('0x5c')]?a6_0x2d17('0x3a')+_0x5e54ca[a6_0x2d17('0x5c')]:'';const _0x592775=_0x341574>0x1?a6_0x2d17('0x22')+_0x341574:'';const _0x5d391e='npx\x20nx\x20run-many\x20--target='+_0x5e54ca[a6_0x2d17('0x4b')]+'\x20'+_0x3daaad+a6_0x2d17('0x17')+_0x5e54ca[a6_0x2d17('0x59')][a6_0x2d17('0x39')](',')+'\x20'+_0x5e54ca[a6_0x2d17('0x3d')]+_0x592775;if(environment_1[a6_0x2d17('0x42')]){output[a6_0x2d17('0x1')]({'title':a6_0x2d17('0x48')+_0x5d391e+'\x27'});}try{(0x0,child_process_1[a6_0x2d17('0x35')])(_0x5d391e,{'stdio':[a6_0x2d17('0x26'),a6_0x2d17('0x1b'),a6_0x2d17('0x1b')],'env':Object['assign'](Object['assign']({},process[a6_0x2d17('0x11')]),{'NX_CACHE_FAILURES':a6_0x2d17('0x13'),'NX_CLOUD_DISTRIBUTED_EXECUTION_ID':_0x586648,'NX_STREAM_OUTPUT':a6_0x2d17('0x13'),'NX_PREFIX_OUTPUT':a6_0x2d17('0x13')})});_0x534907[a6_0x2d17('0x37')](...readCompletedTasks(_0x1b2431,_0x586648));}catch(_0x56f6c5){if(_0x56f6c5['status']===environment_1[a6_0x2d17('0x18')]){throw _0x56f6c5;}else{_0x2f49ab=0x1;_0x534907[a6_0x2d17('0x37')](...readCompletedTasks(_0x1b2431,_0x586648));}}}return{'completedStatusCode':_0x2f49ab,'completedTasks':_0x534907};}function groupByTarget(_0x53fcee){const _0x52fd27=[];_0x53fcee[a6_0x2d17('0x4d')](_0x53a588=>{const _0x34177b=_0x52fd27['find'](_0x5c7072=>_0x5c7072[a6_0x2d17('0x4b')]===_0x53a588[a6_0x2d17('0x4b')]&&_0x5c7072[a6_0x2d17('0x5c')]===_0x53a588[a6_0x2d17('0x5c')]);if(_0x34177b){_0x34177b[a6_0x2d17('0x59')][a6_0x2d17('0x37')](_0x53a588[a6_0x2d17('0x15')]);}else{_0x52fd27[a6_0x2d17('0x37')]({'target':_0x53a588[a6_0x2d17('0x4b')],'projects':[_0x53a588[a6_0x2d17('0x15')]],'params':_0x53a588[a6_0x2d17('0x3d')],'configuration':_0x53a588['configuration']});}});return _0x52fd27;}function getAgentName(){if(process[a6_0x2d17('0x11')][a6_0x2d17('0x4c')]!==undefined){return process[a6_0x2d17('0x11')][a6_0x2d17('0x4c')];}else if(process[a6_0x2d17('0x11')][a6_0x2d17('0x2d')]!==undefined&&process['env']['CIRCLE_STAGE']){return process[a6_0x2d17('0x11')][a6_0x2d17('0x55')];}else if(process[a6_0x2d17('0x11')][a6_0x2d17('0x2d')]!==undefined&&process[a6_0x2d17('0x11')]['CIRCLE_JOB']){return process[a6_0x2d17('0x11')][a6_0x2d17('0x32')];}else{return a6_0x2d17('0x25')+Math['floor'](Math[a6_0x2d17('0x4')]()*0x186a0);}}function createAgentLockfileAndSetUpListeners(_0x3b3558,_0x4ebb39,_0x9a58d0){const _0xde00d7=(0x0,environment_1[a6_0x2d17('0x20')])(_0x4ebb39);const _0x2e7cf7=_0xde00d7+'/lockfiles';const _0x3809c7=_0x2e7cf7+'/'+_0x9a58d0+a6_0x2d17('0x67');if(!(0x0,fs_1['existsSync'])(_0x2e7cf7)){(0x0,fs_1[a6_0x2d17('0x29')])(_0x2e7cf7,{'recursive':!![]});}const _0x5f278c=(0x0,fs_1[a6_0x2d17('0x1f')])(_0x2e7cf7);if(_0x5f278c[a6_0x2d17('0x14')]){if(_0x5f278c[a6_0x2d17('0x1a')](_0x9a58d0+a6_0x2d17('0x67'))){output[a6_0x2d17('0x5f')]({'title':a6_0x2d17('0x45'),'bodyLines':['We\x20have\x20detected\x20another\x20agent\x20with\x20this\x20ID\x20running\x20in\x20this\x20workspace.\x20This\x20should\x20not\x20happen.','',a6_0x2d17('0x6a')]});process['exit'](0x1);}output['warn']({'title':'Other\x20Nx\x20Cloud\x20Agents\x20Detected','bodyLines':[a6_0x2d17('0x61'),'',a6_0x2d17('0x0'),a6_0x2d17('0x12')]});}(0x0,fs_1[a6_0x2d17('0x1c')])(_0x3809c7,'');process['on']('exit',_0x2c1459=>{cleanupAgentLockfile(_0x3809c7,_0x2c1459);});process['on'](a6_0x2d17('0x2c'),()=>__awaiter(this,void 0x0,void 0x0,function*(){yield _0x3b3558['completeRunGroupWithError']('Agent\x20was\x20terminated\x20via\x20SIGTERM');cleanupAgentLockfile(_0x3809c7,0x1);}));process['on'](a6_0x2d17('0x38'),()=>__awaiter(this,void 0x0,void 0x0,function*(){yield _0x3b3558['completeRunGroupWithError'](a6_0x2d17('0x40'));cleanupAgentLockfile(_0x3809c7,0x1);}));}function cleanupAgentLockfile(_0x1e5f39,_0xfe9e77){if((0x0,fs_1[a6_0x2d17('0x4a')])(_0x1e5f39)){(0x0,fs_1[a6_0x2d17('0x43')])(_0x1e5f39);process[a6_0x2d17('0x1d')](_0xfe9e77);}}function startAgent(){return __awaiter(this,void 0x0,void 0x0,function*(){const _0x42b4b3=(0x0,environment_1[a6_0x2d17('0x6e')])();if(!_0x42b4b3){(0x0,print_run_group_error_1[a6_0x2d17('0x36')])();return process['exit'](0x1);}if(args[a6_0x2d17('0x4e')]&&args['targets'][a6_0x2d17('0x14')]){output['note']({'title':'Starting\x20an\x20agent\x20for\x20running\x20Nx\x20target(s)\x20['+args['targets'][a6_0x2d17('0x39')](',\x20')+']'});}else{output['note']({'title':a6_0x2d17('0x64')});}const _0xaf2fb=JSON[a6_0x2d17('0x4f')](stripJsonComments((0x0,fs_1['readFileSync'])(workspaceRoot+a6_0x2d17('0x41'))[a6_0x2d17('0x65')]()))[a6_0x2d17('0x63')][a6_0x2d17('0x66')];if(_0xaf2fb[a6_0x2d17('0x3e')]!==a6_0x2d17('0x56')){(0x0,print_invalid_runner_error_1[a6_0x2d17('0x27')])();return process[a6_0x2d17('0x1d')](0x1);}const _0x596158=_0xaf2fb[a6_0x2d17('0x6f')];if(args['targets']&&args[a6_0x2d17('0x4e')][a6_0x2d17('0xf')](_0x15f806=>{var _0x5765a7;return!((_0x5765a7=_0x596158['cacheableOperations'])===null||_0x5765a7===void 0x0?void 0x0:_0x5765a7[a6_0x2d17('0x1a')](_0x15f806));})){const _0x52727a=args[a6_0x2d17('0x4e')]['filter'](_0x1800cf=>{var _0x1b8304;return!((_0x1b8304=_0x596158[a6_0x2d17('0x3f')])===null||_0x1b8304===void 0x0?void 0x0:_0x1b8304[a6_0x2d17('0x1a')](_0x1800cf));});(0x0,print_cacheable_targets_error_1[a6_0x2d17('0x57')])(_0x52727a);return process[a6_0x2d17('0x1d')](0x1);}const _0x465932=getAgentName();const _0x1427e8=new distributed_agent_api_1[(a6_0x2d17('0x33'))](_0x596158,_0x42b4b3,_0x465932);createAgentLockfileAndSetUpListeners(_0x1427e8,_0x596158,_0x465932);return executeTasks(_0x596158,_0x1427e8)[a6_0x2d17('0x5a')](_0x35b515=>__awaiter(this,void 0x0,void 0x0,function*(){yield(0x0,metric_logger_1['submitRunMetrics'])(_0x596158);return _0x35b515;}))['catch'](_0x34e09d=>__awaiter(this,void 0x0,void 0x0,function*(){yield _0x1427e8[a6_0x2d17('0x52')]('Critical\x20Error\x20in\x20Agent:\x20\x22'+_0x34e09d[a6_0x2d17('0x62')]+'\x22');throw _0x34e09d;}));});}exports[a6_0x2d17('0x47')]=startAgent;
|
|
@@ -1,143 +1 @@
|
|
|
1
|
-
|
|
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(runGroup, 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 run group with an error',
|
|
81
|
-
bodyLines: [`runGroup: ${runGroup}`, `error: ${error}`],
|
|
82
|
-
});
|
|
83
|
-
}
|
|
84
|
-
try {
|
|
85
|
-
const resp = yield (0, axios_1.axiosMultipleTries)(() => this.apiAxiosInstance.post('/nx-cloud/executions/complete-run-group', {
|
|
86
|
-
runGroup: runGroup,
|
|
87
|
-
criticalErrorMessage: error,
|
|
88
|
-
}), 3);
|
|
89
|
-
recorder.recordMetric((0, metric_logger_1.mapRespToPerfEntry)(resp));
|
|
90
|
-
}
|
|
91
|
-
catch (e) {
|
|
92
|
-
recorder.recordMetric(((_a = e === null || e === void 0 ? void 0 : e.axiosException) === null || _a === void 0 ? void 0 : _a.response)
|
|
93
|
-
? (0, metric_logger_1.mapRespToPerfEntry)(e.axiosException.response)
|
|
94
|
-
: metric_logger_1.RUNNER_FAILURE_PERF_ENTRY);
|
|
95
|
-
}
|
|
96
|
-
});
|
|
97
|
-
}
|
|
98
|
-
}
|
|
99
|
-
exports.DistributedExecutionApi = DistributedExecutionApi;
|
|
100
|
-
function createStartRequest(runGroup, task, options) {
|
|
101
|
-
const tasksToExecute = task.map((arr) => {
|
|
102
|
-
return arr.map((t) => {
|
|
103
|
-
return {
|
|
104
|
-
taskId: t.id,
|
|
105
|
-
hash: t.hash,
|
|
106
|
-
projectName: t.target.project,
|
|
107
|
-
target: t.target.target,
|
|
108
|
-
configuration: t.target.configuration || null,
|
|
109
|
-
params: (0, serializer_overrides_1.serializeOverrides)(t),
|
|
110
|
-
};
|
|
111
|
-
});
|
|
112
|
-
});
|
|
113
|
-
const request = {
|
|
114
|
-
command: (0, environment_1.parseCommand)(),
|
|
115
|
-
branch: (0, environment_1.getBranch)(),
|
|
116
|
-
runGroup,
|
|
117
|
-
tasks: tasksToExecute,
|
|
118
|
-
maxParallel: calculateMaxParallel(options),
|
|
119
|
-
};
|
|
120
|
-
if (environment_1.NX_CLOUD_DISTRIBUTED_EXECUTION_AGENT_COUNT) {
|
|
121
|
-
request.agentCount = environment_1.NX_CLOUD_DISTRIBUTED_EXECUTION_AGENT_COUNT;
|
|
122
|
-
}
|
|
123
|
-
if (!environment_1.NX_CLOUD_DISTRIBUTED_EXECUTION_STOP_AGENTS_ON_FAILURE) {
|
|
124
|
-
request.stopAgentsOnFailure = false;
|
|
125
|
-
}
|
|
126
|
-
return request;
|
|
127
|
-
}
|
|
128
|
-
exports.createStartRequest = createStartRequest;
|
|
129
|
-
function calculateMaxParallel(options) {
|
|
130
|
-
if (options.parallel === 'false' || options.parallel === false) {
|
|
131
|
-
return 1;
|
|
132
|
-
}
|
|
133
|
-
else if (options.parallel === 'true' || options.parallel === true) {
|
|
134
|
-
return Number(options.maxParallel || 3);
|
|
135
|
-
}
|
|
136
|
-
else if (options.parallel === undefined) {
|
|
137
|
-
return options.maxParallel ? Number(options.maxParallel) : 3;
|
|
138
|
-
}
|
|
139
|
-
else {
|
|
140
|
-
return Number(options.parallel) || 3;
|
|
141
|
-
}
|
|
142
|
-
}
|
|
143
|
-
//# sourceMappingURL=distributed-execution.api.js.map
|
|
1
|
+
const a7_0x2a61=['error','RUNNER_FAILURE_PERF_ENTRY','error:\x20','defineProperty','note','configuration','axiosMultipleTries','maxParallel','completeRunGroup','/nx-cloud/executions/complete-run-group','false','__awaiter','done','throw','data','DistributedExecutionApi','map','createApiAxiosInstance','getBranch','../../../utilities/environment','stopAgentsOnFailure','parseCommand','completeRunGroupWithError','../../../utilities/metric-logger','post','../../../utilities/nx-imports','target','VERBOSE_LOGGING','mapRespToPerfEntry','then','apply','Completing\x20run\x20group\x20with\x20an\x20error','recordMetric','../../../utilities/serializer-overrides','status','exit','createStartRequest','createMetricRecorder','serializeOverrides','stringify','parallel','/nx-cloud/executions/start','../../../utilities/axios','axiosException','dteStatus','true','dteStart','value','NX_CLOUD_DISTRIBUTED_EXECUTION_AGENT_COUNT','agentCount','next','project','response','apiAxiosInstance','__esModule'];(function(_0x3ae8a5,_0x2a6142){const _0x41d584=function(_0x3e97aa){while(--_0x3e97aa){_0x3ae8a5['push'](_0x3ae8a5['shift']());}};_0x41d584(++_0x2a6142);}(a7_0x2a61,0x15b));const a7_0x41d5=function(_0x3ae8a5,_0x2a6142){_0x3ae8a5=_0x3ae8a5-0x0;let _0x41d584=a7_0x2a61[_0x3ae8a5];return _0x41d584;};'use strict';var __awaiter=this&&this[a7_0x41d5('0x31')]||function(_0x448ba6,_0x2fda7b,_0x1ce3c9,_0x34ebc1){function _0x537379(_0xa3ee0a){return _0xa3ee0a instanceof _0x1ce3c9?_0xa3ee0a:new _0x1ce3c9(function(_0x379b43){_0x379b43(_0xa3ee0a);});}return new(_0x1ce3c9||(_0x1ce3c9=Promise))(function(_0x51e37b,_0x530830){function _0x3164a3(_0x4e3ecd){try{_0x4981ba(_0x34ebc1[a7_0x41d5('0x21')](_0x4e3ecd));}catch(_0x23e564){_0x530830(_0x23e564);}}function _0x1bba4c(_0x5c4dec){try{_0x4981ba(_0x34ebc1[a7_0x41d5('0x33')](_0x5c4dec));}catch(_0x3e25d4){_0x530830(_0x3e25d4);}}function _0x4981ba(_0x57abea){_0x57abea[a7_0x41d5('0x32')]?_0x51e37b(_0x57abea[a7_0x41d5('0x1e')]):_0x537379(_0x57abea['value'])[a7_0x41d5('0xc')](_0x3164a3,_0x1bba4c);}_0x4981ba((_0x34ebc1=_0x34ebc1[a7_0x41d5('0xd')](_0x448ba6,_0x2fda7b||[]))[a7_0x41d5('0x21')]());});};Object[a7_0x41d5('0x29')](exports,a7_0x41d5('0x25'),{'value':!![]});exports['createStartRequest']=exports['DistributedExecutionApi']=void 0x0;const axios_1=require(a7_0x41d5('0x19'));const environment_1=require(a7_0x41d5('0x2'));const metric_logger_1=require(a7_0x41d5('0x6'));const serializer_overrides_1=require(a7_0x41d5('0x10'));const {output}=require(a7_0x41d5('0x8'));class DistributedExecutionApi{constructor(_0x285696){this[a7_0x41d5('0x24')]=(0x0,axios_1[a7_0x41d5('0x0')])(_0x285696);}['start'](_0x1c0221){var _0x4ac8ed;return __awaiter(this,void 0x0,void 0x0,function*(){const _0x49765d=(0x0,metric_logger_1[a7_0x41d5('0x14')])(a7_0x41d5('0x1d'));let _0x373930;if(environment_1[a7_0x41d5('0xa')]){output[a7_0x41d5('0x2a')]({'title':'Starting\x20a\x20distributed\x20execution','bodyLines':[JSON[a7_0x41d5('0x16')](_0x1c0221,null,0x2)]});}try{_0x373930=yield(0x0,axios_1[a7_0x41d5('0x2c')])(()=>this['apiAxiosInstance']['post'](a7_0x41d5('0x18'),_0x1c0221));_0x49765d['recordMetric']((0x0,metric_logger_1[a7_0x41d5('0xb')])(_0x373930));}catch(_0x25cde2){_0x49765d[a7_0x41d5('0xf')](((_0x4ac8ed=_0x25cde2===null||_0x25cde2===void 0x0?void 0x0:_0x25cde2[a7_0x41d5('0x1a')])===null||_0x4ac8ed===void 0x0?void 0x0:_0x4ac8ed[a7_0x41d5('0x23')])?(0x0,metric_logger_1[a7_0x41d5('0xb')])(_0x25cde2[a7_0x41d5('0x1a')][a7_0x41d5('0x23')]):metric_logger_1[a7_0x41d5('0x27')]);throw _0x25cde2;}if(!_0x373930[a7_0x41d5('0x34')]['enabled']){throw new Error('Workspace\x20is\x20disabled.\x20Cannot\x20perform\x20distributed\x20task\x20executions.');}if(_0x373930[a7_0x41d5('0x34')]['error']){throw new Error(_0x373930[a7_0x41d5('0x34')]['error']);}return _0x373930[a7_0x41d5('0x34')]['id'];});}[a7_0x41d5('0x11')](_0xeddf97){var _0x42bcd3;return __awaiter(this,void 0x0,void 0x0,function*(){const _0xda4012=(0x0,metric_logger_1[a7_0x41d5('0x14')])(a7_0x41d5('0x1b'));try{const _0x1a984e=yield(0x0,axios_1[a7_0x41d5('0x2c')])(()=>this[a7_0x41d5('0x24')][a7_0x41d5('0x7')]('/nx-cloud/executions/status',{'id':_0xeddf97}));_0xda4012['recordMetric']((0x0,metric_logger_1[a7_0x41d5('0xb')])(_0x1a984e));return _0x1a984e['data'];}catch(_0x10b263){_0xda4012[a7_0x41d5('0xf')](((_0x42bcd3=_0x10b263===null||_0x10b263===void 0x0?void 0x0:_0x10b263[a7_0x41d5('0x1a')])===null||_0x42bcd3===void 0x0?void 0x0:_0x42bcd3[a7_0x41d5('0x23')])?(0x0,metric_logger_1[a7_0x41d5('0xb')])(_0x10b263[a7_0x41d5('0x1a')][a7_0x41d5('0x23')]):metric_logger_1[a7_0x41d5('0x27')]);output[a7_0x41d5('0x26')]({'title':_0x10b263['message']});process[a7_0x41d5('0x12')](0x1);}});}[a7_0x41d5('0x5')](_0x152f8d,_0x1e60c5){var _0x6581f6;return __awaiter(this,void 0x0,void 0x0,function*(){const _0x4360a9=(0x0,metric_logger_1[a7_0x41d5('0x14')])(a7_0x41d5('0x2e'));if(environment_1['VERBOSE_LOGGING']){output['note']({'title':a7_0x41d5('0xe'),'bodyLines':['runGroup:\x20'+_0x152f8d,a7_0x41d5('0x28')+_0x1e60c5]});}try{const _0x190242=yield(0x0,axios_1[a7_0x41d5('0x2c')])(()=>this[a7_0x41d5('0x24')][a7_0x41d5('0x7')](a7_0x41d5('0x2f'),{'runGroup':_0x152f8d,'criticalErrorMessage':_0x1e60c5}),0x3);_0x4360a9[a7_0x41d5('0xf')]((0x0,metric_logger_1[a7_0x41d5('0xb')])(_0x190242));}catch(_0x56af48){_0x4360a9[a7_0x41d5('0xf')](((_0x6581f6=_0x56af48===null||_0x56af48===void 0x0?void 0x0:_0x56af48[a7_0x41d5('0x1a')])===null||_0x6581f6===void 0x0?void 0x0:_0x6581f6[a7_0x41d5('0x23')])?(0x0,metric_logger_1[a7_0x41d5('0xb')])(_0x56af48[a7_0x41d5('0x1a')][a7_0x41d5('0x23')]):metric_logger_1['RUNNER_FAILURE_PERF_ENTRY']);}});}}exports[a7_0x41d5('0x35')]=DistributedExecutionApi;function createStartRequest(_0x3dad89,_0x4d57a2,_0x4418d6){const _0x404b9e=_0x4d57a2[a7_0x41d5('0x36')](_0x563829=>{return _0x563829['map'](_0x4e23c7=>{return{'taskId':_0x4e23c7['id'],'hash':_0x4e23c7['hash'],'projectName':_0x4e23c7[a7_0x41d5('0x9')][a7_0x41d5('0x22')],'target':_0x4e23c7['target'][a7_0x41d5('0x9')],'configuration':_0x4e23c7['target'][a7_0x41d5('0x2b')]||null,'params':(0x0,serializer_overrides_1[a7_0x41d5('0x15')])(_0x4e23c7)};});});const _0x236726={'command':(0x0,environment_1[a7_0x41d5('0x4')])(),'branch':(0x0,environment_1[a7_0x41d5('0x1')])(),'runGroup':_0x3dad89,'tasks':_0x404b9e,'maxParallel':calculateMaxParallel(_0x4418d6)};if(environment_1[a7_0x41d5('0x1f')]){_0x236726[a7_0x41d5('0x20')]=environment_1[a7_0x41d5('0x1f')];}if(!environment_1['NX_CLOUD_DISTRIBUTED_EXECUTION_STOP_AGENTS_ON_FAILURE']){_0x236726[a7_0x41d5('0x3')]=![];}return _0x236726;}exports[a7_0x41d5('0x13')]=createStartRequest;function calculateMaxParallel(_0x42d87f){if(_0x42d87f[a7_0x41d5('0x17')]===a7_0x41d5('0x30')||_0x42d87f[a7_0x41d5('0x17')]===![]){return 0x1;}else if(_0x42d87f[a7_0x41d5('0x17')]===a7_0x41d5('0x1c')||_0x42d87f[a7_0x41d5('0x17')]===!![]){return Number(_0x42d87f[a7_0x41d5('0x2d')]||0x3);}else if(_0x42d87f['parallel']===undefined){return _0x42d87f['maxParallel']?Number(_0x42d87f[a7_0x41d5('0x2d')]):0x3;}else{return Number(_0x42d87f[a7_0x41d5('0x17')])||0x3;}}
|