@nrwl/nx-cloud 12.5.2 → 13.0.0-beta.4
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/bin/nx-cloud.js +5 -5
- package/bin/nx-cloud.js.map +1 -1
- package/lib/core/api/run-group.api.js +59 -1
- package/lib/core/api/run-group.api.js.map +1 -1
- package/lib/core/commands/clean-up-agents.js +2 -2
- package/lib/core/commands/clean-up-agents.js.map +1 -1
- package/lib/core/commands/start-ci-run.js +4 -4
- package/lib/core/commands/start-ci-run.js.map +1 -1
- package/lib/core/commands/stop-all-agents.js +3 -3
- package/lib/core/commands/stop-all-agents.js.map +1 -1
- package/lib/core/file-storage/e2e-encryption.js +7 -7
- package/lib/core/file-storage/e2e-encryption.js.map +1 -1
- package/lib/core/file-storage/file-storage.js +43 -24
- package/lib/core/file-storage/file-storage.js.map +1 -1
- package/lib/core/runners/cloud-enabled/{task-runner-life-cycle.d.ts → cloud-enabled-life-cycle.d.ts} +4 -3
- package/lib/core/runners/cloud-enabled/cloud-enabled-life-cycle.js +121 -0
- package/lib/core/runners/cloud-enabled/cloud-enabled-life-cycle.js.map +1 -0
- package/lib/core/runners/cloud-enabled/cloud-enabled.runner.js +165 -1
- package/lib/core/runners/cloud-enabled/cloud-enabled.runner.js.map +1 -1
- package/lib/core/runners/cloud-enabled/cloud-remote-cache.js +113 -1
- package/lib/core/runners/cloud-enabled/cloud-remote-cache.js.map +1 -1
- package/lib/core/runners/cloud-enabled/cloud-run.api.js +135 -1
- package/lib/core/runners/cloud-enabled/cloud-run.api.js.map +1 -1
- package/lib/core/runners/distributed-agent/distributed-agent.api.js +73 -1
- package/lib/core/runners/distributed-agent/distributed-agent.api.js.map +1 -1
- package/lib/core/runners/distributed-agent/{distributed-agent.runner.d.ts → distributed-agent.impl.d.ts} +0 -0
- package/lib/core/runners/distributed-agent/distributed-agent.impl.js +233 -0
- package/lib/core/runners/distributed-agent/distributed-agent.impl.js.map +1 -0
- package/lib/core/runners/distributed-execution/distributed-execution.api.d.ts +1 -1
- package/lib/core/runners/distributed-execution/distributed-execution.api.js +117 -1
- package/lib/core/runners/distributed-execution/distributed-execution.api.js.map +1 -1
- package/lib/core/runners/distributed-execution/distributed-execution.runner.js +270 -1
- package/lib/core/runners/distributed-execution/distributed-execution.runner.js.map +1 -1
- package/lib/core/terminal-output/end-of-run-message.d.ts +2 -5
- package/lib/core/terminal-output/end-of-run-message.js +4 -41
- package/lib/core/terminal-output/end-of-run-message.js.map +1 -1
- package/lib/core/terminal-output/message-reporter.js +1 -1
- package/lib/core/terminal-output/message-reporter.js.map +1 -1
- package/lib/core/terminal-output/output-obfuscator.js +1 -1
- package/lib/core/terminal-output/output-obfuscator.js.map +1 -1
- package/lib/generators/init/init.js +1 -1
- package/lib/generators/init/init.js.map +1 -1
- package/lib/nx-cloud-tasks-runner.js +7 -7
- package/lib/nx-cloud-tasks-runner.js.map +1 -1
- package/lib/utilities/axios.js +1 -1
- package/lib/utilities/axios.js.map +1 -1
- package/lib/utilities/environment.d.ts +1 -0
- package/lib/utilities/environment.js +5 -4
- package/lib/utilities/environment.js.map +1 -1
- package/lib/utilities/metric-logger.d.ts +34 -0
- package/lib/utilities/metric-logger.js +72 -0
- package/lib/utilities/metric-logger.js.map +1 -0
- package/package.json +1 -1
- package/lib/core/runners/cloud-enabled/task-runner-life-cycle.js +0 -1
- package/lib/core/runners/cloud-enabled/task-runner-life-cycle.js.map +0 -1
- package/lib/core/runners/distributed-agent/distributed-agent.runner.js +0 -1
- package/lib/core/runners/distributed-agent/distributed-agent.runner.js.map +0 -1
|
@@ -1 +1,165 @@
|
|
|
1
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.cloudEnabledTasksRunner = void 0;
|
|
13
|
+
const Subject_1 = require("rxjs/internal/Subject");
|
|
14
|
+
const message_reporter_1 = require("../../terminal-output/message-reporter");
|
|
15
|
+
const end_of_run_message_1 = require("../../terminal-output/end-of-run-message");
|
|
16
|
+
const output_obfuscator_1 = require("../../terminal-output/output-obfuscator");
|
|
17
|
+
const cloud_enabled_life_cycle_1 = require("./cloud-enabled-life-cycle");
|
|
18
|
+
const file_storage_1 = require("../../file-storage/file-storage");
|
|
19
|
+
const e2e_encryption_1 = require("../../file-storage/e2e-encryption");
|
|
20
|
+
const environment_1 = require("../../../utilities/environment");
|
|
21
|
+
const cloud_remote_cache_1 = require("./cloud-remote-cache");
|
|
22
|
+
const tasks_runner_v2_1 = require("@nrwl/workspace/src/tasks-runner/tasks-runner-v2");
|
|
23
|
+
const output_1 = require("@nrwl/workspace/src/utilities/output");
|
|
24
|
+
const cloud_run_api_1 = require("./cloud-run.api");
|
|
25
|
+
const fs_1 = require("fs");
|
|
26
|
+
const path = require("path");
|
|
27
|
+
const metric_logger_1 = require("../../../utilities/metric-logger");
|
|
28
|
+
function createApi(errors, options, runContext) {
|
|
29
|
+
const machineInfo = (0, environment_1.getMachineInfo)(options);
|
|
30
|
+
return new cloud_run_api_1.CloudRunApi(errors, runContext, options, machineInfo);
|
|
31
|
+
}
|
|
32
|
+
function storeTaskHashes(taskExecutions, directory) {
|
|
33
|
+
const hashes = JSON.stringify(taskExecutions.map((t) => ({
|
|
34
|
+
taskId: t.taskId,
|
|
35
|
+
hash: t.hash,
|
|
36
|
+
})));
|
|
37
|
+
if (environment_1.VERBOSE_LOGGING) {
|
|
38
|
+
output_1.output.note({
|
|
39
|
+
title: `Executed tasks with hashes: ${hashes}`,
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
(0, fs_1.writeFileSync)(path.join(directory, 'tasks-hashes'), hashes);
|
|
43
|
+
}
|
|
44
|
+
function onComplete(lifeCycle, options, remoteCache, api, outputObfuscator, runStartTime, messages, endOfRunMessage, taskExecutions) {
|
|
45
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
46
|
+
const runEndTime = new Date().toISOString();
|
|
47
|
+
if (environment_1.VERBOSE_LOGGING) {
|
|
48
|
+
const tasks = taskExecutions.map((tt) => {
|
|
49
|
+
return Object.assign(Object.assign({}, tt), { terminalOutput: tt.terminalOutput
|
|
50
|
+
? `${tt.terminalOutput.slice(0, 20)}...`
|
|
51
|
+
: undefined });
|
|
52
|
+
});
|
|
53
|
+
output_1.output.note({
|
|
54
|
+
title: 'Completed tasks',
|
|
55
|
+
bodyLines: ['\n' + JSON.stringify(tasks, null, 2)],
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
if (environment_1.AGENT_RUNNING_IN_DISTRIBUTED_EXECUTION) {
|
|
59
|
+
storeTaskHashes(taskExecutions, options.cacheDirectory || './node_modules/.cache/nx');
|
|
60
|
+
}
|
|
61
|
+
const branch = (0, environment_1.getBranch)();
|
|
62
|
+
const endRequest = yield Promise.all([
|
|
63
|
+
remoteCache.waitForStoreRequestsToComplete(),
|
|
64
|
+
api.endRun({
|
|
65
|
+
command: outputObfuscator.obfuscate((0, environment_1.parseCommand)()),
|
|
66
|
+
startTime: runStartTime,
|
|
67
|
+
endTime: runEndTime,
|
|
68
|
+
distributedExecutionId: environment_1.NX_CLOUD_DISTRIBUTED_EXECUTION_ID,
|
|
69
|
+
branch: branch,
|
|
70
|
+
scan: true,
|
|
71
|
+
runGroup: (0, environment_1.getRunGroup)(),
|
|
72
|
+
// only set sha if branch is set cause we invoke a separate process,
|
|
73
|
+
// which adds a few millis
|
|
74
|
+
sha: branch ? (0, environment_1.extractGitSha)() : undefined,
|
|
75
|
+
}, taskExecutions),
|
|
76
|
+
]);
|
|
77
|
+
messages.printMessages();
|
|
78
|
+
if (!messages.anyErrors) {
|
|
79
|
+
endOfRunMessage.printCacheHitsMessage();
|
|
80
|
+
}
|
|
81
|
+
if (environment_1.AGENT_RUNNING_IN_DISTRIBUTED_EXECUTION) {
|
|
82
|
+
if (!endRequest[0]) {
|
|
83
|
+
output_1.output.error({
|
|
84
|
+
title: `Agent wasn't able to store artifacts`,
|
|
85
|
+
});
|
|
86
|
+
process.exit(environment_1.DISTRIBUTED_TASK_EXECUTION_INTERNAL_ERROR_STATUS_CODE);
|
|
87
|
+
}
|
|
88
|
+
if (!endRequest[1]) {
|
|
89
|
+
output_1.output.error({
|
|
90
|
+
title: `Agent wasn't able to record its run`,
|
|
91
|
+
});
|
|
92
|
+
process.exit(environment_1.DISTRIBUTED_TASK_EXECUTION_INTERNAL_ERROR_STATUS_CODE);
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
try {
|
|
96
|
+
yield (0, metric_logger_1.submitRunMetrics)(options);
|
|
97
|
+
}
|
|
98
|
+
catch (e) { }
|
|
99
|
+
});
|
|
100
|
+
}
|
|
101
|
+
function createLifeCycle(runContext, options, outputObfuscator, tasks) {
|
|
102
|
+
const cloudEnabledLifeCycle = new cloud_enabled_life_cycle_1.CloudEnabledLifeCycle(runContext, options.cacheDirectory, options.scan === undefined ? true : options.scan, options.cacheableOperations || [], outputObfuscator, tasks);
|
|
103
|
+
try {
|
|
104
|
+
const { CompositeLifeCycle, } = require('@nrwl/workspace/src/tasks-runner/life-cycle');
|
|
105
|
+
if (!CompositeLifeCycle)
|
|
106
|
+
return cloudEnabledLifeCycle;
|
|
107
|
+
return new CompositeLifeCycle([options.lifeCycle, cloudEnabledLifeCycle]);
|
|
108
|
+
}
|
|
109
|
+
catch (e) {
|
|
110
|
+
return cloudEnabledLifeCycle;
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
function cloudEnabledTasksRunner(tasks, options, context) {
|
|
114
|
+
const runContext = {
|
|
115
|
+
statuses: {},
|
|
116
|
+
scheduledTasks: [],
|
|
117
|
+
requests: {},
|
|
118
|
+
allTasks: tasks,
|
|
119
|
+
};
|
|
120
|
+
const taskExecutions = [];
|
|
121
|
+
const messages = new message_reporter_1.MessageReporter(options);
|
|
122
|
+
const api = createApi(messages, options, runContext);
|
|
123
|
+
const endOfRunMessage = new end_of_run_message_1.EndOfRunMessage(runContext, taskExecutions);
|
|
124
|
+
const outputObfuscator = new output_obfuscator_1.OutputObfuscator();
|
|
125
|
+
const hashes = tasks.map((t) => t.hash).filter((h) => !!h);
|
|
126
|
+
const startRunRequest = api.startRun(environment_1.NX_CLOUD_DISTRIBUTED_EXECUTION_ID, hashes);
|
|
127
|
+
hashes.forEach((hash) => {
|
|
128
|
+
runContext.requests[hash] = startRunRequest;
|
|
129
|
+
});
|
|
130
|
+
const runStartTime = new Date().toISOString();
|
|
131
|
+
const lifeCycle = createLifeCycle(runContext, options, outputObfuscator, taskExecutions);
|
|
132
|
+
const encryption = new e2e_encryption_1.E2EEncryption(environment_1.ENCRYPTION_KEY || options.encryptionKey);
|
|
133
|
+
const fileStorage = new file_storage_1.FileStorage(encryption, environment_1.NUMBER_OF_TRIES);
|
|
134
|
+
const remoteCache = new cloud_remote_cache_1.CloudRemoteCache(messages, api, runContext, fileStorage);
|
|
135
|
+
// have to reset it so we don't capture inner tasks
|
|
136
|
+
delete process.env.NX_CLOUD_DISTRIBUTED_EXECUTION_ID;
|
|
137
|
+
const res = (0, tasks_runner_v2_1.tasksRunnerV2)(tasks, Object.assign(Object.assign({}, options), { remoteCache, lifeCycle }), context);
|
|
138
|
+
// observable -> legacy
|
|
139
|
+
if (res.subscribe) {
|
|
140
|
+
const wrappedRes = new Subject_1.Subject();
|
|
141
|
+
res.subscribe({
|
|
142
|
+
next: (value) => wrappedRes.next(value),
|
|
143
|
+
error: (err) => wrappedRes.error(err),
|
|
144
|
+
complete: () => __awaiter(this, void 0, void 0, function* () {
|
|
145
|
+
yield onComplete(lifeCycle, options, remoteCache, api, outputObfuscator, runStartTime, messages, endOfRunMessage, taskExecutions);
|
|
146
|
+
wrappedRes.complete();
|
|
147
|
+
}),
|
|
148
|
+
});
|
|
149
|
+
return wrappedRes;
|
|
150
|
+
// promise
|
|
151
|
+
}
|
|
152
|
+
else {
|
|
153
|
+
return res
|
|
154
|
+
.then((r) => __awaiter(this, void 0, void 0, function* () {
|
|
155
|
+
yield onComplete(lifeCycle, options, remoteCache, api, outputObfuscator, runStartTime, messages, endOfRunMessage, taskExecutions);
|
|
156
|
+
return r;
|
|
157
|
+
}))
|
|
158
|
+
.catch((e) => __awaiter(this, void 0, void 0, function* () {
|
|
159
|
+
yield onComplete(lifeCycle, options, remoteCache, api, outputObfuscator, runStartTime, messages, endOfRunMessage, taskExecutions);
|
|
160
|
+
throw e;
|
|
161
|
+
}));
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
exports.cloudEnabledTasksRunner = cloudEnabledTasksRunner;
|
|
165
|
+
//# sourceMappingURL=cloud-enabled.runner.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cloud-enabled.runner.js","sourceRoot":"","sources":["../../../../../../../../libs/nx-packages/nx-cloud/src/lib/core/runners/cloud-enabled/cloud-enabled.runner.ts"],"names":[],"mappings":";;;;;;;;;;;;AAMA,mDAAgD;AAEhD,6EAAyE;AACzE,iFAA2E;AAC3E,+EAA2E;AAC3E,
|
|
1
|
+
{"version":3,"file":"cloud-enabled.runner.js","sourceRoot":"","sources":["../../../../../../../../libs/nx-packages/nx-cloud/src/lib/core/runners/cloud-enabled/cloud-enabled.runner.ts"],"names":[],"mappings":";;;;;;;;;;;;AAMA,mDAAgD;AAEhD,6EAAyE;AACzE,iFAA2E;AAC3E,+EAA2E;AAC3E,yEAAmE;AACnE,kE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ACpC,OAAO,CACD,CAAC;IACT,uBAAuB;IACvB,IAAK,GAAW,CAAC,SAAS,EAAE;QAC1B,MAAM,UAAU,GAAG,IAAI,iBAAO,EAAS,CAAC;QACxC,GAAG,CAAC,SAAS,CAAC;YACZ,IAAI,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,UAAU,CAAC,IAAI,CAAC,KAAK,CAAC;YACvC,KAAK,EAAE,CAAC,GAAG,EAAE,EAAE,CAAC,UAAU,CAAC,KAAK,CAAC,GAAG,CAAC;YACrC,QAAQ,EAAE,GAAS,EAAE;gBACnB,MAAM,UAAU,CACd,SAAS,EACT,OAAO,EACP,WAAW,EACX,GAAG,EACH,gBAAgB,EAChB,YAAY,EACZ,QAAQ,EACR,eAAe,EACf,cAAc,CACf,CAAC;gBACF,UAAU,CAAC,QAAQ,EAAE,CAAC;YACxB,CAAC,CAAA;SACF,CAAC,CAAC;QACH,OAAO,UAAU,CAAC;QAClB,UAAU;KACX;SAAM;QACL,OAAO,GAAG;aACP,IAAI,CAAC,CAAO,CAAC,EAAE,EAAE;YAChB,MAAM,UAAU,CACd,SAAS,EACT,OAAO,EACP,WAAW,EACX,GAAG,EACH,gBAAgB,EAChB,YAAY,EACZ,QAAQ,EACR,eAAe,EACf,cAAc,CACf,CAAC;YACF,OAAO,CAAC,CAAC;QACX,CAAC,CAAA,CAAC;aACD,KAAK,CAAC,CAAO,CAAC,EAAE,EAAE;YACjB,MAAM,UAAU,CACd,SAAS,EACT,OAAO,EACP,WAAW,EACX,GAAG,EACH,gBAAgB,EAChB,YAAY,EACZ,QAAQ,EACR,eAAe,EACf,cAAc,CACf,CAAC;YACF,MAAM,CAAC,CAAC;QACV,CAAC,CAAA,CAAC,CAAC;KACN;AACH,CAAC;AAxGD,0DAwGC"}
|
|
@@ -1 +1,113 @@
|
|
|
1
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.CloudRemoteCache = void 0;
|
|
13
|
+
const output_1 = require("@nrwl/workspace/src/utilities/output");
|
|
14
|
+
const environment_1 = require("../../../utilities/environment");
|
|
15
|
+
class CloudRemoteCache {
|
|
16
|
+
constructor(messages, api, runContext, fileStorage) {
|
|
17
|
+
this.messages = messages;
|
|
18
|
+
this.api = api;
|
|
19
|
+
this.runContext = runContext;
|
|
20
|
+
this.fileStorage = fileStorage;
|
|
21
|
+
this.storeRequests = [];
|
|
22
|
+
}
|
|
23
|
+
retrieve(hash, cacheDirectory) {
|
|
24
|
+
var _a;
|
|
25
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
26
|
+
if (this.messages.cacheError)
|
|
27
|
+
return false;
|
|
28
|
+
const hashUrls = yield this.hashUrls(hash);
|
|
29
|
+
if (!hashUrls || !hashUrls.get) {
|
|
30
|
+
if (environment_1.VERBOSE_LOGGING) {
|
|
31
|
+
output_1.output.note({ title: `Nx Cloud: Cache miss ${hash}.` });
|
|
32
|
+
}
|
|
33
|
+
this.runContext.statuses[hash] = 'cache-miss';
|
|
34
|
+
return false;
|
|
35
|
+
}
|
|
36
|
+
try {
|
|
37
|
+
yield this.fileStorage.retrieve(hash, hashUrls.get, cacheDirectory);
|
|
38
|
+
this.runContext.statuses[hash] = 'remote-cache-hit';
|
|
39
|
+
return true;
|
|
40
|
+
}
|
|
41
|
+
catch (ee) {
|
|
42
|
+
const e = (_a = ee.axiosException) !== null && _a !== void 0 ? _a : ee;
|
|
43
|
+
if (e.response && e.response.status === 404) {
|
|
44
|
+
if (environment_1.VERBOSE_LOGGING) {
|
|
45
|
+
output_1.output.note({ title: `Nx Cloud: Cache miss ${hash}. Status 404.` });
|
|
46
|
+
}
|
|
47
|
+
// cache miss. print nothing
|
|
48
|
+
}
|
|
49
|
+
else {
|
|
50
|
+
this.messages.cacheError = this.messages.extractErrorMessage(e, 'storage');
|
|
51
|
+
}
|
|
52
|
+
this.runContext.statuses[hash] = 'cache-miss';
|
|
53
|
+
return false;
|
|
54
|
+
}
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
store(hash, cacheDirectory) {
|
|
58
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
59
|
+
if (this.messages.cacheError)
|
|
60
|
+
return false;
|
|
61
|
+
const res = Promise.resolve().then(() => __awaiter(this, void 0, void 0, function* () {
|
|
62
|
+
var _a;
|
|
63
|
+
const hashUrls = yield this.hashUrls(hash);
|
|
64
|
+
if (!hashUrls)
|
|
65
|
+
return false;
|
|
66
|
+
if (!hashUrls.put) {
|
|
67
|
+
if (environment_1.VERBOSE_LOGGING) {
|
|
68
|
+
output_1.output.note({
|
|
69
|
+
title: `Nx Cloud: Skipping storing ${hash}. Read only token is used.`,
|
|
70
|
+
});
|
|
71
|
+
}
|
|
72
|
+
return true;
|
|
73
|
+
}
|
|
74
|
+
try {
|
|
75
|
+
yield this.fileStorage.store(hash, hashUrls.put, cacheDirectory);
|
|
76
|
+
return true;
|
|
77
|
+
}
|
|
78
|
+
catch (ee) {
|
|
79
|
+
const e = (_a = ee.axiosException) !== null && _a !== void 0 ? _a : ee;
|
|
80
|
+
this.messages.cacheError = this.messages.extractErrorMessage(e, 'storage');
|
|
81
|
+
return false;
|
|
82
|
+
}
|
|
83
|
+
}));
|
|
84
|
+
this.storeRequests.push(res);
|
|
85
|
+
return res;
|
|
86
|
+
});
|
|
87
|
+
}
|
|
88
|
+
hashUrls(hash) {
|
|
89
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
90
|
+
if (hash in this.runContext.requests) {
|
|
91
|
+
return (yield this.runContext.requests[hash])[hash];
|
|
92
|
+
}
|
|
93
|
+
else {
|
|
94
|
+
const scheduledTaskHashesWithoutRequests = this.runContext.scheduledTasks
|
|
95
|
+
.filter((t) => !this.runContext.requests[t.hash])
|
|
96
|
+
.map((t) => t.hash);
|
|
97
|
+
if (scheduledTaskHashesWithoutRequests.indexOf(hash) === -1) {
|
|
98
|
+
scheduledTaskHashesWithoutRequests.push(hash);
|
|
99
|
+
}
|
|
100
|
+
const request = this.api.startRun(environment_1.NX_CLOUD_DISTRIBUTED_EXECUTION_ID, scheduledTaskHashesWithoutRequests);
|
|
101
|
+
scheduledTaskHashesWithoutRequests.forEach((taskHash) => {
|
|
102
|
+
this.runContext.requests[taskHash] = request;
|
|
103
|
+
});
|
|
104
|
+
return (yield request)[hash];
|
|
105
|
+
}
|
|
106
|
+
});
|
|
107
|
+
}
|
|
108
|
+
waitForStoreRequestsToComplete() {
|
|
109
|
+
return Promise.all(this.storeRequests).then((r) => r.reduce((a, b) => a && b, true));
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
exports.CloudRemoteCache = CloudRemoteCache;
|
|
113
|
+
//# sourceMappingURL=cloud-remote-cache.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cloud-remote-cache.js","sourceRoot":"","sources":["../../../../../../../../libs/nx-packages/nx-cloud/src/lib/core/runners/cloud-enabled/cloud-remote-cache.ts"],"names":[],"mappings":";;;;;;;;;;;;AACA,iEAA8D;AAI9D,gEAGwC;AAGxC,MAAa,gBAAgB;IAG3B,YACmB,QAAyB,EACzB,GAAgB,EAChB,UAAsB,EACtB,WAAwB;QAHxB,aAAQ,GAAR,QAAQ,CAAiB;QACzB,QAAG,GAAH,GAAG,CAAa;QAChB,eAAU,GAAV,UAAU,CAAY;QACtB,gBAAW,GAAX,WAAW,CAAa;QAN1B,kBAAa,GAAG,EAAwB,CAAC;IAOvD,CAAC;IAEE,QAAQ,CAAC,IAAY,EAAE,cAAsB;;;YACjD,IAAI,IAAI,CAAC,QAAQ,CAAC,UAAU;gBAAE,OAAO,KAAK,CAAC;YAE3C,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC;YAC3C,IAAI,CAAC,QAAQ,IAAI,CAAC,QAAQ,CAAC,GAAG,EAAE;gBAC9B,IAAI,6BAAe,EAAE;oBACnB,eAAM,CAAC,IAAI,CAAC,EAAE,KAAK,EAAE,wBAAwB,IAAI,GAAG,EAAE,CAAC,CAAC;iBACzD;gBACD,IAAI,CAAC,UAAU,CAAC,QAAQ,CAAC,IAAI,CAAC,GAAG,YAAY,CAAC;gBAC9C,OAAO,KAAK,CAAC;aACd;YAED,IAAI;gBACF,MAAM,IAAI,CAAC,WAAW,CAAC,QAAQ,CAAC,IAAI,EAAE,QAAQ,CAAC,GAAG,EAAE,cAAc,CAAC,CAAC;gBACpE,IAAI,CAAC,UAAU,CAAC,QAAQ,CAAC,IAAI,CAAC,GAAG,kBAAkB,CAAC;gBACpD,OAAO,IAAI,CAAC;aACb;YAAC,OAAO,
|
|
1
|
+
{"version":3,"file":"cloud-remote-cache.js","sourceRoot":"","sources":["../../../../../../../../libs/nx-packages/nx-cloud/src/lib/core/runners/cloud-enabled/cloud-remote-cache.ts"],"names":[],"mappings":";;;;;;;;;;;;AACA,iEAA8D;AAI9D,gEAGwC;AAGxC,MAAa,gBAAgB;IAG3B,YACmB,QAAyB,EACzB,GAAgB,EAChB,UAAsB,EACtB,WAAwB;QAHxB,aAAQ,GAAR,QAAQ,CAAiB;QACzB,QAAG,GAAH,GAAG,CAAa;QAChB,eAAU,GAAV,UAAU,CAAY;QACtB,gBAAW,GAAX,WAAW,CAAa;QAN1B,kBAAa,GAAG,EAAwB,CAAC;IAOvD,CAAC;IAEE,QAAQ,CAAC,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AC;aACrD;iBAAM;gBACL,MAAM,kCAAkC,GAAG,IAAI,CAAC,UAAU,CAAC,cAAc;qBACtE,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,IAAI,CAAC,UAAU,CAAC,QAAQ,CAAC,CAAC,CAAC,IAAM,CAAC,CAAC;qBAClD,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAM,CAAC,CAAC;gBACxB,IAAI,kCAAkC,CAAC,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,EAAE;oBAC3D,kCAAkC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;iBAC/C;gBACD,MAAM,OAAO,GAAG,IAAI,CAAC,GAAG,CAAC,QAAQ,CAC/B,+CAAiC,EACjC,kCAAkC,CACnC,CAAC;gBACF,kCAAkC,CAAC,OAAO,CAAC,CAAC,QAAQ,EAAE,EAAE;oBACtD,IAAI,CAAC,UAAU,CAAC,QAAQ,CAAC,QAAQ,CAAC,GAAG,OAAO,CAAC;gBAC/C,CAAC,CAAC,CAAC;gBACH,OAAO,CAAC,MAAM,OAAO,CAAC,CAAC,IAAI,CAAC,CAAC;aAC9B;QACH,CAAC;KAAA;IAED,8BAA8B;QAC5B,OAAO,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAChD,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,IAAI,CAAC,EAAE,IAAI,CAAC,CACjC,CAAC;IACJ,CAAC;CACF;AAtGD,4CAsGC"}
|
|
@@ -1 +1,135 @@
|
|
|
1
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.CloudRunApi = void 0;
|
|
13
|
+
const 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 resp = yield (0, axios_1.axiosMultipleTries)(() => this.apiAxiosInstance.post('/nx-cloud/runs/start', {
|
|
32
|
+
meta: {
|
|
33
|
+
nxCloudVersion: this.nxCloudVersion(),
|
|
34
|
+
},
|
|
35
|
+
branch: (0, environment_1.getBranch)(),
|
|
36
|
+
runGroup: (0, environment_1.getRunGroup)(),
|
|
37
|
+
distributedExecutionId,
|
|
38
|
+
hashes,
|
|
39
|
+
}), environment_1.NUMBER_OF_TRIES);
|
|
40
|
+
recorder.recordMetric((0, metric_logger_1.mapRespToPerfEntry)(resp));
|
|
41
|
+
if (resp.data && resp.data.message) {
|
|
42
|
+
this.messages.message = resp.data.message;
|
|
43
|
+
}
|
|
44
|
+
if (!resp.data || !resp.data.urls) {
|
|
45
|
+
this.messages.apiError = `Invalid Nx Cloud response: ${JSON.stringify(resp.data)}`;
|
|
46
|
+
return {};
|
|
47
|
+
}
|
|
48
|
+
return resp.data.urls;
|
|
49
|
+
}
|
|
50
|
+
catch (e) {
|
|
51
|
+
recorder.recordMetric(metric_logger_1.RUNNER_FAILURE_PERF_ENTRY);
|
|
52
|
+
this.messages.apiError = this.messages.extractErrorMessage(e, 'api');
|
|
53
|
+
return {};
|
|
54
|
+
}
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
endRun(run, tasks) {
|
|
58
|
+
var _a;
|
|
59
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
60
|
+
// API is not working, don't make the end request
|
|
61
|
+
if (this.messages.apiError)
|
|
62
|
+
return false;
|
|
63
|
+
const uncompressedReqBody = {
|
|
64
|
+
meta: {
|
|
65
|
+
nxCloudVersion: this.nxCloudVersion(),
|
|
66
|
+
},
|
|
67
|
+
tasks,
|
|
68
|
+
run: run,
|
|
69
|
+
machineInfo: this.machineInfo,
|
|
70
|
+
};
|
|
71
|
+
const uncompressedBuffer = Buffer.from(JSON.stringify(uncompressedReqBody));
|
|
72
|
+
const compressedBuffer = yield (0, util_1.promisify)(zlib_1.gzip)(uncompressedBuffer);
|
|
73
|
+
const recorder = (0, metric_logger_1.createMetricRecorder)('endRun');
|
|
74
|
+
try {
|
|
75
|
+
const resp = yield (0, axios_1.axiosMultipleTries)(() => this.apiAxiosInstance.post('/nx-cloud/runs/end', compressedBuffer, {
|
|
76
|
+
headers: Object.assign(Object.assign({}, this.apiAxiosInstance.defaults.headers), { 'Content-Encoding': 'gzip', 'Content-Type': 'application/octet-stream' }),
|
|
77
|
+
}), environment_1.NUMBER_OF_TRIES);
|
|
78
|
+
if (resp) {
|
|
79
|
+
recorder.recordMetric((0, metric_logger_1.mapRespToPerfEntry)(resp));
|
|
80
|
+
if (resp.data && resp.data.runUrl && resp.data.status === 'success') {
|
|
81
|
+
this.runContext.runUrl = resp.data.runUrl;
|
|
82
|
+
return true;
|
|
83
|
+
}
|
|
84
|
+
if (resp.data && resp.data.status) {
|
|
85
|
+
this.messages.apiError = `Invalid end run response: ${JSON.stringify(resp.data.message)}`;
|
|
86
|
+
}
|
|
87
|
+
else if (resp.data && typeof resp.data === 'string') {
|
|
88
|
+
if (resp.data !== 'success') {
|
|
89
|
+
this.messages.apiError = `Invalid end run response: ${JSON.stringify(resp.data)}`;
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
else {
|
|
93
|
+
this.messages.apiError = `Invalid end run response: ${JSON.stringify(resp.data)}`;
|
|
94
|
+
}
|
|
95
|
+
if (environment_1.VERBOSE_LOGGING) {
|
|
96
|
+
output_1.output.note({
|
|
97
|
+
title: 'Invalid end run response',
|
|
98
|
+
bodyLines: [JSON.stringify(resp.data, null, 2)],
|
|
99
|
+
});
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
else {
|
|
103
|
+
output_1.output.error({
|
|
104
|
+
title: 'Nx Cloud: Unknown Error Occurred',
|
|
105
|
+
bodyLines: [
|
|
106
|
+
'Run completion responded with `undefined`.',
|
|
107
|
+
'Run Details:',
|
|
108
|
+
JSON.stringify(run, null, 2),
|
|
109
|
+
'Stack Trace:',
|
|
110
|
+
JSON.stringify(new Error().stack, null, 2),
|
|
111
|
+
],
|
|
112
|
+
});
|
|
113
|
+
}
|
|
114
|
+
return false;
|
|
115
|
+
}
|
|
116
|
+
catch (ee) {
|
|
117
|
+
recorder.recordMetric(metric_logger_1.RUNNER_FAILURE_PERF_ENTRY);
|
|
118
|
+
const e = (_a = ee.axiosException) !== null && _a !== void 0 ? _a : ee;
|
|
119
|
+
this.messages.apiError = this.messages.extractErrorMessage(e, 'api');
|
|
120
|
+
return false;
|
|
121
|
+
}
|
|
122
|
+
});
|
|
123
|
+
}
|
|
124
|
+
nxCloudVersion() {
|
|
125
|
+
try {
|
|
126
|
+
const v = JSON.parse((0, fs_1.readFileSync)(`package.json`).toString());
|
|
127
|
+
return v.devDependencies['@nrwl/nx-cloud'];
|
|
128
|
+
}
|
|
129
|
+
catch (e) {
|
|
130
|
+
return 'unknown';
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
exports.CloudRunApi = CloudRunApi;
|
|
135
|
+
//# sourceMappingURL=cloud-run.api.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cloud-run.api.js","sourceRoot":"","sources":["../../../../../../../../libs/nx-packages/nx-cloud/src/lib/core/runners/cloud-enabled/cloud-run.api.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,iEAA8D;AAK9D,oDAGkC;AAClC,gEAKwC;AAIxC,2BAAkC;AAClC,+BAA4B;AAC5B,+BAAiC;
|
|
1
|
+
{"version":3,"file":"cloud-run.api.js","sourceRoot":"","sources":["../../../../../../../../libs/nx-packages/nx-cloud/src/lib/core/runners/cloud-enabled/cloud-run.api.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,iEAA8D;AAK9D,oDAGkC;AAClC,gEAKwC;AAIxC,2BAAkC;AAClC,+BAA4B;AAC5B,+BAAiC;AACjC,oEAI0C;AAE1C,MAAa,WAAW;IAGtB,YACmB,QAAyB,EACzB,UAAsB,EACvC,OAA+B,EACd,WAAwB;QAHxB,aAAQ,GAAR,QAAQ,CAAiB;QACzB,eAAU,GAAV,UAAU,CAAY;QAEtB,gBAAW,GAAX,WAAW,CAAa;QAEzC,IAAI,CAAC,gBAAgB,GAAG,IAAA,8BAAsB,EAAC,OAAO,CAAC,CAAC;IAC1D,CAAC;IAEK,QAAQ,CACZ,sBAA0C,EAC1C,MAAgB;;YAEhB,MAAM,QAAQ,GAAG,IAAA,oCAAoB,EAAC,UAAU,CAAC,CAA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mB,CAAC,CAAC,EAAE,KAAK,CAAC,CAAC;gBACrE,OAAO,KAAK,CAAC;aACd;;KACF;IAEO,cAAc;QACpB,IAAI;YACF,MAAM,CAAC,GAAG,IAAI,CAAC,KAAK,CAAC,IAAA,iBAAY,EAAC,cAAc,CAAC,CAAC,QAAQ,EAAE,CAAC,CAAC;YAC9D,OAAO,CAAC,CAAC,eAAe,CAAC,gBAAgB,CAAC,CAAC;SAC5C;QAAC,OAAO,CAAC,EAAE;YACV,OAAO,SAAS,CAAC;SAClB;IACH,CAAC;CACF;AAhJD,kCAgJC"}
|
|
@@ -1 +1,73 @@
|
|
|
1
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.DistributedAgentApi = void 0;
|
|
13
|
+
const 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
|