@nrwl/nx-cloud 15.3.0 → 15.3.1-beta.1
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.js +73 -1
- package/lib/core/runners/cloud-enabled/cloud-enabled-life-cycle.js +93 -1
- package/lib/core/runners/cloud-enabled/cloud-enabled.runner.js +320 -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.js +168 -1
- package/lib/core/runners/cloud-enabled/id-generator.js +16 -1
- package/lib/core/runners/distributed-agent/distributed-agent.api.js +93 -1
- package/lib/core/runners/distributed-agent/distributed-agent.impl.js +157 -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.js +152 -1
- package/lib/core/runners/distributed-execution/distributed-execution.runner.js +118 -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/daemon/process-run-end.js +1 -1
- package/lib/daemon/process-run-end.js.map +1 -1
- package/package.json +1 -1
|
@@ -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,118 @@
|
|
|
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.nxCloudDistributedTasksRunner = void 0;
|
|
13
|
+
const environment_1 = require("../../../utilities/environment");
|
|
14
|
+
const metric_logger_1 = require("../../../utilities/metric-logger");
|
|
15
|
+
const error_reporter_api_1 = require("../../api/error-reporter.api");
|
|
16
|
+
const print_run_group_error_1 = require("../../error/print-run-group-error");
|
|
17
|
+
const e2e_encryption_1 = require("../../file-storage/e2e-encryption");
|
|
18
|
+
const file_storage_1 = require("../../file-storage/file-storage");
|
|
19
|
+
const distributed_execution_api_1 = require("./distributed-execution.api");
|
|
20
|
+
const split_task_graph_into_stages_1 = require("./split-task-graph-into-stages");
|
|
21
|
+
const task_graph_creator_1 = require("./task-graph-creator");
|
|
22
|
+
const process_tasks_1 = require("./process-tasks");
|
|
23
|
+
const dte_artifact_storage_1 = require("../../../utilities/dte-artifact-storage");
|
|
24
|
+
const { output } = require('../../../utilities/nx-imports');
|
|
25
|
+
class NoopLifeCycle {
|
|
26
|
+
scheduleTask(task) { }
|
|
27
|
+
startTask(task) { }
|
|
28
|
+
endTasks(tasks) { }
|
|
29
|
+
}
|
|
30
|
+
const nxCloudDistributedTasksRunner = (tasks, options, context) => __awaiter(void 0, void 0, void 0, function* () {
|
|
31
|
+
if (options.skipNxCache) {
|
|
32
|
+
output.warn({
|
|
33
|
+
title: `--skip-nx-cache is ignored when using distributed tasks execution (DTE).`,
|
|
34
|
+
bodyLine: [`DTE needs the cache to share files between agents.`],
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
if (environment_1.VERBOSE_LOGGING) {
|
|
38
|
+
output.note({
|
|
39
|
+
title: 'Starting distributed command execution',
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
options.lifeCycle = new NoopLifeCycle();
|
|
43
|
+
const branch = (0, environment_1.getBranch)();
|
|
44
|
+
const runGroup = (0, environment_1.getRunGroup)();
|
|
45
|
+
const ciExecutionId = (0, environment_1.getCIExecutionId)();
|
|
46
|
+
const ciExecutionEnv = (0, environment_1.getCIExecutionEnv)();
|
|
47
|
+
if (!(0, print_run_group_error_1.canDetectRunGroup)(runGroup, ciExecutionId)) {
|
|
48
|
+
(0, print_run_group_error_1.printRunGroupError)();
|
|
49
|
+
process.exit(1);
|
|
50
|
+
}
|
|
51
|
+
const encryption = new e2e_encryption_1.E2EEncryption(environment_1.ENCRYPTION_KEY || options.encryptionKey);
|
|
52
|
+
const errorReporter = new error_reporter_api_1.ErrorReporterApi(options);
|
|
53
|
+
const dteArtifactStorage = new dte_artifact_storage_1.DteArtifactStorage(new file_storage_1.FileStorage(encryption, errorReporter, options, 'dte-main'), (0, environment_1.getNxCacheDirectory)(options));
|
|
54
|
+
const api = new distributed_execution_api_1.DistributedExecutionApi(options);
|
|
55
|
+
attachSignalListenersToCompleteRunGroupOnError(api, branch, runGroup, ciExecutionId, ciExecutionEnv);
|
|
56
|
+
try {
|
|
57
|
+
const taskGraph = getTaskGraph(context, tasks, options);
|
|
58
|
+
const r = yield runDistributedExecution(api, options, dteArtifactStorage, branch, runGroup, ciExecutionId, ciExecutionEnv, taskGraph);
|
|
59
|
+
if (r.commandStatus === 0) {
|
|
60
|
+
output.success({
|
|
61
|
+
title: 'Successfully completed running the command.',
|
|
62
|
+
bodyLines: [`See run details at ${r.runUrl}`],
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
else {
|
|
66
|
+
output.error({
|
|
67
|
+
title: 'Command execution failed.',
|
|
68
|
+
bodyLines: [`See run details at ${r.runUrl}`],
|
|
69
|
+
});
|
|
70
|
+
}
|
|
71
|
+
yield (0, metric_logger_1.submitRunMetrics)(options);
|
|
72
|
+
process.exit(r.commandStatus);
|
|
73
|
+
}
|
|
74
|
+
catch (e) {
|
|
75
|
+
output.error({
|
|
76
|
+
title: 'Unable to complete a run.',
|
|
77
|
+
bodyLines: [e.message],
|
|
78
|
+
});
|
|
79
|
+
if (e.axiosException) {
|
|
80
|
+
console.log(e.axiosException);
|
|
81
|
+
}
|
|
82
|
+
else {
|
|
83
|
+
console.log(e);
|
|
84
|
+
}
|
|
85
|
+
try {
|
|
86
|
+
yield api.completeRunGroupWithError(branch, runGroup, ciExecutionId, ciExecutionEnv, `Main job terminated with an error: "${e.message}"`);
|
|
87
|
+
}
|
|
88
|
+
finally {
|
|
89
|
+
process.exit(1);
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
});
|
|
93
|
+
exports.nxCloudDistributedTasksRunner = nxCloudDistributedTasksRunner;
|
|
94
|
+
function getTaskGraph(context, tasks, options) {
|
|
95
|
+
if (context.taskGraph) {
|
|
96
|
+
return context.taskGraph;
|
|
97
|
+
}
|
|
98
|
+
else {
|
|
99
|
+
return (0, task_graph_creator_1.createTaskGraphCompat)(options, context.projectGraph, tasks);
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
function attachSignalListenersToCompleteRunGroupOnError(api, branch, runGroup, ciExecutionId, ciExecutionEnv) {
|
|
103
|
+
process.on('SIGINT', () => __awaiter(this, void 0, void 0, function* () {
|
|
104
|
+
yield api.completeRunGroupWithError(branch, runGroup, ciExecutionId, ciExecutionEnv, 'Main job was terminated via SIGINT');
|
|
105
|
+
process.exit(1);
|
|
106
|
+
}));
|
|
107
|
+
process.on('SIGTERM', () => __awaiter(this, void 0, void 0, function* () {
|
|
108
|
+
yield api.completeRunGroupWithError(branch, runGroup, ciExecutionId, ciExecutionEnv, 'Main job was terminated via SIGTERM');
|
|
109
|
+
process.exit(1);
|
|
110
|
+
}));
|
|
111
|
+
}
|
|
112
|
+
function runDistributedExecution(api, options, dteArtifactStorage, branch, runGroup, ciExecutionId, ciExecutionEnv, taskGraph) {
|
|
113
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
114
|
+
const id = yield api.start((0, distributed_execution_api_1.createStartRequest)(branch, runGroup, ciExecutionId, ciExecutionEnv, (0, split_task_graph_into_stages_1.splitTasksIntoStages)(taskGraph), options));
|
|
115
|
+
return yield (0, process_tasks_1.processTasks)(api, dteArtifactStorage, id, Object.values(taskGraph.tasks));
|
|
116
|
+
});
|
|
117
|
+
}
|
|
118
|
+
//# sourceMappingURL=distributed-execution.runner.js.map
|
|
@@ -1 +1,45 @@
|
|
|
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.processTask = void 0;
|
|
13
|
+
const environment_1 = require("../../../utilities/environment");
|
|
14
|
+
const serializer_overrides_1 = require("../../../utilities/serializer-overrides");
|
|
15
|
+
const { output } = require('../../../utilities/nx-imports');
|
|
16
|
+
function processTask(dteArtifactStorage, tasks, completedTask) {
|
|
17
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
18
|
+
if (environment_1.VERBOSE_LOGGING) {
|
|
19
|
+
output.note({
|
|
20
|
+
title: `Processing task ${completedTask.taskId}`,
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
const matchingTask = tasks.find((tt) => completedTask.taskId === tt.id);
|
|
24
|
+
if (!matchingTask) {
|
|
25
|
+
throw new Error(`Found unknown task: ${completedTask.taskId}`);
|
|
26
|
+
}
|
|
27
|
+
const terminalOutput = yield dteArtifactStorage.retrieveAndExtract(completedTask.hash, completedTask.url);
|
|
28
|
+
output.logCommand(getCommand(matchingTask));
|
|
29
|
+
process.stdout.write(terminalOutput);
|
|
30
|
+
output.addVerticalSeparator();
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
exports.processTask = processTask;
|
|
34
|
+
function getCommand(task) {
|
|
35
|
+
const config = task.target.configuration
|
|
36
|
+
? `:${task.target.configuration}`
|
|
37
|
+
: '';
|
|
38
|
+
return [
|
|
39
|
+
'nx',
|
|
40
|
+
'run',
|
|
41
|
+
`${task.target.project}:${task.target.target}${config}`,
|
|
42
|
+
(0, serializer_overrides_1.serializeOverrides)(task),
|
|
43
|
+
].join(' ');
|
|
44
|
+
}
|
|
45
|
+
//# sourceMappingURL=process-task.js.map
|
|
@@ -1 +1,67 @@
|
|
|
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.processTasks = 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 process_task_1 = require("./process-task");
|
|
17
|
+
const { output } = require('../../../utilities/nx-imports');
|
|
18
|
+
function processTasks(api, dteArtifactStorage, executionId, tasks) {
|
|
19
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
20
|
+
const processedTasks = {};
|
|
21
|
+
const failIfNumberOfCompletedTasksDoesNotChangeAfterTimeout = (0, create_unchanged_value_timeout_1.createUnchangedValueTimeout)({
|
|
22
|
+
title: `No new completed tasks after ${environment_1.NO_COMPLETED_TASKS_TIMEOUT / 1000} seconds.`,
|
|
23
|
+
timeout: environment_1.NO_COMPLETED_TASKS_TIMEOUT,
|
|
24
|
+
});
|
|
25
|
+
const waiter = new waiter_1.Waiter();
|
|
26
|
+
while (true) {
|
|
27
|
+
if (environment_1.VERBOSE_LOGGING) {
|
|
28
|
+
output.note({
|
|
29
|
+
title: 'Waiting...',
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
yield waiter.wait();
|
|
33
|
+
const r = yield api.status(executionId);
|
|
34
|
+
if (environment_1.VERBOSE_LOGGING) {
|
|
35
|
+
output.note({
|
|
36
|
+
title: `Status update`,
|
|
37
|
+
bodyLines: [
|
|
38
|
+
`executionId: ${executionId}`,
|
|
39
|
+
`executionStatus: ${r.executionStatus}`,
|
|
40
|
+
`number of completed tasks: ${r.completedTasks.length}`,
|
|
41
|
+
`error: ${r.criticalErrorMessage}`,
|
|
42
|
+
],
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
if (r.criticalErrorMessage) {
|
|
46
|
+
output.error({
|
|
47
|
+
title: 'Distributed Execution Terminated',
|
|
48
|
+
bodyLines: ['Error:', r.criticalErrorMessage],
|
|
49
|
+
});
|
|
50
|
+
process.exit(1);
|
|
51
|
+
}
|
|
52
|
+
failIfNumberOfCompletedTasksDoesNotChangeAfterTimeout(r.completedTasks.length);
|
|
53
|
+
for (const t of r.completedTasks) {
|
|
54
|
+
if (processedTasks[t.taskId])
|
|
55
|
+
continue;
|
|
56
|
+
yield (0, process_task_1.processTask)(dteArtifactStorage, tasks, t);
|
|
57
|
+
waiter.reset();
|
|
58
|
+
processedTasks[t.taskId] = true;
|
|
59
|
+
}
|
|
60
|
+
if (r.executionStatus === 'COMPLETED') {
|
|
61
|
+
return { commandStatus: r.commandStatus, runUrl: r.runUrl };
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
exports.processTasks = processTasks;
|
|
67
|
+
//# sourceMappingURL=process-tasks.js.map
|
|
@@ -1 +1,37 @@
|
|
|
1
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.splitTasksIntoStages = void 0;
|
|
4
|
+
function splitTasksIntoStages(taskGraph) {
|
|
5
|
+
const stages = [];
|
|
6
|
+
const notStagedTaskIds = new Set(Object.values(taskGraph.tasks).map((t) => t.id));
|
|
7
|
+
let stageIndex = 0;
|
|
8
|
+
// Loop through tasks and try to stage them. As tasks are staged, they are removed from the loop
|
|
9
|
+
while (notStagedTaskIds.size > 0) {
|
|
10
|
+
const currentStage = (stages[stageIndex] = []);
|
|
11
|
+
for (const taskId of notStagedTaskIds) {
|
|
12
|
+
let ready = true;
|
|
13
|
+
for (const dependency of taskGraph.dependencies[taskId]) {
|
|
14
|
+
if (notStagedTaskIds.has(dependency)) {
|
|
15
|
+
// dependency has not been staged yet, this task is not ready to be staged.
|
|
16
|
+
ready = false;
|
|
17
|
+
break;
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
// Some dependency still has not been staged, skip it for now, it will be processed again
|
|
21
|
+
if (!ready) {
|
|
22
|
+
continue;
|
|
23
|
+
}
|
|
24
|
+
// All the dependencies have been staged, let's stage it.
|
|
25
|
+
const task = taskGraph.tasks[taskId];
|
|
26
|
+
currentStage.push(task);
|
|
27
|
+
}
|
|
28
|
+
// Remove the entire new stage of tasks from the list
|
|
29
|
+
for (const task of currentStage) {
|
|
30
|
+
notStagedTaskIds.delete(task.id);
|
|
31
|
+
}
|
|
32
|
+
stageIndex++;
|
|
33
|
+
}
|
|
34
|
+
return stages;
|
|
35
|
+
}
|
|
36
|
+
exports.splitTasksIntoStages = splitTasksIntoStages;
|
|
37
|
+
//# sourceMappingURL=split-task-graph-into-stages.js.map
|
|
@@ -1 +1,100 @@
|
|
|
1
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.TaskGraphCreator = exports.createTaskGraphCompat = void 0;
|
|
4
|
+
const stripJsonComments = require("strip-json-comments");
|
|
5
|
+
const fs_1 = require("fs");
|
|
6
|
+
const { getDependencyConfigs, workspaceRoot, } = require('../../../utilities/nx-imports');
|
|
7
|
+
function createTaskGraphCompat(options, projectGraph, tasks) {
|
|
8
|
+
const nxjson = JSON.parse(stripJsonComments((0, fs_1.readFileSync)(`${workspaceRoot}/nx.json`).toString()));
|
|
9
|
+
return new TaskGraphCreator(projectGraph, getDefaultDependencyConfigs(nxjson, options)).createTaskGraph(tasks);
|
|
10
|
+
}
|
|
11
|
+
exports.createTaskGraphCompat = createTaskGraphCompat;
|
|
12
|
+
function getDefaultDependencyConfigs(nxJson, runnerOptions) {
|
|
13
|
+
var _a, _b;
|
|
14
|
+
const defaults = (_a = nxJson.targetDependencies) !== null && _a !== void 0 ? _a : {};
|
|
15
|
+
const strictlyOrderedTargets = runnerOptions
|
|
16
|
+
? (_b = runnerOptions.strictlyOrderedTargets) !== null && _b !== void 0 ? _b : ['build']
|
|
17
|
+
: [];
|
|
18
|
+
// Strictly Ordered Targets depend on their dependencies
|
|
19
|
+
for (const target of strictlyOrderedTargets) {
|
|
20
|
+
defaults[target] = defaults[target] || [];
|
|
21
|
+
defaults[target].push({
|
|
22
|
+
target,
|
|
23
|
+
projects: 'dependencies',
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
return defaults;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* This is only used for versions of Nx prior to 14 where the task graph
|
|
30
|
+
* wasn't part of the context so we have to recreate it
|
|
31
|
+
*/
|
|
32
|
+
class TaskGraphCreator {
|
|
33
|
+
constructor(projectGraph, defaultTargetDependencies) {
|
|
34
|
+
this.projectGraph = projectGraph;
|
|
35
|
+
this.defaultTargetDependencies = defaultTargetDependencies;
|
|
36
|
+
}
|
|
37
|
+
createTaskGraph(tasks) {
|
|
38
|
+
const graph = {
|
|
39
|
+
roots: [],
|
|
40
|
+
tasks: {},
|
|
41
|
+
dependencies: {},
|
|
42
|
+
};
|
|
43
|
+
for (const task of tasks) {
|
|
44
|
+
this.addTaskToGraph(task, graph);
|
|
45
|
+
const dependencyConfigs = getDependencyConfigs(task.target, this.defaultTargetDependencies, this.projectGraph);
|
|
46
|
+
if (!dependencyConfigs) {
|
|
47
|
+
continue;
|
|
48
|
+
}
|
|
49
|
+
this.addTaskDependencies(task, dependencyConfigs, tasks, graph);
|
|
50
|
+
}
|
|
51
|
+
graph.roots = Object.keys(graph.dependencies).filter((k) => graph.dependencies[k].length === 0);
|
|
52
|
+
return graph;
|
|
53
|
+
}
|
|
54
|
+
addTaskDependencies(task, dependencyConfigs, tasks, graph) {
|
|
55
|
+
for (const dependencyConfig of dependencyConfigs) {
|
|
56
|
+
if (dependencyConfig.projects === 'self') {
|
|
57
|
+
for (const t of tasks) {
|
|
58
|
+
if (t.target.project === task.target.project &&
|
|
59
|
+
t.target.target === dependencyConfig.target) {
|
|
60
|
+
graph.dependencies[task.id].push(t.id);
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
else if (dependencyConfig.projects === 'dependencies') {
|
|
65
|
+
const seen = new Set();
|
|
66
|
+
this.addDependencies(task.target.project, dependencyConfig.target, tasks, graph, task.id, seen);
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
addDependencies(project, target, tasks, graph, taskId, seen) {
|
|
71
|
+
seen.add(project);
|
|
72
|
+
const dependencies = this.projectGraph.dependencies[project];
|
|
73
|
+
if (dependencies) {
|
|
74
|
+
const projectDependencies = dependencies.map((dependency) => dependency.target);
|
|
75
|
+
for (const projectDependency of projectDependencies) {
|
|
76
|
+
if (seen.has(projectDependency)) {
|
|
77
|
+
continue;
|
|
78
|
+
}
|
|
79
|
+
const dependency = this.findTask({ project: projectDependency, target }, tasks);
|
|
80
|
+
if (dependency) {
|
|
81
|
+
if (graph.dependencies[taskId].indexOf(dependency.id) === -1) {
|
|
82
|
+
graph.dependencies[taskId].push(dependency.id);
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
else {
|
|
86
|
+
this.addDependencies(projectDependency, target, tasks, graph, taskId, seen);
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
findTask({ project, target }, tasks) {
|
|
92
|
+
return tasks.find((t) => t.target.project === project && t.target.target === target);
|
|
93
|
+
}
|
|
94
|
+
addTaskToGraph(task, graph) {
|
|
95
|
+
graph.tasks[task.id] = task;
|
|
96
|
+
graph.dependencies[task.id] = [];
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
exports.TaskGraphCreator = TaskGraphCreator;
|
|
100
|
+
//# sourceMappingURL=task-graph-creator.js.map
|
|
@@ -47,7 +47,7 @@ function processRunEnd(data, logger) {
|
|
|
47
47
|
logger.log('Sending EndRun request');
|
|
48
48
|
// check the return value
|
|
49
49
|
try {
|
|
50
|
-
const res = yield api.endRun(data.runEnd.runData, data.runEnd.taskExecutions, data.runEnd.linkId);
|
|
50
|
+
const res = yield api.endRun(data.runEnd.runData, data.runEnd.taskExecutions, data.ciExecutionContext, data.runEnd.linkId);
|
|
51
51
|
if (!res) {
|
|
52
52
|
throw new Error(reporter.apiError);
|
|
53
53
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"process-run-end.js","sourceRoot":"","sources":["../../../../../../libs/nx-packages/nx-cloud/lib/daemon/process-run-end.ts"],"names":[],"mappings":";;;;;;;;;;;AAAA,oEAAgE;AAChE,+EAA0E;AAC1E,uEAAkE;AAClE,wEAAoE;AACpE,0DAA+E;AAC/E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CAAC,YAAY,EAAE;gBAC3C,MAAM,YAAY,GAAG,IAAI,CAAC,MAAM,CAAC,cAAc,CAAC,IAAI,CAClD,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,KAAK,IAAI,CACvB,CAAC;gBACF,IAAI,CAAC,YAAY,EAAE;oBACjB,MAAM,IAAI,KAAK,CAAC,kBAAkB,IAAI,iBAAiB,CAAC,CAAC;iBAC1D;gBACD,YAAY,CAAC,iBAAiB,GAAG,IAAI,CAAC;aACvC;YAED,MAAM,CAAC,GAAG,CAAC,wBAAwB,CAAC,CAAC;YACrC,yBAAyB;YACzB,IAAI;gBACF,MAAM,GAAG,GAAG,MAAM,GAAG,CAAC,MAAM,CAC1B,IAAI,CAAC,MAAM,CAAC,OAAO,EACnB,IAAI,CAAC,MAAM,CAAC,cAAc,EAC1B,IAAI,CAAC,MAAM,CAAC,MAAM,CACnB,CAAC;gBACF,IAAI,CAAC,GAAG,EAAE;oBACR,MAAM,IAAI,KAAK,CAAC,QAAQ,CAAC,QAAU,CAAC,CAAC;iBACtC;gBACD,MAAM,CAAC,GAAG,CAAC,6BAA6B,CAAC,CAAC;aAC3C;YAAC,OAAO,CAAC,EAAE;gBACV,MAAM,CAAC,GAAG,CAAC,2BAA2B,CAAC,CAAC;gBACxC,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;aAChB;YACD,MAAM,IAAA,gCAAgB,EAAC,IAAI,CAAC,UAAU,CAAC,CAAC;QAC1C,CAAC,CAAA,EAAE,CAAC,CAAC,CAAC;QAEN,OAAO,IAAI,CAAC;IACd,CAAC;CAAA;
|
|
1
|
+
{"version":3,"file":"process-run-end.js","sourceRoot":"","sources":["../../../../../../libs/nx-packages/nx-cloud/lib/daemon/process-run-end.ts"],"names":[],"mappings":";;;;;;;;;;;AAAA,oEAAgE;AAChE,+EAA0E;AAC1E,uEAAkE;AAClE,wEAAoE;AACpE,0DAA+E;AAC/E,+EAA2E;AAC3E,8DAA8D;AAE9D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