@nrwl/nx-cloud 15.3.4 → 15.4.0-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/file-storage/file-storage.js +4 -2
- package/lib/core/file-storage/file-storage.js.map +1 -1
- package/lib/core/models/cloud-task-runner-options.d.ts +1 -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-remote-cache.js +133 -1
- package/lib/core/runners/cloud-enabled/cloud-run.api.js +174 -1
- package/lib/core/runners/cloud-enabled/cloud-run.api.js.map +1 -1
- package/lib/core/runners/cloud-enabled/id-generator.js +16 -1
- package/lib/core/runners/distributed-agent/distributed-agent.api.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/utilities/axios.js +8 -2
- package/lib/utilities/axios.js.map +1 -1
- package/lib/utilities/environment.d.ts +1 -1
- package/lib/utilities/environment.js +2 -0
- package/lib/utilities/environment.js.map +1 -1
- package/package.json +1 -1
|
@@ -1 +1,133 @@
|
|
|
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.CloudRemoteCache = void 0;
|
|
13
|
+
const environment_1 = require("../../../utilities/environment");
|
|
14
|
+
const { output } = require('../../../utilities/nx-imports');
|
|
15
|
+
class CloudRemoteCache {
|
|
16
|
+
constructor(messages, api, runContext, fileStorage, distributedExecutionId, storeInCurrentProcess) {
|
|
17
|
+
this.messages = messages;
|
|
18
|
+
this.api = api;
|
|
19
|
+
this.runContext = runContext;
|
|
20
|
+
this.fileStorage = fileStorage;
|
|
21
|
+
this.distributedExecutionId = distributedExecutionId;
|
|
22
|
+
this.storeInCurrentProcess = storeInCurrentProcess;
|
|
23
|
+
this.storeRequests = [];
|
|
24
|
+
this.delayedStoreRequests = [];
|
|
25
|
+
}
|
|
26
|
+
retrieve(hash, cacheDirectory) {
|
|
27
|
+
var _a;
|
|
28
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
29
|
+
if (this.messages.cacheError)
|
|
30
|
+
return false;
|
|
31
|
+
const hashUrls = yield this.hashUrls(hash);
|
|
32
|
+
if (!hashUrls || !hashUrls.get) {
|
|
33
|
+
if (environment_1.VERBOSE_LOGGING) {
|
|
34
|
+
output.note({ title: `Nx Cloud: Cache miss ${hash}.` });
|
|
35
|
+
}
|
|
36
|
+
this.runContext.statuses[hash] = 'cache-miss';
|
|
37
|
+
return false;
|
|
38
|
+
}
|
|
39
|
+
try {
|
|
40
|
+
yield this.fileStorage.retrieve(hash, hashUrls.get, cacheDirectory);
|
|
41
|
+
this.runContext.statuses[hash] = 'remote-cache-hit';
|
|
42
|
+
return true;
|
|
43
|
+
}
|
|
44
|
+
catch (ee) {
|
|
45
|
+
const e = (_a = ee.axiosException) !== null && _a !== void 0 ? _a : ee;
|
|
46
|
+
// TODO: vsavkin remove this handling Oct 2023
|
|
47
|
+
// 404 indicates that something is broken, but older versions
|
|
48
|
+
// of the api can result in such errors
|
|
49
|
+
// we ignore them for now
|
|
50
|
+
if (e.response && e.response.status === 404) {
|
|
51
|
+
if (environment_1.VERBOSE_LOGGING) {
|
|
52
|
+
output.note({ title: `Nx Cloud: Cache miss ${hash}. Status 404.` });
|
|
53
|
+
}
|
|
54
|
+
// cache miss. print nothing
|
|
55
|
+
}
|
|
56
|
+
else {
|
|
57
|
+
this.messages.cacheError = this.messages.extractErrorMessage(e, 'storage');
|
|
58
|
+
}
|
|
59
|
+
this.runContext.statuses[hash] = 'cache-miss';
|
|
60
|
+
return false;
|
|
61
|
+
}
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
store(hash, cacheDirectory) {
|
|
65
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
66
|
+
if (this.messages.cacheError)
|
|
67
|
+
return false;
|
|
68
|
+
const res = Promise.resolve().then(() => __awaiter(this, void 0, void 0, function* () {
|
|
69
|
+
var _a;
|
|
70
|
+
const hashUrls = yield this.hashUrls(hash);
|
|
71
|
+
if (!hashUrls)
|
|
72
|
+
return false;
|
|
73
|
+
if (!hashUrls.put) {
|
|
74
|
+
if (environment_1.VERBOSE_LOGGING) {
|
|
75
|
+
output.note({
|
|
76
|
+
title: `Nx Cloud: Skipping storing ${hash}.`,
|
|
77
|
+
bodyLines: [
|
|
78
|
+
`There are several reasons why this can happen.`,
|
|
79
|
+
`Maybe you are using a read-only token or the artifact has already being uploaded.`,
|
|
80
|
+
],
|
|
81
|
+
});
|
|
82
|
+
}
|
|
83
|
+
return true;
|
|
84
|
+
}
|
|
85
|
+
if (!this.storeInCurrentProcess) {
|
|
86
|
+
this.delayedStoreRequests.push({ hash: hash, url: hashUrls.put });
|
|
87
|
+
return true;
|
|
88
|
+
}
|
|
89
|
+
try {
|
|
90
|
+
yield this.fileStorage.store(hash, hashUrls.put, cacheDirectory);
|
|
91
|
+
return true;
|
|
92
|
+
}
|
|
93
|
+
catch (ee) {
|
|
94
|
+
const e = (_a = ee.axiosException) !== null && _a !== void 0 ? _a : ee;
|
|
95
|
+
this.messages.cacheError = this.messages.extractErrorMessage(e, 'storage');
|
|
96
|
+
return false;
|
|
97
|
+
}
|
|
98
|
+
}));
|
|
99
|
+
this.storeRequests.push(res);
|
|
100
|
+
return res;
|
|
101
|
+
});
|
|
102
|
+
}
|
|
103
|
+
hashUrls(hash) {
|
|
104
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
105
|
+
if (hash in this.runContext.requests) {
|
|
106
|
+
return (yield this.runContext.requests[hash])[hash];
|
|
107
|
+
}
|
|
108
|
+
else {
|
|
109
|
+
const scheduledTaskHashesWithoutRequests = this.runContext.scheduledTasks
|
|
110
|
+
.filter((t) => !this.runContext.requests[t.hash])
|
|
111
|
+
.map((t) => t.hash);
|
|
112
|
+
if (scheduledTaskHashesWithoutRequests.indexOf(hash) === -1) {
|
|
113
|
+
scheduledTaskHashesWithoutRequests.push(hash);
|
|
114
|
+
}
|
|
115
|
+
const request = this.api.startRun(this.distributedExecutionId, scheduledTaskHashesWithoutRequests);
|
|
116
|
+
scheduledTaskHashesWithoutRequests.forEach((taskHash) => {
|
|
117
|
+
this.runContext.requests[taskHash] = request;
|
|
118
|
+
});
|
|
119
|
+
return (yield request)[hash];
|
|
120
|
+
}
|
|
121
|
+
});
|
|
122
|
+
}
|
|
123
|
+
waitForStoreRequestsToComplete() {
|
|
124
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
125
|
+
const res = yield Promise.all(this.storeRequests).then((r) => r.reduce((a, b) => a && b, true));
|
|
126
|
+
if (!res) {
|
|
127
|
+
throw new Error(`Error when storing artifacts`);
|
|
128
|
+
}
|
|
129
|
+
});
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
exports.CloudRemoteCache = CloudRemoteCache;
|
|
133
|
+
//# sourceMappingURL=cloud-remote-cache.js.map
|
|
@@ -1 +1,174 @@
|
|
|
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.CloudRunApi = void 0;
|
|
13
|
+
const axios_1 = require("../../../utilities/axios");
|
|
14
|
+
const environment_1 = require("../../../utilities/environment");
|
|
15
|
+
const fs_1 = require("fs");
|
|
16
|
+
const zlib_1 = require("zlib");
|
|
17
|
+
const util_1 = require("util");
|
|
18
|
+
const metric_logger_1 = require("../../../utilities/metric-logger");
|
|
19
|
+
const is_private_cloud_1 = require("../../../utilities/is-private-cloud");
|
|
20
|
+
const { output } = require('../../../utilities/nx-imports');
|
|
21
|
+
class CloudRunApi {
|
|
22
|
+
constructor(messages, runContext, options, machineInfo) {
|
|
23
|
+
this.messages = messages;
|
|
24
|
+
this.runContext = runContext;
|
|
25
|
+
this.machineInfo = machineInfo;
|
|
26
|
+
this.apiAxiosInstance = (0, axios_1.createApiAxiosInstance)(options);
|
|
27
|
+
}
|
|
28
|
+
startRun(distributedExecutionId, hashes) {
|
|
29
|
+
var _a;
|
|
30
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
31
|
+
// API is not working, don't make the end request
|
|
32
|
+
if (this.messages.apiError)
|
|
33
|
+
return {};
|
|
34
|
+
const recorder = (0, metric_logger_1.createMetricRecorder)('startRun');
|
|
35
|
+
try {
|
|
36
|
+
const request = {
|
|
37
|
+
meta: {
|
|
38
|
+
nxCloudVersion: this.nxCloudVersion(),
|
|
39
|
+
},
|
|
40
|
+
branch: (0, environment_1.getBranch)(),
|
|
41
|
+
runGroup: (0, environment_1.getRunGroup)(),
|
|
42
|
+
ciExecutionId: (0, environment_1.getCIExecutionId)(),
|
|
43
|
+
ciExecutionEnv: (0, environment_1.getCIExecutionEnv)(),
|
|
44
|
+
distributedExecutionId,
|
|
45
|
+
hashes,
|
|
46
|
+
};
|
|
47
|
+
if (environment_1.VERBOSE_LOGGING) {
|
|
48
|
+
output.note({
|
|
49
|
+
title: 'RunStart',
|
|
50
|
+
bodyLines: ['\n' + JSON.stringify(request, null, 2)],
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
const resp = yield (0, axios_1.printDuration)('RunStart duration', () => (0, axios_1.axiosMultipleTries)(() => this.apiAxiosInstance.post('/nx-cloud/runs/start', request)));
|
|
54
|
+
recorder.recordMetric((0, metric_logger_1.mapRespToPerfEntry)(resp));
|
|
55
|
+
if (resp.data && resp.data.message) {
|
|
56
|
+
this.messages.message = resp.data.message;
|
|
57
|
+
}
|
|
58
|
+
if (!resp.data || !resp.data.urls) {
|
|
59
|
+
this.messages.apiError = `Invalid Nx Cloud response: ${JSON.stringify(resp.data)}`;
|
|
60
|
+
return {};
|
|
61
|
+
}
|
|
62
|
+
return resp.data.urls;
|
|
63
|
+
}
|
|
64
|
+
catch (e) {
|
|
65
|
+
recorder.recordMetric(((_a = e === null || e === void 0 ? void 0 : e.axiosException) === null || _a === void 0 ? void 0 : _a.response)
|
|
66
|
+
? (0, metric_logger_1.mapRespToPerfEntry)(e.axiosException.response)
|
|
67
|
+
: metric_logger_1.RUNNER_FAILURE_PERF_ENTRY);
|
|
68
|
+
this.messages.apiError = this.messages.extractErrorMessage(e, 'api');
|
|
69
|
+
return {};
|
|
70
|
+
}
|
|
71
|
+
});
|
|
72
|
+
}
|
|
73
|
+
createReqBody(run, tasks, ciExecutionContext, linkId) {
|
|
74
|
+
if ((0, is_private_cloud_1.isConnectedToPrivateCloud)()) {
|
|
75
|
+
for (let t of tasks) {
|
|
76
|
+
delete t.uploadedToStorage;
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
const uncompressedReqBody = Object.assign(Object.assign({ meta: {
|
|
80
|
+
nxCloudVersion: this.nxCloudVersion(),
|
|
81
|
+
}, tasks,
|
|
82
|
+
run,
|
|
83
|
+
linkId }, ((0, is_private_cloud_1.isConnectedToPrivateCloud)() ? {} : ciExecutionContext)), { machineInfo: this.machineInfo });
|
|
84
|
+
return JSON.stringify(uncompressedReqBody);
|
|
85
|
+
}
|
|
86
|
+
endRun(run, tasks, ciExecutionContext, linkId) {
|
|
87
|
+
var _a, _b;
|
|
88
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
89
|
+
// API is not working, don't make the end request
|
|
90
|
+
if (this.messages.apiError)
|
|
91
|
+
return false;
|
|
92
|
+
let uncompressedBodyString = this.createReqBody(run, tasks, ciExecutionContext, linkId);
|
|
93
|
+
// if the req body is > 20mb, remove hashDetails
|
|
94
|
+
if (uncompressedBodyString.length > 20 * 1000 * 1000) {
|
|
95
|
+
uncompressedBodyString = this.createReqBody(run, tasks.map((t) => (Object.assign(Object.assign({}, t), { hashDetails: undefined }))), ciExecutionContext, linkId);
|
|
96
|
+
}
|
|
97
|
+
const uncompressedBuffer = Buffer.from(uncompressedBodyString);
|
|
98
|
+
const compressedBuffer = yield (0, util_1.promisify)(zlib_1.gzip)(uncompressedBuffer);
|
|
99
|
+
const recorder = (0, metric_logger_1.createMetricRecorder)('endRun');
|
|
100
|
+
try {
|
|
101
|
+
if (environment_1.VERBOSE_LOGGING) {
|
|
102
|
+
const t = tasks.map((tt) => {
|
|
103
|
+
return Object.assign(Object.assign({}, tt), { terminalOutput: tt.terminalOutput
|
|
104
|
+
? `${tt.terminalOutput.slice(0, 20)}...`
|
|
105
|
+
: undefined });
|
|
106
|
+
});
|
|
107
|
+
output.note({
|
|
108
|
+
title: 'RunEnd. Completed tasks',
|
|
109
|
+
bodyLines: ['\n' + JSON.stringify(t, null, 2)],
|
|
110
|
+
});
|
|
111
|
+
}
|
|
112
|
+
const resp = yield (0, axios_1.printDuration)('RunEnd duration', () => (0, axios_1.axiosMultipleTries)(() => this.apiAxiosInstance.post('/nx-cloud/runs/end', compressedBuffer, {
|
|
113
|
+
headers: Object.assign(Object.assign({}, this.apiAxiosInstance.defaults.headers), { 'Content-Encoding': 'gzip', 'Content-Type': 'application/octet-stream' }),
|
|
114
|
+
})));
|
|
115
|
+
if (resp) {
|
|
116
|
+
recorder.recordMetric((0, metric_logger_1.mapRespToPerfEntry)(resp));
|
|
117
|
+
if (resp.data && resp.data.runUrl && resp.data.status === 'success') {
|
|
118
|
+
this.runContext.runUrl = resp.data.runUrl;
|
|
119
|
+
return true;
|
|
120
|
+
}
|
|
121
|
+
if (resp.data && resp.data.status) {
|
|
122
|
+
this.messages.apiError = `Invalid end run response: ${JSON.stringify(resp.data.message)}`;
|
|
123
|
+
}
|
|
124
|
+
else if (resp.data && typeof resp.data === 'string') {
|
|
125
|
+
if (resp.data !== 'success') {
|
|
126
|
+
this.messages.apiError = `Invalid end run response: ${JSON.stringify(resp.data)}`;
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
else {
|
|
130
|
+
this.messages.apiError = `Invalid end run response: ${JSON.stringify(resp.data)}`;
|
|
131
|
+
}
|
|
132
|
+
if (environment_1.VERBOSE_LOGGING) {
|
|
133
|
+
output.note({
|
|
134
|
+
title: 'Invalid end run response',
|
|
135
|
+
bodyLines: [JSON.stringify(resp.data, null, 2)],
|
|
136
|
+
});
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
else {
|
|
140
|
+
output.error({
|
|
141
|
+
title: 'Nx Cloud: Unknown Error Occurred',
|
|
142
|
+
bodyLines: [
|
|
143
|
+
'Run completion responded with `undefined`.',
|
|
144
|
+
'Run Details:',
|
|
145
|
+
JSON.stringify(run, null, 2),
|
|
146
|
+
'Stack Trace:',
|
|
147
|
+
JSON.stringify(new Error().stack, null, 2),
|
|
148
|
+
],
|
|
149
|
+
});
|
|
150
|
+
}
|
|
151
|
+
return false;
|
|
152
|
+
}
|
|
153
|
+
catch (ee) {
|
|
154
|
+
recorder.recordMetric(((_a = ee === null || ee === void 0 ? void 0 : ee.axiosException) === null || _a === void 0 ? void 0 : _a.response)
|
|
155
|
+
? (0, metric_logger_1.mapRespToPerfEntry)(ee.axiosException.response)
|
|
156
|
+
: metric_logger_1.RUNNER_FAILURE_PERF_ENTRY);
|
|
157
|
+
const e = (_b = ee.axiosException) !== null && _b !== void 0 ? _b : ee;
|
|
158
|
+
this.messages.apiError = this.messages.extractErrorMessage(e, 'api');
|
|
159
|
+
return false;
|
|
160
|
+
}
|
|
161
|
+
});
|
|
162
|
+
}
|
|
163
|
+
nxCloudVersion() {
|
|
164
|
+
try {
|
|
165
|
+
const v = JSON.parse((0, fs_1.readFileSync)(`package.json`).toString());
|
|
166
|
+
return v.devDependencies['@nrwl/nx-cloud'];
|
|
167
|
+
}
|
|
168
|
+
catch (e) {
|
|
169
|
+
return 'unknown';
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
exports.CloudRunApi = CloudRunApi;
|
|
174
|
+
//# sourceMappingURL=cloud-run.api.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cloud-run.api.js","sourceRoot":"","sources":["../../../../../../../../libs/nx-packages/nx-cloud/lib/core/runners/cloud-enabled/cloud-run.api.ts"],"names":[],"mappings":";;;;;;;;;;;;AAIA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mBAAmB,iCACvB,IAAI,EAAE;gBACJ,cAAc,EAAE,IAAI,CAAC,cAAc,EAAE;aACtC,EACD,KAAK;YACL,GAAG;YACH,MAAM,IACH,kBAAkB,
|
|
1
|
+
{"version":3,"file":"cloud-run.api.js","sourceRoot":"","sources":["../../../../../../../../libs/nx-packages/nx-cloud/lib/core/runners/cloud-enabled/cloud-run.api.ts"],"names":[],"mappings":";;;;;;;;;;;;AAIA,oDAIkC;AAClC,gEAMwC;AAIxC,2BAAkC;AAClC,+BAA4B;AAC5B,+BAAiC;AACjC,oEAI0C;AAC1C,0EAAgF;AAEhF,MAAM,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,+BAA+B,CAAC,CAAC;AAE5D,MAAa,WAAW;IAGtB,YACmB,QAAyB,EACzB,UAAsB,EACvC,OAA+B,EACd,WAAwB;QAHxB,aAAQ,GAAR,QAAQ,CAAiB;QACzB,eAAU,GAAV,UAAU,CAAY;QAEtB,gBAAW,GAAX,WAAW,CAAa;QAEzC,IAAI,CAAC,gBAAgB,GAAG,IAAA,8BAAsB,EAAC,OAAO,CAAC,CAAC;IAC1D,CAAC;IAEK,QAAQ,CACZ,sBAA0C,EAC1C,MAAgB;;;YAEhB,iDAAiD;YACjD,IAAI,IAAI,CAAC,QAAQ,CAAC,QAAQ;gBAAE,OAAO,EAAE,CAAC;YACtC,MAAM,QAAQ,GAAG,IAAA,oCAAoB,EAAC,UAAU,CAAC,CAAC;YAElD,IAAI;gBACF,MAAM,OAAO,GAAG;oBACd,IAAI,EAAE;wBACJ,cAAc,EAAE,IAAI,CAAC,cAAc,EAAE;qBACtC;oBACD,MAAM,EAAE,IAAA,uBAAS,GAAE;oBACnB,QAAQ,EAAE,IAAA,yBAAW,GAAE;oBACvB,aAAa,EAAE,IAAA,8BAAgB,GAAE;oBACjC,cAAc,EAAE,IAAA,+BAAiB,GAAE;oBACnC,sBAAsB;oBACtB,MAAM;iBACP,CAAC;gBACF,IAAI,6BAAe,EAAE;oBACnB,MAA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EAAO,EAAE;gBAChB,QAAQ,CAAC,YAAY,CACnB,CAAA,MAAA,EAAE,aAAF,EAAE,uBAAF,EAAE,CAAE,cAAc,0CAAE,QAAQ;oBAC1B,CAAC,CAAC,IAAA,kCAAkB,EAAC,EAAE,CAAC,cAAc,CAAC,QAAQ,CAAC;oBAChD,CAAC,CAAC,yCAAyB,CAC9B,CAAC;gBAEF,MAAM,CAAC,GAAG,MAAA,EAAE,CAAC,cAAc,mCAAI,EAAE,CAAC;gBAClC,IAAI,CAAC,QAAQ,CAAC,QAAQ,GAAG,IAAI,CAAC,QAAQ,CAAC,mBAAmB,CAAC,CAAC,EAAE,KAAK,CAAC,CAAC;gBACrE,OAAO,KAAK,CAAC;aACd;;KACF;IAEO,cAAc;QACpB,IAAI;YACF,MAAM,CAAC,GAAG,IAAI,CAAC,KAAK,CAAC,IAAA,iBAAY,EAAC,cAAc,CAAC,CAAC,QAAQ,EAAE,CAAC,CAAC;YAC9D,OAAO,CAAC,CAAC,eAAe,CAAC,gBAAgB,CAAC,CAAC;SAC5C;QAAC,OAAO,CAAC,EAAE;YACV,OAAO,SAAS,CAAC;SAClB;IACH,CAAC;CACF;AAjOD,kCAiOC"}
|
|
@@ -1 +1,16 @@
|
|
|
1
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.generateUniqueLinkId = void 0;
|
|
4
|
+
const upper = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ';
|
|
5
|
+
const digits = '0123456789';
|
|
6
|
+
const lower = upper.toLowerCase();
|
|
7
|
+
const alphanum = upper + lower + digits;
|
|
8
|
+
function generateUniqueLinkId() {
|
|
9
|
+
let res = '';
|
|
10
|
+
for (let i = 0; i < 10; ++i) {
|
|
11
|
+
res += alphanum[Math.floor(Math.random() * alphanum.length)];
|
|
12
|
+
}
|
|
13
|
+
return res;
|
|
14
|
+
}
|
|
15
|
+
exports.generateUniqueLinkId = generateUniqueLinkId;
|
|
16
|
+
//# sourceMappingURL=id-generator.js.map
|
|
@@ -1 +1,93 @@
|
|
|
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.DistributedAgentApi = 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 { output } = require('../../../utilities/nx-imports');
|
|
17
|
+
class DistributedAgentApi {
|
|
18
|
+
constructor(options, branch, runGroup, ciExecutionId, ciExecutionEnv, agentName) {
|
|
19
|
+
this.branch = branch;
|
|
20
|
+
this.runGroup = runGroup;
|
|
21
|
+
this.ciExecutionId = ciExecutionId;
|
|
22
|
+
this.ciExecutionEnv = ciExecutionEnv;
|
|
23
|
+
this.agentName = agentName;
|
|
24
|
+
this.apiAxiosInstance = (0, axios_1.createApiAxiosInstance)(options);
|
|
25
|
+
}
|
|
26
|
+
tasks(executionId, statusCode, completedTasks, targets) {
|
|
27
|
+
var _a;
|
|
28
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
29
|
+
const recorder = (0, metric_logger_1.createMetricRecorder)('dtePollTasks');
|
|
30
|
+
try {
|
|
31
|
+
const res = yield (0, axios_1.axiosMultipleTries)(() => this.apiAxiosInstance.post('/nx-cloud/executions/tasks', {
|
|
32
|
+
runGroup: this.runGroup,
|
|
33
|
+
ciExecutionId: this.ciExecutionId,
|
|
34
|
+
ciExecutionEnv: this.ciExecutionEnv,
|
|
35
|
+
agentName: this.agentName,
|
|
36
|
+
executionId,
|
|
37
|
+
statusCode,
|
|
38
|
+
completedTasks,
|
|
39
|
+
targets,
|
|
40
|
+
}));
|
|
41
|
+
recorder.recordMetric((0, metric_logger_1.mapRespToPerfEntry)(res));
|
|
42
|
+
return res.data;
|
|
43
|
+
}
|
|
44
|
+
catch (e) {
|
|
45
|
+
recorder.recordMetric(((_a = e === null || e === void 0 ? void 0 : e.axiosException) === null || _a === void 0 ? void 0 : _a.response)
|
|
46
|
+
? (0, metric_logger_1.mapRespToPerfEntry)(e.axiosException.response)
|
|
47
|
+
: metric_logger_1.RUNNER_FAILURE_PERF_ENTRY);
|
|
48
|
+
throw e;
|
|
49
|
+
}
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
completeRunGroupWithError(error) {
|
|
53
|
+
var _a;
|
|
54
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
55
|
+
if (environment_1.VERBOSE_LOGGING) {
|
|
56
|
+
output.note({
|
|
57
|
+
title: 'Completing with an error',
|
|
58
|
+
bodyLines: [
|
|
59
|
+
`ciExecutionId: ${this.ciExecutionId}`,
|
|
60
|
+
`ciExecutionEnv: ${this.ciExecutionEnv}`,
|
|
61
|
+
`runGroup: ${this.runGroup}`,
|
|
62
|
+
`error: ${error}`,
|
|
63
|
+
],
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
const recorder = (0, metric_logger_1.createMetricRecorder)('completeRunGroup');
|
|
67
|
+
try {
|
|
68
|
+
const resp = yield (0, axios_1.axiosMultipleTries)(() => this.apiAxiosInstance.post('/nx-cloud/executions/complete-run-group', {
|
|
69
|
+
branch: this.branch,
|
|
70
|
+
runGroup: this.runGroup,
|
|
71
|
+
ciExecutionId: this.ciExecutionId,
|
|
72
|
+
ciExecutionEnv: this.ciExecutionEnv,
|
|
73
|
+
agentName: this.agentName,
|
|
74
|
+
criticalErrorMessage: error,
|
|
75
|
+
}));
|
|
76
|
+
if (environment_1.VERBOSE_LOGGING) {
|
|
77
|
+
output.note({
|
|
78
|
+
title: 'Completed run group with an error',
|
|
79
|
+
});
|
|
80
|
+
}
|
|
81
|
+
recorder.recordMetric((0, metric_logger_1.mapRespToPerfEntry)(resp));
|
|
82
|
+
}
|
|
83
|
+
catch (e) {
|
|
84
|
+
recorder.recordMetric(((_a = e === null || e === void 0 ? void 0 : e.axiosException) === null || _a === void 0 ? void 0 : _a.response)
|
|
85
|
+
? (0, metric_logger_1.mapRespToPerfEntry)(e.axiosException.response)
|
|
86
|
+
: metric_logger_1.RUNNER_FAILURE_PERF_ENTRY);
|
|
87
|
+
console.error(e);
|
|
88
|
+
}
|
|
89
|
+
});
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
exports.DistributedAgentApi = DistributedAgentApi;
|
|
93
|
+
//# sourceMappingURL=distributed-agent.api.js.map
|