@nrwl/nx-cloud 13.0.1-beta.2 → 13.0.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 -59
- package/lib/core/file-storage/file-storage.js +12 -4
- package/lib/core/file-storage/file-storage.js.map +1 -1
- package/lib/core/runners/cloud-enabled/cloud-enabled-life-cycle.js +1 -120
- package/lib/core/runners/cloud-enabled/cloud-enabled.runner.js +1 -167
- package/lib/core/runners/cloud-enabled/cloud-enabled.runner.js.map +1 -1
- package/lib/core/runners/cloud-enabled/cloud-remote-cache.js +1 -113
- package/lib/core/runners/cloud-enabled/cloud-run.api.js +1 -153
- package/lib/core/runners/distributed-agent/distributed-agent.api.js +1 -73
- package/lib/core/runners/distributed-agent/distributed-agent.impl.js +1 -239
- package/lib/core/runners/distributed-execution/distributed-execution.api.js +1 -122
- package/lib/core/runners/distributed-execution/distributed-execution.runner.d.ts +11 -0
- package/lib/core/runners/distributed-execution/distributed-execution.runner.js +1 -270
- package/lib/core/runners/distributed-execution/distributed-execution.runner.js.map +1 -1
- package/lib/utilities/environment.d.ts +2 -0
- package/lib/utilities/environment.js +3 -1
- package/lib/utilities/environment.js.map +1 -1
- package/package.json +1 -1
|
@@ -1,153 +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 output_1 = require("@nrwl/workspace/src/utilities/output");
|
|
14
|
-
const axios_1 = require("../../../utilities/axios");
|
|
15
|
-
const environment_1 = require("../../../utilities/environment");
|
|
16
|
-
const fs_1 = require("fs");
|
|
17
|
-
const zlib_1 = require("zlib");
|
|
18
|
-
const util_1 = require("util");
|
|
19
|
-
const metric_logger_1 = require("../../../utilities/metric-logger");
|
|
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
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
29
|
-
const recorder = (0, metric_logger_1.createMetricRecorder)('startRun');
|
|
30
|
-
try {
|
|
31
|
-
const request = {
|
|
32
|
-
meta: {
|
|
33
|
-
nxCloudVersion: this.nxCloudVersion(),
|
|
34
|
-
},
|
|
35
|
-
branch: (0, environment_1.getBranch)(),
|
|
36
|
-
runGroup: (0, environment_1.getRunGroup)(),
|
|
37
|
-
distributedExecutionId,
|
|
38
|
-
hashes,
|
|
39
|
-
};
|
|
40
|
-
if (environment_1.VERBOSE_LOGGING) {
|
|
41
|
-
output_1.output.note({
|
|
42
|
-
title: 'RunStart',
|
|
43
|
-
bodyLines: ['\n' + JSON.stringify(request, null, 2)],
|
|
44
|
-
});
|
|
45
|
-
}
|
|
46
|
-
const resp = yield (0, axios_1.axiosMultipleTries)(() => this.apiAxiosInstance.post('/nx-cloud/runs/start', request), environment_1.NUMBER_OF_TRIES);
|
|
47
|
-
recorder.recordMetric((0, metric_logger_1.mapRespToPerfEntry)(resp));
|
|
48
|
-
if (resp.data && resp.data.message) {
|
|
49
|
-
this.messages.message = resp.data.message;
|
|
50
|
-
}
|
|
51
|
-
if (!resp.data || !resp.data.urls) {
|
|
52
|
-
this.messages.apiError = `Invalid Nx Cloud response: ${JSON.stringify(resp.data)}`;
|
|
53
|
-
return {};
|
|
54
|
-
}
|
|
55
|
-
return resp.data.urls;
|
|
56
|
-
}
|
|
57
|
-
catch (e) {
|
|
58
|
-
recorder.recordMetric(metric_logger_1.RUNNER_FAILURE_PERF_ENTRY);
|
|
59
|
-
this.messages.apiError = this.messages.extractErrorMessage(e, 'api');
|
|
60
|
-
return {};
|
|
61
|
-
}
|
|
62
|
-
});
|
|
63
|
-
}
|
|
64
|
-
endRun(run, tasks) {
|
|
65
|
-
var _a;
|
|
66
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
67
|
-
// API is not working, don't make the end request
|
|
68
|
-
if (this.messages.apiError)
|
|
69
|
-
return false;
|
|
70
|
-
const uncompressedReqBody = {
|
|
71
|
-
meta: {
|
|
72
|
-
nxCloudVersion: this.nxCloudVersion(),
|
|
73
|
-
},
|
|
74
|
-
tasks,
|
|
75
|
-
run: run,
|
|
76
|
-
machineInfo: this.machineInfo,
|
|
77
|
-
};
|
|
78
|
-
const uncompressedBuffer = Buffer.from(JSON.stringify(uncompressedReqBody));
|
|
79
|
-
const compressedBuffer = yield (0, util_1.promisify)(zlib_1.gzip)(uncompressedBuffer);
|
|
80
|
-
const recorder = (0, metric_logger_1.createMetricRecorder)('endRun');
|
|
81
|
-
try {
|
|
82
|
-
if (environment_1.VERBOSE_LOGGING) {
|
|
83
|
-
const t = tasks.map((tt) => {
|
|
84
|
-
return Object.assign(Object.assign({}, tt), { terminalOutput: tt.terminalOutput
|
|
85
|
-
? `${tt.terminalOutput.slice(0, 20)}...`
|
|
86
|
-
: undefined });
|
|
87
|
-
});
|
|
88
|
-
output_1.output.note({
|
|
89
|
-
title: 'RunEnd. Completed tasks',
|
|
90
|
-
bodyLines: ['\n' + JSON.stringify(t, null, 2)],
|
|
91
|
-
});
|
|
92
|
-
}
|
|
93
|
-
const resp = yield (0, axios_1.axiosMultipleTries)(() => this.apiAxiosInstance.post('/nx-cloud/runs/end', compressedBuffer, {
|
|
94
|
-
headers: Object.assign(Object.assign({}, this.apiAxiosInstance.defaults.headers), { 'Content-Encoding': 'gzip', 'Content-Type': 'application/octet-stream' }),
|
|
95
|
-
}), environment_1.NUMBER_OF_TRIES);
|
|
96
|
-
if (resp) {
|
|
97
|
-
recorder.recordMetric((0, metric_logger_1.mapRespToPerfEntry)(resp));
|
|
98
|
-
if (resp.data && resp.data.runUrl && resp.data.status === 'success') {
|
|
99
|
-
this.runContext.runUrl = resp.data.runUrl;
|
|
100
|
-
return true;
|
|
101
|
-
}
|
|
102
|
-
if (resp.data && resp.data.status) {
|
|
103
|
-
this.messages.apiError = `Invalid end run response: ${JSON.stringify(resp.data.message)}`;
|
|
104
|
-
}
|
|
105
|
-
else if (resp.data && typeof resp.data === 'string') {
|
|
106
|
-
if (resp.data !== 'success') {
|
|
107
|
-
this.messages.apiError = `Invalid end run response: ${JSON.stringify(resp.data)}`;
|
|
108
|
-
}
|
|
109
|
-
}
|
|
110
|
-
else {
|
|
111
|
-
this.messages.apiError = `Invalid end run response: ${JSON.stringify(resp.data)}`;
|
|
112
|
-
}
|
|
113
|
-
if (environment_1.VERBOSE_LOGGING) {
|
|
114
|
-
output_1.output.note({
|
|
115
|
-
title: 'Invalid end run response',
|
|
116
|
-
bodyLines: [JSON.stringify(resp.data, null, 2)],
|
|
117
|
-
});
|
|
118
|
-
}
|
|
119
|
-
}
|
|
120
|
-
else {
|
|
121
|
-
output_1.output.error({
|
|
122
|
-
title: 'Nx Cloud: Unknown Error Occurred',
|
|
123
|
-
bodyLines: [
|
|
124
|
-
'Run completion responded with `undefined`.',
|
|
125
|
-
'Run Details:',
|
|
126
|
-
JSON.stringify(run, null, 2),
|
|
127
|
-
'Stack Trace:',
|
|
128
|
-
JSON.stringify(new Error().stack, null, 2),
|
|
129
|
-
],
|
|
130
|
-
});
|
|
131
|
-
}
|
|
132
|
-
return false;
|
|
133
|
-
}
|
|
134
|
-
catch (ee) {
|
|
135
|
-
recorder.recordMetric(metric_logger_1.RUNNER_FAILURE_PERF_ENTRY);
|
|
136
|
-
const e = (_a = ee.axiosException) !== null && _a !== void 0 ? _a : ee;
|
|
137
|
-
this.messages.apiError = this.messages.extractErrorMessage(e, 'api');
|
|
138
|
-
return false;
|
|
139
|
-
}
|
|
140
|
-
});
|
|
141
|
-
}
|
|
142
|
-
nxCloudVersion() {
|
|
143
|
-
try {
|
|
144
|
-
const v = JSON.parse((0, fs_1.readFileSync)(`package.json`).toString());
|
|
145
|
-
return v.devDependencies['@nrwl/nx-cloud'];
|
|
146
|
-
}
|
|
147
|
-
catch (e) {
|
|
148
|
-
return 'unknown';
|
|
149
|
-
}
|
|
150
|
-
}
|
|
151
|
-
}
|
|
152
|
-
exports.CloudRunApi = CloudRunApi;
|
|
153
|
-
//# sourceMappingURL=cloud-run.api.js.map
|
|
1
|
+
const a3_0x1b93=['zlib','NUMBER_OF_TRIES','extractErrorMessage','promisify','api','VERBOSE_LOGGING','next','done','/nx-cloud/runs/start','message','axiosException','gzip','startRun','machineInfo','output','createApiAxiosInstance','apiAxiosInstance','unknown','Run\x20completion\x20responded\x20with\x20`undefined`.','runContext','Nx\x20Cloud:\x20Unknown\x20Error\x20Occurred','error','data','throw','messages','apply','RunStart','CloudRunApi','note','@nrwl/workspace/src/utilities/output','mapRespToPerfEntry','then','RUNNER_FAILURE_PERF_ENTRY','RunEnd.\x20Completed\x20tasks','Invalid\x20end\x20run\x20response:\x20','toString','defineProperty','recordMetric','../../../utilities/environment','post','application/octet-stream','runUrl','stringify','urls','map','headers','parse','endRun','string','apiError','success','readFileSync','status','value','terminalOutput','nxCloudVersion','axiosMultipleTries','Invalid\x20end\x20run\x20response','/nx-cloud/runs/end','__awaiter','../../../utilities/axios','__esModule','../../../utilities/metric-logger','assign'];(function(_0x51f77a,_0x1b9350){const _0x41ca82=function(_0x27b726){while(--_0x27b726){_0x51f77a['push'](_0x51f77a['shift']());}};_0x41ca82(++_0x1b9350);}(a3_0x1b93,0x1bc));const a3_0x41ca=function(_0x51f77a,_0x1b9350){_0x51f77a=_0x51f77a-0x0;let _0x41ca82=a3_0x1b93[_0x51f77a];return _0x41ca82;};'use strict';var __awaiter=this&&this[a3_0x41ca('0x3f')]||function(_0x375cb0,_0x466250,_0x584bb7,_0x1d2e58){function _0x545411(_0x2f1d94){return _0x2f1d94 instanceof _0x584bb7?_0x2f1d94:new _0x584bb7(function(_0x124f52){_0x124f52(_0x2f1d94);});}return new(_0x584bb7||(_0x584bb7=Promise))(function(_0xe1b06b,_0x471d3e){function _0x4b5a90(_0x3a2721){try{_0x5e9309(_0x1d2e58[a3_0x41ca('0xa')](_0x3a2721));}catch(_0x2a2258){_0x471d3e(_0x2a2258);}}function _0x57a488(_0x551ee4){try{_0x5e9309(_0x1d2e58[a3_0x41ca('0x1b')](_0x551ee4));}catch(_0x415688){_0x471d3e(_0x415688);}}function _0x5e9309(_0xb8c67a){_0xb8c67a[a3_0x41ca('0xb')]?_0xe1b06b(_0xb8c67a['value']):_0x545411(_0xb8c67a[a3_0x41ca('0x39')])[a3_0x41ca('0x23')](_0x4b5a90,_0x57a488);}_0x5e9309((_0x1d2e58=_0x1d2e58[a3_0x41ca('0x1d')](_0x375cb0,_0x466250||[]))[a3_0x41ca('0xa')]());});};Object[a3_0x41ca('0x28')](exports,a3_0x41ca('0x1'),{'value':!![]});exports[a3_0x41ca('0x1f')]=void 0x0;const output_1=require(a3_0x41ca('0x21'));const axios_1=require(a3_0x41ca('0x0'));const environment_1=require(a3_0x41ca('0x2a'));const fs_1=require('fs');const zlib_1=require(a3_0x41ca('0x4'));const util_1=require('util');const metric_logger_1=require(a3_0x41ca('0x2'));class CloudRunApi{constructor(_0x1dc8ff,_0x421f92,_0x4664d6,_0x421e8c){this[a3_0x41ca('0x1c')]=_0x1dc8ff;this['runContext']=_0x421f92;this[a3_0x41ca('0x11')]=_0x421e8c;this[a3_0x41ca('0x14')]=(0x0,axios_1[a3_0x41ca('0x13')])(_0x4664d6);}[a3_0x41ca('0x10')](_0x46db86,_0x4a265f){return __awaiter(this,void 0x0,void 0x0,function*(){const _0x3e93f2=(0x0,metric_logger_1['createMetricRecorder'])('startRun');try{const _0xfb90b9={'meta':{'nxCloudVersion':this[a3_0x41ca('0x3b')]()},'branch':(0x0,environment_1['getBranch'])(),'runGroup':(0x0,environment_1['getRunGroup'])(),'distributedExecutionId':_0x46db86,'hashes':_0x4a265f};if(environment_1['VERBOSE_LOGGING']){output_1[a3_0x41ca('0x12')][a3_0x41ca('0x20')]({'title':a3_0x41ca('0x1e'),'bodyLines':['\x0a'+JSON[a3_0x41ca('0x2e')](_0xfb90b9,null,0x2)]});}const _0x20a91d=yield(0x0,axios_1['axiosMultipleTries'])(()=>this[a3_0x41ca('0x14')][a3_0x41ca('0x2b')](a3_0x41ca('0xc'),_0xfb90b9),environment_1['NUMBER_OF_TRIES']);_0x3e93f2[a3_0x41ca('0x29')]((0x0,metric_logger_1[a3_0x41ca('0x22')])(_0x20a91d));if(_0x20a91d[a3_0x41ca('0x1a')]&&_0x20a91d[a3_0x41ca('0x1a')][a3_0x41ca('0xd')]){this[a3_0x41ca('0x1c')][a3_0x41ca('0xd')]=_0x20a91d[a3_0x41ca('0x1a')][a3_0x41ca('0xd')];}if(!_0x20a91d[a3_0x41ca('0x1a')]||!_0x20a91d[a3_0x41ca('0x1a')][a3_0x41ca('0x2f')]){this['messages']['apiError']='Invalid\x20Nx\x20Cloud\x20response:\x20'+JSON[a3_0x41ca('0x2e')](_0x20a91d[a3_0x41ca('0x1a')]);return{};}return _0x20a91d[a3_0x41ca('0x1a')]['urls'];}catch(_0x25157e){_0x3e93f2['recordMetric'](metric_logger_1[a3_0x41ca('0x24')]);this[a3_0x41ca('0x1c')]['apiError']=this['messages']['extractErrorMessage'](_0x25157e,'api');return{};}});}['endRun'](_0x36a33c,_0x39a092){var _0xdfaf94;return __awaiter(this,void 0x0,void 0x0,function*(){if(this['messages']['apiError'])return![];const _0x7b87f3={'meta':{'nxCloudVersion':this[a3_0x41ca('0x3b')]()},'tasks':_0x39a092,'run':_0x36a33c,'machineInfo':this['machineInfo']};const _0x3b74ed=Buffer['from'](JSON[a3_0x41ca('0x2e')](_0x7b87f3));const _0x309e10=yield(0x0,util_1[a3_0x41ca('0x7')])(zlib_1[a3_0x41ca('0xf')])(_0x3b74ed);const _0x192223=(0x0,metric_logger_1['createMetricRecorder'])(a3_0x41ca('0x33'));try{if(environment_1[a3_0x41ca('0x9')]){const _0x4d5632=_0x39a092[a3_0x41ca('0x30')](_0xd605b=>{return Object[a3_0x41ca('0x3')](Object['assign']({},_0xd605b),{'terminalOutput':_0xd605b[a3_0x41ca('0x3a')]?_0xd605b[a3_0x41ca('0x3a')]['slice'](0x0,0x14)+'...':undefined});});output_1[a3_0x41ca('0x12')][a3_0x41ca('0x20')]({'title':a3_0x41ca('0x25'),'bodyLines':['\x0a'+JSON['stringify'](_0x4d5632,null,0x2)]});}const _0x2da2f8=yield(0x0,axios_1[a3_0x41ca('0x3c')])(()=>this[a3_0x41ca('0x14')][a3_0x41ca('0x2b')](a3_0x41ca('0x3e'),_0x309e10,{'headers':Object[a3_0x41ca('0x3')](Object[a3_0x41ca('0x3')]({},this['apiAxiosInstance']['defaults'][a3_0x41ca('0x31')]),{'Content-Encoding':'gzip','Content-Type':a3_0x41ca('0x2c')})}),environment_1[a3_0x41ca('0x5')]);if(_0x2da2f8){_0x192223[a3_0x41ca('0x29')]((0x0,metric_logger_1[a3_0x41ca('0x22')])(_0x2da2f8));if(_0x2da2f8[a3_0x41ca('0x1a')]&&_0x2da2f8[a3_0x41ca('0x1a')]['runUrl']&&_0x2da2f8[a3_0x41ca('0x1a')][a3_0x41ca('0x38')]===a3_0x41ca('0x36')){this[a3_0x41ca('0x17')][a3_0x41ca('0x2d')]=_0x2da2f8[a3_0x41ca('0x1a')][a3_0x41ca('0x2d')];return!![];}if(_0x2da2f8[a3_0x41ca('0x1a')]&&_0x2da2f8[a3_0x41ca('0x1a')][a3_0x41ca('0x38')]){this['messages'][a3_0x41ca('0x35')]=a3_0x41ca('0x26')+JSON[a3_0x41ca('0x2e')](_0x2da2f8[a3_0x41ca('0x1a')][a3_0x41ca('0xd')]);}else if(_0x2da2f8['data']&&typeof _0x2da2f8[a3_0x41ca('0x1a')]===a3_0x41ca('0x34')){if(_0x2da2f8[a3_0x41ca('0x1a')]!==a3_0x41ca('0x36')){this[a3_0x41ca('0x1c')][a3_0x41ca('0x35')]=a3_0x41ca('0x26')+JSON[a3_0x41ca('0x2e')](_0x2da2f8[a3_0x41ca('0x1a')]);}}else{this['messages']['apiError']=a3_0x41ca('0x26')+JSON[a3_0x41ca('0x2e')](_0x2da2f8[a3_0x41ca('0x1a')]);}if(environment_1['VERBOSE_LOGGING']){output_1['output'][a3_0x41ca('0x20')]({'title':a3_0x41ca('0x3d'),'bodyLines':[JSON['stringify'](_0x2da2f8[a3_0x41ca('0x1a')],null,0x2)]});}}else{output_1[a3_0x41ca('0x12')][a3_0x41ca('0x19')]({'title':a3_0x41ca('0x18'),'bodyLines':[a3_0x41ca('0x16'),'Run\x20Details:',JSON['stringify'](_0x36a33c,null,0x2),'Stack\x20Trace:',JSON[a3_0x41ca('0x2e')](new Error()['stack'],null,0x2)]});}return![];}catch(_0x500a9f){_0x192223[a3_0x41ca('0x29')](metric_logger_1['RUNNER_FAILURE_PERF_ENTRY']);const _0x177003=(_0xdfaf94=_0x500a9f[a3_0x41ca('0xe')])!==null&&_0xdfaf94!==void 0x0?_0xdfaf94:_0x500a9f;this['messages'][a3_0x41ca('0x35')]=this[a3_0x41ca('0x1c')][a3_0x41ca('0x6')](_0x177003,a3_0x41ca('0x8'));return![];}});}['nxCloudVersion'](){try{const _0x3e51ec=JSON[a3_0x41ca('0x32')]((0x0,fs_1[a3_0x41ca('0x37')])('package.json')[a3_0x41ca('0x27')]());return _0x3e51ec['devDependencies']['@nrwl/nx-cloud'];}catch(_0x1b696f){return a3_0x41ca('0x15');}}}exports['CloudRunApi']=CloudRunApi;
|
|
@@ -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.DistributedAgentApi = void 0;
|
|
13
|
-
const output_1 = require("@nrwl/workspace/src/utilities/output");
|
|
14
|
-
const axios_1 = require("../../../utilities/axios");
|
|
15
|
-
const environment_1 = require("../../../utilities/environment");
|
|
16
|
-
const metric_logger_1 = require("../../../utilities/metric-logger");
|
|
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
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
25
|
-
const recorder = (0, metric_logger_1.createMetricRecorder)('dtePollTasks');
|
|
26
|
-
try {
|
|
27
|
-
const res = yield (0, axios_1.axiosMultipleTries)(() => this.apiAxiosInstance.post('/nx-cloud/executions/tasks', {
|
|
28
|
-
runGroup: this.runGroup,
|
|
29
|
-
agentName: this.agentName,
|
|
30
|
-
executionId,
|
|
31
|
-
statusCode,
|
|
32
|
-
completedTasks,
|
|
33
|
-
}), 30);
|
|
34
|
-
recorder.recordMetric((0, metric_logger_1.mapRespToPerfEntry)(res));
|
|
35
|
-
return res.data;
|
|
36
|
-
}
|
|
37
|
-
catch (e) {
|
|
38
|
-
recorder.recordMetric(metric_logger_1.RUNNER_FAILURE_PERF_ENTRY);
|
|
39
|
-
throw e;
|
|
40
|
-
}
|
|
41
|
-
});
|
|
42
|
-
}
|
|
43
|
-
completeRunGroupWithError(error) {
|
|
44
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
45
|
-
if (environment_1.VERBOSE_LOGGING) {
|
|
46
|
-
output_1.output.note({
|
|
47
|
-
title: 'Completing run group with an error',
|
|
48
|
-
bodyLines: [`runGroup: ${this.runGroup}`, `error: ${error}`],
|
|
49
|
-
});
|
|
50
|
-
}
|
|
51
|
-
const recorder = (0, metric_logger_1.createMetricRecorder)('completeRunGroup');
|
|
52
|
-
try {
|
|
53
|
-
const resp = yield (0, axios_1.axiosMultipleTries)(() => this.apiAxiosInstance.post('/nx-cloud/executions/complete-run-group', {
|
|
54
|
-
runGroup: this.runGroup,
|
|
55
|
-
agentName: this.agentName,
|
|
56
|
-
criticalErrorMessage: error,
|
|
57
|
-
}), 3);
|
|
58
|
-
if (environment_1.VERBOSE_LOGGING) {
|
|
59
|
-
output_1.output.note({
|
|
60
|
-
title: 'Completed run group with an error',
|
|
61
|
-
});
|
|
62
|
-
}
|
|
63
|
-
recorder.recordMetric((0, metric_logger_1.mapRespToPerfEntry)(resp));
|
|
64
|
-
}
|
|
65
|
-
catch (e) {
|
|
66
|
-
recorder.recordMetric(metric_logger_1.RUNNER_FAILURE_PERF_ENTRY);
|
|
67
|
-
console.error(e);
|
|
68
|
-
}
|
|
69
|
-
});
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
exports.DistributedAgentApi = DistributedAgentApi;
|
|
73
|
-
//# sourceMappingURL=distributed-agent.api.js.map
|
|
1
|
+
const a4_0x4e5c=['agentName','data','runGroup','throw','__awaiter','completeRunGroup','apiAxiosInstance','post','output','mapRespToPerfEntry','Completing\x20run\x20group\x20with\x20an\x20error','error:\x20','DistributedAgentApi','next','../../../utilities/environment','RUNNER_FAILURE_PERF_ENTRY','note','error','../../../utilities/metric-logger','defineProperty','recordMetric','axiosMultipleTries','../../../utilities/axios','value','apply','then','VERBOSE_LOGGING','createMetricRecorder','__esModule','done'];(function(_0x371213,_0x4e5c42){const _0x4b4506=function(_0x41e3fd){while(--_0x41e3fd){_0x371213['push'](_0x371213['shift']());}};_0x4b4506(++_0x4e5c42);}(a4_0x4e5c,0x14b));const a4_0x4b45=function(_0x371213,_0x4e5c42){_0x371213=_0x371213-0x0;let _0x4b4506=a4_0x4e5c[_0x371213];return _0x4b4506;};'use strict';var __awaiter=this&&this[a4_0x4b45('0x3')]||function(_0x1ee249,_0x2c5a88,_0x14c166,_0x9d7703){function _0x4c885a(_0x41262f){return _0x41262f instanceof _0x14c166?_0x41262f:new _0x14c166(function(_0x373f44){_0x373f44(_0x41262f);});}return new(_0x14c166||(_0x14c166=Promise))(function(_0x3d2240,_0x2d25e0){function _0x21fc04(_0x2f92db){try{_0xd6bcd1(_0x9d7703['next'](_0x2f92db));}catch(_0x895a57){_0x2d25e0(_0x895a57);}}function _0x570c7c(_0x58374b){try{_0xd6bcd1(_0x9d7703[a4_0x4b45('0x2')](_0x58374b));}catch(_0x5b74d6){_0x2d25e0(_0x5b74d6);}}function _0xd6bcd1(_0x40fa55){_0x40fa55[a4_0x4b45('0x1c')]?_0x3d2240(_0x40fa55[a4_0x4b45('0x16')]):_0x4c885a(_0x40fa55['value'])[a4_0x4b45('0x18')](_0x21fc04,_0x570c7c);}_0xd6bcd1((_0x9d7703=_0x9d7703[a4_0x4b45('0x17')](_0x1ee249,_0x2c5a88||[]))[a4_0x4b45('0xc')]());});};Object[a4_0x4b45('0x12')](exports,a4_0x4b45('0x1b'),{'value':!![]});exports['DistributedAgentApi']=void 0x0;const output_1=require('@nrwl/workspace/src/utilities/output');const axios_1=require(a4_0x4b45('0x15'));const environment_1=require(a4_0x4b45('0xd'));const metric_logger_1=require(a4_0x4b45('0x11'));class DistributedAgentApi{constructor(_0x19205a,_0x40e695,_0x54c546){this[a4_0x4b45('0x1')]=_0x40e695;this[a4_0x4b45('0x1d')]=_0x54c546;this[a4_0x4b45('0x5')]=(0x0,axios_1['createApiAxiosInstance'])(_0x19205a);}['tasks'](_0x5104bb,_0x12ede1,_0x2b1a3b){return __awaiter(this,void 0x0,void 0x0,function*(){const _0xe05bbd=(0x0,metric_logger_1[a4_0x4b45('0x1a')])('dtePollTasks');try{const _0x2d519e=yield(0x0,axios_1[a4_0x4b45('0x14')])(()=>this[a4_0x4b45('0x5')][a4_0x4b45('0x6')]('/nx-cloud/executions/tasks',{'runGroup':this[a4_0x4b45('0x1')],'agentName':this[a4_0x4b45('0x1d')],'executionId':_0x5104bb,'statusCode':_0x12ede1,'completedTasks':_0x2b1a3b}),0x1e);_0xe05bbd[a4_0x4b45('0x13')]((0x0,metric_logger_1[a4_0x4b45('0x8')])(_0x2d519e));return _0x2d519e[a4_0x4b45('0x0')];}catch(_0x5ac7aa){_0xe05bbd['recordMetric'](metric_logger_1[a4_0x4b45('0xe')]);throw _0x5ac7aa;}});}['completeRunGroupWithError'](_0xcf1c49){return __awaiter(this,void 0x0,void 0x0,function*(){if(environment_1[a4_0x4b45('0x19')]){output_1[a4_0x4b45('0x7')][a4_0x4b45('0xf')]({'title':a4_0x4b45('0x9'),'bodyLines':['runGroup:\x20'+this[a4_0x4b45('0x1')],a4_0x4b45('0xa')+_0xcf1c49]});}const _0x5bdbbe=(0x0,metric_logger_1['createMetricRecorder'])(a4_0x4b45('0x4'));try{const _0x447408=yield(0x0,axios_1[a4_0x4b45('0x14')])(()=>this[a4_0x4b45('0x5')][a4_0x4b45('0x6')]('/nx-cloud/executions/complete-run-group',{'runGroup':this[a4_0x4b45('0x1')],'agentName':this[a4_0x4b45('0x1d')],'criticalErrorMessage':_0xcf1c49}),0x3);if(environment_1[a4_0x4b45('0x19')]){output_1['output'][a4_0x4b45('0xf')]({'title':'Completed\x20run\x20group\x20with\x20an\x20error'});}_0x5bdbbe['recordMetric']((0x0,metric_logger_1[a4_0x4b45('0x8')])(_0x447408));}catch(_0x464458){_0x5bdbbe[a4_0x4b45('0x13')](metric_logger_1[a4_0x4b45('0xe')]);console[a4_0x4b45('0x10')](_0x464458);}});}}exports[a4_0x4b45('0xb')]=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 output_1 = require("@nrwl/workspace/src/utilities/output");
|
|
14
|
-
const child_process_1 = require("child_process");
|
|
15
|
-
const stripJsonComments = require("strip-json-comments");
|
|
16
|
-
const distributed_agent_api_1 = require("./distributed-agent.api");
|
|
17
|
-
const waiter_1 = require("../../../utilities/waiter");
|
|
18
|
-
const environment_1 = require("../../../utilities/environment");
|
|
19
|
-
const print_run_group_error_1 = require("../../error/print-run-group-error");
|
|
20
|
-
const create_no_new_messages_timeout_1 = require("../../../utilities/create-no-new-messages-timeout");
|
|
21
|
-
const fs_1 = require("fs");
|
|
22
|
-
const metric_logger_1 = require("../../../utilities/metric-logger");
|
|
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_1.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_1.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_1.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_1.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_1.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_1.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_1.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_1.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_0x243b=['../../../utilities/create-no-new-messages-timeout','map','assign','\x20--projects=','cacheDirectory','completedTasks','random','../../error/print-run-group-error','retryDuring','Executing:\x20\x27','options','./distributed-agent.api','taskId','maxParallel','SIGINT','maxParallel:\x20','next','inherit','completed','Command\x20execution\x20failed\x20(distributed\x20task\x20execution:\x20','../../../utilities/waiter','find','/tasks-hashes-','@nrwl/workspace/src/utilities/output','target','apply','Starting\x20an\x20agent\x20for\x20running\x20Nx\x20tasks','criticalErrorMessage','Distributed\x20Execution\x20Terminated','executionId:\x20','exit','number\x20of\x20tasks:\x20','../../../utilities/environment','npx\x20nx\x20run-many\x20--target=','This\x20can\x20also\x20be\x20a\x20false\x20positive\x20caused\x20by\x20agents\x20that\x20did\x20not\x20shut\x20down\x20correctly.','__awaiter','push','true','wait','floor','End\x20all\x20currently\x20running\x20agents,\x20run\x20\x22npx\x20nx-cloud\x20clean-up-agents\x22,\x20and\x20try\x20again.','unlinkSync','If\x20you\x20believe\x20this\x20is\x20the\x20case,\x20run\x20\x22npx\x20nx-cloud\x20clean-up-agents\x22.','status','We\x20have\x20detected\x20other\x20agents\x20running\x20in\x20this\x20workspace.\x20This\x20can\x20cause\x20unexpected\x20behavior.','NX_AGENT_NAME','note','projectName','VERBOSE_LOGGING','error','warn','execSync','parse','executionId','\x20--parallel\x20--max-parallel=','Critical\x20Error\x20in\x20Agent:\x20\x22','CIRCLE_STAGE','nx.json','Other\x20Nx\x20Cloud\x20Agents\x20Detected','reset','env','configuration','error:\x20','strip-json-comments','completed:\x20','then','mkdirSync','getTime','output','API\x20Response','value','submitRunMetrics','child_process','Waiting...','completedStatusCode','CIRCLECI','readFileSync','createNoNewMessagesTimeout','params','default','length','forEach',').\x20Tasks\x20hashes\x20haven\x27t\x20been\x20recorded.','Error:','message','startAgent','../../../utilities/metric-logger','toString','existsSync','projects','Duplicate\x20Agent\x20ID\x20Detected','throw','getRunGroup','__esModule','completeRunGroupWithError','done','DISTRIBUTED_TASK_EXECUTION_INTERNAL_ERROR_STATUS_CODE','defineProperty','tasks'];(function(_0x2d6cf7,_0x243bd2){const _0x2c2ce6=function(_0x27d1e5){while(--_0x27d1e5){_0x2d6cf7['push'](_0x2d6cf7['shift']());}};_0x2c2ce6(++_0x243bd2);}(a5_0x243b,0x122));const a5_0x2c2c=function(_0x2d6cf7,_0x243bd2){_0x2d6cf7=_0x2d6cf7-0x0;let _0x2c2ce6=a5_0x243b[_0x2d6cf7];return _0x2c2ce6;};'use strict';var __awaiter=this&&this[a5_0x2c2c('0x2a')]||function(_0x527d3a,_0x39c161,_0x4aba95,_0xf2ac67){function _0x2616a9(_0xe168cc){return _0xe168cc instanceof _0x4aba95?_0xe168cc:new _0x4aba95(function(_0x55ce39){_0x55ce39(_0xe168cc);});}return new(_0x4aba95||(_0x4aba95=Promise))(function(_0x25c8a3,_0xd4858a){function _0x2769ee(_0x17256e){try{_0x26701b(_0xf2ac67[a5_0x2c2c('0x17')](_0x17256e));}catch(_0xef1488){_0xd4858a(_0xef1488);}}function _0x59c5b5(_0x3a6b0d){try{_0x26701b(_0xf2ac67[a5_0x2c2c('0x62')](_0x3a6b0d));}catch(_0x159d47){_0xd4858a(_0x159d47);}}function _0x26701b(_0x565ed5){_0x565ed5[a5_0x2c2c('0x3')]?_0x25c8a3(_0x565ed5['value']):_0x2616a9(_0x565ed5[a5_0x2c2c('0x4d')])[a5_0x2c2c('0x48')](_0x2769ee,_0x59c5b5);}_0x26701b((_0xf2ac67=_0xf2ac67[a5_0x2c2c('0x20')](_0x527d3a,_0x39c161||[]))[a5_0x2c2c('0x17')]());});};Object[a5_0x2c2c('0x5')](exports,a5_0x2c2c('0x1'),{'value':!![]});exports[a5_0x2c2c('0x5c')]=void 0x0;const output_1=require(a5_0x2c2c('0x1e'));const child_process_1=require(a5_0x2c2c('0x4f'));const stripJsonComments=require(a5_0x2c2c('0x46'));const distributed_agent_api_1=require(a5_0x2c2c('0x12'));const waiter_1=require(a5_0x2c2c('0x1b'));const environment_1=require(a5_0x2c2c('0x27'));const print_run_group_error_1=require(a5_0x2c2c('0xe'));const create_no_new_messages_timeout_1=require(a5_0x2c2c('0x7'));const fs_1=require('fs');const metric_logger_1=require(a5_0x2c2c('0x5d'));function executeTasks(_0x162682,_0x316ca1){return __awaiter(this,void 0x0,void 0x0,function*(){let _0x562da3=0x0;let _0x558996=null;const _0x1dd3e4=(0x0,create_no_new_messages_timeout_1[a5_0x2c2c('0x54')])();const _0x316498=new waiter_1['Waiter']();let _0x3979a9=[];const _0x2d2fd6=new Date();let _0x1f26ec=![];while(!![]){if(environment_1[a5_0x2c2c('0x37')]){output_1[a5_0x2c2c('0x4b')][a5_0x2c2c('0x35')]({'title':'Fetching\x20tasks...'});}_0x558996=yield _0x316ca1['tasks'](_0x558996?_0x558996[a5_0x2c2c('0x3c')]:null,_0x562da3,_0x3979a9);if(environment_1[a5_0x2c2c('0x37')]){output_1[a5_0x2c2c('0x4b')][a5_0x2c2c('0x35')]({'title':a5_0x2c2c('0x4c'),'bodyLines':[a5_0x2c2c('0x47')+_0x558996[a5_0x2c2c('0x19')],'retryDuring:\x20'+_0x558996[a5_0x2c2c('0xf')],a5_0x2c2c('0x24')+_0x558996[a5_0x2c2c('0x3c')],a5_0x2c2c('0x26')+_0x558996['tasks'][a5_0x2c2c('0x57')],a5_0x2c2c('0x45')+_0x558996[a5_0x2c2c('0x22')],a5_0x2c2c('0x16')+_0x558996[a5_0x2c2c('0x14')]]});}if(_0x558996[a5_0x2c2c('0x22')]){output_1[a5_0x2c2c('0x4b')][a5_0x2c2c('0x38')]({'title':a5_0x2c2c('0x23'),'bodyLines':[a5_0x2c2c('0x5a'),_0x558996[a5_0x2c2c('0x22')]]});process[a5_0x2c2c('0x25')](0x0);}if((_0x558996===null||_0x558996===void 0x0?void 0x0:_0x558996[a5_0x2c2c('0xf')])&&(_0x558996===null||_0x558996===void 0x0?void 0x0:_0x558996['retryDuring'])!==0x0&&!_0x1f26ec&&new Date()[a5_0x2c2c('0x4a')]()-_0x2d2fd6['getTime']()>_0x558996[a5_0x2c2c('0xf')]){yield _0x316498['wait']();continue;}if(_0x558996[a5_0x2c2c('0x19')])return;_0x1dd3e4(_0x558996[a5_0x2c2c('0x6')][a5_0x2c2c('0x8')](_0x339f13=>_0x339f13[a5_0x2c2c('0x13')])['join'](''));if(!_0x558996[a5_0x2c2c('0x3c')]){if(environment_1['VERBOSE_LOGGING']){output_1[a5_0x2c2c('0x4b')][a5_0x2c2c('0x35')]({'title':a5_0x2c2c('0x50')});}yield _0x316498[a5_0x2c2c('0x2d')]();_0x562da3=0x0;_0x3979a9=[];continue;}_0x316498[a5_0x2c2c('0x42')]();_0x1f26ec=!![];const _0x21f0a0=invokeTasksUsingRunMany(_0x162682,_0x558996[a5_0x2c2c('0x3c')],_0x558996[a5_0x2c2c('0x6')],_0x558996['maxParallel']);_0x562da3=_0x21f0a0[a5_0x2c2c('0x51')];_0x3979a9=_0x21f0a0[a5_0x2c2c('0xc')];}});}function readCompletedTasks(_0x4d5530,_0x2c6120){const _0x1549b0=a5_0x2c2c('0x1a')+_0x2c6120+a5_0x2c2c('0x59');let _0x4708ed;try{const _0x5c9e0c=_0x4d5530[a5_0x2c2c('0xb')]||'./node_modules/.cache/nx';const _0x4d8b1e=_0x5c9e0c+a5_0x2c2c('0x1d')+_0x2c6120;_0x4708ed=JSON[a5_0x2c2c('0x3b')]((0x0,fs_1[a5_0x2c2c('0x53')])(_0x4d8b1e)['toString']());(0x0,fs_1[a5_0x2c2c('0x30')])(_0x4d8b1e);}catch(_0x70cafb){throw new Error(_0x1549b0);}if(_0x4708ed[a5_0x2c2c('0x57')]==0x0){throw new Error(_0x1549b0);}return _0x4708ed;}function invokeTasksUsingRunMany(_0x2e58d7,_0x26eee8,_0x42d426,_0xab053e){let _0x19c5d9=0x0;const _0x2e7069=[];for(const _0x478197 of groupByTarget(_0x42d426)){const _0x4f451e=_0x478197[a5_0x2c2c('0x44')]?'--configuration='+_0x478197[a5_0x2c2c('0x44')]:'';const _0x3e48c0=_0xab053e>0x1?a5_0x2c2c('0x3d')+_0xab053e:'';const _0xcd14fd=a5_0x2c2c('0x28')+_0x478197[a5_0x2c2c('0x1f')]+'\x20'+_0x4f451e+a5_0x2c2c('0xa')+_0x478197[a5_0x2c2c('0x60')]['join'](',')+'\x20'+_0x478197[a5_0x2c2c('0x55')]+_0x3e48c0;if(environment_1[a5_0x2c2c('0x37')]){output_1[a5_0x2c2c('0x4b')]['note']({'title':a5_0x2c2c('0x10')+_0xcd14fd+'\x27'});}try{(0x0,child_process_1[a5_0x2c2c('0x3a')])(_0xcd14fd,{'stdio':['inherit','inherit',a5_0x2c2c('0x18')],'env':Object['assign'](Object[a5_0x2c2c('0x9')]({},process['env']),{'NX_CACHE_FAILURES':a5_0x2c2c('0x2c'),'NX_CLOUD_DISTRIBUTED_EXECUTION_ID':_0x26eee8})});}catch(_0x1ddb96){if(_0x1ddb96[a5_0x2c2c('0x32')]===environment_1[a5_0x2c2c('0x4')]){throw _0x1ddb96;}else{_0x19c5d9=0x1;}}finally{_0x2e7069[a5_0x2c2c('0x2b')](...readCompletedTasks(_0x2e58d7,_0x26eee8));}}return{'completedStatusCode':_0x19c5d9,'completedTasks':_0x2e7069};}function groupByTarget(_0x1ad12f){const _0x17f672=[];_0x1ad12f[a5_0x2c2c('0x58')](_0x2df7e0=>{const _0x131fd2=_0x17f672[a5_0x2c2c('0x1c')](_0x1bcc53=>_0x1bcc53[a5_0x2c2c('0x1f')]===_0x2df7e0[a5_0x2c2c('0x1f')]&&_0x1bcc53[a5_0x2c2c('0x44')]===_0x2df7e0['configuration']);if(_0x131fd2){_0x131fd2[a5_0x2c2c('0x60')]['push'](_0x2df7e0[a5_0x2c2c('0x36')]);}else{_0x17f672[a5_0x2c2c('0x2b')]({'target':_0x2df7e0['target'],'projects':[_0x2df7e0[a5_0x2c2c('0x36')]],'params':_0x2df7e0[a5_0x2c2c('0x55')],'configuration':_0x2df7e0['configuration']});}});return _0x17f672;}function getAgentName(){if(process[a5_0x2c2c('0x43')][a5_0x2c2c('0x34')]!==undefined){return process[a5_0x2c2c('0x43')][a5_0x2c2c('0x34')];}else if(process[a5_0x2c2c('0x43')][a5_0x2c2c('0x52')]!==undefined){return process['env'][a5_0x2c2c('0x3f')];}else{return'Agent\x20'+Math[a5_0x2c2c('0x2e')](Math[a5_0x2c2c('0xd')]()*0x186a0);}}function createAgentLockfile(_0x5b9886,_0x4baaba){const _0x3894aa=_0x5b9886[a5_0x2c2c('0xb')]||'./node_modules/.cache/nx';const _0x555509=_0x3894aa+'/lockfiles';const _0x2bba8b=_0x555509+'/'+_0x4baaba+'.lock';if(!(0x0,fs_1['existsSync'])(_0x555509)){(0x0,fs_1[a5_0x2c2c('0x49')])(_0x555509,{'recursive':!![]});}const _0x4f4c6f=(0x0,fs_1['readdirSync'])(_0x555509);if(_0x4f4c6f[a5_0x2c2c('0x57')]){if(_0x4f4c6f['includes'](_0x4baaba+'.lock')){output_1[a5_0x2c2c('0x4b')]['error']({'title':a5_0x2c2c('0x61'),'bodyLines':['We\x20have\x20detected\x20another\x20agent\x20with\x20this\x20ID\x20running\x20in\x20this\x20workspace.\x20This\x20should\x20not\x20happen.','',a5_0x2c2c('0x2f')]});process[a5_0x2c2c('0x25')](0x1);}output_1[a5_0x2c2c('0x4b')][a5_0x2c2c('0x39')]({'title':a5_0x2c2c('0x41'),'bodyLines':[a5_0x2c2c('0x33'),'',a5_0x2c2c('0x29'),a5_0x2c2c('0x31')]});}(0x0,fs_1['writeFileSync'])(_0x2bba8b,'');process['on'](a5_0x2c2c('0x25'),()=>cleanupAgentLockfile(_0x2bba8b));process['on'](a5_0x2c2c('0x15'),()=>cleanupAgentLockfile(_0x2bba8b));}function cleanupAgentLockfile(_0x316e17){if((0x0,fs_1[a5_0x2c2c('0x5f')])(_0x316e17)){(0x0,fs_1[a5_0x2c2c('0x30')])(_0x316e17);}}function startAgent(){return __awaiter(this,void 0x0,void 0x0,function*(){const _0x171b58=(0x0,environment_1[a5_0x2c2c('0x0')])();if(!_0x171b58){(0x0,print_run_group_error_1['printRunGroupError'])();return process[a5_0x2c2c('0x25')](0x1);}output_1[a5_0x2c2c('0x4b')][a5_0x2c2c('0x35')]({'title':a5_0x2c2c('0x21')});const _0x427e5b=JSON['parse'](stripJsonComments((0x0,fs_1['readFileSync'])(a5_0x2c2c('0x40'))[a5_0x2c2c('0x5e')]()))['tasksRunnerOptions'][a5_0x2c2c('0x56')][a5_0x2c2c('0x11')];const _0x7acbfa=getAgentName();createAgentLockfile(_0x427e5b,_0x7acbfa);const _0xc1c2e7=new distributed_agent_api_1['DistributedAgentApi'](_0x427e5b,_0x171b58,_0x7acbfa);return executeTasks(_0x427e5b,_0xc1c2e7)[a5_0x2c2c('0x48')](_0x2ebec2=>__awaiter(this,void 0x0,void 0x0,function*(){yield(0x0,metric_logger_1[a5_0x2c2c('0x4e')])(_0x427e5b);return _0x2ebec2;}))['catch'](_0xc396ad=>__awaiter(this,void 0x0,void 0x0,function*(){yield _0xc1c2e7[a5_0x2c2c('0x2')](a5_0x2c2c('0x3e')+_0xc396ad[a5_0x2c2c('0x5b')]+'\x22');throw _0xc396ad;}));});}exports['startAgent']=startAgent;
|