@nrwl/nx-cloud 15.3.0 → 15.3.1-beta.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (22) hide show
  1. package/lib/core/api/error-reporter.api.js +36 -1
  2. package/lib/core/api/run-group.api.js +73 -1
  3. package/lib/core/runners/cloud-enabled/cloud-enabled-life-cycle.js +93 -1
  4. package/lib/core/runners/cloud-enabled/cloud-enabled.runner.js +320 -1
  5. package/lib/core/runners/cloud-enabled/cloud-enabled.runner.js.map +1 -1
  6. package/lib/core/runners/cloud-enabled/cloud-remote-cache.js +133 -1
  7. package/lib/core/runners/cloud-enabled/cloud-run.api.js +168 -1
  8. package/lib/core/runners/cloud-enabled/id-generator.js +16 -1
  9. package/lib/core/runners/distributed-agent/distributed-agent.api.js +93 -1
  10. package/lib/core/runners/distributed-agent/distributed-agent.impl.js +157 -1
  11. package/lib/core/runners/distributed-agent/execute-tasks.js +114 -1
  12. package/lib/core/runners/distributed-agent/invoke-tasks-using-nx-imperative-api.js +58 -1
  13. package/lib/core/runners/distributed-agent/invoke-tasks-using-run-many.js +97 -1
  14. package/lib/core/runners/distributed-execution/distributed-execution.api.js +152 -1
  15. package/lib/core/runners/distributed-execution/distributed-execution.runner.js +118 -1
  16. package/lib/core/runners/distributed-execution/process-task.js +45 -1
  17. package/lib/core/runners/distributed-execution/process-tasks.js +67 -1
  18. package/lib/core/runners/distributed-execution/split-task-graph-into-stages.js +37 -1
  19. package/lib/core/runners/distributed-execution/task-graph-creator.js +100 -1
  20. package/lib/daemon/process-run-end.js +1 -1
  21. package/lib/daemon/process-run-end.js.map +1 -1
  22. package/package.json +1 -1
