@nrwl/nx-cloud 15.3.0-beta.4 → 15.3.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 -73
- package/lib/core/runners/cloud-enabled/cloud-enabled-life-cycle.js +1 -93
- package/lib/core/runners/cloud-enabled/cloud-enabled.runner.js +1 -318
- package/lib/core/runners/cloud-enabled/cloud-remote-cache.js +1 -133
- package/lib/core/runners/cloud-enabled/cloud-run.api.js +1 -168
- package/lib/core/runners/cloud-enabled/id-generator.js +1 -16
- package/lib/core/runners/distributed-agent/distributed-agent.api.js +1 -93
- package/lib/core/runners/distributed-agent/distributed-agent.impl.js +1 -157
- package/lib/core/runners/distributed-agent/execute-tasks.js +1 -114
- package/lib/core/runners/distributed-agent/invoke-tasks-using-nx-imperative-api.js +1 -58
- package/lib/core/runners/distributed-agent/invoke-tasks-using-run-many.js +1 -97
- package/lib/core/runners/distributed-execution/distributed-execution.api.js +1 -152
- package/lib/core/runners/distributed-execution/distributed-execution.runner.js +1 -118
- package/lib/core/runners/distributed-execution/process-task.js +1 -45
- package/lib/core/runners/distributed-execution/process-tasks.js +1 -67
- 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 -100
- package/package.json +1 -1
|
@@ -1,36 +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.ErrorReporterApi = void 0;
|
|
13
|
-
const axios_1 = require("../../utilities/axios");
|
|
14
|
-
const { output } = require('../../utilities/nx-imports');
|
|
15
|
-
class ErrorReporterApi {
|
|
16
|
-
constructor(options) {
|
|
17
|
-
this.apiAxiosInstance = (0, axios_1.createApiAxiosInstance)(options);
|
|
18
|
-
}
|
|
19
|
-
reportError(message) {
|
|
20
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
21
|
-
try {
|
|
22
|
-
yield (0, axios_1.axiosMultipleTries)(() => this.apiAxiosInstance.post('/nx-cloud/report-client-error', {
|
|
23
|
-
message,
|
|
24
|
-
}));
|
|
25
|
-
}
|
|
26
|
-
catch (e) {
|
|
27
|
-
output.warn({
|
|
28
|
-
title: `Unable to record the following error: '${message}'`,
|
|
29
|
-
bodyLines: [e.message],
|
|
30
|
-
});
|
|
31
|
-
}
|
|
32
|
-
});
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
exports.ErrorReporterApi = ErrorReporterApi;
|
|
36
|
-
//# sourceMappingURL=error-reporter.api.js.map
|
|
1
|
+
const a0_0x29a2=['__awaiter','warn','Unable\x20to\x20record\x20the\x20following\x20error:\x20\x27','ErrorReporterApi','../../utilities/axios','reportError','defineProperty','createApiAxiosInstance','throw','next','value','../../utilities/nx-imports','apiAxiosInstance','then','__esModule','post','message','done','axiosMultipleTries'];(function(_0x9b7157,_0x29a225){const _0x5b07c5=function(_0x3e34e3){while(--_0x3e34e3){_0x9b7157['push'](_0x9b7157['shift']());}};_0x5b07c5(++_0x29a225);}(a0_0x29a2,0x8c));const a0_0x5b07=function(_0x9b7157,_0x29a225){_0x9b7157=_0x9b7157-0x0;let _0x5b07c5=a0_0x29a2[_0x9b7157];return _0x5b07c5;};'use strict';var __awaiter=this&&this[a0_0x5b07('0xc')]||function(_0x4d52ae,_0x4540cd,_0x1aa8ff,_0x3d82cd){function _0x1f3017(_0x3c1d70){return _0x3c1d70 instanceof _0x1aa8ff?_0x3c1d70:new _0x1aa8ff(function(_0x169150){_0x169150(_0x3c1d70);});}return new(_0x1aa8ff||(_0x1aa8ff=Promise))(function(_0x488e7b,_0x355beb){function _0x8fd3(_0x53cc97){try{_0x385944(_0x3d82cd[a0_0x5b07('0x2')](_0x53cc97));}catch(_0x92573f){_0x355beb(_0x92573f);}}function _0x23e69a(_0x36f22a){try{_0x385944(_0x3d82cd[a0_0x5b07('0x1')](_0x36f22a));}catch(_0x3cdff9){_0x355beb(_0x3cdff9);}}function _0x385944(_0x476439){_0x476439[a0_0x5b07('0xa')]?_0x488e7b(_0x476439[a0_0x5b07('0x3')]):_0x1f3017(_0x476439[a0_0x5b07('0x3')])[a0_0x5b07('0x6')](_0x8fd3,_0x23e69a);}_0x385944((_0x3d82cd=_0x3d82cd['apply'](_0x4d52ae,_0x4540cd||[]))[a0_0x5b07('0x2')]());});};Object[a0_0x5b07('0x12')](exports,a0_0x5b07('0x7'),{'value':!![]});exports[a0_0x5b07('0xf')]=void 0x0;const axios_1=require(a0_0x5b07('0x10'));const {output}=require(a0_0x5b07('0x4'));class ErrorReporterApi{constructor(_0x4b0c9c){this[a0_0x5b07('0x5')]=(0x0,axios_1[a0_0x5b07('0x0')])(_0x4b0c9c);}[a0_0x5b07('0x11')](_0x575fe8){return __awaiter(this,void 0x0,void 0x0,function*(){try{yield(0x0,axios_1[a0_0x5b07('0xb')])(()=>this[a0_0x5b07('0x5')][a0_0x5b07('0x8')]('/nx-cloud/report-client-error',{'message':_0x575fe8}));}catch(_0x4f214b){output[a0_0x5b07('0xd')]({'title':a0_0x5b07('0xe')+_0x575fe8+'\x27','bodyLines':[_0x4f214b[a0_0x5b07('0x9')]]});}});}}exports[a0_0x5b07('0xf')]=ErrorReporterApi;
|
|
@@ -1,73 +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.RunGroupApi = void 0;
|
|
13
|
-
const axios_1 = require("../../utilities/axios");
|
|
14
|
-
const metric_logger_1 = require("../../utilities/metric-logger");
|
|
15
|
-
const { output } = require('../../utilities/nx-imports');
|
|
16
|
-
class RunGroupApi {
|
|
17
|
-
constructor(options) {
|
|
18
|
-
this.apiAxiosInstance = (0, axios_1.createApiAxiosInstance)(options);
|
|
19
|
-
}
|
|
20
|
-
createRunGroup(branch, runGroup, ciExecutionId, ciExecutionEnv, stopAgentsOnFailure, agentCount, stopAgentsAfter) {
|
|
21
|
-
var _a;
|
|
22
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
23
|
-
const recorder = (0, metric_logger_1.createMetricRecorder)('createRunGroup');
|
|
24
|
-
try {
|
|
25
|
-
const resp = yield (0, axios_1.axiosMultipleTries)(() => this.apiAxiosInstance.post('/nx-cloud/executions/create-run-group', {
|
|
26
|
-
branch,
|
|
27
|
-
runGroup,
|
|
28
|
-
ciExecutionId,
|
|
29
|
-
ciExecutionEnv,
|
|
30
|
-
stopAgentsOnFailure,
|
|
31
|
-
agentCount,
|
|
32
|
-
stopAgentsAfter,
|
|
33
|
-
}));
|
|
34
|
-
recorder.recordMetric((0, metric_logger_1.mapRespToPerfEntry)(resp));
|
|
35
|
-
}
|
|
36
|
-
catch (e) {
|
|
37
|
-
recorder.recordMetric(((_a = e === null || e === void 0 ? void 0 : e.axiosException) === null || _a === void 0 ? void 0 : _a.response)
|
|
38
|
-
? (0, metric_logger_1.mapRespToPerfEntry)(e.axiosException.response)
|
|
39
|
-
: metric_logger_1.RUNNER_FAILURE_PERF_ENTRY);
|
|
40
|
-
output.error({
|
|
41
|
-
title: e.message,
|
|
42
|
-
});
|
|
43
|
-
process.exit(1);
|
|
44
|
-
}
|
|
45
|
-
});
|
|
46
|
-
}
|
|
47
|
-
completeRunGroup(branch, runGroup, ciExecutionId, ciExecutionEnv) {
|
|
48
|
-
var _a;
|
|
49
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
50
|
-
const recorder = (0, metric_logger_1.createMetricRecorder)('createRunGroup');
|
|
51
|
-
try {
|
|
52
|
-
const resp = yield (0, axios_1.axiosMultipleTries)(() => this.apiAxiosInstance.post('/nx-cloud/executions/complete-run-group', {
|
|
53
|
-
branch,
|
|
54
|
-
runGroup,
|
|
55
|
-
ciExecutionId,
|
|
56
|
-
ciExecutionEnv,
|
|
57
|
-
}));
|
|
58
|
-
recorder.recordMetric((0, metric_logger_1.mapRespToPerfEntry)(resp));
|
|
59
|
-
}
|
|
60
|
-
catch (e) {
|
|
61
|
-
recorder.recordMetric(((_a = e === null || e === void 0 ? void 0 : e.axiosException) === null || _a === void 0 ? void 0 : _a.response)
|
|
62
|
-
? (0, metric_logger_1.mapRespToPerfEntry)(e.axiosException.response)
|
|
63
|
-
: metric_logger_1.RUNNER_FAILURE_PERF_ENTRY);
|
|
64
|
-
output.error({
|
|
65
|
-
title: e.message,
|
|
66
|
-
});
|
|
67
|
-
process.exit(1);
|
|
68
|
-
}
|
|
69
|
-
});
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
exports.RunGroupApi = RunGroupApi;
|
|
73
|
-
//# sourceMappingURL=run-group.api.js.map
|
|
1
|
+
const a1_0x5e47=['axiosMultipleTries','/nx-cloud/executions/complete-run-group','RunGroupApi','next','completeRunGroup','createMetricRecorder','axiosException','defineProperty','post','apply','createRunGroup','../../utilities/metric-logger','response','mapRespToPerfEntry','exit','throw','createApiAxiosInstance','/nx-cloud/executions/create-run-group','apiAxiosInstance','error','value','../../utilities/axios','recordMetric','__esModule','RUNNER_FAILURE_PERF_ENTRY'];(function(_0x1b17ea,_0x5e4799){const _0x3f7d26=function(_0x47c08e){while(--_0x47c08e){_0x1b17ea['push'](_0x1b17ea['shift']());}};_0x3f7d26(++_0x5e4799);}(a1_0x5e47,0xd5));const a1_0x3f7d=function(_0x1b17ea,_0x5e4799){_0x1b17ea=_0x1b17ea-0x0;let _0x3f7d26=a1_0x5e47[_0x1b17ea];return _0x3f7d26;};'use strict';var __awaiter=this&&this['__awaiter']||function(_0xd60aa9,_0x41297c,_0x3fb2dd,_0x5cda2c){function _0x3426b4(_0x7d0a53){return _0x7d0a53 instanceof _0x3fb2dd?_0x7d0a53:new _0x3fb2dd(function(_0x3301ac){_0x3301ac(_0x7d0a53);});}return new(_0x3fb2dd||(_0x3fb2dd=Promise))(function(_0x3e91b6,_0x48dec0){function _0x20eebd(_0x9ba2){try{_0x3cbd93(_0x5cda2c[a1_0x3f7d('0xf')](_0x9ba2));}catch(_0x5608ab){_0x48dec0(_0x5608ab);}}function _0x1e730d(_0x2e4368){try{_0x3cbd93(_0x5cda2c[a1_0x3f7d('0x2')](_0x2e4368));}catch(_0xbe3644){_0x48dec0(_0xbe3644);}}function _0x3cbd93(_0x35fa43){_0x35fa43['done']?_0x3e91b6(_0x35fa43['value']):_0x3426b4(_0x35fa43[a1_0x3f7d('0x7')])['then'](_0x20eebd,_0x1e730d);}_0x3cbd93((_0x5cda2c=_0x5cda2c[a1_0x3f7d('0x15')](_0xd60aa9,_0x41297c||[]))[a1_0x3f7d('0xf')]());});};Object[a1_0x3f7d('0x13')](exports,a1_0x3f7d('0xa'),{'value':!![]});exports[a1_0x3f7d('0xe')]=void 0x0;const axios_1=require(a1_0x3f7d('0x8'));const metric_logger_1=require(a1_0x3f7d('0x17'));const {output}=require('../../utilities/nx-imports');class RunGroupApi{constructor(_0x5e0469){this['apiAxiosInstance']=(0x0,axios_1[a1_0x3f7d('0x3')])(_0x5e0469);}[a1_0x3f7d('0x16')](_0x4f4118,_0x4c71f6,_0x5c6f23,_0x5d28b2,_0x437866,_0xec796b,_0x1e8bd7){var _0x30e4ba;return __awaiter(this,void 0x0,void 0x0,function*(){const _0x18909f=(0x0,metric_logger_1[a1_0x3f7d('0x11')])('createRunGroup');try{const _0x1f5c43=yield(0x0,axios_1[a1_0x3f7d('0xc')])(()=>this[a1_0x3f7d('0x5')][a1_0x3f7d('0x14')](a1_0x3f7d('0x4'),{'branch':_0x4f4118,'runGroup':_0x4c71f6,'ciExecutionId':_0x5c6f23,'ciExecutionEnv':_0x5d28b2,'stopAgentsOnFailure':_0x437866,'agentCount':_0xec796b,'stopAgentsAfter':_0x1e8bd7}));_0x18909f[a1_0x3f7d('0x9')]((0x0,metric_logger_1['mapRespToPerfEntry'])(_0x1f5c43));}catch(_0x24ac9c){_0x18909f[a1_0x3f7d('0x9')](((_0x30e4ba=_0x24ac9c===null||_0x24ac9c===void 0x0?void 0x0:_0x24ac9c[a1_0x3f7d('0x12')])===null||_0x30e4ba===void 0x0?void 0x0:_0x30e4ba[a1_0x3f7d('0x18')])?(0x0,metric_logger_1['mapRespToPerfEntry'])(_0x24ac9c[a1_0x3f7d('0x12')][a1_0x3f7d('0x18')]):metric_logger_1[a1_0x3f7d('0xb')]);output[a1_0x3f7d('0x6')]({'title':_0x24ac9c['message']});process[a1_0x3f7d('0x1')](0x1);}});}[a1_0x3f7d('0x10')](_0x535f7e,_0xc6d2ae,_0x45e573,_0x2fd04d){var _0x1d9183;return __awaiter(this,void 0x0,void 0x0,function*(){const _0x7b7ed8=(0x0,metric_logger_1[a1_0x3f7d('0x11')])(a1_0x3f7d('0x16'));try{const _0x2a0154=yield(0x0,axios_1[a1_0x3f7d('0xc')])(()=>this[a1_0x3f7d('0x5')][a1_0x3f7d('0x14')](a1_0x3f7d('0xd'),{'branch':_0x535f7e,'runGroup':_0xc6d2ae,'ciExecutionId':_0x45e573,'ciExecutionEnv':_0x2fd04d}));_0x7b7ed8[a1_0x3f7d('0x9')]((0x0,metric_logger_1['mapRespToPerfEntry'])(_0x2a0154));}catch(_0x45a547){_0x7b7ed8[a1_0x3f7d('0x9')](((_0x1d9183=_0x45a547===null||_0x45a547===void 0x0?void 0x0:_0x45a547[a1_0x3f7d('0x12')])===null||_0x1d9183===void 0x0?void 0x0:_0x1d9183[a1_0x3f7d('0x18')])?(0x0,metric_logger_1[a1_0x3f7d('0x0')])(_0x45a547['axiosException']['response']):metric_logger_1['RUNNER_FAILURE_PERF_ENTRY']);output[a1_0x3f7d('0x6')]({'title':_0x45a547['message']});process[a1_0x3f7d('0x1')](0x1);}});}}exports[a1_0x3f7d('0xe')]=RunGroupApi;
|
|
@@ -1,93 +1 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.CloudEnabledLifeCycle = void 0;
|
|
4
|
-
const serializer_overrides_1 = require("../../../utilities/serializer-overrides");
|
|
5
|
-
const read_task_terminal_output_1 = require("../../terminal-output/read-task-terminal-output");
|
|
6
|
-
class CloudEnabledLifeCycle {
|
|
7
|
-
constructor(runContext, cacheDirectory, collectTerminalOutput, cacheableOperations, outputObfuscator, tasks) {
|
|
8
|
-
this.runContext = runContext;
|
|
9
|
-
this.cacheDirectory = cacheDirectory;
|
|
10
|
-
this.collectTerminalOutput = collectTerminalOutput;
|
|
11
|
-
this.cacheableOperations = cacheableOperations;
|
|
12
|
-
this.outputObfuscator = outputObfuscator;
|
|
13
|
-
this.tasks = tasks;
|
|
14
|
-
}
|
|
15
|
-
scheduleTask(task) {
|
|
16
|
-
this.runContext.scheduledTasks.push(task);
|
|
17
|
-
}
|
|
18
|
-
// this gets called for every tasks that starts.
|
|
19
|
-
startTask(task) {
|
|
20
|
-
this.tasks.push({
|
|
21
|
-
taskId: task.id,
|
|
22
|
-
startTime: new Date().toISOString(),
|
|
23
|
-
target: task.target.target,
|
|
24
|
-
projectName: task.target.project,
|
|
25
|
-
hash: task.hash,
|
|
26
|
-
hashDetails: this.cleanUpHashDetails(task.hashDetails),
|
|
27
|
-
params: (0, serializer_overrides_1.serializeOverrides)(task),
|
|
28
|
-
uploadedToStorage: false,
|
|
29
|
-
});
|
|
30
|
-
}
|
|
31
|
-
endTasks(tasks) {
|
|
32
|
-
// this can be called multiple times changing this time.
|
|
33
|
-
for (let t of tasks) {
|
|
34
|
-
let cacheStatus;
|
|
35
|
-
const taskIsRemoteCacheHit = t.status === 'remote-cache';
|
|
36
|
-
const taskIsLocalCacheHitPreNx135 = t.status === 'cache';
|
|
37
|
-
const taskIsLocalCacheHit = t.status === 'local-cache' ||
|
|
38
|
-
t.status === 'local-cache-kept-existing' ||
|
|
39
|
-
taskIsLocalCacheHitPreNx135;
|
|
40
|
-
if (this.runContext.statuses[t.task.hash]) {
|
|
41
|
-
cacheStatus = this.runContext.statuses[t.task.hash];
|
|
42
|
-
}
|
|
43
|
-
else if (taskIsRemoteCacheHit) {
|
|
44
|
-
cacheStatus = 'remote-cache-hit';
|
|
45
|
-
}
|
|
46
|
-
else if (taskIsLocalCacheHit) {
|
|
47
|
-
cacheStatus = 'local-cache-hit';
|
|
48
|
-
}
|
|
49
|
-
else {
|
|
50
|
-
cacheStatus = 'cache-miss';
|
|
51
|
-
}
|
|
52
|
-
this.updateStartedTask(t, cacheStatus);
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
endCommand() { }
|
|
56
|
-
updateStartedTask(result, cacheStatus) {
|
|
57
|
-
const startedTask = this.tasks.find((t) => t.taskId === result.task.id);
|
|
58
|
-
if (!startedTask) {
|
|
59
|
-
throw new Error(`Cannot find task ${result.task.id}`);
|
|
60
|
-
}
|
|
61
|
-
if ((result === null || result === void 0 ? void 0 : result.startTime) && (result === null || result === void 0 ? void 0 : result.endTime)) {
|
|
62
|
-
startedTask.startTime = new Date(result.startTime).toISOString();
|
|
63
|
-
startedTask.endTime = new Date(result.endTime).toISOString();
|
|
64
|
-
}
|
|
65
|
-
else {
|
|
66
|
-
startedTask.endTime = new Date().toISOString();
|
|
67
|
-
}
|
|
68
|
-
startedTask.status = result.code;
|
|
69
|
-
startedTask.params = this.outputObfuscator.obfuscate(startedTask.params);
|
|
70
|
-
startedTask.cacheStatus = cacheStatus;
|
|
71
|
-
if (this.collectTerminalOutput) {
|
|
72
|
-
startedTask.terminalOutput = this.getTerminalOutput(result.task.hash, startedTask.cacheStatus, result.code);
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
getTerminalOutput(hash, cacheStatus, code) {
|
|
76
|
-
return (0, read_task_terminal_output_1.readTaskTerminalOutput)(this.cacheDirectory, this.outputObfuscator, hash, cacheStatus, code);
|
|
77
|
-
}
|
|
78
|
-
cleanUpHashDetails(hashDetails) {
|
|
79
|
-
const nodes = {};
|
|
80
|
-
Object.keys(hashDetails.nodes)
|
|
81
|
-
.filter((k) => !k.startsWith('npm:'))
|
|
82
|
-
.forEach((k) => {
|
|
83
|
-
nodes[k] = hashDetails.nodes[k];
|
|
84
|
-
});
|
|
85
|
-
return {
|
|
86
|
-
nodes,
|
|
87
|
-
runtime: hashDetails.runtime,
|
|
88
|
-
implicitDeps: hashDetails.implicitDeps,
|
|
89
|
-
};
|
|
90
|
-
}
|
|
91
|
-
}
|
|
92
|
-
exports.CloudEnabledLifeCycle = CloudEnabledLifeCycle;
|
|
93
|
-
//# sourceMappingURL=cloud-enabled-life-cycle.js.map
|
|
1
|
+
const a0_0x771c=['statuses','implicitDeps','tasks','code','cache-miss','cleanUpHashDetails','taskId','remote-cache','scheduleTask','params','status','readTaskTerminalOutput','forEach','serializeOverrides','toISOString','CloudEnabledLifeCycle','npm:','startsWith','task','../../../utilities/serializer-overrides','runContext','terminalOutput','project','hashDetails','filter','cacheStatus','cacheableOperations','remote-cache-hit','endTasks','push','startTask','updateStartedTask','collectTerminalOutput','cacheDirectory','obfuscate','runtime','local-cache-kept-existing','getTerminalOutput','target','nodes','hash','startTime','Cannot\x20find\x20task\x20','local-cache-hit','outputObfuscator','endCommand','endTime'];(function(_0x9b6b19,_0x771c9){const _0x32bba6=function(_0x516a1e){while(--_0x516a1e){_0x9b6b19['push'](_0x9b6b19['shift']());}};_0x32bba6(++_0x771c9);}(a0_0x771c,0x8c));const a0_0x32bb=function(_0x9b6b19,_0x771c9){_0x9b6b19=_0x9b6b19-0x0;let _0x32bba6=a0_0x771c[_0x9b6b19];return _0x32bba6;};'use strict';Object['defineProperty'](exports,'__esModule',{'value':!![]});exports[a0_0x32bb('0x10')]=void 0x0;const serializer_overrides_1=require(a0_0x32bb('0x14'));const read_task_terminal_output_1=require('../../terminal-output/read-task-terminal-output');class CloudEnabledLifeCycle{constructor(_0x2583d,_0x2e6d71,_0xc2bf7c,_0x425ecd,_0x1c654a,_0x5a0eda){this[a0_0x32bb('0x15')]=_0x2583d;this[a0_0x32bb('0x22')]=_0x2e6d71;this[a0_0x32bb('0x21')]=_0xc2bf7c;this[a0_0x32bb('0x1b')]=_0x425ecd;this[a0_0x32bb('0x2d')]=_0x1c654a;this['tasks']=_0x5a0eda;}[a0_0x32bb('0x9')](_0x4d16c2){this[a0_0x32bb('0x15')]['scheduledTasks'][a0_0x32bb('0x1e')](_0x4d16c2);}[a0_0x32bb('0x1f')](_0x534ddd){this['tasks'][a0_0x32bb('0x1e')]({'taskId':_0x534ddd['id'],'startTime':new Date()[a0_0x32bb('0xf')](),'target':_0x534ddd[a0_0x32bb('0x27')][a0_0x32bb('0x27')],'projectName':_0x534ddd['target'][a0_0x32bb('0x17')],'hash':_0x534ddd[a0_0x32bb('0x29')],'hashDetails':this[a0_0x32bb('0x6')](_0x534ddd[a0_0x32bb('0x18')]),'params':(0x0,serializer_overrides_1[a0_0x32bb('0xe')])(_0x534ddd),'uploadedToStorage':![]});}[a0_0x32bb('0x1d')](_0x4ef9dd){for(let _0xb1ddc of _0x4ef9dd){let _0x4d0864;const _0x41a6c6=_0xb1ddc[a0_0x32bb('0xb')]===a0_0x32bb('0x8');const _0x27cd32=_0xb1ddc[a0_0x32bb('0xb')]==='cache';const _0xa67ec5=_0xb1ddc[a0_0x32bb('0xb')]==='local-cache'||_0xb1ddc[a0_0x32bb('0xb')]===a0_0x32bb('0x25')||_0x27cd32;if(this[a0_0x32bb('0x15')][a0_0x32bb('0x1')][_0xb1ddc['task'][a0_0x32bb('0x29')]]){_0x4d0864=this[a0_0x32bb('0x15')][a0_0x32bb('0x1')][_0xb1ddc[a0_0x32bb('0x13')]['hash']];}else if(_0x41a6c6){_0x4d0864=a0_0x32bb('0x1c');}else if(_0xa67ec5){_0x4d0864=a0_0x32bb('0x2c');}else{_0x4d0864=a0_0x32bb('0x5');}this[a0_0x32bb('0x20')](_0xb1ddc,_0x4d0864);}}[a0_0x32bb('0x2e')](){}['updateStartedTask'](_0x1df291,_0x33f6bb){const _0x452869=this[a0_0x32bb('0x3')]['find'](_0x4b18fd=>_0x4b18fd[a0_0x32bb('0x7')]===_0x1df291[a0_0x32bb('0x13')]['id']);if(!_0x452869){throw new Error(a0_0x32bb('0x2b')+_0x1df291[a0_0x32bb('0x13')]['id']);}if((_0x1df291===null||_0x1df291===void 0x0?void 0x0:_0x1df291[a0_0x32bb('0x2a')])&&(_0x1df291===null||_0x1df291===void 0x0?void 0x0:_0x1df291[a0_0x32bb('0x0')])){_0x452869['startTime']=new Date(_0x1df291[a0_0x32bb('0x2a')])['toISOString']();_0x452869[a0_0x32bb('0x0')]=new Date(_0x1df291[a0_0x32bb('0x0')])[a0_0x32bb('0xf')]();}else{_0x452869[a0_0x32bb('0x0')]=new Date()['toISOString']();}_0x452869[a0_0x32bb('0xb')]=_0x1df291[a0_0x32bb('0x4')];_0x452869['params']=this['outputObfuscator'][a0_0x32bb('0x23')](_0x452869[a0_0x32bb('0xa')]);_0x452869[a0_0x32bb('0x1a')]=_0x33f6bb;if(this[a0_0x32bb('0x21')]){_0x452869[a0_0x32bb('0x16')]=this[a0_0x32bb('0x26')](_0x1df291['task']['hash'],_0x452869[a0_0x32bb('0x1a')],_0x1df291[a0_0x32bb('0x4')]);}}[a0_0x32bb('0x26')](_0x27a429,_0x2fd105,_0x1c670d){return(0x0,read_task_terminal_output_1[a0_0x32bb('0xc')])(this['cacheDirectory'],this[a0_0x32bb('0x2d')],_0x27a429,_0x2fd105,_0x1c670d);}[a0_0x32bb('0x6')](_0x39257d){const _0x4b4a3e={};Object['keys'](_0x39257d[a0_0x32bb('0x28')])[a0_0x32bb('0x19')](_0x33efff=>!_0x33efff[a0_0x32bb('0x12')](a0_0x32bb('0x11')))[a0_0x32bb('0xd')](_0xfb3dd6=>{_0x4b4a3e[_0xfb3dd6]=_0x39257d[a0_0x32bb('0x28')][_0xfb3dd6];});return{'nodes':_0x4b4a3e,'runtime':_0x39257d[a0_0x32bb('0x24')],'implicitDeps':_0x39257d[a0_0x32bb('0x2')]};}}exports[a0_0x32bb('0x10')]=CloudEnabledLifeCycle;
|
|
@@ -1,318 +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.cloudEnabledTasksRunner = void 0;
|
|
13
|
-
const message_reporter_1 = require("../../terminal-output/message-reporter");
|
|
14
|
-
const end_of_run_message_1 = require("../../terminal-output/end-of-run-message");
|
|
15
|
-
const output_obfuscator_1 = require("../../terminal-output/output-obfuscator");
|
|
16
|
-
const cloud_enabled_life_cycle_1 = require("./cloud-enabled-life-cycle");
|
|
17
|
-
const file_storage_1 = require("../../file-storage/file-storage");
|
|
18
|
-
const e2e_encryption_1 = require("../../file-storage/e2e-encryption");
|
|
19
|
-
const environment_1 = require("../../../utilities/environment");
|
|
20
|
-
const cloud_remote_cache_1 = require("./cloud-remote-cache");
|
|
21
|
-
const cloud_run_api_1 = require("./cloud-run.api");
|
|
22
|
-
const fs_1 = require("fs");
|
|
23
|
-
const path = require("path");
|
|
24
|
-
const path_1 = require("path");
|
|
25
|
-
const metric_logger_1 = require("../../../utilities/metric-logger");
|
|
26
|
-
const error_reporter_api_1 = require("../../api/error-reporter.api");
|
|
27
|
-
const fs_extra_1 = require("fs-extra");
|
|
28
|
-
const id_generator_1 = require("./id-generator");
|
|
29
|
-
const { tasksRunner, output } = require('../../../utilities/nx-imports');
|
|
30
|
-
function createApi(errors, options, runContext) {
|
|
31
|
-
const machineInfo = (0, environment_1.getMachineInfo)(options);
|
|
32
|
-
return new cloud_run_api_1.CloudRunApi(errors, runContext, options, machineInfo);
|
|
33
|
-
}
|
|
34
|
-
function storeTaskHashes(taskExecutions, directory, distributedExecutionId) {
|
|
35
|
-
const hashes = JSON.stringify(taskExecutions.map((t) => ({
|
|
36
|
-
taskId: t.taskId,
|
|
37
|
-
hash: t.hash,
|
|
38
|
-
})));
|
|
39
|
-
if (environment_1.VERBOSE_LOGGING) {
|
|
40
|
-
output.note({
|
|
41
|
-
title: `Executed tasks with hashes: ${hashes}`,
|
|
42
|
-
});
|
|
43
|
-
}
|
|
44
|
-
(0, fs_1.writeFileSync)(path.join(directory, `tasks-hashes-${distributedExecutionId}`), hashes);
|
|
45
|
-
}
|
|
46
|
-
/*
|
|
47
|
-
* It can happen that a task is executed multiple times on an agent, say for DTE1 and DTE2.
|
|
48
|
-
* When it runs for DTE2, it will be a local cache hit, so it will be marked as completed.
|
|
49
|
-
* However, Nx won't upload an artifact to S3 in this case. Usually this isn't a problem,
|
|
50
|
-
* cause the first DTE would have uploaded it. But if you are using a DTE, with a read-only token,
|
|
51
|
-
* the uploaded artifact will have a different scoped hash.
|
|
52
|
-
*
|
|
53
|
-
* To address this: we are finding all local cache hits, and upload everything that has a put url.
|
|
54
|
-
*/
|
|
55
|
-
function storeLocalCacheHits(taskExecutions, remoteCache, nxCacheDirectory) {
|
|
56
|
-
const hashes = taskExecutions
|
|
57
|
-
.filter((t) => t.cacheStatus === 'local-cache-hit')
|
|
58
|
-
.map((t) => t.hash);
|
|
59
|
-
hashes.forEach((hash) => remoteCache.store(hash, nxCacheDirectory));
|
|
60
|
-
}
|
|
61
|
-
function onComplete({ daemon, options, fileStorage, remoteCache, api, outputObfuscator, runStartTime, messages, endOfRunMessage, taskExecutions, versionOfNxBefore133, inner, encryptionKey, storeInCurrentProcess, distributedExecutionId, runContext, }) {
|
|
62
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
63
|
-
const runEndTime = new Date().toISOString();
|
|
64
|
-
const branch = (0, environment_1.getBranch)();
|
|
65
|
-
const runData = {
|
|
66
|
-
command: outputObfuscator.obfuscate((0, environment_1.parseCommand)()),
|
|
67
|
-
startTime: runStartTime,
|
|
68
|
-
endTime: runEndTime,
|
|
69
|
-
distributedExecutionId,
|
|
70
|
-
branch: branch,
|
|
71
|
-
runGroup: (0, environment_1.getRunGroup)(),
|
|
72
|
-
// only set sha if branch is set because we invoke a separate process,
|
|
73
|
-
// which adds a few millis
|
|
74
|
-
sha: branch ? (0, environment_1.extractGitSha)() : undefined,
|
|
75
|
-
inner: inner,
|
|
76
|
-
};
|
|
77
|
-
if (storeInCurrentProcess) {
|
|
78
|
-
if ((0, environment_1.agentRunningInDistributedExecution)(distributedExecutionId)) {
|
|
79
|
-
const nxCacheDirectory = (0, environment_1.getNxCacheDirectory)(options);
|
|
80
|
-
storeTaskHashes(taskExecutions, nxCacheDirectory, distributedExecutionId);
|
|
81
|
-
storeLocalCacheHits(taskExecutions, remoteCache, nxCacheDirectory);
|
|
82
|
-
}
|
|
83
|
-
try {
|
|
84
|
-
yield remoteCache.waitForStoreRequestsToComplete();
|
|
85
|
-
}
|
|
86
|
-
catch (e) {
|
|
87
|
-
output.error({
|
|
88
|
-
title: `Nx Cloud wasn't able to store artifacts.`,
|
|
89
|
-
});
|
|
90
|
-
messages.printMessages();
|
|
91
|
-
return false;
|
|
92
|
-
}
|
|
93
|
-
for (const hash of fileStorage.storedHashes) {
|
|
94
|
-
const matchingTask = taskExecutions.find((t) => t.hash === hash);
|
|
95
|
-
if (!matchingTask) {
|
|
96
|
-
throw new Error(`Task with hash ${hash} isn't recorded`);
|
|
97
|
-
}
|
|
98
|
-
matchingTask.uploadedToStorage = true;
|
|
99
|
-
}
|
|
100
|
-
try {
|
|
101
|
-
yield api.endRun(runData, taskExecutions, {
|
|
102
|
-
branch: branch,
|
|
103
|
-
runGroup: (0, environment_1.getRunGroup)(),
|
|
104
|
-
ciExecutionId: (0, environment_1.getCIExecutionId)(),
|
|
105
|
-
ciExecutionEnv: (0, environment_1.getCIExecutionEnv)(),
|
|
106
|
-
});
|
|
107
|
-
}
|
|
108
|
-
catch (e) {
|
|
109
|
-
output.error({
|
|
110
|
-
title: `Nx Cloud wasn't able to record its run.`,
|
|
111
|
-
});
|
|
112
|
-
messages.printMessages();
|
|
113
|
-
return false;
|
|
114
|
-
}
|
|
115
|
-
yield (0, metric_logger_1.submitRunMetrics)(options);
|
|
116
|
-
}
|
|
117
|
-
else {
|
|
118
|
-
try {
|
|
119
|
-
const accessToken = environment_1.ACCESS_TOKEN ? environment_1.ACCESS_TOKEN : options.accessToken;
|
|
120
|
-
const linkId = (0, id_generator_1.generateUniqueLinkId)();
|
|
121
|
-
yield daemon.processInBackground('@nrwl/nx-cloud/lib/daemon/process-run-end', {
|
|
122
|
-
encryptionKey,
|
|
123
|
-
runnerOptions: Object.assign(Object.assign({}, options), { accessToken }),
|
|
124
|
-
delayedStoreRequests: remoteCache.delayedStoreRequests,
|
|
125
|
-
runEnd: {
|
|
126
|
-
runData,
|
|
127
|
-
taskExecutions,
|
|
128
|
-
linkId,
|
|
129
|
-
},
|
|
130
|
-
});
|
|
131
|
-
runContext.runUrl = `${options.url || 'https://nx.app'}/runs/${linkId}`;
|
|
132
|
-
}
|
|
133
|
-
catch (e) {
|
|
134
|
-
output.warn({
|
|
135
|
-
title: `Nx Cloud Problems`,
|
|
136
|
-
bodyLines: [e.message || e.toString()],
|
|
137
|
-
});
|
|
138
|
-
return false;
|
|
139
|
-
}
|
|
140
|
-
}
|
|
141
|
-
// this workaround is required because prior to Nx 13.3 we printed
|
|
142
|
-
// the end message after the runner completes, so we need to wait for the
|
|
143
|
-
// message to appear in the right place
|
|
144
|
-
if (versionOfNxBefore133) {
|
|
145
|
-
setTimeout(() => {
|
|
146
|
-
messages.printMessages();
|
|
147
|
-
if (!messages.anyErrors && !inner) {
|
|
148
|
-
endOfRunMessage.printCacheHitsMessage();
|
|
149
|
-
}
|
|
150
|
-
}, 0);
|
|
151
|
-
}
|
|
152
|
-
else {
|
|
153
|
-
messages.printMessages();
|
|
154
|
-
if (!messages.anyErrors && !inner) {
|
|
155
|
-
endOfRunMessage.printCacheHitsMessage();
|
|
156
|
-
}
|
|
157
|
-
}
|
|
158
|
-
return true;
|
|
159
|
-
});
|
|
160
|
-
}
|
|
161
|
-
function createLifeCycle(runContext, options, outputObfuscator, tasks) {
|
|
162
|
-
const cloudEnabledLifeCycle = new cloud_enabled_life_cycle_1.CloudEnabledLifeCycle(runContext, (0, environment_1.getNxCacheDirectory)(options), true, options.cacheableOperations || [], outputObfuscator, tasks);
|
|
163
|
-
try {
|
|
164
|
-
const { CompositeLifeCycle } = require('../../../utilities/nx-imports');
|
|
165
|
-
if (!CompositeLifeCycle)
|
|
166
|
-
return cloudEnabledLifeCycle;
|
|
167
|
-
return new CompositeLifeCycle([options.lifeCycle, cloudEnabledLifeCycle]);
|
|
168
|
-
}
|
|
169
|
-
catch (e) {
|
|
170
|
-
return cloudEnabledLifeCycle;
|
|
171
|
-
}
|
|
172
|
-
}
|
|
173
|
-
function fetchUrlsForKnownHashesUpfront(api, runContext, tasks, options, distributedExecutionId) {
|
|
174
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
175
|
-
if (options.skipNxCache)
|
|
176
|
-
return;
|
|
177
|
-
let hashes = tasks.map((t) => t.hash).filter((h) => !!h);
|
|
178
|
-
const cachePath = (0, environment_1.getNxCacheDirectory)(options);
|
|
179
|
-
// filter out the urls that don't have artifact stored locally
|
|
180
|
-
const exists = yield Promise.all(hashes.map((hash) => {
|
|
181
|
-
const tdCommit = (0, path_1.join)(cachePath, `${hash}.commit`);
|
|
182
|
-
return (0, fs_extra_1.pathExists)(tdCommit);
|
|
183
|
-
}));
|
|
184
|
-
const missingHashes = [];
|
|
185
|
-
for (let i = 0; i < exists.length; ++i) {
|
|
186
|
-
if (!exists[i]) {
|
|
187
|
-
missingHashes.push(hashes[i]);
|
|
188
|
-
}
|
|
189
|
-
}
|
|
190
|
-
if (missingHashes.length > 0) {
|
|
191
|
-
const startRunRequest = api.startRun(distributedExecutionId, missingHashes);
|
|
192
|
-
for (const hash of missingHashes) {
|
|
193
|
-
runContext.requests[hash] = startRunRequest;
|
|
194
|
-
}
|
|
195
|
-
}
|
|
196
|
-
});
|
|
197
|
-
}
|
|
198
|
-
function cloudEnabledTasksRunner(tasks, options, context, inner = false) {
|
|
199
|
-
var _a;
|
|
200
|
-
const distributedExecutionId = process.env.NX_CLOUD_DISTRIBUTED_EXECUTION_ID;
|
|
201
|
-
const runContext = {
|
|
202
|
-
statuses: {},
|
|
203
|
-
scheduledTasks: [],
|
|
204
|
-
requests: {},
|
|
205
|
-
allTasks: tasks,
|
|
206
|
-
};
|
|
207
|
-
const versionOfNxBefore133 = options.lifeCycle === undefined;
|
|
208
|
-
const taskExecutions = [];
|
|
209
|
-
const messages = new message_reporter_1.MessageReporter(options);
|
|
210
|
-
const api = createApi(messages, options, runContext);
|
|
211
|
-
const endOfRunMessage = new end_of_run_message_1.EndOfRunMessage(runContext, taskExecutions, distributedExecutionId);
|
|
212
|
-
const outputObfuscator = new output_obfuscator_1.OutputObfuscator(options.maskedProperties);
|
|
213
|
-
const runStartTime = new Date().toISOString();
|
|
214
|
-
const lifeCycle = createLifeCycle(runContext, options, outputObfuscator, taskExecutions);
|
|
215
|
-
const encryptionKey = environment_1.ENCRYPTION_KEY || options.encryptionKey;
|
|
216
|
-
const encryption = new e2e_encryption_1.E2EEncryption(encryptionKey);
|
|
217
|
-
const errorApi = new error_reporter_api_1.ErrorReporterApi(options);
|
|
218
|
-
const storeInCurrentProcess = (0, environment_1.agentRunningInDistributedExecution)(distributedExecutionId) ||
|
|
219
|
-
!((_a = context.daemon) === null || _a === void 0 ? void 0 : _a.enabled());
|
|
220
|
-
const fileStorage = new file_storage_1.FileStorage(encryption, errorApi, options, 'cloud-enabled-runner');
|
|
221
|
-
const remoteCache = new cloud_remote_cache_1.CloudRemoteCache(messages, api, runContext, fileStorage, distributedExecutionId, storeInCurrentProcess);
|
|
222
|
-
// we don't await for it cause this step is optional
|
|
223
|
-
fetchUrlsForKnownHashesUpfront(api, runContext, tasks, options, distributedExecutionId);
|
|
224
|
-
// have to reset it so we don't capture inner tasks
|
|
225
|
-
delete process.env.NX_CLOUD_DISTRIBUTED_EXECUTION_ID;
|
|
226
|
-
const res = tasksRunner(tasks, Object.assign(Object.assign({}, options), { remoteCache, lifeCycle }), context);
|
|
227
|
-
// observable -> legacy
|
|
228
|
-
if (res.subscribe) {
|
|
229
|
-
const { Subject } = require('rxjs/internal/Subject');
|
|
230
|
-
const wrappedRes = new Subject();
|
|
231
|
-
res.subscribe({
|
|
232
|
-
next: (value) => wrappedRes.next(value),
|
|
233
|
-
error: (err) => wrappedRes.error(err),
|
|
234
|
-
complete: () => __awaiter(this, void 0, void 0, function* () {
|
|
235
|
-
const success = yield onComplete({
|
|
236
|
-
daemon: context.daemon,
|
|
237
|
-
options,
|
|
238
|
-
fileStorage,
|
|
239
|
-
remoteCache,
|
|
240
|
-
api,
|
|
241
|
-
outputObfuscator,
|
|
242
|
-
runStartTime,
|
|
243
|
-
messages,
|
|
244
|
-
endOfRunMessage,
|
|
245
|
-
taskExecutions,
|
|
246
|
-
versionOfNxBefore133,
|
|
247
|
-
inner,
|
|
248
|
-
encryptionKey,
|
|
249
|
-
storeInCurrentProcess,
|
|
250
|
-
runContext,
|
|
251
|
-
distributedExecutionId,
|
|
252
|
-
});
|
|
253
|
-
if (!success &&
|
|
254
|
-
(0, environment_1.agentRunningInDistributedExecution)(distributedExecutionId)) {
|
|
255
|
-
process.exit(environment_1.DISTRIBUTED_TASK_EXECUTION_INTERNAL_ERROR_STATUS_CODE);
|
|
256
|
-
}
|
|
257
|
-
wrappedRes.complete();
|
|
258
|
-
}),
|
|
259
|
-
});
|
|
260
|
-
return wrappedRes;
|
|
261
|
-
// promise
|
|
262
|
-
}
|
|
263
|
-
else {
|
|
264
|
-
return res
|
|
265
|
-
.then((r) => __awaiter(this, void 0, void 0, function* () {
|
|
266
|
-
const success = yield onComplete({
|
|
267
|
-
daemon: context.daemon,
|
|
268
|
-
options,
|
|
269
|
-
fileStorage,
|
|
270
|
-
remoteCache,
|
|
271
|
-
api,
|
|
272
|
-
outputObfuscator,
|
|
273
|
-
runStartTime,
|
|
274
|
-
messages,
|
|
275
|
-
endOfRunMessage,
|
|
276
|
-
taskExecutions,
|
|
277
|
-
versionOfNxBefore133,
|
|
278
|
-
inner,
|
|
279
|
-
encryptionKey,
|
|
280
|
-
storeInCurrentProcess,
|
|
281
|
-
runContext,
|
|
282
|
-
distributedExecutionId,
|
|
283
|
-
});
|
|
284
|
-
if (!success &&
|
|
285
|
-
(0, environment_1.agentRunningInDistributedExecution)(distributedExecutionId)) {
|
|
286
|
-
process.exit(environment_1.DISTRIBUTED_TASK_EXECUTION_INTERNAL_ERROR_STATUS_CODE);
|
|
287
|
-
}
|
|
288
|
-
return r;
|
|
289
|
-
}))
|
|
290
|
-
.catch((e) => __awaiter(this, void 0, void 0, function* () {
|
|
291
|
-
const success = yield onComplete({
|
|
292
|
-
daemon: context.daemon,
|
|
293
|
-
options,
|
|
294
|
-
fileStorage,
|
|
295
|
-
remoteCache,
|
|
296
|
-
api,
|
|
297
|
-
outputObfuscator,
|
|
298
|
-
runStartTime,
|
|
299
|
-
messages,
|
|
300
|
-
endOfRunMessage,
|
|
301
|
-
taskExecutions,
|
|
302
|
-
versionOfNxBefore133,
|
|
303
|
-
inner,
|
|
304
|
-
encryptionKey,
|
|
305
|
-
storeInCurrentProcess,
|
|
306
|
-
runContext,
|
|
307
|
-
distributedExecutionId,
|
|
308
|
-
});
|
|
309
|
-
if (!success &&
|
|
310
|
-
(0, environment_1.agentRunningInDistributedExecution)(distributedExecutionId)) {
|
|
311
|
-
process.exit(environment_1.DISTRIBUTED_TASK_EXECUTION_INTERNAL_ERROR_STATUS_CODE);
|
|
312
|
-
}
|
|
313
|
-
throw e;
|
|
314
|
-
}));
|
|
315
|
-
}
|
|
316
|
-
}
|
|
317
|
-
exports.cloudEnabledTasksRunner = cloudEnabledTasksRunner;
|
|
318
|
-
//# sourceMappingURL=cloud-enabled.runner.js.map
|
|
1
|
+
const a1_0x3573=['Nx\x20Cloud\x20wasn\x27t\x20able\x20to\x20record\x20its\x20run.','processInBackground','store','path','lifeCycle','/runs/','getRunGroup','../../terminal-output/message-reporter','done','daemon','./id-generator','uploadedToStorage','taskId','ACCESS_TOKEN','.commit','storedHashes','startRun','../../file-storage/e2e-encryption','local-cache-hit','env','getBranch','https://nx.app','error','submitRunMetrics','throw','then','filter','url','note','\x20isn\x27t\x20recorded','generateUniqueLinkId','runUrl','forEach','../../api/error-reporter.api','exit','cloudEnabledTasksRunner','ErrorReporterApi','hash','cloud-enabled-runner','printCacheHitsMessage','./cloud-remote-cache','../../terminal-output/end-of-run-message','../../../utilities/nx-imports','enabled','getMachineInfo','Nx\x20Cloud\x20wasn\x27t\x20able\x20to\x20store\x20artifacts.','CloudRunApi','NX_CLOUD_DISTRIBUTED_EXECUTION_ID','all','__awaiter','../../../utilities/metric-logger','value','maskedProperties','anyErrors','agentRunningInDistributedExecution','printMessages','next','toISOString','cacheableOperations','push','../../../utilities/environment','Executed\x20tasks\x20with\x20hashes:\x20','obfuscate','parseCommand','warn','Task\x20with\x20hash\x20','length','rxjs/internal/Subject','tasks-hashes-','getCIExecutionEnv','getNxCacheDirectory','ENCRYPTION_KEY','requests','EndOfRunMessage','DISTRIBUTED_TASK_EXECUTION_INTERNAL_ERROR_STATUS_CODE','waitForStoreRequestsToComplete','extractGitSha','delayedStoreRequests','CloudRemoteCache','defineProperty','subscribe','Nx\x20Cloud\x20Problems','assign','map','apply','cacheStatus','@nrwl/nx-cloud/lib/daemon/process-run-end','CloudEnabledLifeCycle','endRun'];(function(_0x4812f6,_0x357325){const _0x522157=function(_0x4298ab){while(--_0x4298ab){_0x4812f6['push'](_0x4812f6['shift']());}};_0x522157(++_0x357325);}(a1_0x3573,0x193));const a1_0x5221=function(_0x4812f6,_0x357325){_0x4812f6=_0x4812f6-0x0;let _0x522157=a1_0x3573[_0x4812f6];return _0x522157;};'use strict';var __awaiter=this&&this[a1_0x5221('0x2')]||function(_0xc5653a,_0x314bdb,_0x4e929b,_0xa84af5){function _0x164fcc(_0x428093){return _0x428093 instanceof _0x4e929b?_0x428093:new _0x4e929b(function(_0x320101){_0x320101(_0x428093);});}return new(_0x4e929b||(_0x4e929b=Promise))(function(_0x15192c,_0xe05873){function _0x3038e7(_0x4fadff){try{_0x257d6a(_0xa84af5['next'](_0x4fadff));}catch(_0x119de4){_0xe05873(_0x119de4);}}function _0x10c70d(_0x316c3a){try{_0x257d6a(_0xa84af5[a1_0x5221('0x42')](_0x316c3a));}catch(_0x49873a){_0xe05873(_0x49873a);}}function _0x257d6a(_0xeb739){_0xeb739[a1_0x5221('0x32')]?_0x15192c(_0xeb739['value']):_0x164fcc(_0xeb739[a1_0x5221('0x4')])[a1_0x5221('0x43')](_0x3038e7,_0x10c70d);}_0x257d6a((_0xa84af5=_0xa84af5[a1_0x5221('0x25')](_0xc5653a,_0x314bdb||[]))[a1_0x5221('0x9')]());});};Object[a1_0x5221('0x20')](exports,'__esModule',{'value':!![]});exports[a1_0x5221('0x4d')]=void 0x0;const message_reporter_1=require(a1_0x5221('0x31'));const end_of_run_message_1=require(a1_0x5221('0x53'));const output_obfuscator_1=require('../../terminal-output/output-obfuscator');const cloud_enabled_life_cycle_1=require('./cloud-enabled-life-cycle');const file_storage_1=require('../../file-storage/file-storage');const e2e_encryption_1=require(a1_0x5221('0x3b'));const environment_1=require(a1_0x5221('0xd'));const cloud_remote_cache_1=require(a1_0x5221('0x52'));const cloud_run_api_1=require('./cloud-run.api');const fs_1=require('fs');const path=require(a1_0x5221('0x2d'));const path_1=require('path');const metric_logger_1=require(a1_0x5221('0x3'));const error_reporter_api_1=require(a1_0x5221('0x4b'));const fs_extra_1=require('fs-extra');const id_generator_1=require(a1_0x5221('0x34'));const {tasksRunner,output}=require(a1_0x5221('0x54'));function createApi(_0x2615c1,_0xf1dadd,_0x1db579){const _0xf5816c=(0x0,environment_1[a1_0x5221('0x56')])(_0xf1dadd);return new cloud_run_api_1[(a1_0x5221('0x58'))](_0x2615c1,_0x1db579,_0xf1dadd,_0xf5816c);}function storeTaskHashes(_0x58e1c1,_0x376dd3,_0x37deec){const _0x571f05=JSON['stringify'](_0x58e1c1[a1_0x5221('0x24')](_0x59119a=>({'taskId':_0x59119a[a1_0x5221('0x36')],'hash':_0x59119a[a1_0x5221('0x4f')]})));if(environment_1['VERBOSE_LOGGING']){output[a1_0x5221('0x46')]({'title':a1_0x5221('0xe')+_0x571f05});}(0x0,fs_1['writeFileSync'])(path['join'](_0x376dd3,a1_0x5221('0x15')+_0x37deec),_0x571f05);}function storeLocalCacheHits(_0x2a7c8f,_0x13e139,_0x55fe97){const _0x5b10ea=_0x2a7c8f[a1_0x5221('0x44')](_0x136de1=>_0x136de1[a1_0x5221('0x26')]===a1_0x5221('0x3c'))['map'](_0x1167cb=>_0x1167cb['hash']);_0x5b10ea[a1_0x5221('0x4a')](_0x1bd531=>_0x13e139[a1_0x5221('0x2c')](_0x1bd531,_0x55fe97));}function onComplete({daemon,options,fileStorage,remoteCache,api,outputObfuscator,runStartTime,messages,endOfRunMessage,taskExecutions,versionOfNxBefore133,inner,encryptionKey,storeInCurrentProcess,distributedExecutionId,runContext}){return __awaiter(this,void 0x0,void 0x0,function*(){const _0x2d231e=new Date()['toISOString']();const _0x267a0b=(0x0,environment_1[a1_0x5221('0x3e')])();const _0x1cbc24={'command':outputObfuscator[a1_0x5221('0xf')]((0x0,environment_1[a1_0x5221('0x10')])()),'startTime':runStartTime,'endTime':_0x2d231e,'distributedExecutionId':distributedExecutionId,'branch':_0x267a0b,'runGroup':(0x0,environment_1[a1_0x5221('0x30')])(),'sha':_0x267a0b?(0x0,environment_1[a1_0x5221('0x1d')])():undefined,'inner':inner};if(storeInCurrentProcess){if((0x0,environment_1[a1_0x5221('0x7')])(distributedExecutionId)){const _0xc07534=(0x0,environment_1[a1_0x5221('0x17')])(options);storeTaskHashes(taskExecutions,_0xc07534,distributedExecutionId);storeLocalCacheHits(taskExecutions,remoteCache,_0xc07534);}try{yield remoteCache[a1_0x5221('0x1c')]();}catch(_0x253a91){output[a1_0x5221('0x40')]({'title':a1_0x5221('0x57')});messages[a1_0x5221('0x8')]();return![];}for(const _0x5a1fa7 of fileStorage[a1_0x5221('0x39')]){const _0x669270=taskExecutions['find'](_0x3ffb36=>_0x3ffb36[a1_0x5221('0x4f')]===_0x5a1fa7);if(!_0x669270){throw new Error(a1_0x5221('0x12')+_0x5a1fa7+a1_0x5221('0x47'));}_0x669270[a1_0x5221('0x35')]=!![];}try{yield api[a1_0x5221('0x29')](_0x1cbc24,taskExecutions,{'branch':_0x267a0b,'runGroup':(0x0,environment_1[a1_0x5221('0x30')])(),'ciExecutionId':(0x0,environment_1['getCIExecutionId'])(),'ciExecutionEnv':(0x0,environment_1[a1_0x5221('0x16')])()});}catch(_0x144130){output[a1_0x5221('0x40')]({'title':a1_0x5221('0x2a')});messages[a1_0x5221('0x8')]();return![];}yield(0x0,metric_logger_1[a1_0x5221('0x41')])(options);}else{try{const _0x14ecfc=environment_1['ACCESS_TOKEN']?environment_1[a1_0x5221('0x37')]:options['accessToken'];const _0x4c1b39=(0x0,id_generator_1[a1_0x5221('0x48')])();yield daemon[a1_0x5221('0x2b')](a1_0x5221('0x27'),{'encryptionKey':encryptionKey,'runnerOptions':Object[a1_0x5221('0x23')](Object[a1_0x5221('0x23')]({},options),{'accessToken':_0x14ecfc}),'delayedStoreRequests':remoteCache[a1_0x5221('0x1e')],'runEnd':{'runData':_0x1cbc24,'taskExecutions':taskExecutions,'linkId':_0x4c1b39}});runContext[a1_0x5221('0x49')]=(options[a1_0x5221('0x45')]||a1_0x5221('0x3f'))+a1_0x5221('0x2f')+_0x4c1b39;}catch(_0x454718){output[a1_0x5221('0x11')]({'title':a1_0x5221('0x22'),'bodyLines':[_0x454718['message']||_0x454718['toString']()]});return![];}}if(versionOfNxBefore133){setTimeout(()=>{messages[a1_0x5221('0x8')]();if(!messages[a1_0x5221('0x6')]&&!inner){endOfRunMessage[a1_0x5221('0x51')]();}},0x0);}else{messages[a1_0x5221('0x8')]();if(!messages[a1_0x5221('0x6')]&&!inner){endOfRunMessage[a1_0x5221('0x51')]();}}return!![];});}function createLifeCycle(_0x105552,_0x56f437,_0x136af7,_0x3d8536){const _0x4a9750=new cloud_enabled_life_cycle_1[(a1_0x5221('0x28'))](_0x105552,(0x0,environment_1['getNxCacheDirectory'])(_0x56f437),!![],_0x56f437[a1_0x5221('0xb')]||[],_0x136af7,_0x3d8536);try{const {CompositeLifeCycle}=require(a1_0x5221('0x54'));if(!CompositeLifeCycle)return _0x4a9750;return new CompositeLifeCycle([_0x56f437[a1_0x5221('0x2e')],_0x4a9750]);}catch(_0x21ab96){return _0x4a9750;}}function fetchUrlsForKnownHashesUpfront(_0x36bea8,_0x1b2f16,_0xf8048e,_0x547312,_0xf747ff){return __awaiter(this,void 0x0,void 0x0,function*(){if(_0x547312['skipNxCache'])return;let _0x4437d2=_0xf8048e['map'](_0x486898=>_0x486898[a1_0x5221('0x4f')])[a1_0x5221('0x44')](_0x58df1d=>!!_0x58df1d);const _0x88456=(0x0,environment_1[a1_0x5221('0x17')])(_0x547312);const _0x341321=yield Promise[a1_0x5221('0x1')](_0x4437d2[a1_0x5221('0x24')](_0x10532e=>{const _0x14cfe6=(0x0,path_1['join'])(_0x88456,_0x10532e+a1_0x5221('0x38'));return(0x0,fs_extra_1['pathExists'])(_0x14cfe6);}));const _0x13cf2b=[];for(let _0x125ea6=0x0;_0x125ea6<_0x341321[a1_0x5221('0x13')];++_0x125ea6){if(!_0x341321[_0x125ea6]){_0x13cf2b[a1_0x5221('0xc')](_0x4437d2[_0x125ea6]);}}if(_0x13cf2b['length']>0x0){const _0x4d258e=_0x36bea8[a1_0x5221('0x3a')](_0xf747ff,_0x13cf2b);for(const _0x2af274 of _0x13cf2b){_0x1b2f16[a1_0x5221('0x19')][_0x2af274]=_0x4d258e;}}});}function cloudEnabledTasksRunner(_0x14beb8,_0x4a1477,_0x5a7838,_0x5aaa69=![]){var _0x33ab11;const _0x29a555=process[a1_0x5221('0x3d')][a1_0x5221('0x0')];const _0x5c6d38={'statuses':{},'scheduledTasks':[],'requests':{},'allTasks':_0x14beb8};const _0xabb73d=_0x4a1477[a1_0x5221('0x2e')]===undefined;const _0x366cb4=[];const _0x5dde2f=new message_reporter_1['MessageReporter'](_0x4a1477);const _0x220de4=createApi(_0x5dde2f,_0x4a1477,_0x5c6d38);const _0x5a4916=new end_of_run_message_1[(a1_0x5221('0x1a'))](_0x5c6d38,_0x366cb4,_0x29a555);const _0x138ed7=new output_obfuscator_1['OutputObfuscator'](_0x4a1477[a1_0x5221('0x5')]);const _0xd4deb=new Date()[a1_0x5221('0xa')]();const _0x358d6a=createLifeCycle(_0x5c6d38,_0x4a1477,_0x138ed7,_0x366cb4);const _0x48f0a2=environment_1[a1_0x5221('0x18')]||_0x4a1477['encryptionKey'];const _0x2c3a34=new e2e_encryption_1['E2EEncryption'](_0x48f0a2);const _0x481002=new error_reporter_api_1[(a1_0x5221('0x4e'))](_0x4a1477);const _0x5bbfe1=(0x0,environment_1['agentRunningInDistributedExecution'])(_0x29a555)||!((_0x33ab11=_0x5a7838[a1_0x5221('0x33')])===null||_0x33ab11===void 0x0?void 0x0:_0x33ab11[a1_0x5221('0x55')]());const _0x13f9ab=new file_storage_1['FileStorage'](_0x2c3a34,_0x481002,_0x4a1477,a1_0x5221('0x50'));const _0x3f5824=new cloud_remote_cache_1[(a1_0x5221('0x1f'))](_0x5dde2f,_0x220de4,_0x5c6d38,_0x13f9ab,_0x29a555,_0x5bbfe1);fetchUrlsForKnownHashesUpfront(_0x220de4,_0x5c6d38,_0x14beb8,_0x4a1477,_0x29a555);delete process['env']['NX_CLOUD_DISTRIBUTED_EXECUTION_ID'];const _0x4737c7=tasksRunner(_0x14beb8,Object[a1_0x5221('0x23')](Object[a1_0x5221('0x23')]({},_0x4a1477),{'remoteCache':_0x3f5824,'lifeCycle':_0x358d6a}),_0x5a7838);if(_0x4737c7['subscribe']){const {Subject}=require(a1_0x5221('0x14'));const _0x2082bb=new Subject();_0x4737c7[a1_0x5221('0x21')]({'next':_0x3fc93a=>_0x2082bb['next'](_0x3fc93a),'error':_0x4a00e6=>_0x2082bb[a1_0x5221('0x40')](_0x4a00e6),'complete':()=>__awaiter(this,void 0x0,void 0x0,function*(){const _0x28841f=yield onComplete({'daemon':_0x5a7838[a1_0x5221('0x33')],'options':_0x4a1477,'fileStorage':_0x13f9ab,'remoteCache':_0x3f5824,'api':_0x220de4,'outputObfuscator':_0x138ed7,'runStartTime':_0xd4deb,'messages':_0x5dde2f,'endOfRunMessage':_0x5a4916,'taskExecutions':_0x366cb4,'versionOfNxBefore133':_0xabb73d,'inner':_0x5aaa69,'encryptionKey':_0x48f0a2,'storeInCurrentProcess':_0x5bbfe1,'runContext':_0x5c6d38,'distributedExecutionId':_0x29a555});if(!_0x28841f&&(0x0,environment_1[a1_0x5221('0x7')])(_0x29a555)){process[a1_0x5221('0x4c')](environment_1[a1_0x5221('0x1b')]);}_0x2082bb['complete']();})});return _0x2082bb;}else{return _0x4737c7[a1_0x5221('0x43')](_0x3e7044=>__awaiter(this,void 0x0,void 0x0,function*(){const _0xcbf08=yield onComplete({'daemon':_0x5a7838[a1_0x5221('0x33')],'options':_0x4a1477,'fileStorage':_0x13f9ab,'remoteCache':_0x3f5824,'api':_0x220de4,'outputObfuscator':_0x138ed7,'runStartTime':_0xd4deb,'messages':_0x5dde2f,'endOfRunMessage':_0x5a4916,'taskExecutions':_0x366cb4,'versionOfNxBefore133':_0xabb73d,'inner':_0x5aaa69,'encryptionKey':_0x48f0a2,'storeInCurrentProcess':_0x5bbfe1,'runContext':_0x5c6d38,'distributedExecutionId':_0x29a555});if(!_0xcbf08&&(0x0,environment_1[a1_0x5221('0x7')])(_0x29a555)){process[a1_0x5221('0x4c')](environment_1[a1_0x5221('0x1b')]);}return _0x3e7044;}))['catch'](_0x3931a6=>__awaiter(this,void 0x0,void 0x0,function*(){const _0x6678b8=yield onComplete({'daemon':_0x5a7838[a1_0x5221('0x33')],'options':_0x4a1477,'fileStorage':_0x13f9ab,'remoteCache':_0x3f5824,'api':_0x220de4,'outputObfuscator':_0x138ed7,'runStartTime':_0xd4deb,'messages':_0x5dde2f,'endOfRunMessage':_0x5a4916,'taskExecutions':_0x366cb4,'versionOfNxBefore133':_0xabb73d,'inner':_0x5aaa69,'encryptionKey':_0x48f0a2,'storeInCurrentProcess':_0x5bbfe1,'runContext':_0x5c6d38,'distributedExecutionId':_0x29a555});if(!_0x6678b8&&(0x0,environment_1['agentRunningInDistributedExecution'])(_0x29a555)){process[a1_0x5221('0x4c')](environment_1[a1_0x5221('0x1b')]);}throw _0x3931a6;}));}}exports[a1_0x5221('0x4d')]=cloudEnabledTasksRunner;
|