@nrwl/nx-cloud 15.0.4-beta.2 → 15.0.4-beta.3

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.
Files changed (154) hide show
  1. package/bin/nx-cloud.d.ts +2 -0
  2. package/bin/nx-cloud.js +50 -0
  3. package/bin/nx-cloud.js.map +1 -0
  4. package/index.d.ts +2 -0
  5. package/index.js +5 -0
  6. package/index.js.map +1 -0
  7. package/lib/core/api/error-reporter.api.d.ts +6 -0
  8. package/lib/core/api/error-reporter.api.js +36 -0
  9. package/lib/core/api/error-reporter.api.js.map +1 -0
  10. package/lib/core/api/run-group.api.d.ts +7 -0
  11. package/lib/core/api/run-group.api.js +68 -0
  12. package/lib/core/api/run-group.api.js.map +1 -0
  13. package/lib/core/commands/clean-up-agents.d.ts +1 -0
  14. package/lib/core/commands/clean-up-agents.js +34 -0
  15. package/lib/core/commands/clean-up-agents.js.map +1 -0
  16. package/lib/core/commands/record-output.d.ts +1 -0
  17. package/lib/core/commands/record-output.js +177 -0
  18. package/lib/core/commands/record-output.js.map +1 -0
  19. package/lib/core/commands/start-ci-run.d.ts +1 -0
  20. package/lib/core/commands/start-ci-run.js +61 -0
  21. package/lib/core/commands/start-ci-run.js.map +1 -0
  22. package/lib/core/commands/stop-all-agents.d.ts +1 -0
  23. package/lib/core/commands/stop-all-agents.js +37 -0
  24. package/lib/core/commands/stop-all-agents.js.map +1 -0
  25. package/lib/core/commands/upload-and-show-run-details.d.ts +1 -0
  26. package/lib/core/commands/upload-and-show-run-details.js +60 -0
  27. package/lib/core/commands/upload-and-show-run-details.js.map +1 -0
  28. package/lib/core/error/print-invalid-runner-error.d.ts +1 -0
  29. package/lib/core/error/print-invalid-runner-error.js +17 -0
  30. package/lib/core/error/print-invalid-runner-error.js.map +1 -0
  31. package/lib/core/error/print-run-group-error.d.ts +1 -0
  32. package/lib/core/error/print-run-group-error.js +16 -0
  33. package/lib/core/error/print-run-group-error.js.map +1 -0
  34. package/lib/core/file-storage/e2e-encryption.d.ts +9 -0
  35. package/lib/core/file-storage/e2e-encryption.js +46 -0
  36. package/lib/core/file-storage/e2e-encryption.js.map +1 -0
  37. package/lib/core/file-storage/file-storage.d.ts +24 -0
  38. package/lib/core/file-storage/file-storage.js +262 -0
  39. package/lib/core/file-storage/file-storage.js.map +1 -0
  40. package/lib/core/models/cache-urls.model.d.ts +6 -0
  41. package/lib/core/models/cache-urls.model.js +3 -0
  42. package/lib/core/models/cache-urls.model.js.map +1 -0
  43. package/lib/core/models/cloud-task-runner-options.d.ts +20 -0
  44. package/lib/core/models/cloud-task-runner-options.js +3 -0
  45. package/lib/core/models/cloud-task-runner-options.js.map +1 -0
  46. package/lib/core/models/distributed-agent/grouped-tasks.model.d.ts +6 -0
  47. package/lib/core/models/distributed-agent/grouped-tasks.model.js +3 -0
  48. package/lib/core/models/distributed-agent/grouped-tasks.model.js.map +1 -0
  49. package/lib/core/models/distributed-agent/index.d.ts +3 -0
  50. package/lib/core/models/distributed-agent/index.js +20 -0
  51. package/lib/core/models/distributed-agent/index.js.map +1 -0
  52. package/lib/core/models/distributed-agent/task-to-execute.model.d.ts +7 -0
  53. package/lib/core/models/distributed-agent/task-to-execute.model.js +3 -0
  54. package/lib/core/models/distributed-agent/task-to-execute.model.js.map +1 -0
  55. package/lib/core/models/distributed-agent/tasks-api-response.model.d.ts +10 -0
  56. package/lib/core/models/distributed-agent/tasks-api-response.model.js +3 -0
  57. package/lib/core/models/distributed-agent/tasks-api-response.model.js.map +1 -0
  58. package/lib/core/models/machine-info.model.d.ts +6 -0
  59. package/lib/core/models/machine-info.model.js +3 -0
  60. package/lib/core/models/machine-info.model.js.map +1 -0
  61. package/lib/core/models/run-context.model.d.ts +128 -0
  62. package/lib/core/models/run-context.model.js +22 -0
  63. package/lib/core/models/run-context.model.js.map +1 -0
  64. package/lib/core/models/run-data.model.d.ts +11 -0
  65. package/lib/core/models/run-data.model.js +3 -0
  66. package/lib/core/models/run-data.model.js.map +1 -0
  67. package/lib/core/models/task-execution.model.d.ts +13 -0
  68. package/lib/core/models/task-execution.model.js +3 -0
  69. package/lib/core/models/task-execution.model.js.map +1 -0
  70. package/lib/core/runners/cloud-enabled/cloud-enabled-life-cycle.d.ts +19 -0
  71. package/lib/core/runners/cloud-enabled/cloud-enabled-life-cycle.js +84 -0
  72. package/lib/core/runners/cloud-enabled/cloud-enabled-life-cycle.js.map +1 -0
  73. package/lib/core/runners/cloud-enabled/cloud-enabled.runner.d.ts +3 -0
  74. package/lib/core/runners/cloud-enabled/cloud-enabled.runner.js +288 -0
  75. package/lib/core/runners/cloud-enabled/cloud-enabled.runner.js.map +1 -0
  76. package/lib/core/runners/cloud-enabled/cloud-remote-cache.d.ts +16 -0
  77. package/lib/core/runners/cloud-enabled/cloud-remote-cache.js +117 -0
  78. package/lib/core/runners/cloud-enabled/cloud-remote-cache.js.map +1 -0
  79. package/lib/core/runners/cloud-enabled/cloud-run.api.d.ts +18 -0
  80. package/lib/core/runners/cloud-enabled/cloud-run.api.js +167 -0
  81. package/lib/core/runners/cloud-enabled/cloud-run.api.js.map +1 -0
  82. package/lib/core/runners/cloud-enabled/id-generator.d.ts +1 -0
  83. package/lib/core/runners/cloud-enabled/id-generator.js +16 -0
  84. package/lib/core/runners/cloud-enabled/id-generator.js.map +1 -0
  85. package/lib/core/runners/distributed-agent/distributed-agent.api.d.ts +13 -0
  86. package/lib/core/runners/distributed-agent/distributed-agent.api.js +79 -0
  87. package/lib/core/runners/distributed-agent/distributed-agent.api.js.map +1 -0
  88. package/lib/core/runners/distributed-agent/distributed-agent.impl.d.ts +1 -0
  89. package/lib/core/runners/distributed-agent/distributed-agent.impl.js +269 -0
  90. package/lib/core/runners/distributed-agent/distributed-agent.impl.js.map +1 -0
  91. package/lib/core/runners/distributed-execution/distributed-execution.api.d.ts +10 -0
  92. package/lib/core/runners/distributed-execution/distributed-execution.api.js +143 -0
  93. package/lib/core/runners/distributed-execution/distributed-execution.api.js.map +1 -0
  94. package/lib/core/runners/distributed-execution/distributed-execution.runner.d.ts +1 -0
  95. package/lib/core/runners/distributed-execution/distributed-execution.runner.js +241 -0
  96. package/lib/core/runners/distributed-execution/distributed-execution.runner.js.map +1 -0
  97. package/lib/core/runners/distributed-execution/split-task-graph-into-stages.d.ts +2 -0
  98. package/lib/core/runners/distributed-execution/split-task-graph-into-stages.js +37 -0
  99. package/lib/core/runners/distributed-execution/split-task-graph-into-stages.js.map +1 -0
  100. package/lib/core/runners/distributed-execution/task-graph-creator.d.ts +15 -0
  101. package/lib/core/runners/distributed-execution/task-graph-creator.js +77 -0
  102. package/lib/core/runners/distributed-execution/task-graph-creator.js.map +1 -0
  103. package/lib/core/terminal-output/end-of-run-message.d.ts +8 -0
  104. package/lib/core/terminal-output/end-of-run-message.js +44 -0
  105. package/lib/core/terminal-output/end-of-run-message.js.map +1 -0
  106. package/lib/core/terminal-output/message-reporter.d.ts +11 -0
  107. package/lib/core/terminal-output/message-reporter.js +71 -0
  108. package/lib/core/terminal-output/message-reporter.js.map +1 -0
  109. package/lib/core/terminal-output/output-obfuscator.d.ts +6 -0
  110. package/lib/core/terminal-output/output-obfuscator.js +48 -0
  111. package/lib/core/terminal-output/output-obfuscator.js.map +1 -0
  112. package/lib/core/terminal-output/read-task-terminal-output.d.ts +2 -0
  113. package/lib/core/terminal-output/read-task-terminal-output.js +60 -0
  114. package/lib/core/terminal-output/read-task-terminal-output.js.map +1 -0
  115. package/lib/daemon/process-run-end.d.ts +3 -0
  116. package/lib/daemon/process-run-end.js +60 -0
  117. package/lib/daemon/process-run-end.js.map +1 -0
  118. package/lib/generators/init/init.d.ts +1 -0
  119. package/lib/generators/init/init.js +96 -0
  120. package/lib/generators/init/init.js.map +1 -0
  121. package/lib/nx-cloud-tasks-runner.d.ts +2 -0
  122. package/lib/nx-cloud-tasks-runner.js +146 -0
  123. package/lib/nx-cloud-tasks-runner.js.map +1 -0
  124. package/lib/utilities/axios.d.ts +10 -0
  125. package/lib/utilities/axios.js +87 -0
  126. package/lib/utilities/axios.js.map +1 -0
  127. package/lib/utilities/create-unchanged-value-timeout.d.ts +4 -0
  128. package/lib/utilities/create-unchanged-value-timeout.js +24 -0
  129. package/lib/utilities/create-unchanged-value-timeout.js.map +1 -0
  130. package/lib/utilities/distributed-task-execution-detection.d.ts +2 -0
  131. package/lib/utilities/distributed-task-execution-detection.js +36 -0
  132. package/lib/utilities/distributed-task-execution-detection.js.map +1 -0
  133. package/lib/utilities/environment.d.ts +27 -0
  134. package/lib/utilities/environment.js +200 -0
  135. package/lib/utilities/environment.js.map +1 -0
  136. package/lib/utilities/is-ci.d.ts +1 -0
  137. package/lib/utilities/is-ci.js +21 -0
  138. package/lib/utilities/is-ci.js.map +1 -0
  139. package/lib/utilities/metric-logger.d.ts +22 -0
  140. package/lib/utilities/metric-logger.js +70 -0
  141. package/lib/utilities/metric-logger.js.map +1 -0
  142. package/lib/utilities/nx-imports.d.ts +0 -0
  143. package/lib/utilities/nx-imports.js +59 -0
  144. package/lib/utilities/nx-imports.js.map +1 -0
  145. package/lib/utilities/print-message.d.ts +1 -0
  146. package/lib/utilities/print-message.js +64 -0
  147. package/lib/utilities/print-message.js.map +1 -0
  148. package/lib/utilities/serializer-overrides.d.ts +2 -0
  149. package/lib/utilities/serializer-overrides.js +40 -0
  150. package/lib/utilities/serializer-overrides.js.map +1 -0
  151. package/lib/utilities/waiter.d.ts +6 -0
  152. package/lib/utilities/waiter.js +36 -0
  153. package/lib/utilities/waiter.js.map +1 -0
  154. package/package.json +1 -1