@@ -1 +1,133 @@
1
- const a2_0xd262=['../../../utilities/nx-imports','hash','Error\x20when\x20storing\x20artifacts','Nx\x20Cloud:\x20Cache\x20miss\x20','.\x20Status\x20404.','requests','startRun','hashUrls','Nx\x20Cloud:\x20Skipping\x20storing\x20','CloudRemoteCache','next','all','api','done','distributedExecutionId','response','retrieve','Maybe\x20you\x20are\x20using\x20a\x20read-only\x20token\x20or\x20the\x20artifact\x20has\x20already\x20being\x20uploaded.','messages','storeRequests','status','runContext','remote-cache-hit','push','axiosException','then','VERBOSE_LOGGING','delayedStoreRequests','__esModule','storeInCurrentProcess','map','reduce','../../../utilities/environment','There\x20are\x20several\x20reasons\x20why\x20this\x20can\x20happen.','store','value','throw','statuses','fileStorage','defineProperty','note','extractErrorMessage','scheduledTasks','storage','get','cacheError'];(function(_0x28847a,_0xd26288){const _0x22c47f=function(_0x53b2b3){while(--_0x53b2b3){_0x28847a['push'](_0x28847a['shift']());}};_0x22c47f(++_0xd26288);}(a2_0xd262,0x10e));const a2_0x22c4=function(_0x28847a,_0xd26288){_0x28847a=_0x28847a-0x0;let _0x22c47f=a2_0xd262[_0x28847a];return _0x22c47f;};'use strict';var __awaiter=this&&this['__awaiter']||function(_0x590b94,_0x1be646,_0x361007,_0x482975){function _0x3c025c(_0x4f2ceb){return _0x4f2ceb instanceof _0x361007?_0x4f2ceb:new _0x361007(function(_0x30615f){_0x30615f(_0x4f2ceb);});}return new(_0x361007||(_0x361007=Promise))(function(_0x3985d5,_0x30a014){function _0x54a38f(_0x44f205){try{_0xf41031(_0x482975[a2_0x22c4('0x10')](_0x44f205));}catch(_0x11de90){_0x30a014(_0x11de90);}}function _0x4eed1f(_0x4fa277){try{_0xf41031(_0x482975[a2_0x22c4('0x2a')](_0x4fa277));}catch(_0x303c4a){_0x30a014(_0x303c4a);}}function _0xf41031(_0x261e2d){_0x261e2d[a2_0x22c4('0x13')]?_0x3985d5(_0x261e2d[a2_0x22c4('0x29')]):_0x3c025c(_0x261e2d[a2_0x22c4('0x29')])[a2_0x22c4('0x1f')](_0x54a38f,_0x4eed1f);}_0xf41031((_0x482975=_0x482975['apply'](_0x590b94,_0x1be646||[]))['next']());});};Object[a2_0x22c4('0x2d')](exports,a2_0x22c4('0x22'),{'value':!![]});exports[a2_0x22c4('0xf')]=void 0x0;const environment_1=require(a2_0x22c4('0x26'));const {output}=require(a2_0x22c4('0x6'));class CloudRemoteCache{constructor(_0x4e0236,_0x16a2ff,_0x4bd123,_0x5661da,_0x16eb32,_0x42483c){this[a2_0x22c4('0x18')]=_0x4e0236;this[a2_0x22c4('0x12')]=_0x16a2ff;this[a2_0x22c4('0x1b')]=_0x4bd123;this['fileStorage']=_0x5661da;this[a2_0x22c4('0x14')]=_0x16eb32;this[a2_0x22c4('0x23')]=_0x42483c;this[a2_0x22c4('0x19')]=[];this[a2_0x22c4('0x21')]=[];}[a2_0x22c4('0x16')](_0x48c9ad,_0x402c10){var _0x3845ae;return __awaiter(this,void 0x0,void 0x0,function*(){if(this[a2_0x22c4('0x18')][a2_0x22c4('0x5')])return![];const _0x462791=yield this['hashUrls'](_0x48c9ad);if(!_0x462791||!_0x462791[a2_0x22c4('0x4')]){if(environment_1['VERBOSE_LOGGING']){output[a2_0x22c4('0x0')]({'title':a2_0x22c4('0x9')+_0x48c9ad+'.'});}this[a2_0x22c4('0x1b')][a2_0x22c4('0x2b')][_0x48c9ad]='cache-miss';return![];}try{yield this[a2_0x22c4('0x2c')][a2_0x22c4('0x16')](_0x48c9ad,_0x462791['get'],_0x402c10);this[a2_0x22c4('0x1b')][a2_0x22c4('0x2b')][_0x48c9ad]=a2_0x22c4('0x1c');return!![];}catch(_0x40e054){const _0x280959=(_0x3845ae=_0x40e054[a2_0x22c4('0x1e')])!==null&&_0x3845ae!==void 0x0?_0x3845ae:_0x40e054;if(_0x280959[a2_0x22c4('0x15')]&&_0x280959[a2_0x22c4('0x15')][a2_0x22c4('0x1a')]===0x194){if(environment_1[a2_0x22c4('0x20')]){output[a2_0x22c4('0x0')]({'title':a2_0x22c4('0x9')+_0x48c9ad+a2_0x22c4('0xa')});}}else{this['messages'][a2_0x22c4('0x5')]=this[a2_0x22c4('0x18')][a2_0x22c4('0x1')](_0x280959,a2_0x22c4('0x3'));}this['runContext']['statuses'][_0x48c9ad]='cache-miss';return![];}});}[a2_0x22c4('0x28')](_0x3d220d,_0x3bda4e){return __awaiter(this,void 0x0,void 0x0,function*(){if(this[a2_0x22c4('0x18')][a2_0x22c4('0x5')])return![];const _0x2c988a=Promise['resolve']()['then'](()=>__awaiter(this,void 0x0,void 0x0,function*(){var _0x12d379;const _0x3b443b=yield this[a2_0x22c4('0xd')](_0x3d220d);if(!_0x3b443b)return![];if(!_0x3b443b['put']){if(environment_1['VERBOSE_LOGGING']){output['note']({'title':a2_0x22c4('0xe')+_0x3d220d+'.','bodyLines':[a2_0x22c4('0x27'),a2_0x22c4('0x17')]});}return!![];}if(!this[a2_0x22c4('0x23')]){this['delayedStoreRequests'][a2_0x22c4('0x1d')]({'hash':_0x3d220d,'url':_0x3b443b['put']});return!![];}try{yield this['fileStorage'][a2_0x22c4('0x28')](_0x3d220d,_0x3b443b['put'],_0x3bda4e);return!![];}catch(_0x35ac44){const _0xe2ef6d=(_0x12d379=_0x35ac44[a2_0x22c4('0x1e')])!==null&&_0x12d379!==void 0x0?_0x12d379:_0x35ac44;this[a2_0x22c4('0x18')]['cacheError']=this[a2_0x22c4('0x18')]['extractErrorMessage'](_0xe2ef6d,'storage');return![];}}));this[a2_0x22c4('0x19')]['push'](_0x2c988a);return _0x2c988a;});}[a2_0x22c4('0xd')](_0xd7bbee){return __awaiter(this,void 0x0,void 0x0,function*(){if(_0xd7bbee in this['runContext'][a2_0x22c4('0xb')]){return(yield this[a2_0x22c4('0x1b')][a2_0x22c4('0xb')][_0xd7bbee])[_0xd7bbee];}else{const _0x487389=this[a2_0x22c4('0x1b')][a2_0x22c4('0x2')]['filter'](_0x5024ee=>!this[a2_0x22c4('0x1b')][a2_0x22c4('0xb')][_0x5024ee[a2_0x22c4('0x7')]])[a2_0x22c4('0x24')](_0x161381=>_0x161381[a2_0x22c4('0x7')]);if(_0x487389['indexOf'](_0xd7bbee)===-0x1){_0x487389[a2_0x22c4('0x1d')](_0xd7bbee);}const _0x2e38e5=this[a2_0x22c4('0x12')][a2_0x22c4('0xc')](this[a2_0x22c4('0x14')],_0x487389);_0x487389['forEach'](_0x58b436=>{this[a2_0x22c4('0x1b')]['requests'][_0x58b436]=_0x2e38e5;});return(yield _0x2e38e5)[_0xd7bbee];}});}['waitForStoreRequestsToComplete'](){return __awaiter(this,void 0x0,void 0x0,function*(){const _0x30f7e9=yield Promise[a2_0x22c4('0x11')](this[a2_0x22c4('0x19')])[a2_0x22c4('0x1f')](_0x4a212a=>_0x4a212a[a2_0x22c4('0x25')]((_0xe5773f,_0x4b99a8)=>_0xe5773f&&_0x4b99a8,!![]));if(!_0x30f7e9){throw new Error(a2_0x22c4('0x8'));}});}}exports[a2_0x22c4('0xf')]=CloudRemoteCache;
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.CloudRemoteCache = void 0;
13
+ const environment_1 = require("../../../utilities/environment");
14
+ const { output } = require('../../../utilities/nx-imports');
15
+ class CloudRemoteCache {
16
+ constructor(messages, api, runContext, fileStorage, distributedExecutionId, storeInCurrentProcess) {
17
+ this.messages = messages;
18
+ this.api = api;
19
+ this.runContext = runContext;
20
+ this.fileStorage = fileStorage;
21
+ this.distributedExecutionId = distributedExecutionId;
22
+ this.storeInCurrentProcess = storeInCurrentProcess;
23
+ this.storeRequests = [];
24
+ this.delayedStoreRequests = [];
25
+ }
26
+ retrieve(hash, cacheDirectory) {
27
+ var _a;
28
+ return __awaiter(this, void 0, void 0, function* () {
29
+ if (this.messages.cacheError)
30
+ return false;
31
+ const hashUrls = yield this.hashUrls(hash);
32
+ if (!hashUrls || !hashUrls.get) {
33
+ if (environment_1.VERBOSE_LOGGING) {
34
+ output.note({ title: `Nx Cloud: Cache miss ${hash}.` });
35
+ }
36
+ this.runContext.statuses[hash] = 'cache-miss';
37
+ return false;
38
+ }
39
+ try {
40
+ yield this.fileStorage.retrieve(hash, hashUrls.get, cacheDirectory);
41
+ this.runContext.statuses[hash] = 'remote-cache-hit';
42
+ return true;
43
+ }
44
+ catch (ee) {
45
+ const e = (_a = ee.axiosException) !== null && _a !== void 0 ? _a : ee;
46
+ // TODO: vsavkin remove this handling Oct 2023
47
+ // 404 indicates that something is broken, but older versions
48
+ // of the api can result in such errors
49
+ // we ignore them for now
50
+ if (e.response && e.response.status === 404) {
51
+ if (environment_1.VERBOSE_LOGGING) {
52
+ output.note({ title: `Nx Cloud: Cache miss ${hash}. Status 404.` });
53
+ }
54
+ // cache miss. print nothing
55
+ }
56
+ else {
57
+ this.messages.cacheError = this.messages.extractErrorMessage(e, 'storage');
58
+ }
59
+ this.runContext.statuses[hash] = 'cache-miss';
60
+ return false;
61
+ }
62
+ });
63
+ }
64
+ store(hash, cacheDirectory) {
65
+ return __awaiter(this, void 0, void 0, function* () {
66
+ if (this.messages.cacheError)
67
+ return false;
68
+ const res = Promise.resolve().then(() => __awaiter(this, void 0, void 0, function* () {
69
+ var _a;
70
+ const hashUrls = yield this.hashUrls(hash);
71
+ if (!hashUrls)
72
+ return false;
73
+ if (!hashUrls.put) {
74
+ if (environment_1.VERBOSE_LOGGING) {
75
+ output.note({
76
+ title: `Nx Cloud: Skipping storing ${hash}.`,
77
+ bodyLines: [
78
+ `There are several reasons why this can happen.`,
79
+ `Maybe you are using a read-only token or the artifact has already being uploaded.`,
80
+ ],
81
+ });
82
+ }
83
+ return true;
84
+ }
85
+ if (!this.storeInCurrentProcess) {
86
+ this.delayedStoreRequests.push({ hash: hash, url: hashUrls.put });
87
+ return true;
88
+ }
89
+ try {
90
+ yield this.fileStorage.store(hash, hashUrls.put, cacheDirectory);
91
+ return true;
92
+ }
93
+ catch (ee) {
94
+ const e = (_a = ee.axiosException) !== null && _a !== void 0 ? _a : ee;
95
+ this.messages.cacheError = this.messages.extractErrorMessage(e, 'storage');
96
+ return false;
97
+ }
98
+ }));
99
+ this.storeRequests.push(res);
100
+ return res;
101
+ });
102
+ }
103
+ hashUrls(hash) {
104
+ return __awaiter(this, void 0, void 0, function* () {
105
+ if (hash in this.runContext.requests) {
106
+ return (yield this.runContext.requests[hash])[hash];
107
+ }
108
+ else {
109
+ const scheduledTaskHashesWithoutRequests = this.runContext.scheduledTasks
110
+ .filter((t) => !this.runContext.requests[t.hash])
111
+ .map((t) => t.hash);
112
+ if (scheduledTaskHashesWithoutRequests.indexOf(hash) === -1) {
113
+ scheduledTaskHashesWithoutRequests.push(hash);
114
+ }
115
+ const request = this.api.startRun(this.distributedExecutionId, scheduledTaskHashesWithoutRequests);
116
+ scheduledTaskHashesWithoutRequests.forEach((taskHash) => {
117
+ this.runContext.requests[taskHash] = request;
118
+ });
119
+ return (yield request)[hash];
120
+ }
121
+ });
122
+ }
123
+ waitForStoreRequestsToComplete() {
124
+ return __awaiter(this, void 0, void 0, function* () {
125
+ const res = yield Promise.all(this.storeRequests).then((r) => r.reduce((a, b) => a && b, true));
126
+ if (!res) {
127
+ throw new Error(`Error when storing artifacts`);
128
+ }
129
+ });
130
+ }
131
+ }
132
+ exports.CloudRemoteCache = CloudRemoteCache;
133
+ //# sourceMappingURL=cloud-remote-cache.js.map
@@ -1 +1,168 @@
1
- const a3_0x2897=['Invalid\x20end\x20run\x20response','application/octet-stream','data','endRun','length','getBranch','machineInfo','startRun','recordMetric','string','value','runUrl','urls','util','error','package.json','done','createApiAxiosInstance','runContext','then','terminalOutput','defaults','mapRespToPerfEntry','slice','__esModule','RunStart\x20duration','messages','createReqBody','RunStart','next','axiosMultipleTries','zlib','post','axiosException','RunEnd.\x20Completed\x20tasks','note','/nx-cloud/runs/end','message','...','Nx\x20Cloud:\x20Unknown\x20Error\x20Occurred','@nrwl/nx-cloud','response','../../../utilities/axios','map','VERBOSE_LOGGING','success','api','printDuration','devDependencies','apiAxiosInstance','stringify','extractErrorMessage','createMetricRecorder','../../../utilities/metric-logger','assign','throw','nxCloudVersion','apply','headers','RUNNER_FAILURE_PERF_ENTRY','getRunGroup','CloudRunApi','toString','apiError','Invalid\x20Nx\x20Cloud\x20response:\x20','Run\x20Details:','parse','getCIExecutionId','status','Invalid\x20end\x20run\x20response:\x20'];(function(_0x4c2ca1,_0x289780){const _0x2f562d=function(_0x4dded8){while(--_0x4dded8){_0x4c2ca1['push'](_0x4c2ca1['shift']());}};_0x2f562d(++_0x289780);}(a3_0x2897,0x1a4));const a3_0x2f56=function(_0x4c2ca1,_0x289780){_0x4c2ca1=_0x4c2ca1-0x0;let _0x2f562d=a3_0x2897[_0x4c2ca1];return _0x2f562d;};'use strict';var __awaiter=this&&this['__awaiter']||function(_0x5113c4,_0x19161a,_0x398e6a,_0xa0f36f){function _0xf35ae3(_0x37298d){return _0x37298d instanceof _0x398e6a?_0x37298d:new _0x398e6a(function(_0x3f135f){_0x3f135f(_0x37298d);});}return new(_0x398e6a||(_0x398e6a=Promise))(function(_0x5ba433,_0x5e03d8){function _0xf6645(_0x359c56){try{_0x458215(_0xa0f36f[a3_0x2f56('0x1d')](_0x359c56));}catch(_0x14caba){_0x5e03d8(_0x14caba);}}function _0x5f23df(_0x1cdc19){try{_0x458215(_0xa0f36f[a3_0x2f56('0x37')](_0x1cdc19));}catch(_0x2c98ae){_0x5e03d8(_0x2c98ae);}}function _0x458215(_0x21d043){_0x21d043[a3_0x2f56('0x10')]?_0x5ba433(_0x21d043[a3_0x2f56('0xa')]):_0xf35ae3(_0x21d043[a3_0x2f56('0xa')])[a3_0x2f56('0x13')](_0xf6645,_0x5f23df);}_0x458215((_0xa0f36f=_0xa0f36f[a3_0x2f56('0x39')](_0x5113c4,_0x19161a||[]))[a3_0x2f56('0x1d')]());});};Object['defineProperty'](exports,a3_0x2f56('0x18'),{'value':!![]});exports[a3_0x2f56('0x3d')]=void 0x0;const axios_1=require(a3_0x2f56('0x2a'));const environment_1=require('../../../utilities/environment');const fs_1=require('fs');const zlib_1=require(a3_0x2f56('0x1f'));const util_1=require(a3_0x2f56('0xd'));const metric_logger_1=require(a3_0x2f56('0x35'));const {output}=require('../../../utilities/nx-imports');class CloudRunApi{constructor(_0x253684,_0xf5b6ee,_0x275b14,_0xea234c){this[a3_0x2f56('0x1a')]=_0x253684;this[a3_0x2f56('0x12')]=_0xf5b6ee;this[a3_0x2f56('0x6')]=_0xea234c;this[a3_0x2f56('0x31')]=(0x0,axios_1[a3_0x2f56('0x11')])(_0x275b14);}[a3_0x2f56('0x7')](_0x1bee88,_0x4ddbe8){var _0x53a1d5;return __awaiter(this,void 0x0,void 0x0,function*(){if(this[a3_0x2f56('0x1a')][a3_0x2f56('0x3f')])return{};const _0x438f76=(0x0,metric_logger_1[a3_0x2f56('0x34')])(a3_0x2f56('0x7'));try{const _0x4857ee={'meta':{'nxCloudVersion':this[a3_0x2f56('0x38')]()},'branch':(0x0,environment_1[a3_0x2f56('0x5')])(),'runGroup':(0x0,environment_1[a3_0x2f56('0x3c')])(),'ciExecutionId':(0x0,environment_1[a3_0x2f56('0x43')])(),'ciExecutionEnv':(0x0,environment_1['getCIExecutionEnv'])(),'distributedExecutionId':_0x1bee88,'hashes':_0x4ddbe8};if(environment_1[a3_0x2f56('0x2c')]){output[a3_0x2f56('0x23')]({'title':a3_0x2f56('0x1c'),'bodyLines':['\x0a'+JSON['stringify'](_0x4857ee,null,0x2)]});}const _0x2f4185=yield(0x0,axios_1['printDuration'])(a3_0x2f56('0x19'),()=>(0x0,axios_1[a3_0x2f56('0x1e')])(()=>this[a3_0x2f56('0x31')]['post']('/nx-cloud/runs/start',_0x4857ee)));_0x438f76[a3_0x2f56('0x8')]((0x0,metric_logger_1[a3_0x2f56('0x16')])(_0x2f4185));if(_0x2f4185[a3_0x2f56('0x2')]&&_0x2f4185[a3_0x2f56('0x2')][a3_0x2f56('0x25')]){this[a3_0x2f56('0x1a')][a3_0x2f56('0x25')]=_0x2f4185[a3_0x2f56('0x2')]['message'];}if(!_0x2f4185[a3_0x2f56('0x2')]||!_0x2f4185[a3_0x2f56('0x2')][a3_0x2f56('0xc')]){this['messages'][a3_0x2f56('0x3f')]=a3_0x2f56('0x40')+JSON['stringify'](_0x2f4185[a3_0x2f56('0x2')]);return{};}return _0x2f4185['data'][a3_0x2f56('0xc')];}catch(_0x281e41){_0x438f76[a3_0x2f56('0x8')](((_0x53a1d5=_0x281e41===null||_0x281e41===void 0x0?void 0x0:_0x281e41[a3_0x2f56('0x21')])===null||_0x53a1d5===void 0x0?void 0x0:_0x53a1d5[a3_0x2f56('0x29')])?(0x0,metric_logger_1[a3_0x2f56('0x16')])(_0x281e41['axiosException']['response']):metric_logger_1['RUNNER_FAILURE_PERF_ENTRY']);this[a3_0x2f56('0x1a')][a3_0x2f56('0x3f')]=this[a3_0x2f56('0x1a')]['extractErrorMessage'](_0x281e41,'api');return{};}});}[a3_0x2f56('0x1b')](_0x3ba394,_0x14ff36,_0x1e5861,_0x586c43){const _0x26580a=Object[a3_0x2f56('0x36')](Object[a3_0x2f56('0x36')]({'meta':{'nxCloudVersion':this[a3_0x2f56('0x38')]()},'tasks':_0x14ff36,'run':_0x3ba394,'linkId':_0x586c43},_0x1e5861),{'machineInfo':this['machineInfo']});return JSON['stringify'](_0x26580a);}[a3_0x2f56('0x3')](_0x5253ff,_0x1daf7c,_0xb9f2c2,_0x360bcd){var _0x15c8b0,_0x47f74c;return __awaiter(this,void 0x0,void 0x0,function*(){if(this[a3_0x2f56('0x1a')][a3_0x2f56('0x3f')])return![];let _0x34edee=this[a3_0x2f56('0x1b')](_0x5253ff,_0x1daf7c,_0xb9f2c2,_0x360bcd);if(_0x34edee[a3_0x2f56('0x4')]>0x14*0x3e8*0x3e8){_0x34edee=this[a3_0x2f56('0x1b')](_0x5253ff,_0x1daf7c['map'](_0x2f7de9=>Object[a3_0x2f56('0x36')](Object[a3_0x2f56('0x36')]({},_0x2f7de9),{'hashDetails':undefined})),_0xb9f2c2,_0x360bcd);}const _0x2dfd26=Buffer['from'](_0x34edee);const _0x54828f=yield(0x0,util_1['promisify'])(zlib_1['gzip'])(_0x2dfd26);const _0x576bbe=(0x0,metric_logger_1[a3_0x2f56('0x34')])(a3_0x2f56('0x3'));try{if(environment_1['VERBOSE_LOGGING']){const _0x3c4428=_0x1daf7c[a3_0x2f56('0x2b')](_0x57f305=>{return Object[a3_0x2f56('0x36')](Object[a3_0x2f56('0x36')]({},_0x57f305),{'terminalOutput':_0x57f305[a3_0x2f56('0x14')]?_0x57f305[a3_0x2f56('0x14')][a3_0x2f56('0x17')](0x0,0x14)+a3_0x2f56('0x26'):undefined});});output[a3_0x2f56('0x23')]({'title':a3_0x2f56('0x22'),'bodyLines':['\x0a'+JSON[a3_0x2f56('0x32')](_0x3c4428,null,0x2)]});}const _0xedd654=yield(0x0,axios_1[a3_0x2f56('0x2f')])('RunEnd\x20duration',()=>(0x0,axios_1[a3_0x2f56('0x1e')])(()=>this[a3_0x2f56('0x31')][a3_0x2f56('0x20')](a3_0x2f56('0x24'),_0x54828f,{'headers':Object[a3_0x2f56('0x36')](Object['assign']({},this['apiAxiosInstance'][a3_0x2f56('0x15')][a3_0x2f56('0x3a')]),{'Content-Encoding':'gzip','Content-Type':a3_0x2f56('0x1')})})));if(_0xedd654){_0x576bbe[a3_0x2f56('0x8')]((0x0,metric_logger_1['mapRespToPerfEntry'])(_0xedd654));if(_0xedd654[a3_0x2f56('0x2')]&&_0xedd654[a3_0x2f56('0x2')][a3_0x2f56('0xb')]&&_0xedd654[a3_0x2f56('0x2')][a3_0x2f56('0x44')]===a3_0x2f56('0x2d')){this[a3_0x2f56('0x12')]['runUrl']=_0xedd654[a3_0x2f56('0x2')][a3_0x2f56('0xb')];return!![];}if(_0xedd654[a3_0x2f56('0x2')]&&_0xedd654[a3_0x2f56('0x2')][a3_0x2f56('0x44')]){this['messages']['apiError']='Invalid\x20end\x20run\x20response:\x20'+JSON['stringify'](_0xedd654[a3_0x2f56('0x2')][a3_0x2f56('0x25')]);}else if(_0xedd654[a3_0x2f56('0x2')]&&typeof _0xedd654[a3_0x2f56('0x2')]===a3_0x2f56('0x9')){if(_0xedd654['data']!==a3_0x2f56('0x2d')){this[a3_0x2f56('0x1a')]['apiError']=a3_0x2f56('0x45')+JSON[a3_0x2f56('0x32')](_0xedd654[a3_0x2f56('0x2')]);}}else{this[a3_0x2f56('0x1a')][a3_0x2f56('0x3f')]=a3_0x2f56('0x45')+JSON['stringify'](_0xedd654[a3_0x2f56('0x2')]);}if(environment_1[a3_0x2f56('0x2c')]){output[a3_0x2f56('0x23')]({'title':a3_0x2f56('0x0'),'bodyLines':[JSON['stringify'](_0xedd654[a3_0x2f56('0x2')],null,0x2)]});}}else{output[a3_0x2f56('0xe')]({'title':a3_0x2f56('0x27'),'bodyLines':['Run\x20completion\x20responded\x20with\x20`undefined`.',a3_0x2f56('0x41'),JSON[a3_0x2f56('0x32')](_0x5253ff,null,0x2),'Stack\x20Trace:',JSON['stringify'](new Error()['stack'],null,0x2)]});}return![];}catch(_0x4d7e30){_0x576bbe['recordMetric'](((_0x15c8b0=_0x4d7e30===null||_0x4d7e30===void 0x0?void 0x0:_0x4d7e30['axiosException'])===null||_0x15c8b0===void 0x0?void 0x0:_0x15c8b0['response'])?(0x0,metric_logger_1[a3_0x2f56('0x16')])(_0x4d7e30[a3_0x2f56('0x21')][a3_0x2f56('0x29')]):metric_logger_1[a3_0x2f56('0x3b')]);const _0x24b6aa=(_0x47f74c=_0x4d7e30[a3_0x2f56('0x21')])!==null&&_0x47f74c!==void 0x0?_0x47f74c:_0x4d7e30;this[a3_0x2f56('0x1a')][a3_0x2f56('0x3f')]=this[a3_0x2f56('0x1a')][a3_0x2f56('0x33')](_0x24b6aa,a3_0x2f56('0x2e'));return![];}});}[a3_0x2f56('0x38')](){try{const _0x43d0b8=JSON[a3_0x2f56('0x42')]((0x0,fs_1['readFileSync'])(a3_0x2f56('0xf'))[a3_0x2f56('0x3e')]());return _0x43d0b8[a3_0x2f56('0x30')][a3_0x2f56('0x28')];}catch(_0x507f05){return'unknown';}}}exports[a3_0x2f56('0x3d')]=CloudRunApi;
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.CloudRunApi = void 0;
13
+ const axios_1 = require("../../../utilities/axios");
14
+ const environment_1 = require("../../../utilities/environment");
15
+ const fs_1 = require("fs");
16
+ const zlib_1 = require("zlib");
17
+ const util_1 = require("util");
18
+ const metric_logger_1 = require("../../../utilities/metric-logger");
19
+ const { 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
+ // API is not working, don't make the end request
31
+ if (this.messages.apiError)
32
+ return {};
33
+ const recorder = (0, metric_logger_1.createMetricRecorder)('startRun');
34
+ try {
35
+ const request = {
36
+ meta: {
37
+ nxCloudVersion: this.nxCloudVersion(),
38
+ },
39
+ branch: (0, environment_1.getBranch)(),
40
+ runGroup: (0, environment_1.getRunGroup)(),
41
+ ciExecutionId: (0, environment_1.getCIExecutionId)(),
42
+ ciExecutionEnv: (0, environment_1.getCIExecutionEnv)(),
43
+ distributedExecutionId,
44
+ hashes,
45
+ };
46
+ if (environment_1.VERBOSE_LOGGING) {
47
+ output.note({
48
+ title: 'RunStart',
49
+ bodyLines: ['\n' + JSON.stringify(request, null, 2)],
50
+ });
51
+ }
52
+ const resp = yield (0, axios_1.printDuration)('RunStart duration', () => (0, axios_1.axiosMultipleTries)(() => this.apiAxiosInstance.post('/nx-cloud/runs/start', request)));
53
+ recorder.recordMetric((0, metric_logger_1.mapRespToPerfEntry)(resp));
54
+ if (resp.data && resp.data.message) {
55
+ this.messages.message = resp.data.message;
56
+ }
57
+ if (!resp.data || !resp.data.urls) {
58
+ this.messages.apiError = `Invalid Nx Cloud response: ${JSON.stringify(resp.data)}`;
59
+ return {};
60
+ }
61
+ return resp.data.urls;
62
+ }
63
+ catch (e) {
64
+ recorder.recordMetric(((_a = e === null || e === void 0 ? void 0 : e.axiosException) === null || _a === void 0 ? void 0 : _a.response)
65
+ ? (0, metric_logger_1.mapRespToPerfEntry)(e.axiosException.response)
66
+ : metric_logger_1.RUNNER_FAILURE_PERF_ENTRY);
67
+ this.messages.apiError = this.messages.extractErrorMessage(e, 'api');
68
+ return {};
69
+ }
70
+ });
71
+ }
72
+ createReqBody(run, tasks, ciExecutionContext, linkId) {
73
+ const uncompressedReqBody = Object.assign(Object.assign({ meta: {
74
+ nxCloudVersion: this.nxCloudVersion(),
75
+ }, tasks,
76
+ run,
77
+ linkId }, ciExecutionContext), { machineInfo: this.machineInfo });
78
+ return JSON.stringify(uncompressedReqBody);
79
+ }
80
+ endRun(run, tasks, ciExecutionContext, linkId) {
81
+ var _a, _b;
82
+ return __awaiter(this, void 0, void 0, function* () {
83
+ // API is not working, don't make the end request
84
+ if (this.messages.apiError)
85
+ return false;
86
+ let uncompressedBodyString = this.createReqBody(run, tasks, ciExecutionContext, linkId);
87
+ // if the req body is > 20mb, remove hashDetails
88
+ if (uncompressedBodyString.length > 20 * 1000 * 1000) {
89
+ uncompressedBodyString = this.createReqBody(run, tasks.map((t) => (Object.assign(Object.assign({}, t), { hashDetails: undefined }))), ciExecutionContext, linkId);
90
+ }
91
+ const uncompressedBuffer = Buffer.from(uncompressedBodyString);
92
+ const compressedBuffer = yield (0, util_1.promisify)(zlib_1.gzip)(uncompressedBuffer);
93
+ const recorder = (0, metric_logger_1.createMetricRecorder)('endRun');
94
+ try {
95
+ if (environment_1.VERBOSE_LOGGING) {
96
+ const t = tasks.map((tt) => {
97
+ return Object.assign(Object.assign({}, tt), { terminalOutput: tt.terminalOutput
98
+ ? `${tt.terminalOutput.slice(0, 20)}...`
99
+ : undefined });
100
+ });
101
+ output.note({
102
+ title: 'RunEnd. Completed tasks',
103
+ bodyLines: ['\n' + JSON.stringify(t, null, 2)],
104
+ });
105
+ }
106
+ const resp = yield (0, axios_1.printDuration)('RunEnd duration', () => (0, axios_1.axiosMultipleTries)(() => this.apiAxiosInstance.post('/nx-cloud/runs/end', compressedBuffer, {
107
+ headers: Object.assign(Object.assign({}, this.apiAxiosInstance.defaults.headers), { 'Content-Encoding': 'gzip', 'Content-Type': 'application/octet-stream' }),
108
+ })));
109
+ if (resp) {
110
+ recorder.recordMetric((0, metric_logger_1.mapRespToPerfEntry)(resp));
111
+ if (resp.data && resp.data.runUrl && resp.data.status === 'success') {
112
+ this.runContext.runUrl = resp.data.runUrl;
113
+ return true;
114
+ }
115
+ if (resp.data && resp.data.status) {
116
+ this.messages.apiError = `Invalid end run response: ${JSON.stringify(resp.data.message)}`;
117
+ }
118
+ else if (resp.data && typeof resp.data === 'string') {
119
+ if (resp.data !== 'success') {
120
+ this.messages.apiError = `Invalid end run response: ${JSON.stringify(resp.data)}`;
121
+ }
122
+ }
123
+ else {
124
+ this.messages.apiError = `Invalid end run response: ${JSON.stringify(resp.data)}`;
125
+ }
126
+ if (environment_1.VERBOSE_LOGGING) {
127
+ output.note({
128
+ title: 'Invalid end run response',
129
+ bodyLines: [JSON.stringify(resp.data, null, 2)],
130
+ });
131
+ }
132
+ }
133
+ else {
134
+ output.error({
135
+ title: 'Nx Cloud: Unknown Error Occurred',
136
+ bodyLines: [
137
+ 'Run completion responded with `undefined`.',
138
+ 'Run Details:',
139
+ JSON.stringify(run, null, 2),
140
+ 'Stack Trace:',
141
+ JSON.stringify(new Error().stack, null, 2),
142
+ ],
143
+ });
144
+ }
145
+ return false;
146
+ }
147
+ catch (ee) {
148
+ recorder.recordMetric(((_a = ee === null || ee === void 0 ? void 0 : ee.axiosException) === null || _a === void 0 ? void 0 : _a.response)
149
+ ? (0, metric_logger_1.mapRespToPerfEntry)(ee.axiosException.response)
150
+ : metric_logger_1.RUNNER_FAILURE_PERF_ENTRY);
151
+ const e = (_b = ee.axiosException) !== null && _b !== void 0 ? _b : ee;
152
+ this.messages.apiError = this.messages.extractErrorMessage(e, 'api');
153
+ return false;
154
+ }
155
+ });
156
+ }
157
+ nxCloudVersion() {
158
+ try {
159
+ const v = JSON.parse((0, fs_1.readFileSync)(`package.json`).toString());
160
+ return v.devDependencies['@nrwl/nx-cloud'];
161
+ }
162
+ catch (e) {
163
+ return 'unknown';
164
+ }
165
+ }
166
+ }
167
+ exports.CloudRunApi = CloudRunApi;
168
+ //# sourceMappingURL=cloud-run.api.js.map
@@ -1 +1,16 @@
1
- const a4_0x21b7=['length','generateUniqueLinkId','ABCDEFGHIJKLMNOPQRSTUVWXYZ','toLowerCase','floor','defineProperty'];(function(_0x1b06ad,_0x21b7b8){const _0x284bce=function(_0x18ce9d){while(--_0x18ce9d){_0x1b06ad['push'](_0x1b06ad['shift']());}};_0x284bce(++_0x21b7b8);}(a4_0x21b7,0xd5));const a4_0x284b=function(_0x1b06ad,_0x21b7b8){_0x1b06ad=_0x1b06ad-0x0;let _0x284bce=a4_0x21b7[_0x1b06ad];return _0x284bce;};'use strict';Object[a4_0x284b('0x2')](exports,'__esModule',{'value':!![]});exports['generateUniqueLinkId']=void 0x0;const upper=a4_0x284b('0x5');const digits='0123456789';const lower=upper[a4_0x284b('0x0')]();const alphanum=upper+lower+digits;function generateUniqueLinkId(){let _0x2c1916='';for(let _0x30e3ab=0x0;_0x30e3ab<0xa;++_0x30e3ab){_0x2c1916+=alphanum[Math[a4_0x284b('0x1')](Math['random']()*alphanum[a4_0x284b('0x3')])];}return _0x2c1916;}exports[a4_0x284b('0x4')]=generateUniqueLinkId;
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.generateUniqueLinkId = void 0;
4
+ const upper = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ';
5
+ const digits = '0123456789';
6
+ const lower = upper.toLowerCase();
7
+ const alphanum = upper + lower + digits;
8
+ function generateUniqueLinkId() {
9
+ let res = '';
10
+ for (let i = 0; i < 10; ++i) {
11
+ res += alphanum[Math.floor(Math.random() * alphanum.length)];
12
+ }
13
+ return res;
14
+ }
15
+ exports.generateUniqueLinkId = generateUniqueLinkId;
16
+ //# sourceMappingURL=id-generator.js.map
@@ -1 +1,93 @@
1
- const a5_0x1202=['Completed\x20run\x20group\x20with\x20an\x20error','error','response','ciExecutionId:\x20','../../../utilities/environment','done','../../../utilities/metric-logger','RUNNER_FAILURE_PERF_ENTRY','ciExecutionEnv','error:\x20','runGroup:\x20','apply','value','ciExecutionEnv:\x20','mapRespToPerfEntry','completeRunGroup','defineProperty','note','agentName','branch','recordMetric','next','createMetricRecorder','tasks','runGroup','../../../utilities/axios','then','../../../utilities/nx-imports','data','DistributedAgentApi','axiosMultipleTries','axiosException','throw','completeRunGroupWithError','apiAxiosInstance','/nx-cloud/executions/tasks','post','ciExecutionId','/nx-cloud/executions/complete-run-group'];(function(_0x34593d,_0x120289){const _0x31ae10=function(_0x5c597e){while(--_0x5c597e){_0x34593d['push'](_0x34593d['shift']());}};_0x31ae10(++_0x120289);}(a5_0x1202,0x140));const a5_0x31ae=function(_0x34593d,_0x120289){_0x34593d=_0x34593d-0x0;let _0x31ae10=a5_0x1202[_0x34593d];return _0x31ae10;};'use strict';var __awaiter=this&&this['__awaiter']||function(_0x54ad12,_0x1a62d7,_0x40b89b,_0x1a2173){function _0x2073bb(_0xa3dd7a){return _0xa3dd7a instanceof _0x40b89b?_0xa3dd7a:new _0x40b89b(function(_0x1a67fc){_0x1a67fc(_0xa3dd7a);});}return new(_0x40b89b||(_0x40b89b=Promise))(function(_0x30853b,_0x389739){function _0x4feba8(_0x25579a){try{_0x60b604(_0x1a2173[a5_0x31ae('0xd')](_0x25579a));}catch(_0x324c04){_0x389739(_0x324c04);}}function _0x48faf5(_0x267518){try{_0x60b604(_0x1a2173[a5_0x31ae('0x18')](_0x267518));}catch(_0x3a6cf9){_0x389739(_0x3a6cf9);}}function _0x60b604(_0xe745a){_0xe745a[a5_0x31ae('0x24')]?_0x30853b(_0xe745a[a5_0x31ae('0x4')]):_0x2073bb(_0xe745a['value'])[a5_0x31ae('0x12')](_0x4feba8,_0x48faf5);}_0x60b604((_0x1a2173=_0x1a2173[a5_0x31ae('0x3')](_0x54ad12,_0x1a62d7||[]))[a5_0x31ae('0xd')]());});};Object[a5_0x31ae('0x8')](exports,'__esModule',{'value':!![]});exports[a5_0x31ae('0x15')]=void 0x0;const axios_1=require(a5_0x31ae('0x11'));const environment_1=require(a5_0x31ae('0x23'));const metric_logger_1=require(a5_0x31ae('0x25'));const {output}=require(a5_0x31ae('0x13'));class DistributedAgentApi{constructor(_0x50d9fc,_0x419973,_0x1421b3,_0x46d933,_0x5e3439,_0x14c356){this[a5_0x31ae('0xb')]=_0x419973;this[a5_0x31ae('0x10')]=_0x1421b3;this[a5_0x31ae('0x1d')]=_0x46d933;this[a5_0x31ae('0x0')]=_0x5e3439;this[a5_0x31ae('0xa')]=_0x14c356;this[a5_0x31ae('0x1a')]=(0x0,axios_1['createApiAxiosInstance'])(_0x50d9fc);}[a5_0x31ae('0xf')](_0x343e19,_0x1e67d0,_0x43fe74,_0x3b102b){var _0x44ec36;return __awaiter(this,void 0x0,void 0x0,function*(){const _0x3022c1=(0x0,metric_logger_1['createMetricRecorder'])('dtePollTasks');try{const _0x415c67=yield(0x0,axios_1[a5_0x31ae('0x16')])(()=>this[a5_0x31ae('0x1a')][a5_0x31ae('0x1c')](a5_0x31ae('0x1b'),{'runGroup':this[a5_0x31ae('0x10')],'ciExecutionId':this['ciExecutionId'],'ciExecutionEnv':this['ciExecutionEnv'],'agentName':this['agentName'],'executionId':_0x343e19,'statusCode':_0x1e67d0,'completedTasks':_0x43fe74,'targets':_0x3b102b}));_0x3022c1[a5_0x31ae('0xc')]((0x0,metric_logger_1[a5_0x31ae('0x6')])(_0x415c67));return _0x415c67[a5_0x31ae('0x14')];}catch(_0x478116){_0x3022c1[a5_0x31ae('0xc')](((_0x44ec36=_0x478116===null||_0x478116===void 0x0?void 0x0:_0x478116[a5_0x31ae('0x17')])===null||_0x44ec36===void 0x0?void 0x0:_0x44ec36[a5_0x31ae('0x21')])?(0x0,metric_logger_1['mapRespToPerfEntry'])(_0x478116[a5_0x31ae('0x17')][a5_0x31ae('0x21')]):metric_logger_1[a5_0x31ae('0x26')]);throw _0x478116;}});}[a5_0x31ae('0x19')](_0x46895d){var _0x41cba1;return __awaiter(this,void 0x0,void 0x0,function*(){if(environment_1['VERBOSE_LOGGING']){output[a5_0x31ae('0x9')]({'title':'Completing\x20with\x20an\x20error','bodyLines':[a5_0x31ae('0x22')+this['ciExecutionId'],a5_0x31ae('0x5')+this['ciExecutionEnv'],a5_0x31ae('0x2')+this[a5_0x31ae('0x10')],a5_0x31ae('0x1')+_0x46895d]});}const _0xc44c03=(0x0,metric_logger_1[a5_0x31ae('0xe')])(a5_0x31ae('0x7'));try{const _0x4c8e36=yield(0x0,axios_1['axiosMultipleTries'])(()=>this[a5_0x31ae('0x1a')][a5_0x31ae('0x1c')](a5_0x31ae('0x1e'),{'branch':this[a5_0x31ae('0xb')],'runGroup':this['runGroup'],'ciExecutionId':this[a5_0x31ae('0x1d')],'ciExecutionEnv':this[a5_0x31ae('0x0')],'agentName':this[a5_0x31ae('0xa')],'criticalErrorMessage':_0x46895d}));if(environment_1['VERBOSE_LOGGING']){output[a5_0x31ae('0x9')]({'title':a5_0x31ae('0x1f')});}_0xc44c03[a5_0x31ae('0xc')]((0x0,metric_logger_1[a5_0x31ae('0x6')])(_0x4c8e36));}catch(_0x57ad36){_0xc44c03[a5_0x31ae('0xc')](((_0x41cba1=_0x57ad36===null||_0x57ad36===void 0x0?void 0x0:_0x57ad36[a5_0x31ae('0x17')])===null||_0x41cba1===void 0x0?void 0x0:_0x41cba1[a5_0x31ae('0x21')])?(0x0,metric_logger_1[a5_0x31ae('0x6')])(_0x57ad36[a5_0x31ae('0x17')][a5_0x31ae('0x21')]):metric_logger_1['RUNNER_FAILURE_PERF_ENTRY']);console[a5_0x31ae('0x20')](_0x57ad36);}});}}exports[a5_0x31ae('0x15')]=DistributedAgentApi;
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.DistributedAgentApi = void 0;
13
+ const axios_1 = require("../../../utilities/axios");
14
+ const environment_1 = require("../../../utilities/environment");
15
+ const metric_logger_1 = require("../../../utilities/metric-logger");
16
+ const { output } = require('../../../utilities/nx-imports');
17
+ class DistributedAgentApi {
18
+ constructor(options, branch, runGroup, ciExecutionId, ciExecutionEnv, agentName) {
19
+ this.branch = branch;
20
+ this.runGroup = runGroup;
21
+ this.ciExecutionId = ciExecutionId;
22
+ this.ciExecutionEnv = ciExecutionEnv;
23
+ this.agentName = agentName;
24
+ this.apiAxiosInstance = (0, axios_1.createApiAxiosInstance)(options);
25
+ }
26
+ tasks(executionId, statusCode, completedTasks, targets) {
27
+ var _a;
28
+ return __awaiter(this, void 0, void 0, function* () {
29
+ const recorder = (0, metric_logger_1.createMetricRecorder)('dtePollTasks');
30
+ try {
31
+ const res = yield (0, axios_1.axiosMultipleTries)(() => this.apiAxiosInstance.post('/nx-cloud/executions/tasks', {
32
+ runGroup: this.runGroup,
33
+ ciExecutionId: this.ciExecutionId,
34
+ ciExecutionEnv: this.ciExecutionEnv,
35
+ agentName: this.agentName,
36
+ executionId,
37
+ statusCode,
38
+ completedTasks,
39
+ targets,
40
+ }));
41
+ recorder.recordMetric((0, metric_logger_1.mapRespToPerfEntry)(res));
42
+ return res.data;
43
+ }
44
+ catch (e) {
45
+ recorder.recordMetric(((_a = e === null || e === void 0 ? void 0 : e.axiosException) === null || _a === void 0 ? void 0 : _a.response)
46
+ ? (0, metric_logger_1.mapRespToPerfEntry)(e.axiosException.response)
47
+ : metric_logger_1.RUNNER_FAILURE_PERF_ENTRY);
48
+ throw e;
49
+ }
50
+ });
51
+ }
52
+ completeRunGroupWithError(error) {
53
+ var _a;
54
+ return __awaiter(this, void 0, void 0, function* () {
55
+ if (environment_1.VERBOSE_LOGGING) {
56
+ output.note({
57
+ title: 'Completing with an error',
58
+ bodyLines: [
59
+ `ciExecutionId: ${this.ciExecutionId}`,
60
+ `ciExecutionEnv: ${this.ciExecutionEnv}`,
61
+ `runGroup: ${this.runGroup}`,
62
+ `error: ${error}`,
63
+ ],
64
+ });
65
+ }
66
+ const recorder = (0, metric_logger_1.createMetricRecorder)('completeRunGroup');
67
+ try {
68
+ const resp = yield (0, axios_1.axiosMultipleTries)(() => this.apiAxiosInstance.post('/nx-cloud/executions/complete-run-group', {
69
+ branch: this.branch,
70
+ runGroup: this.runGroup,
71
+ ciExecutionId: this.ciExecutionId,
72
+ ciExecutionEnv: this.ciExecutionEnv,
73
+ agentName: this.agentName,
74
+ criticalErrorMessage: error,
75
+ }));
76
+ if (environment_1.VERBOSE_LOGGING) {
77
+ output.note({
78
+ title: 'Completed run group with an error',
79
+ });
80
+ }
81
+ recorder.recordMetric((0, metric_logger_1.mapRespToPerfEntry)(resp));
82
+ }
83
+ catch (e) {
84
+ recorder.recordMetric(((_a = e === null || e === void 0 ? void 0 : e.axiosException) === null || _a === void 0 ? void 0 : _a.response)
85
+ ? (0, metric_logger_1.mapRespToPerfEntry)(e.axiosException.response)
86
+ : metric_logger_1.RUNNER_FAILURE_PERF_ENTRY);
87
+ console.error(e);
88
+ }
89
+ });
90
+ }
91
+ }
92
+ exports.DistributedAgentApi = DistributedAgentApi;
93
+ //# sourceMappingURL=distributed-agent.api.js.map