@nrwl/nx-cloud 13.2.0-beta.3 → 13.2.2
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/run-group.api.js +1 -65
- package/lib/core/runners/cloud-enabled/cloud-enabled-life-cycle.js +1 -138
- package/lib/core/runners/cloud-enabled/cloud-enabled.runner.js +1 -166
- package/lib/core/runners/cloud-enabled/cloud-remote-cache.js +1 -113
- package/lib/core/runners/cloud-enabled/cloud-run.api.js +1 -158
- package/lib/core/runners/distributed-agent/distributed-agent.api.js +1 -79
- package/lib/core/runners/distributed-agent/distributed-agent.impl.js +1 -239
- package/lib/core/runners/distributed-execution/distributed-execution.api.js +1 -130
- package/lib/core/runners/distributed-execution/distributed-execution.runner.js +1 -306
- package/package.json +4 -7
|
@@ -1,158 +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.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 { output } = require('../../../utilities/nx-imports');
|
|
20
|
-
class CloudRunApi {
|
|
21
|
-
constructor(messages, runContext, options, machineInfo) {
|
|
22
|
-
this.messages = messages;
|
|
23
|
-
this.runContext = runContext;
|
|
24
|
-
this.machineInfo = machineInfo;
|
|
25
|
-
this.apiAxiosInstance = (0, axios_1.createApiAxiosInstance)(options);
|
|
26
|
-
}
|
|
27
|
-
startRun(distributedExecutionId, hashes) {
|
|
28
|
-
var _a;
|
|
29
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
30
|
-
const recorder = (0, metric_logger_1.createMetricRecorder)('startRun');
|
|
31
|
-
try {
|
|
32
|
-
const request = {
|
|
33
|
-
meta: {
|
|
34
|
-
nxCloudVersion: this.nxCloudVersion(),
|
|
35
|
-
},
|
|
36
|
-
branch: (0, environment_1.getBranch)(),
|
|
37
|
-
runGroup: (0, environment_1.getRunGroup)(),
|
|
38
|
-
distributedExecutionId,
|
|
39
|
-
hashes,
|
|
40
|
-
};
|
|
41
|
-
if (environment_1.VERBOSE_LOGGING) {
|
|
42
|
-
output.note({
|
|
43
|
-
title: 'RunStart',
|
|
44
|
-
bodyLines: ['\n' + JSON.stringify(request, null, 2)],
|
|
45
|
-
});
|
|
46
|
-
}
|
|
47
|
-
const resp = yield (0, axios_1.axiosMultipleTries)(() => this.apiAxiosInstance.post('/nx-cloud/runs/start', request));
|
|
48
|
-
recorder.recordMetric((0, metric_logger_1.mapRespToPerfEntry)(resp));
|
|
49
|
-
if (resp.data && resp.data.message) {
|
|
50
|
-
this.messages.message = resp.data.message;
|
|
51
|
-
}
|
|
52
|
-
if (!resp.data || !resp.data.urls) {
|
|
53
|
-
this.messages.apiError = `Invalid Nx Cloud response: ${JSON.stringify(resp.data)}`;
|
|
54
|
-
return {};
|
|
55
|
-
}
|
|
56
|
-
return resp.data.urls;
|
|
57
|
-
}
|
|
58
|
-
catch (e) {
|
|
59
|
-
recorder.recordMetric(((_a = e === null || e === void 0 ? void 0 : e.axiosException) === null || _a === void 0 ? void 0 : _a.response)
|
|
60
|
-
? (0, metric_logger_1.mapRespToPerfEntry)(e.axiosException.response)
|
|
61
|
-
: metric_logger_1.RUNNER_FAILURE_PERF_ENTRY);
|
|
62
|
-
this.messages.apiError = this.messages.extractErrorMessage(e, 'api');
|
|
63
|
-
return {};
|
|
64
|
-
}
|
|
65
|
-
});
|
|
66
|
-
}
|
|
67
|
-
endRun(run, tasks) {
|
|
68
|
-
var _a, _b;
|
|
69
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
70
|
-
// API is not working, don't make the end request
|
|
71
|
-
if (this.messages.apiError)
|
|
72
|
-
return false;
|
|
73
|
-
const uncompressedReqBody = {
|
|
74
|
-
meta: {
|
|
75
|
-
nxCloudVersion: this.nxCloudVersion(),
|
|
76
|
-
},
|
|
77
|
-
tasks,
|
|
78
|
-
run: run,
|
|
79
|
-
machineInfo: this.machineInfo,
|
|
80
|
-
};
|
|
81
|
-
const uncompressedBuffer = Buffer.from(JSON.stringify(uncompressedReqBody));
|
|
82
|
-
const compressedBuffer = yield (0, util_1.promisify)(zlib_1.gzip)(uncompressedBuffer);
|
|
83
|
-
const recorder = (0, metric_logger_1.createMetricRecorder)('endRun');
|
|
84
|
-
try {
|
|
85
|
-
if (environment_1.VERBOSE_LOGGING) {
|
|
86
|
-
const t = tasks.map((tt) => {
|
|
87
|
-
return Object.assign(Object.assign({}, tt), { terminalOutput: tt.terminalOutput
|
|
88
|
-
? `${tt.terminalOutput.slice(0, 20)}...`
|
|
89
|
-
: undefined });
|
|
90
|
-
});
|
|
91
|
-
output.note({
|
|
92
|
-
title: 'RunEnd. Completed tasks',
|
|
93
|
-
bodyLines: ['\n' + JSON.stringify(t, null, 2)],
|
|
94
|
-
});
|
|
95
|
-
}
|
|
96
|
-
const resp = yield (0, axios_1.axiosMultipleTries)(() => this.apiAxiosInstance.post('/nx-cloud/runs/end', compressedBuffer, {
|
|
97
|
-
headers: Object.assign(Object.assign({}, this.apiAxiosInstance.defaults.headers), { 'Content-Encoding': 'gzip', 'Content-Type': 'application/octet-stream' }),
|
|
98
|
-
}));
|
|
99
|
-
if (resp) {
|
|
100
|
-
recorder.recordMetric((0, metric_logger_1.mapRespToPerfEntry)(resp));
|
|
101
|
-
if (resp.data && resp.data.runUrl && resp.data.status === 'success') {
|
|
102
|
-
this.runContext.runUrl = resp.data.runUrl;
|
|
103
|
-
return true;
|
|
104
|
-
}
|
|
105
|
-
if (resp.data && resp.data.status) {
|
|
106
|
-
this.messages.apiError = `Invalid end run response: ${JSON.stringify(resp.data.message)}`;
|
|
107
|
-
}
|
|
108
|
-
else if (resp.data && typeof resp.data === 'string') {
|
|
109
|
-
if (resp.data !== 'success') {
|
|
110
|
-
this.messages.apiError = `Invalid end run response: ${JSON.stringify(resp.data)}`;
|
|
111
|
-
}
|
|
112
|
-
}
|
|
113
|
-
else {
|
|
114
|
-
this.messages.apiError = `Invalid end run response: ${JSON.stringify(resp.data)}`;
|
|
115
|
-
}
|
|
116
|
-
if (environment_1.VERBOSE_LOGGING) {
|
|
117
|
-
output.note({
|
|
118
|
-
title: 'Invalid end run response',
|
|
119
|
-
bodyLines: [JSON.stringify(resp.data, null, 2)],
|
|
120
|
-
});
|
|
121
|
-
}
|
|
122
|
-
}
|
|
123
|
-
else {
|
|
124
|
-
output.error({
|
|
125
|
-
title: 'Nx Cloud: Unknown Error Occurred',
|
|
126
|
-
bodyLines: [
|
|
127
|
-
'Run completion responded with `undefined`.',
|
|
128
|
-
'Run Details:',
|
|
129
|
-
JSON.stringify(run, null, 2),
|
|
130
|
-
'Stack Trace:',
|
|
131
|
-
JSON.stringify(new Error().stack, null, 2),
|
|
132
|
-
],
|
|
133
|
-
});
|
|
134
|
-
}
|
|
135
|
-
return false;
|
|
136
|
-
}
|
|
137
|
-
catch (ee) {
|
|
138
|
-
recorder.recordMetric(((_a = ee === null || ee === void 0 ? void 0 : ee.axiosException) === null || _a === void 0 ? void 0 : _a.response)
|
|
139
|
-
? (0, metric_logger_1.mapRespToPerfEntry)(ee.axiosException.response)
|
|
140
|
-
: metric_logger_1.RUNNER_FAILURE_PERF_ENTRY);
|
|
141
|
-
const e = (_b = ee.axiosException) !== null && _b !== void 0 ? _b : ee;
|
|
142
|
-
this.messages.apiError = this.messages.extractErrorMessage(e, 'api');
|
|
143
|
-
return false;
|
|
144
|
-
}
|
|
145
|
-
});
|
|
146
|
-
}
|
|
147
|
-
nxCloudVersion() {
|
|
148
|
-
try {
|
|
149
|
-
const v = JSON.parse((0, fs_1.readFileSync)(`package.json`).toString());
|
|
150
|
-
return v.devDependencies['@nrwl/nx-cloud'];
|
|
151
|
-
}
|
|
152
|
-
catch (e) {
|
|
153
|
-
return 'unknown';
|
|
154
|
-
}
|
|
155
|
-
}
|
|
156
|
-
}
|
|
157
|
-
exports.CloudRunApi = CloudRunApi;
|
|
158
|
-
//# sourceMappingURL=cloud-run.api.js.map
|
|
1
|
+
const a3_0x885d=['createApiAxiosInstance','__esModule','defineProperty','__awaiter','terminalOutput','axiosMultipleTries','unknown','promisify','api','success','value','apiError','next','Stack\x20Trace:','status','slice','mapRespToPerfEntry','util','headers','runContext','Run\x20Details:','../../../utilities/axios','error','data','nxCloudVersion','readFileSync','endRun','from','Run\x20completion\x20responded\x20with\x20`undefined`.','stack','string','response','../../../utilities/nx-imports','apiAxiosInstance','VERBOSE_LOGGING','RUNNER_FAILURE_PERF_ENTRY','startRun','assign','@nrwl/nx-cloud','CloudRunApi','defaults','apply','urls','Invalid\x20end\x20run\x20response:\x20','/nx-cloud/runs/end','note','...','stringify','Nx\x20Cloud:\x20Unknown\x20Error\x20Occurred','axiosException','extractErrorMessage','messages','gzip','message','Invalid\x20Nx\x20Cloud\x20response:\x20','runUrl','recordMetric','Invalid\x20end\x20run\x20response','getBranch','/nx-cloud/runs/start'];(function(_0x515497,_0x885d0e){const _0xe1c6a0=function(_0x4074b3){while(--_0x4074b3){_0x515497['push'](_0x515497['shift']());}};_0xe1c6a0(++_0x885d0e);}(a3_0x885d,0x79));const a3_0xe1c6=function(_0x515497,_0x885d0e){_0x515497=_0x515497-0x0;let _0xe1c6a0=a3_0x885d[_0x515497];return _0xe1c6a0;};'use strict';var __awaiter=this&&this[a3_0xe1c6('0x2')]||function(_0x4672c6,_0x35ba64,_0x129dc4,_0x2ecea3){function _0x407fb9(_0x4d73d8){return _0x4d73d8 instanceof _0x129dc4?_0x4d73d8:new _0x129dc4(function(_0x42c52b){_0x42c52b(_0x4d73d8);});}return new(_0x129dc4||(_0x129dc4=Promise))(function(_0x4674a6,_0x1dfed2){function _0x289f85(_0x3c36ae){try{_0x24a912(_0x2ecea3[a3_0xe1c6('0xb')](_0x3c36ae));}catch(_0x5f140a){_0x1dfed2(_0x5f140a);}}function _0x2a7a81(_0x43c6ab){try{_0x24a912(_0x2ecea3['throw'](_0x43c6ab));}catch(_0x55a167){_0x1dfed2(_0x55a167);}}function _0x24a912(_0xace957){_0xace957['done']?_0x4674a6(_0xace957[a3_0xe1c6('0x9')]):_0x407fb9(_0xace957[a3_0xe1c6('0x9')])['then'](_0x289f85,_0x2a7a81);}_0x24a912((_0x2ecea3=_0x2ecea3[a3_0xe1c6('0x28')](_0x4672c6,_0x35ba64||[]))[a3_0xe1c6('0xb')]());});};Object[a3_0xe1c6('0x1')](exports,a3_0xe1c6('0x0'),{'value':!![]});exports['CloudRunApi']=void 0x0;const axios_1=require(a3_0xe1c6('0x14'));const environment_1=require('../../../utilities/environment');const fs_1=require('fs');const zlib_1=require('zlib');const util_1=require(a3_0xe1c6('0x10'));const metric_logger_1=require('../../../utilities/metric-logger');const {output}=require(a3_0xe1c6('0x1f'));class CloudRunApi{constructor(_0x583147,_0xb5373c,_0xd58050,_0x1f1e2e){this[a3_0xe1c6('0x32')]=_0x583147;this[a3_0xe1c6('0x12')]=_0xb5373c;this['machineInfo']=_0x1f1e2e;this['apiAxiosInstance']=(0x0,axios_1[a3_0xe1c6('0x3b')])(_0xd58050);}[a3_0xe1c6('0x23')](_0x7b4b0c,_0x42a9f6){var _0x4b8062;return __awaiter(this,void 0x0,void 0x0,function*(){const _0x2e70ea=(0x0,metric_logger_1['createMetricRecorder'])(a3_0xe1c6('0x23'));try{const _0xc619d7={'meta':{'nxCloudVersion':this[a3_0xe1c6('0x17')]()},'branch':(0x0,environment_1[a3_0xe1c6('0x39')])(),'runGroup':(0x0,environment_1['getRunGroup'])(),'distributedExecutionId':_0x7b4b0c,'hashes':_0x42a9f6};if(environment_1[a3_0xe1c6('0x21')]){output[a3_0xe1c6('0x2c')]({'title':'RunStart','bodyLines':['\x0a'+JSON[a3_0xe1c6('0x2e')](_0xc619d7,null,0x2)]});}const _0x28a458=yield(0x0,axios_1[a3_0xe1c6('0x4')])(()=>this[a3_0xe1c6('0x20')]['post'](a3_0xe1c6('0x3a'),_0xc619d7));_0x2e70ea[a3_0xe1c6('0x37')]((0x0,metric_logger_1['mapRespToPerfEntry'])(_0x28a458));if(_0x28a458[a3_0xe1c6('0x16')]&&_0x28a458[a3_0xe1c6('0x16')][a3_0xe1c6('0x34')]){this[a3_0xe1c6('0x32')]['message']=_0x28a458[a3_0xe1c6('0x16')][a3_0xe1c6('0x34')];}if(!_0x28a458[a3_0xe1c6('0x16')]||!_0x28a458[a3_0xe1c6('0x16')][a3_0xe1c6('0x29')]){this[a3_0xe1c6('0x32')]['apiError']=a3_0xe1c6('0x35')+JSON['stringify'](_0x28a458['data']);return{};}return _0x28a458['data'][a3_0xe1c6('0x29')];}catch(_0x3598c9){_0x2e70ea[a3_0xe1c6('0x37')](((_0x4b8062=_0x3598c9===null||_0x3598c9===void 0x0?void 0x0:_0x3598c9[a3_0xe1c6('0x30')])===null||_0x4b8062===void 0x0?void 0x0:_0x4b8062[a3_0xe1c6('0x1e')])?(0x0,metric_logger_1[a3_0xe1c6('0xf')])(_0x3598c9[a3_0xe1c6('0x30')][a3_0xe1c6('0x1e')]):metric_logger_1[a3_0xe1c6('0x22')]);this[a3_0xe1c6('0x32')][a3_0xe1c6('0xa')]=this['messages']['extractErrorMessage'](_0x3598c9,a3_0xe1c6('0x7'));return{};}});}[a3_0xe1c6('0x19')](_0x45364a,_0x5ed028){var _0xa9805e,_0x1a05e5;return __awaiter(this,void 0x0,void 0x0,function*(){if(this[a3_0xe1c6('0x32')][a3_0xe1c6('0xa')])return![];const _0x53bc74={'meta':{'nxCloudVersion':this[a3_0xe1c6('0x17')]()},'tasks':_0x5ed028,'run':_0x45364a,'machineInfo':this['machineInfo']};const _0x12dc60=Buffer[a3_0xe1c6('0x1a')](JSON['stringify'](_0x53bc74));const _0x4965a8=yield(0x0,util_1[a3_0xe1c6('0x6')])(zlib_1['gzip'])(_0x12dc60);const _0x2dc373=(0x0,metric_logger_1['createMetricRecorder'])(a3_0xe1c6('0x19'));try{if(environment_1[a3_0xe1c6('0x21')]){const _0x2ba73d=_0x5ed028['map'](_0x258cc4=>{return Object['assign'](Object[a3_0xe1c6('0x24')]({},_0x258cc4),{'terminalOutput':_0x258cc4[a3_0xe1c6('0x3')]?_0x258cc4['terminalOutput'][a3_0xe1c6('0xe')](0x0,0x14)+a3_0xe1c6('0x2d'):undefined});});output[a3_0xe1c6('0x2c')]({'title':'RunEnd.\x20Completed\x20tasks','bodyLines':['\x0a'+JSON[a3_0xe1c6('0x2e')](_0x2ba73d,null,0x2)]});}const _0x4f15e2=yield(0x0,axios_1[a3_0xe1c6('0x4')])(()=>this['apiAxiosInstance']['post'](a3_0xe1c6('0x2b'),_0x4965a8,{'headers':Object[a3_0xe1c6('0x24')](Object[a3_0xe1c6('0x24')]({},this[a3_0xe1c6('0x20')][a3_0xe1c6('0x27')][a3_0xe1c6('0x11')]),{'Content-Encoding':a3_0xe1c6('0x33'),'Content-Type':'application/octet-stream'})}));if(_0x4f15e2){_0x2dc373[a3_0xe1c6('0x37')]((0x0,metric_logger_1['mapRespToPerfEntry'])(_0x4f15e2));if(_0x4f15e2[a3_0xe1c6('0x16')]&&_0x4f15e2[a3_0xe1c6('0x16')][a3_0xe1c6('0x36')]&&_0x4f15e2[a3_0xe1c6('0x16')]['status']===a3_0xe1c6('0x8')){this[a3_0xe1c6('0x12')]['runUrl']=_0x4f15e2['data'][a3_0xe1c6('0x36')];return!![];}if(_0x4f15e2[a3_0xe1c6('0x16')]&&_0x4f15e2[a3_0xe1c6('0x16')][a3_0xe1c6('0xd')]){this[a3_0xe1c6('0x32')]['apiError']='Invalid\x20end\x20run\x20response:\x20'+JSON[a3_0xe1c6('0x2e')](_0x4f15e2[a3_0xe1c6('0x16')][a3_0xe1c6('0x34')]);}else if(_0x4f15e2['data']&&typeof _0x4f15e2['data']===a3_0xe1c6('0x1d')){if(_0x4f15e2['data']!==a3_0xe1c6('0x8')){this[a3_0xe1c6('0x32')][a3_0xe1c6('0xa')]=a3_0xe1c6('0x2a')+JSON['stringify'](_0x4f15e2[a3_0xe1c6('0x16')]);}}else{this[a3_0xe1c6('0x32')]['apiError']=a3_0xe1c6('0x2a')+JSON[a3_0xe1c6('0x2e')](_0x4f15e2['data']);}if(environment_1['VERBOSE_LOGGING']){output[a3_0xe1c6('0x2c')]({'title':a3_0xe1c6('0x38'),'bodyLines':[JSON[a3_0xe1c6('0x2e')](_0x4f15e2[a3_0xe1c6('0x16')],null,0x2)]});}}else{output[a3_0xe1c6('0x15')]({'title':a3_0xe1c6('0x2f'),'bodyLines':[a3_0xe1c6('0x1b'),a3_0xe1c6('0x13'),JSON[a3_0xe1c6('0x2e')](_0x45364a,null,0x2),a3_0xe1c6('0xc'),JSON[a3_0xe1c6('0x2e')](new Error()[a3_0xe1c6('0x1c')],null,0x2)]});}return![];}catch(_0x27f861){_0x2dc373[a3_0xe1c6('0x37')](((_0xa9805e=_0x27f861===null||_0x27f861===void 0x0?void 0x0:_0x27f861[a3_0xe1c6('0x30')])===null||_0xa9805e===void 0x0?void 0x0:_0xa9805e[a3_0xe1c6('0x1e')])?(0x0,metric_logger_1[a3_0xe1c6('0xf')])(_0x27f861[a3_0xe1c6('0x30')][a3_0xe1c6('0x1e')]):metric_logger_1[a3_0xe1c6('0x22')]);const _0x3623d9=(_0x1a05e5=_0x27f861[a3_0xe1c6('0x30')])!==null&&_0x1a05e5!==void 0x0?_0x1a05e5:_0x27f861;this[a3_0xe1c6('0x32')]['apiError']=this[a3_0xe1c6('0x32')][a3_0xe1c6('0x31')](_0x3623d9,'api');return![];}});}[a3_0xe1c6('0x17')](){try{const _0x10927f=JSON['parse']((0x0,fs_1[a3_0xe1c6('0x18')])('package.json')['toString']());return _0x10927f['devDependencies'][a3_0xe1c6('0x25')];}catch(_0x1e6509){return a3_0xe1c6('0x5');}}}exports[a3_0xe1c6('0x26')]=CloudRunApi;
|
|
@@ -1,79 +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.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, runGroup, agentName) {
|
|
19
|
-
this.runGroup = runGroup;
|
|
20
|
-
this.agentName = agentName;
|
|
21
|
-
this.apiAxiosInstance = (0, axios_1.createApiAxiosInstance)(options);
|
|
22
|
-
}
|
|
23
|
-
tasks(executionId, statusCode, completedTasks) {
|
|
24
|
-
var _a;
|
|
25
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
26
|
-
const recorder = (0, metric_logger_1.createMetricRecorder)('dtePollTasks');
|
|
27
|
-
try {
|
|
28
|
-
const res = yield (0, axios_1.axiosMultipleTries)(() => this.apiAxiosInstance.post('/nx-cloud/executions/tasks', {
|
|
29
|
-
runGroup: this.runGroup,
|
|
30
|
-
agentName: this.agentName,
|
|
31
|
-
executionId,
|
|
32
|
-
statusCode,
|
|
33
|
-
completedTasks,
|
|
34
|
-
}));
|
|
35
|
-
recorder.recordMetric((0, metric_logger_1.mapRespToPerfEntry)(res));
|
|
36
|
-
return res.data;
|
|
37
|
-
}
|
|
38
|
-
catch (e) {
|
|
39
|
-
recorder.recordMetric(((_a = e === null || e === void 0 ? void 0 : e.axiosException) === null || _a === void 0 ? void 0 : _a.response)
|
|
40
|
-
? (0, metric_logger_1.mapRespToPerfEntry)(e.axiosException.response)
|
|
41
|
-
: metric_logger_1.RUNNER_FAILURE_PERF_ENTRY);
|
|
42
|
-
throw e;
|
|
43
|
-
}
|
|
44
|
-
});
|
|
45
|
-
}
|
|
46
|
-
completeRunGroupWithError(error) {
|
|
47
|
-
var _a;
|
|
48
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
49
|
-
if (environment_1.VERBOSE_LOGGING) {
|
|
50
|
-
output.note({
|
|
51
|
-
title: 'Completing run group with an error',
|
|
52
|
-
bodyLines: [`runGroup: ${this.runGroup}`, `error: ${error}`],
|
|
53
|
-
});
|
|
54
|
-
}
|
|
55
|
-
const recorder = (0, metric_logger_1.createMetricRecorder)('completeRunGroup');
|
|
56
|
-
try {
|
|
57
|
-
const resp = yield (0, axios_1.axiosMultipleTries)(() => this.apiAxiosInstance.post('/nx-cloud/executions/complete-run-group', {
|
|
58
|
-
runGroup: this.runGroup,
|
|
59
|
-
agentName: this.agentName,
|
|
60
|
-
criticalErrorMessage: error,
|
|
61
|
-
}));
|
|
62
|
-
if (environment_1.VERBOSE_LOGGING) {
|
|
63
|
-
output.note({
|
|
64
|
-
title: 'Completed run group with an error',
|
|
65
|
-
});
|
|
66
|
-
}
|
|
67
|
-
recorder.recordMetric((0, metric_logger_1.mapRespToPerfEntry)(resp));
|
|
68
|
-
}
|
|
69
|
-
catch (e) {
|
|
70
|
-
recorder.recordMetric(((_a = e === null || e === void 0 ? void 0 : e.axiosException) === null || _a === void 0 ? void 0 : _a.response)
|
|
71
|
-
? (0, metric_logger_1.mapRespToPerfEntry)(e.axiosException.response)
|
|
72
|
-
: metric_logger_1.RUNNER_FAILURE_PERF_ENTRY);
|
|
73
|
-
console.error(e);
|
|
74
|
-
}
|
|
75
|
-
});
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
exports.DistributedAgentApi = DistributedAgentApi;
|
|
79
|
-
//# sourceMappingURL=distributed-agent.api.js.map
|
|
1
|
+
const a4_0x1b01=['completeRunGroup','__awaiter','response','data','../../../utilities/metric-logger','dtePollTasks','createMetricRecorder','apiAxiosInstance','axiosMultipleTries','/nx-cloud/executions/complete-run-group','note','completeRunGroupWithError','mapRespToPerfEntry','recordMetric','/nx-cloud/executions/tasks','Completing\x20run\x20group\x20with\x20an\x20error','tasks','DistributedAgentApi','agentName','RUNNER_FAILURE_PERF_ENTRY','../../../utilities/axios','createApiAxiosInstance','error','__esModule','defineProperty','axiosException','VERBOSE_LOGGING','../../../utilities/nx-imports','value','runGroup'];(function(_0x1c7656,_0x1b01c3){const _0xbe91f0=function(_0x955fbd){while(--_0x955fbd){_0x1c7656['push'](_0x1c7656['shift']());}};_0xbe91f0(++_0x1b01c3);}(a4_0x1b01,0xdb));const a4_0xbe91=function(_0x1c7656,_0x1b01c3){_0x1c7656=_0x1c7656-0x0;let _0xbe91f0=a4_0x1b01[_0x1c7656];return _0xbe91f0;};'use strict';var __awaiter=this&&this[a4_0xbe91('0x16')]||function(_0x27c2d9,_0x324cc3,_0x37e554,_0xf53a1c){function _0x8c3be1(_0x3bbeb0){return _0x3bbeb0 instanceof _0x37e554?_0x3bbeb0:new _0x37e554(function(_0x53be28){_0x53be28(_0x3bbeb0);});}return new(_0x37e554||(_0x37e554=Promise))(function(_0x490000,_0x581552){function _0x310ddf(_0x441c25){try{_0x47333c(_0xf53a1c['next'](_0x441c25));}catch(_0x3c8348){_0x581552(_0x3c8348);}}function _0x2eb104(_0x84ea6d){try{_0x47333c(_0xf53a1c['throw'](_0x84ea6d));}catch(_0x2a5a7f){_0x581552(_0x2a5a7f);}}function _0x47333c(_0x23e819){_0x23e819['done']?_0x490000(_0x23e819[a4_0xbe91('0x13')]):_0x8c3be1(_0x23e819[a4_0xbe91('0x13')])['then'](_0x310ddf,_0x2eb104);}_0x47333c((_0xf53a1c=_0xf53a1c['apply'](_0x27c2d9,_0x324cc3||[]))['next']());});};Object[a4_0xbe91('0xf')](exports,a4_0xbe91('0xe'),{'value':!![]});exports[a4_0xbe91('0x8')]=void 0x0;const axios_1=require(a4_0xbe91('0xb'));const environment_1=require('../../../utilities/environment');const metric_logger_1=require(a4_0xbe91('0x19'));const {output}=require(a4_0xbe91('0x12'));class DistributedAgentApi{constructor(_0x2e3a1d,_0x229a83,_0x19c879){this['runGroup']=_0x229a83;this[a4_0xbe91('0x9')]=_0x19c879;this[a4_0xbe91('0x1c')]=(0x0,axios_1[a4_0xbe91('0xc')])(_0x2e3a1d);}[a4_0xbe91('0x7')](_0x18ba89,_0x322859,_0xc532f){var _0x556d91;return __awaiter(this,void 0x0,void 0x0,function*(){const _0x180874=(0x0,metric_logger_1[a4_0xbe91('0x1b')])(a4_0xbe91('0x1a'));try{const _0x221214=yield(0x0,axios_1['axiosMultipleTries'])(()=>this['apiAxiosInstance']['post'](a4_0xbe91('0x5'),{'runGroup':this[a4_0xbe91('0x14')],'agentName':this[a4_0xbe91('0x9')],'executionId':_0x18ba89,'statusCode':_0x322859,'completedTasks':_0xc532f}));_0x180874[a4_0xbe91('0x4')]((0x0,metric_logger_1[a4_0xbe91('0x3')])(_0x221214));return _0x221214[a4_0xbe91('0x18')];}catch(_0xda2cb2){_0x180874[a4_0xbe91('0x4')](((_0x556d91=_0xda2cb2===null||_0xda2cb2===void 0x0?void 0x0:_0xda2cb2['axiosException'])===null||_0x556d91===void 0x0?void 0x0:_0x556d91['response'])?(0x0,metric_logger_1[a4_0xbe91('0x3')])(_0xda2cb2[a4_0xbe91('0x10')][a4_0xbe91('0x17')]):metric_logger_1[a4_0xbe91('0xa')]);throw _0xda2cb2;}});}[a4_0xbe91('0x2')](_0x4b37c0){var _0x49c34d;return __awaiter(this,void 0x0,void 0x0,function*(){if(environment_1[a4_0xbe91('0x11')]){output[a4_0xbe91('0x1')]({'title':a4_0xbe91('0x6'),'bodyLines':['runGroup:\x20'+this[a4_0xbe91('0x14')],'error:\x20'+_0x4b37c0]});}const _0x820dad=(0x0,metric_logger_1[a4_0xbe91('0x1b')])(a4_0xbe91('0x15'));try{const _0x5f39e5=yield(0x0,axios_1[a4_0xbe91('0x1d')])(()=>this[a4_0xbe91('0x1c')]['post'](a4_0xbe91('0x0'),{'runGroup':this[a4_0xbe91('0x14')],'agentName':this[a4_0xbe91('0x9')],'criticalErrorMessage':_0x4b37c0}));if(environment_1[a4_0xbe91('0x11')]){output[a4_0xbe91('0x1')]({'title':'Completed\x20run\x20group\x20with\x20an\x20error'});}_0x820dad['recordMetric']((0x0,metric_logger_1[a4_0xbe91('0x3')])(_0x5f39e5));}catch(_0x5020a5){_0x820dad[a4_0xbe91('0x4')](((_0x49c34d=_0x5020a5===null||_0x5020a5===void 0x0?void 0x0:_0x5020a5[a4_0xbe91('0x10')])===null||_0x49c34d===void 0x0?void 0x0:_0x49c34d[a4_0xbe91('0x17')])?(0x0,metric_logger_1['mapRespToPerfEntry'])(_0x5020a5[a4_0xbe91('0x10')][a4_0xbe91('0x17')]):metric_logger_1['RUNNER_FAILURE_PERF_ENTRY']);console[a4_0xbe91('0xd')](_0x5020a5);}});}}exports[a4_0xbe91('0x8')]=DistributedAgentApi;
|
|
@@ -1,239 +1 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.startAgent = void 0;
|
|
13
|
-
const child_process_1 = require("child_process");
|
|
14
|
-
const stripJsonComments = require("strip-json-comments");
|
|
15
|
-
const distributed_agent_api_1 = require("./distributed-agent.api");
|
|
16
|
-
const waiter_1 = require("../../../utilities/waiter");
|
|
17
|
-
const environment_1 = require("../../../utilities/environment");
|
|
18
|
-
const print_run_group_error_1 = require("../../error/print-run-group-error");
|
|
19
|
-
const create_no_new_messages_timeout_1 = require("../../../utilities/create-no-new-messages-timeout");
|
|
20
|
-
const fs_1 = require("fs");
|
|
21
|
-
const metric_logger_1 = require("../../../utilities/metric-logger");
|
|
22
|
-
const { output } = require('../../../utilities/nx-imports');
|
|
23
|
-
function executeTasks(options, api) {
|
|
24
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
25
|
-
let completedStatusCode = 0;
|
|
26
|
-
let apiResponse = null;
|
|
27
|
-
const failIfSameTasksIn30Mins = (0, create_no_new_messages_timeout_1.createNoNewMessagesTimeout)();
|
|
28
|
-
const waiter = new waiter_1.Waiter();
|
|
29
|
-
let completedTasks = [];
|
|
30
|
-
const startTime = new Date();
|
|
31
|
-
let executedAnyTasks = false;
|
|
32
|
-
while (true) {
|
|
33
|
-
if (environment_1.VERBOSE_LOGGING) {
|
|
34
|
-
output.note({
|
|
35
|
-
title: 'Fetching tasks...',
|
|
36
|
-
});
|
|
37
|
-
}
|
|
38
|
-
apiResponse = yield api.tasks(apiResponse ? apiResponse.executionId : null, completedStatusCode, completedTasks);
|
|
39
|
-
if (environment_1.VERBOSE_LOGGING) {
|
|
40
|
-
output.note({
|
|
41
|
-
title: 'API Response',
|
|
42
|
-
bodyLines: [
|
|
43
|
-
`completed: ${apiResponse.completed}`,
|
|
44
|
-
`retryDuring: ${apiResponse.retryDuring}`,
|
|
45
|
-
`executionId: ${apiResponse.executionId}`,
|
|
46
|
-
`number of tasks: ${apiResponse.tasks.length}`,
|
|
47
|
-
`error: ${apiResponse.criticalErrorMessage}`,
|
|
48
|
-
`maxParallel: ${apiResponse.maxParallel}`,
|
|
49
|
-
],
|
|
50
|
-
});
|
|
51
|
-
}
|
|
52
|
-
if (apiResponse.criticalErrorMessage) {
|
|
53
|
-
output.error({
|
|
54
|
-
title: 'Distributed Execution Terminated',
|
|
55
|
-
bodyLines: ['Error:', apiResponse.criticalErrorMessage],
|
|
56
|
-
});
|
|
57
|
-
process.exit(0);
|
|
58
|
-
}
|
|
59
|
-
// run group is completed but it might be a rerun
|
|
60
|
-
// we will try several times before going further and
|
|
61
|
-
// completed the response
|
|
62
|
-
// we only do it if we haven't executed any tasks
|
|
63
|
-
if ((apiResponse === null || apiResponse === void 0 ? void 0 : apiResponse.retryDuring) &&
|
|
64
|
-
(apiResponse === null || apiResponse === void 0 ? void 0 : apiResponse.retryDuring) !== 0 &&
|
|
65
|
-
!executedAnyTasks &&
|
|
66
|
-
new Date().getTime() - startTime.getTime() > apiResponse.retryDuring) {
|
|
67
|
-
yield waiter.wait();
|
|
68
|
-
continue;
|
|
69
|
-
}
|
|
70
|
-
if (apiResponse.completed)
|
|
71
|
-
return;
|
|
72
|
-
failIfSameTasksIn30Mins(apiResponse.tasks.map((t) => t.taskId).join(''));
|
|
73
|
-
if (!apiResponse.executionId) {
|
|
74
|
-
if (environment_1.VERBOSE_LOGGING) {
|
|
75
|
-
output.note({
|
|
76
|
-
title: 'Waiting...',
|
|
77
|
-
});
|
|
78
|
-
}
|
|
79
|
-
yield waiter.wait();
|
|
80
|
-
completedStatusCode = 0;
|
|
81
|
-
completedTasks = [];
|
|
82
|
-
continue;
|
|
83
|
-
}
|
|
84
|
-
waiter.reset();
|
|
85
|
-
executedAnyTasks = true;
|
|
86
|
-
const r = invokeTasksUsingRunMany(options, apiResponse.executionId, apiResponse.tasks, apiResponse.maxParallel);
|
|
87
|
-
completedStatusCode = r.completedStatusCode;
|
|
88
|
-
completedTasks = r.completedTasks;
|
|
89
|
-
}
|
|
90
|
-
});
|
|
91
|
-
}
|
|
92
|
-
function readCompletedTasks(options, distributedExecutionId) {
|
|
93
|
-
const errorMessage = `Command execution failed (distributed task execution: ${distributedExecutionId}). Tasks hashes haven\'t been recorded.`;
|
|
94
|
-
let completedTasks;
|
|
95
|
-
try {
|
|
96
|
-
const cacheDirectory = options.cacheDirectory || './node_modules/.cache/nx';
|
|
97
|
-
const taskHashesFile = `${cacheDirectory}/tasks-hashes-${distributedExecutionId}`;
|
|
98
|
-
completedTasks = JSON.parse((0, fs_1.readFileSync)(taskHashesFile).toString());
|
|
99
|
-
// remove it such that if the next command crashes we don't read an obsolete file
|
|
100
|
-
(0, fs_1.unlinkSync)(taskHashesFile);
|
|
101
|
-
}
|
|
102
|
-
catch (e) {
|
|
103
|
-
throw new Error(errorMessage);
|
|
104
|
-
}
|
|
105
|
-
if (completedTasks.length == 0) {
|
|
106
|
-
throw new Error(errorMessage);
|
|
107
|
-
}
|
|
108
|
-
return completedTasks;
|
|
109
|
-
}
|
|
110
|
-
function invokeTasksUsingRunMany(options, executionId, tasks, maxParallel) {
|
|
111
|
-
let completedStatusCode = 0;
|
|
112
|
-
const completedTasks = [];
|
|
113
|
-
for (const g of groupByTarget(tasks)) {
|
|
114
|
-
const config = g.configuration ? `--configuration=${g.configuration}` : ``;
|
|
115
|
-
const parallel = maxParallel > 1 ? ` --parallel --max-parallel=${maxParallel}` : ``;
|
|
116
|
-
// TODO use pnpx or yarn when needed
|
|
117
|
-
const command = `npx nx run-many --target=${g.target} ${config} --projects=${g.projects.join(',')} ${g.params}${parallel}`;
|
|
118
|
-
if (environment_1.VERBOSE_LOGGING) {
|
|
119
|
-
output.note({
|
|
120
|
-
title: `Executing: '${command}'`,
|
|
121
|
-
});
|
|
122
|
-
}
|
|
123
|
-
try {
|
|
124
|
-
(0, child_process_1.execSync)(command, {
|
|
125
|
-
stdio: ['inherit', 'inherit', 'inherit'],
|
|
126
|
-
env: Object.assign(Object.assign({}, process.env), { NX_CACHE_FAILURES: 'true', NX_CLOUD_DISTRIBUTED_EXECUTION_ID: executionId }),
|
|
127
|
-
});
|
|
128
|
-
}
|
|
129
|
-
catch (e) {
|
|
130
|
-
if (e.status === environment_1.DISTRIBUTED_TASK_EXECUTION_INTERNAL_ERROR_STATUS_CODE) {
|
|
131
|
-
throw e;
|
|
132
|
-
}
|
|
133
|
-
else {
|
|
134
|
-
completedStatusCode = 1;
|
|
135
|
-
}
|
|
136
|
-
}
|
|
137
|
-
finally {
|
|
138
|
-
completedTasks.push(...readCompletedTasks(options, executionId));
|
|
139
|
-
}
|
|
140
|
-
}
|
|
141
|
-
return { completedStatusCode, completedTasks };
|
|
142
|
-
}
|
|
143
|
-
function groupByTarget(tasks) {
|
|
144
|
-
const res = [];
|
|
145
|
-
tasks.forEach((t) => {
|
|
146
|
-
const r = res.find((rr) => rr.target === t.target && rr.configuration === t.configuration);
|
|
147
|
-
if (r) {
|
|
148
|
-
r.projects.push(t.projectName);
|
|
149
|
-
}
|
|
150
|
-
else {
|
|
151
|
-
res.push({
|
|
152
|
-
target: t.target,
|
|
153
|
-
projects: [t.projectName],
|
|
154
|
-
params: t.params,
|
|
155
|
-
configuration: t.configuration,
|
|
156
|
-
});
|
|
157
|
-
}
|
|
158
|
-
});
|
|
159
|
-
return res;
|
|
160
|
-
}
|
|
161
|
-
function getAgentName() {
|
|
162
|
-
if (process.env.NX_AGENT_NAME !== undefined) {
|
|
163
|
-
return process.env.NX_AGENT_NAME;
|
|
164
|
-
}
|
|
165
|
-
else if (process.env.CIRCLECI !== undefined) {
|
|
166
|
-
return process.env.CIRCLE_STAGE;
|
|
167
|
-
}
|
|
168
|
-
else {
|
|
169
|
-
return `Agent ${Math.floor(Math.random() * 100000)}`;
|
|
170
|
-
}
|
|
171
|
-
}
|
|
172
|
-
function createAgentLockfile(options, agentName) {
|
|
173
|
-
const cacheDirectory = options.cacheDirectory || './node_modules/.cache/nx';
|
|
174
|
-
const lockFileDirectory = `${cacheDirectory}/lockfiles`;
|
|
175
|
-
const lockFilePath = `${lockFileDirectory}/${agentName}.lock`;
|
|
176
|
-
if (!(0, fs_1.existsSync)(lockFileDirectory)) {
|
|
177
|
-
(0, fs_1.mkdirSync)(lockFileDirectory, { recursive: true });
|
|
178
|
-
}
|
|
179
|
-
// Check for other agents' lockfiles and warn if exist
|
|
180
|
-
const lockFiles = (0, fs_1.readdirSync)(lockFileDirectory);
|
|
181
|
-
if (lockFiles.length) {
|
|
182
|
-
// Check to make sure the current agent name is not in use (only 1/100000 ^ 2 chance of this)
|
|
183
|
-
if (lockFiles.includes(`${agentName}.lock`)) {
|
|
184
|
-
output.error({
|
|
185
|
-
title: 'Duplicate Agent ID Detected',
|
|
186
|
-
bodyLines: [
|
|
187
|
-
'We have detected another agent with this ID running in this workspace. This should not happen.',
|
|
188
|
-
'',
|
|
189
|
-
'End all currently running agents, run "npx nx-cloud clean-up-agents", and try again.',
|
|
190
|
-
],
|
|
191
|
-
});
|
|
192
|
-
process.exit(1);
|
|
193
|
-
}
|
|
194
|
-
output.warn({
|
|
195
|
-
title: 'Other Nx Cloud Agents Detected',
|
|
196
|
-
bodyLines: [
|
|
197
|
-
'We have detected other agents running in this workspace. This can cause unexpected behavior.',
|
|
198
|
-
'',
|
|
199
|
-
'This can also be a false positive caused by agents that did not shut down correctly.',
|
|
200
|
-
'If you believe this is the case, run "npx nx-cloud clean-up-agents".',
|
|
201
|
-
],
|
|
202
|
-
});
|
|
203
|
-
}
|
|
204
|
-
(0, fs_1.writeFileSync)(lockFilePath, '');
|
|
205
|
-
process.on('exit', () => cleanupAgentLockfile(lockFilePath));
|
|
206
|
-
process.on('SIGINT', () => cleanupAgentLockfile(lockFilePath));
|
|
207
|
-
}
|
|
208
|
-
function cleanupAgentLockfile(lockFilePath) {
|
|
209
|
-
if ((0, fs_1.existsSync)(lockFilePath)) {
|
|
210
|
-
(0, fs_1.unlinkSync)(lockFilePath);
|
|
211
|
-
}
|
|
212
|
-
}
|
|
213
|
-
function startAgent() {
|
|
214
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
215
|
-
const runGroup = (0, environment_1.getRunGroup)();
|
|
216
|
-
if (!runGroup) {
|
|
217
|
-
(0, print_run_group_error_1.printRunGroupError)();
|
|
218
|
-
return process.exit(1);
|
|
219
|
-
}
|
|
220
|
-
output.note({
|
|
221
|
-
title: 'Starting an agent for running Nx tasks',
|
|
222
|
-
});
|
|
223
|
-
const options = JSON.parse(stripJsonComments((0, fs_1.readFileSync)('nx.json').toString())).tasksRunnerOptions.default.options;
|
|
224
|
-
const agentName = getAgentName();
|
|
225
|
-
createAgentLockfile(options, agentName);
|
|
226
|
-
const api = new distributed_agent_api_1.DistributedAgentApi(options, runGroup, agentName);
|
|
227
|
-
return executeTasks(options, api)
|
|
228
|
-
.then((res) => __awaiter(this, void 0, void 0, function* () {
|
|
229
|
-
yield (0, metric_logger_1.submitRunMetrics)(options);
|
|
230
|
-
return res;
|
|
231
|
-
}))
|
|
232
|
-
.catch((e) => __awaiter(this, void 0, void 0, function* () {
|
|
233
|
-
yield api.completeRunGroupWithError(`Critical Error in Agent: "${e.message}"`);
|
|
234
|
-
throw e;
|
|
235
|
-
}));
|
|
236
|
-
});
|
|
237
|
-
}
|
|
238
|
-
exports.startAgent = startAgent;
|
|
239
|
-
//# sourceMappingURL=distributed-agent.impl.js.map
|
|
1
|
+
const a5_0x1d19=['/tasks-hashes-','strip-json-comments','\x20--parallel\x20--max-parallel=','NX_AGENT_NAME','target','Critical\x20Error\x20in\x20Agent:\x20\x22','options','This\x20can\x20also\x20be\x20a\x20false\x20positive\x20caused\x20by\x20agents\x20that\x20did\x20not\x20shut\x20down\x20correctly.','../../error/print-run-group-error','\x20--projects=','readdirSync','execSync','getTime','number\x20of\x20tasks:\x20','If\x20you\x20believe\x20this\x20is\x20the\x20case,\x20run\x20\x22npx\x20nx-cloud\x20clean-up-agents\x22.','error','params','--configuration=','inherit','readFileSync','Duplicate\x20Agent\x20ID\x20Detected','startAgent','We\x20have\x20detected\x20another\x20agent\x20with\x20this\x20ID\x20running\x20in\x20this\x20workspace.\x20This\x20should\x20not\x20happen.','wait','Waiting...','note','completedStatusCode','Other\x20Nx\x20Cloud\x20Agents\x20Detected','__esModule','message','writeFileSync','./distributed-agent.api','projects','maxParallel:\x20','../../../utilities/waiter','mkdirSync','status','./node_modules/.cache/nx','value','completeRunGroupWithError','executionId','toString','We\x20have\x20detected\x20other\x20agents\x20running\x20in\x20this\x20workspace.\x20This\x20can\x20cause\x20unexpected\x20behavior.','true','Command\x20execution\x20failed\x20(distributed\x20task\x20execution:\x20','Agent\x20','../../../utilities/nx-imports','tasks','../../../utilities/create-no-new-messages-timeout','retryDuring:\x20','maxParallel','completed','Waiter','projectName','Executing:\x20\x27','unlinkSync','then','next','forEach','VERBOSE_LOGGING','DistributedAgentApi','defineProperty','apply','DISTRIBUTED_TASK_EXECUTION_INTERNAL_ERROR_STATUS_CODE','floor','API\x20Response','reset','length','find','throw','cacheDirectory','Fetching\x20tasks...','child_process','completedTasks','assign','tasksRunnerOptions','End\x20all\x20currently\x20running\x20agents,\x20run\x20\x22npx\x20nx-cloud\x20clean-up-agents\x22,\x20and\x20try\x20again.','/lockfiles','existsSync','../../../utilities/environment','criticalErrorMessage','env','.lock','CIRCLECI','map','configuration','random','retryDuring','Distributed\x20Execution\x20Terminated','SIGINT','__awaiter','exit','submitRunMetrics','includes','createNoNewMessagesTimeout','push','getRunGroup'];(function(_0x273a34,_0x1d195d){const _0x22fd70=function(_0x328a60){while(--_0x328a60){_0x273a34['push'](_0x273a34['shift']());}};_0x22fd70(++_0x1d195d);}(a5_0x1d19,0x108));const a5_0x22fd=function(_0x273a34,_0x1d195d){_0x273a34=_0x273a34-0x0;let _0x22fd70=a5_0x1d19[_0x273a34];return _0x22fd70;};'use strict';var __awaiter=this&&this[a5_0x22fd('0x14')]||function(_0x56ab32,_0xa4f178,_0x5e1b9a,_0x3b02fa){function _0x3720c3(_0x458a29){return _0x458a29 instanceof _0x5e1b9a?_0x458a29:new _0x5e1b9a(function(_0x198629){_0x198629(_0x458a29);});}return new(_0x5e1b9a||(_0x5e1b9a=Promise))(function(_0x2a527c,_0x400977){function _0x21b396(_0x45ea00){try{_0x4e88ea(_0x3b02fa[a5_0x22fd('0x54')](_0x45ea00));}catch(_0xf3542e){_0x400977(_0xf3542e);}}function _0x321d70(_0xdebb8f){try{_0x4e88ea(_0x3b02fa[a5_0x22fd('0x60')](_0xdebb8f));}catch(_0x1a86bf){_0x400977(_0x1a86bf);}}function _0x4e88ea(_0x3b4124){_0x3b4124['done']?_0x2a527c(_0x3b4124[a5_0x22fd('0x41')]):_0x3720c3(_0x3b4124['value'])[a5_0x22fd('0x53')](_0x21b396,_0x321d70);}_0x4e88ea((_0x3b02fa=_0x3b02fa[a5_0x22fd('0x59')](_0x56ab32,_0xa4f178||[]))['next']());});};Object[a5_0x22fd('0x58')](exports,a5_0x22fd('0x37'),{'value':!![]});exports['startAgent']=void 0x0;const child_process_1=require(a5_0x22fd('0x2'));const stripJsonComments=require(a5_0x22fd('0x1c'));const distributed_agent_api_1=require(a5_0x22fd('0x3a'));const waiter_1=require(a5_0x22fd('0x3d'));const environment_1=require(a5_0x22fd('0x9'));const print_run_group_error_1=require(a5_0x22fd('0x23'));const create_no_new_messages_timeout_1=require(a5_0x22fd('0x4b'));const fs_1=require('fs');const metric_logger_1=require('../../../utilities/metric-logger');const {output}=require(a5_0x22fd('0x49'));function executeTasks(_0x5542e6,_0x3759f3){return __awaiter(this,void 0x0,void 0x0,function*(){let _0x591718=0x0;let _0x5987c0=null;const _0x139891=(0x0,create_no_new_messages_timeout_1[a5_0x22fd('0x18')])();const _0x26bdf7=new waiter_1[(a5_0x22fd('0x4f'))]();let _0x59adcc=[];const _0x52c42b=new Date();let _0x2210a9=![];while(!![]){if(environment_1[a5_0x22fd('0x56')]){output[a5_0x22fd('0x34')]({'title':a5_0x22fd('0x1')});}_0x5987c0=yield _0x3759f3[a5_0x22fd('0x4a')](_0x5987c0?_0x5987c0[a5_0x22fd('0x43')]:null,_0x591718,_0x59adcc);if(environment_1[a5_0x22fd('0x56')]){output[a5_0x22fd('0x34')]({'title':a5_0x22fd('0x5c'),'bodyLines':['completed:\x20'+_0x5987c0[a5_0x22fd('0x4e')],a5_0x22fd('0x4c')+_0x5987c0[a5_0x22fd('0x11')],'executionId:\x20'+_0x5987c0['executionId'],a5_0x22fd('0x28')+_0x5987c0[a5_0x22fd('0x4a')][a5_0x22fd('0x5e')],'error:\x20'+_0x5987c0['criticalErrorMessage'],a5_0x22fd('0x3c')+_0x5987c0[a5_0x22fd('0x4d')]]});}if(_0x5987c0[a5_0x22fd('0xa')]){output['error']({'title':a5_0x22fd('0x12'),'bodyLines':['Error:',_0x5987c0[a5_0x22fd('0xa')]]});process[a5_0x22fd('0x15')](0x0);}if((_0x5987c0===null||_0x5987c0===void 0x0?void 0x0:_0x5987c0[a5_0x22fd('0x11')])&&(_0x5987c0===null||_0x5987c0===void 0x0?void 0x0:_0x5987c0[a5_0x22fd('0x11')])!==0x0&&!_0x2210a9&&new Date()[a5_0x22fd('0x27')]()-_0x52c42b[a5_0x22fd('0x27')]()>_0x5987c0[a5_0x22fd('0x11')]){yield _0x26bdf7['wait']();continue;}if(_0x5987c0[a5_0x22fd('0x4e')])return;_0x139891(_0x5987c0['tasks'][a5_0x22fd('0xe')](_0x23f628=>_0x23f628['taskId'])['join'](''));if(!_0x5987c0['executionId']){if(environment_1['VERBOSE_LOGGING']){output[a5_0x22fd('0x34')]({'title':a5_0x22fd('0x33')});}yield _0x26bdf7[a5_0x22fd('0x32')]();_0x591718=0x0;_0x59adcc=[];continue;}_0x26bdf7[a5_0x22fd('0x5d')]();_0x2210a9=!![];const _0x47c7d6=invokeTasksUsingRunMany(_0x5542e6,_0x5987c0[a5_0x22fd('0x43')],_0x5987c0['tasks'],_0x5987c0[a5_0x22fd('0x4d')]);_0x591718=_0x47c7d6[a5_0x22fd('0x35')];_0x59adcc=_0x47c7d6[a5_0x22fd('0x3')];}});}function readCompletedTasks(_0x142286,_0x2a3a89){const _0x49469c=a5_0x22fd('0x47')+_0x2a3a89+').\x20Tasks\x20hashes\x20haven\x27t\x20been\x20recorded.';let _0x523882;try{const _0x15e85a=_0x142286[a5_0x22fd('0x0')]||'./node_modules/.cache/nx';const _0xf98d59=_0x15e85a+a5_0x22fd('0x1b')+_0x2a3a89;_0x523882=JSON['parse']((0x0,fs_1[a5_0x22fd('0x2e')])(_0xf98d59)[a5_0x22fd('0x44')]());(0x0,fs_1['unlinkSync'])(_0xf98d59);}catch(_0x35489e){throw new Error(_0x49469c);}if(_0x523882[a5_0x22fd('0x5e')]==0x0){throw new Error(_0x49469c);}return _0x523882;}function invokeTasksUsingRunMany(_0xe64b75,_0x3523f6,_0x238a2,_0x585a66){let _0x3dc286=0x0;const _0x46a634=[];for(const _0x259e30 of groupByTarget(_0x238a2)){const _0x3c565a=_0x259e30[a5_0x22fd('0xf')]?a5_0x22fd('0x2c')+_0x259e30['configuration']:'';const _0x22ebd6=_0x585a66>0x1?a5_0x22fd('0x1d')+_0x585a66:'';const _0x53108e='npx\x20nx\x20run-many\x20--target='+_0x259e30[a5_0x22fd('0x1f')]+'\x20'+_0x3c565a+a5_0x22fd('0x24')+_0x259e30[a5_0x22fd('0x3b')]['join'](',')+'\x20'+_0x259e30[a5_0x22fd('0x2b')]+_0x22ebd6;if(environment_1[a5_0x22fd('0x56')]){output[a5_0x22fd('0x34')]({'title':a5_0x22fd('0x51')+_0x53108e+'\x27'});}try{(0x0,child_process_1[a5_0x22fd('0x26')])(_0x53108e,{'stdio':[a5_0x22fd('0x2d'),a5_0x22fd('0x2d'),a5_0x22fd('0x2d')],'env':Object[a5_0x22fd('0x4')](Object[a5_0x22fd('0x4')]({},process['env']),{'NX_CACHE_FAILURES':a5_0x22fd('0x46'),'NX_CLOUD_DISTRIBUTED_EXECUTION_ID':_0x3523f6})});}catch(_0x13f5b0){if(_0x13f5b0[a5_0x22fd('0x3f')]===environment_1[a5_0x22fd('0x5a')]){throw _0x13f5b0;}else{_0x3dc286=0x1;}}finally{_0x46a634[a5_0x22fd('0x19')](...readCompletedTasks(_0xe64b75,_0x3523f6));}}return{'completedStatusCode':_0x3dc286,'completedTasks':_0x46a634};}function groupByTarget(_0x143134){const _0x1780dd=[];_0x143134[a5_0x22fd('0x55')](_0x2e5d8d=>{const _0x5e2b82=_0x1780dd[a5_0x22fd('0x5f')](_0x3caa26=>_0x3caa26[a5_0x22fd('0x1f')]===_0x2e5d8d[a5_0x22fd('0x1f')]&&_0x3caa26[a5_0x22fd('0xf')]===_0x2e5d8d[a5_0x22fd('0xf')]);if(_0x5e2b82){_0x5e2b82['projects']['push'](_0x2e5d8d[a5_0x22fd('0x50')]);}else{_0x1780dd['push']({'target':_0x2e5d8d[a5_0x22fd('0x1f')],'projects':[_0x2e5d8d['projectName']],'params':_0x2e5d8d['params'],'configuration':_0x2e5d8d[a5_0x22fd('0xf')]});}});return _0x1780dd;}function getAgentName(){if(process['env'][a5_0x22fd('0x1e')]!==undefined){return process[a5_0x22fd('0xb')]['NX_AGENT_NAME'];}else if(process[a5_0x22fd('0xb')][a5_0x22fd('0xd')]!==undefined){return process[a5_0x22fd('0xb')]['CIRCLE_STAGE'];}else{return a5_0x22fd('0x48')+Math[a5_0x22fd('0x5b')](Math[a5_0x22fd('0x10')]()*0x186a0);}}function createAgentLockfile(_0xa18e4c,_0xb12c26){const _0x5b92d9=_0xa18e4c[a5_0x22fd('0x0')]||a5_0x22fd('0x40');const _0xf6818b=_0x5b92d9+a5_0x22fd('0x7');const _0x99983f=_0xf6818b+'/'+_0xb12c26+a5_0x22fd('0xc');if(!(0x0,fs_1[a5_0x22fd('0x8')])(_0xf6818b)){(0x0,fs_1[a5_0x22fd('0x3e')])(_0xf6818b,{'recursive':!![]});}const _0x416ed9=(0x0,fs_1[a5_0x22fd('0x25')])(_0xf6818b);if(_0x416ed9[a5_0x22fd('0x5e')]){if(_0x416ed9[a5_0x22fd('0x17')](_0xb12c26+a5_0x22fd('0xc'))){output[a5_0x22fd('0x2a')]({'title':a5_0x22fd('0x2f'),'bodyLines':[a5_0x22fd('0x31'),'',a5_0x22fd('0x6')]});process[a5_0x22fd('0x15')](0x1);}output['warn']({'title':a5_0x22fd('0x36'),'bodyLines':[a5_0x22fd('0x45'),'',a5_0x22fd('0x22'),a5_0x22fd('0x29')]});}(0x0,fs_1[a5_0x22fd('0x39')])(_0x99983f,'');process['on']('exit',()=>cleanupAgentLockfile(_0x99983f));process['on'](a5_0x22fd('0x13'),()=>cleanupAgentLockfile(_0x99983f));}function cleanupAgentLockfile(_0x3f6926){if((0x0,fs_1['existsSync'])(_0x3f6926)){(0x0,fs_1[a5_0x22fd('0x52')])(_0x3f6926);}}function startAgent(){return __awaiter(this,void 0x0,void 0x0,function*(){const _0x4b9411=(0x0,environment_1[a5_0x22fd('0x1a')])();if(!_0x4b9411){(0x0,print_run_group_error_1['printRunGroupError'])();return process[a5_0x22fd('0x15')](0x1);}output[a5_0x22fd('0x34')]({'title':'Starting\x20an\x20agent\x20for\x20running\x20Nx\x20tasks'});const _0x57b0f3=JSON['parse'](stripJsonComments((0x0,fs_1['readFileSync'])('nx.json')[a5_0x22fd('0x44')]()))[a5_0x22fd('0x5')]['default'][a5_0x22fd('0x21')];const _0x1f35c6=getAgentName();createAgentLockfile(_0x57b0f3,_0x1f35c6);const _0x5583a3=new distributed_agent_api_1[(a5_0x22fd('0x57'))](_0x57b0f3,_0x4b9411,_0x1f35c6);return executeTasks(_0x57b0f3,_0x5583a3)['then'](_0x5bc62d=>__awaiter(this,void 0x0,void 0x0,function*(){yield(0x0,metric_logger_1[a5_0x22fd('0x16')])(_0x57b0f3);return _0x5bc62d;}))['catch'](_0x442115=>__awaiter(this,void 0x0,void 0x0,function*(){yield _0x5583a3[a5_0x22fd('0x42')](a5_0x22fd('0x20')+_0x442115[a5_0x22fd('0x38')]+'\x22');throw _0x442115;}));});}exports[a5_0x22fd('0x30')]=startAgent;
|