@@ -0,0 +1,269 @@
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 create_unchanged_value_timeout_1 = require("../../../utilities/create-unchanged-value-timeout");
17
+ const environment_1 = require("../../../utilities/environment");
18
+ const metric_logger_1 = require("../../../utilities/metric-logger");
19
+ const waiter_1 = require("../../../utilities/waiter");
20
+ const print_run_group_error_1 = require("../../error/print-run-group-error");
21
+ const distributed_agent_api_1 = require("./distributed-agent.api");
22
+ const print_invalid_runner_error_1 = require("../../error/print-invalid-runner-error");
23
+ const { output, workspaceRoot } = require('../../../utilities/nx-imports');
24
+ function executeTasks(options, api) {
25
+ return __awaiter(this, void 0, void 0, function* () {
26
+ let completedStatusCode = 0;
27
+ let apiResponse = null;
28
+ const failIfSameTasksAfterTimeout = (0, create_unchanged_value_timeout_1.createUnchangedValueTimeout)({
29
+ title: `No new messages received after ${environment_1.NO_MESSAGES_TIMEOUT / 1000} seconds`,
30
+ timeout: environment_1.NO_MESSAGES_TIMEOUT,
31
+ });
32
+ const waiter = new waiter_1.Waiter();
33
+ let completedTasks = [];
34
+ const startTime = new Date();
35
+ let executedAnyTasks = false;
36
+ while (true) {
37
+ if (environment_1.VERBOSE_LOGGING) {
38
+ output.note({
39
+ title: 'Fetching tasks...',
40
+ });
41
+ }
42
+ apiResponse = yield api.tasks(apiResponse ? apiResponse.executionId : null, completedStatusCode, completedTasks);
43
+ if (environment_1.VERBOSE_LOGGING) {
44
+ output.note({
45
+ title: 'API Response',
46
+ bodyLines: [
47
+ `completed: ${apiResponse.completed}`,
48
+ `status: ${apiResponse.status}`,
49
+ `retryDuring: ${apiResponse.retryDuring}`,
50
+ `executionId: ${apiResponse.executionId}`,
51
+ `number of tasks: ${apiResponse.tasks.length}`,
52
+ `error: ${apiResponse.criticalErrorMessage}`,
53
+ `maxParallel: ${apiResponse.maxParallel}`,
54
+ ],
55
+ });
56
+ }
57
+ if (apiResponse.criticalErrorMessage) {
58
+ output.error({
59
+ title: 'Distributed Execution Terminated',
60
+ bodyLines: ['Error:', apiResponse.criticalErrorMessage],
61
+ });
62
+ process.exit(0);
63
+ }
64
+ // run group is completed but it might be a rerun
65
+ // we will try several times before going further and
66
+ // completed the response
67
+ // we only do it if we haven't executed any tasks
68
+ if ((apiResponse === null || apiResponse === void 0 ? void 0 : apiResponse.retryDuring) &&
69
+ (apiResponse === null || apiResponse === void 0 ? void 0 : apiResponse.retryDuring) !== 0 &&
70
+ !executedAnyTasks &&
71
+ new Date().getTime() - startTime.getTime() > apiResponse.retryDuring) {
72
+ yield waiter.wait();
73
+ continue;
74
+ }
75
+ if ((apiResponse === null || apiResponse === void 0 ? void 0 : apiResponse.status) !== undefined) {
76
+ if (apiResponse.status === 'RUN_GROUP_COMPLETED' ||
77
+ apiResponse.status === 'NO_FURTHER_TASKS_TO_RUN') {
78
+ return;
79
+ }
80
+ }
81
+ else if (apiResponse.completed) {
82
+ return;
83
+ }
84
+ // if status is present that use the status instead of completed, otherwise use completed
85
+ failIfSameTasksAfterTimeout(apiResponse.tasks.map((t) => t.taskId).join(''));
86
+ if (!apiResponse.executionId) {
87
+ if (environment_1.VERBOSE_LOGGING) {
88
+ output.note({
89
+ title: 'Waiting...',
90
+ });
91
+ }
92
+ yield waiter.wait();
93
+ completedStatusCode = 0;
94
+ completedTasks = [];
95
+ continue;
96
+ }
97
+ waiter.reset();
98
+ executedAnyTasks = true;
99
+ const r = invokeTasksUsingRunMany(options, apiResponse.executionId, apiResponse.tasks, apiResponse.maxParallel);
100
+ completedStatusCode = r.completedStatusCode;
101
+ completedTasks = r.completedTasks;
102
+ }
103
+ });
104
+ }
105
+ function readCompletedTasks(options, distributedExecutionId) {
106
+ const errorMessage = `Command execution failed (distributed task execution: ${distributedExecutionId}). Tasks hashes haven\'t been recorded.`;
107
+ let completedTasks;
108
+ try {
109
+ const cacheDirectory = (0, environment_1.getNxCacheDirectory)(options);
110
+ const taskHashesFile = `${cacheDirectory}/tasks-hashes-${distributedExecutionId}`;
111
+ completedTasks = JSON.parse((0, fs_1.readFileSync)(taskHashesFile).toString());
112
+ // remove it such that if the next command crashes we don't read an obsolete file
113
+ (0, fs_1.unlinkSync)(taskHashesFile);
114
+ }
115
+ catch (e) {
116
+ throw new Error(errorMessage);
117
+ }
118
+ if (completedTasks.length == 0) {
119
+ throw new Error(errorMessage);
120
+ }
121
+ return completedTasks;
122
+ }
123
+ function invokeTasksUsingRunMany(options, executionId, tasks, maxParallel) {
124
+ let completedStatusCode = 0;
125
+ const completedTasks = [];
126
+ for (const g of groupByTarget(tasks)) {
127
+ const config = g.configuration ? `--configuration=${g.configuration}` : ``;
128
+ const parallel = maxParallel > 1 ? ` --parallel --max-parallel=${maxParallel}` : ``;
129
+ // TODO use pnpx or yarn when needed
130
+ const command = `npx nx run-many --target=${g.target} ${config} --projects=${g.projects.join(',')} ${g.params}${parallel}`;
131
+ if (environment_1.VERBOSE_LOGGING) {
132
+ output.note({
133
+ title: `Executing: '${command}'`,
134
+ });
135
+ }
136
+ try {
137
+ (0, child_process_1.execSync)(command, {
138
+ stdio: ['ignore', 'inherit', 'inherit'],
139
+ 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' }),
140
+ });
141
+ completedTasks.push(...readCompletedTasks(options, executionId));
142
+ }
143
+ catch (e) {
144
+ if (e.status === environment_1.DISTRIBUTED_TASK_EXECUTION_INTERNAL_ERROR_STATUS_CODE) {
145
+ throw e;
146
+ }
147
+ else {
148
+ completedStatusCode = 1;
149
+ completedTasks.push(...readCompletedTasks(options, executionId));
150
+ }
151
+ }
152
+ }
153
+ return { completedStatusCode, completedTasks };
154
+ }
155
+ function groupByTarget(tasks) {
156
+ const res = [];
157
+ tasks.forEach((t) => {
158
+ const r = res.find((rr) => rr.target === t.target && rr.configuration === t.configuration);
159
+ if (r) {
160
+ r.projects.push(t.projectName);
161
+ }
162
+ else {
163
+ res.push({
164
+ target: t.target,
165
+ projects: [t.projectName],
166
+ params: t.params,
167
+ configuration: t.configuration,
168
+ });
169
+ }
170
+ });
171
+ return res;
172
+ }
173
+ function getAgentName() {
174
+ if (process.env.NX_AGENT_NAME !== undefined) {
175
+ return process.env.NX_AGENT_NAME;
176
+ }
177
+ else if (process.env.CIRCLECI !== undefined && process.env.CIRCLE_STAGE) {
178
+ return process.env.CIRCLE_STAGE;
179
+ }
180
+ else if (process.env.CIRCLECI !== undefined && process.env.CIRCLE_JOB) {
181
+ return process.env.CIRCLE_JOB;
182
+ }
183
+ else {
184
+ return `Agent ${Math.floor(Math.random() * 100000)}`;
185
+ }
186
+ }
187
+ function createAgentLockfileAndSetUpListeners(api, options, agentName) {
188
+ const cacheDirectory = (0, environment_1.getNxCacheDirectory)(options);
189
+ const lockFileDirectory = `${cacheDirectory}/lockfiles`;
190
+ const lockFilePath = `${lockFileDirectory}/${agentName}.lock`;
191
+ if (!(0, fs_1.existsSync)(lockFileDirectory)) {
192
+ (0, fs_1.mkdirSync)(lockFileDirectory, { recursive: true });
193
+ }
194
+ // Check for other agents' lockfiles and warn if exist
195
+ const lockFiles = (0, fs_1.readdirSync)(lockFileDirectory);
196
+ if (lockFiles.length) {
197
+ // Check to make sure the current agent name is not in use (only 1/100000 ^ 2 chance of this)
198
+ if (lockFiles.includes(`${agentName}.lock`)) {
199
+ output.error({
200
+ title: 'Duplicate Agent ID Detected',
201
+ bodyLines: [
202
+ 'We have detected another agent with this ID running in this workspace. This should not happen.',
203
+ '',
204
+ 'End all currently running agents, run "npx nx-cloud clean-up-agents", and try again.',
205
+ ],
206
+ });
207
+ process.exit(1);
208
+ }
209
+ output.warn({
210
+ title: 'Other Nx Cloud Agents Detected',
211
+ bodyLines: [
212
+ 'We have detected other agents running in this workspace. This can cause unexpected behavior.',
213
+ '',
214
+ 'This can also be a false positive caused by agents that did not shut down correctly.',
215
+ 'If you believe this is the case, run "npx nx-cloud clean-up-agents".',
216
+ ],
217
+ });
218
+ }
219
+ (0, fs_1.writeFileSync)(lockFilePath, '');
220
+ process.on('exit', (code) => {
221
+ cleanupAgentLockfile(lockFilePath, code);
222
+ });
223
+ process.on('SIGTERM', () => __awaiter(this, void 0, void 0, function* () {
224
+ yield api.completeRunGroupWithError('Agent was terminated via SIGTERM');
225
+ cleanupAgentLockfile(lockFilePath, 1);
226
+ }));
227
+ process.on('SIGINT', () => __awaiter(this, void 0, void 0, function* () {
228
+ yield api.completeRunGroupWithError('Agent was terminated via SIGINT');
229
+ cleanupAgentLockfile(lockFilePath, 1);
230
+ }));
231
+ }
232
+ function cleanupAgentLockfile(lockFilePath, code) {
233
+ if ((0, fs_1.existsSync)(lockFilePath)) {
234
+ (0, fs_1.unlinkSync)(lockFilePath);
235
+ process.exit(code);
236
+ }
237
+ }
238
+ function startAgent() {
239
+ return __awaiter(this, void 0, void 0, function* () {
240
+ const runGroup = (0, environment_1.getRunGroup)();
241
+ if (!runGroup) {
242
+ (0, print_run_group_error_1.printRunGroupError)();
243
+ return process.exit(1);
244
+ }
245
+ output.note({
246
+ title: 'Starting an agent for running Nx tasks',
247
+ });
248
+ const defaultRunnerConfig = JSON.parse(stripJsonComments((0, fs_1.readFileSync)(`${workspaceRoot}/nx.json`).toString())).tasksRunnerOptions.default;
249
+ if (defaultRunnerConfig.runner !== '@nrwl/nx-cloud') {
250
+ (0, print_invalid_runner_error_1.printInvalidRunnerError)();
251
+ return process.exit(1);
252
+ }
253
+ const options = defaultRunnerConfig.options;
254
+ const agentName = getAgentName();
255
+ const api = new distributed_agent_api_1.DistributedAgentApi(options, runGroup, agentName);
256
+ createAgentLockfileAndSetUpListeners(api, options, agentName);
257
+ return executeTasks(options, api)
258
+ .then((res) => __awaiter(this, void 0, void 0, function* () {
259
+ yield (0, metric_logger_1.submitRunMetrics)(options);
260
+ return res;
261
+ }))
262
+ .catch((e) => __awaiter(this, void 0, void 0, function* () {
263
+ yield api.completeRunGroupWithError(`Critical Error in Agent: "${e.message}"`);
264
+ throw e;
265
+ }));
266
+ });
267
+ }
268
+ exports.startAgent = startAgent;
269
+ //# sourceMappingURL=distributed-agent.impl.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"distributed-agent.impl.js","sourceRoot":"","sources":["../../../../../../../../libs/nx-packages/nx-cloud/lib/core/runners/distributed-agent/distributed-agent.impl.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,iDAAyC;AACzC,2BAOY;AACZ,yDAAyD;AACzD,sGAAgG;AAChG,gEAMwC;AACxC,oEAAoE;AACpE,sDAAmD;AACnD,6EAAuE;AAOvE,mEAA8D;AAC9D,uFAAiF;AAEjF,MAAM,EAAE,MAAM,EAAE,aAAa,EAAE,GAAG,OAAO,CAAC,+BAA+B,CAAC,CAAC;AAE3E,SAAe,YAAY,CACzB,OAA+B,EAC/B,GAAwB;;QAExB,IAAI,mBAAmB,GAAG,CAAC,CAAC;QAC5B,IAAI,WAAW,GAA4B,IAAI,CAAC;QAChD,MAAM,2BAA2B,GAAG,IAAA,4DAA2B,EAAC;YAC9D,KAAK,EAAE,kCACL,iCAAmB,GAAG,IACxB,UAAU;YACV,OAAO,EAAE,iCAAmB;SAC7B,CAAC,CAAC;QACH,MAAM,MAAM,GAAG,IAAI,eAAM,EAAE,CAAC;QAE5B,IAAI,cAAc,GAAG,EAAwC,CAAC;QAE9D,MAAM,SAAS,GAAG,IAAI,IAAI,EAAE,CAAC;QAC7B,IAAI,gBAAgB,GAAG,KAAK,CAAC;QAE7B,OAAO,IAAI,EAAE;YACX,IAAI,6BAAe,EAAE;gBACnB,MAAM,CAAC,IAAI,CAAC;oBACV,KAAK,EAAE,mBAAmB;iBAC3B,CAAC,CAAC;aACJ;YAED,WAAY,GAAG,MAAM,GAAG,CAAC,KAAK,CAC5B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IAAI,CAAC;YACV,KAAK,EAAE,wCAAwC;SAChD,CAAC,CAAC;QAEH,MAAM,mBAAmB,GAAG,IAAI,CAAC,KAAK,CACpC,iBAAiB,CAAC,IAAA,iBAAY,EAAC,GAAG,aAAa,UAAU,CAAC,CAAC,QAAQ,EAAE,CAAC,CACvE,CAAC,kBAAkB,CAAC,OAAO,CAAC;QAE7B,IAAI,mBAAmB,CAAC,MAAM,KAAK,gBAAgB,EAAE;YACnD,IAAA,oDAAuB,GAAE,CAAC;YAC1B,OAAO,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;SACxB;QAED,MAAM,OAAO,GAAG,mBAAmB,CAAC,OAAO,CAAC;QAE5C,MAAM,SAAS,GAAG,YAAY,EAAE,CAAC;QACjC,MAAM,GAAG,GAAG,IAAI,2CAAmB,CAAC,OAAO,EAAE,QAAQ,EAAE,SAAS,CAAC,CAAC;QAElE,oCAAoC,CAAC,GAAG,EAAE,OAAO,EAAE,SAAS,CAAC,CAAC;QAE9D,OAAO,YAAY,CAAC,OAAO,EAAE,GAAG,CAAC;aAC9B,IAAI,CAAC,CAAO,GAAG,EAAE,EAAE;YAClB,MAAM,IAAA,gCAAgB,EAAC,OAAO,CAAC,CAAC;YAChC,OAAO,GAAG,CAAC;QACb,CAAC,CAAA,CAAC;aACD,KAAK,CAAC,CAAO,CAAC,EAAE,EAAE;YACjB,MAAM,GAAG,CAAC,yBAAyB,CACjC,6BAA6B,CAAC,CAAC,OAAO,GAAG,CAC1C,CAAC;YACF,MAAM,CAAC,CAAC;QACV,CAAC,CAAA,CAAC,CAAC;IACP,CAAC;CAAA;AAtCD,gCAsCC"}
@@ -0,0 +1,10 @@
1
+ import { CloudTaskRunnerOptions } from '../../models/cloud-task-runner-options';
2
+ import { Task } from '../../models/run-context.model';
3
+ export declare class DistributedExecutionApi {
4
+ private apiAxiosInstance;
5
+ constructor(options: CloudTaskRunnerOptions);
6
+ start(params: any): Promise<string>;
7
+ status(id: string): Promise<any>;
8
+ completeRunGroupWithError(runGroup: string, error: string): Promise<void>;
9
+ }
10
+ export declare function createStartRequest(runGroup: string, task: Task[][], options: CloudTaskRunnerOptions): any;
@@ -0,0 +1,143 @@
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(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
@@ -0,0 +1 @@
1
+ {"version":3,"file":"distributed-execution.api.js","sourceRoot":"","sources":["../../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