@tskmgr/client 2.0.2 → 2.0.5
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/LICENSE +21 -0
- package/README.md +7 -7
- package/package.json +6 -6
- package/src/{index.ts → index.d.ts} +0 -1
- package/src/index.js +22 -0
- package/src/index.js.map +1 -0
- package/src/lib/client-example.d.ts +11 -0
- package/src/lib/client-example.js +120 -0
- package/src/lib/client-example.js.map +1 -0
- package/src/lib/client-factory.d.ts +6 -0
- package/src/lib/client-factory.js +14 -0
- package/src/lib/client-factory.js.map +1 -0
- package/src/lib/client-options.d.ts +12 -0
- package/src/lib/client-options.js +3 -0
- package/src/lib/client-options.js.map +1 -0
- package/src/lib/client.d.ts +24 -0
- package/src/lib/client.js +247 -0
- package/src/lib/client.js.map +1 -0
- package/src/lib/run-tasks-result.d.ts +9 -0
- package/src/lib/run-tasks-result.js +14 -0
- package/src/lib/run-tasks-result.js.map +1 -0
- package/src/lib/task-result.d.ts +10 -0
- package/src/lib/task-result.js +3 -0
- package/src/lib/task-result.js.map +1 -0
- package/src/lib/utils.d.ts +14 -0
- package/src/lib/utils.js +72 -0
- package/src/lib/utils.js.map +1 -0
- package/.babelrc +0 -10
- package/.eslintrc.json +0 -21
- package/jest.config.ts +0 -17
- package/project.json +0 -31
- package/src/lib/client-example.ts +0 -134
- package/src/lib/client-factory.ts +0 -17
- package/src/lib/client-options.ts +0 -12
- package/src/lib/client.spec.ts +0 -5
- package/src/lib/client.ts +0 -280
- package/src/lib/run-tasks-result.ts +0 -17
- package/src/lib/task-result.ts +0 -10
- package/src/lib/utils.ts +0 -68
- package/tsconfig.json +0 -13
- package/tsconfig.lib.json +0 -12
- package/tsconfig.spec.json +0 -20
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2022 Mathieu Paquette
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
# client
|
|
2
|
-
|
|
3
|
-
This library was generated with [Nx](https://nx.dev).
|
|
4
|
-
|
|
5
|
-
## Running unit tests
|
|
6
|
-
|
|
7
|
-
Run `nx test client` to execute the unit tests via [Jest](https://jestjs.io).
|
|
1
|
+
# client
|
|
2
|
+
|
|
3
|
+
This library was generated with [Nx](https://nx.dev).
|
|
4
|
+
|
|
5
|
+
## Running unit tests
|
|
6
|
+
|
|
7
|
+
Run `nx test client` to execute the unit tests via [Jest](https://jestjs.io).
|
package/package.json
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tskmgr/client",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.5",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"dependencies": {
|
|
6
6
|
"debug": "^4.3.4",
|
|
7
|
-
"
|
|
8
|
-
"@tskmgr/common": "2.0.2",
|
|
7
|
+
"@tskmgr/common": "2.0.5",
|
|
9
8
|
"uuid": "^9.0.1",
|
|
10
|
-
"@nx/devkit": "18.0.7"
|
|
11
|
-
|
|
12
|
-
|
|
9
|
+
"@nx/devkit": "18.0.7"
|
|
10
|
+
},
|
|
11
|
+
"main": "./src/index.js",
|
|
12
|
+
"type": "commonjs"
|
|
13
13
|
}
|
package/src/index.js
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./lib/client"), exports);
|
|
18
|
+
__exportStar(require("./lib/client-options"), exports);
|
|
19
|
+
__exportStar(require("./lib/client-factory"), exports);
|
|
20
|
+
__exportStar(require("./lib/run-tasks-result"), exports);
|
|
21
|
+
__exportStar(require("./lib/task-result"), exports);
|
|
22
|
+
//# sourceMappingURL=index.js.map
|
package/src/index.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../libs/client/src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,+CAA6B;AAC7B,uDAAqC;AACrC,uDAAqC;AAErC,yDAAuC;AACvC,oDAAkC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* IntelliJ debug:
|
|
3
|
+
* Node parameters: --require ts-node/register --require tsconfig-paths/register
|
|
4
|
+
* Environment variables: TS_NODE_PROJECT=libs/client/tsconfig.lib.json
|
|
5
|
+
*
|
|
6
|
+
* Start API:
|
|
7
|
+
* nx serve api
|
|
8
|
+
* Command:
|
|
9
|
+
* DEBUG=tskmgr:* ts-node --project libs/client/tsconfig.lib.json -r tsconfig-paths/register "libs/client/src/lib/client-example.ts"
|
|
10
|
+
*/
|
|
11
|
+
export {};
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* IntelliJ debug:
|
|
4
|
+
* Node parameters: --require ts-node/register --require tsconfig-paths/register
|
|
5
|
+
* Environment variables: TS_NODE_PROJECT=libs/client/tsconfig.lib.json
|
|
6
|
+
*
|
|
7
|
+
* Start API:
|
|
8
|
+
* nx serve api
|
|
9
|
+
* Command:
|
|
10
|
+
* DEBUG=tskmgr:* ts-node --project libs/client/tsconfig.lib.json -r tsconfig-paths/register "libs/client/src/lib/client-example.ts"
|
|
11
|
+
*/
|
|
12
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
13
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
14
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
15
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
16
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
17
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
18
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
19
|
+
});
|
|
20
|
+
};
|
|
21
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
22
|
+
const child_process_1 = require("child_process");
|
|
23
|
+
const common_1 = require("@tskmgr/common");
|
|
24
|
+
const client_factory_1 = require("./client-factory");
|
|
25
|
+
const uuid_1 = require("uuid");
|
|
26
|
+
const debug_1 = require("debug");
|
|
27
|
+
const devkit_1 = require("@nx/devkit");
|
|
28
|
+
const fs_1 = require("fs");
|
|
29
|
+
const debug = (0, debug_1.default)('tskmgr:client-example');
|
|
30
|
+
delete process.env.TS_NODE_PROJECT;
|
|
31
|
+
const options = {
|
|
32
|
+
parallel: 1,
|
|
33
|
+
dataCallback,
|
|
34
|
+
errorCallback,
|
|
35
|
+
spawnOptions: { env: Object.assign({}, process.env) },
|
|
36
|
+
};
|
|
37
|
+
const client = client_factory_1.ClientFactory.createNew('http://localhost:3333', 'RUNNER_1', options);
|
|
38
|
+
let completed = false;
|
|
39
|
+
let run;
|
|
40
|
+
(() => __awaiter(void 0, void 0, void 0, function* () {
|
|
41
|
+
try {
|
|
42
|
+
// 1. Create the new run
|
|
43
|
+
run = yield client.createRun({
|
|
44
|
+
name: (0, uuid_1.v4)(),
|
|
45
|
+
type: '123',
|
|
46
|
+
prioritization: [common_1.TaskPriority.Longest],
|
|
47
|
+
});
|
|
48
|
+
debug(run);
|
|
49
|
+
// 2. Leader should create some tasks to run
|
|
50
|
+
const election = yield client.setLeader(run.id);
|
|
51
|
+
if (election.leader) {
|
|
52
|
+
const tasks = getNxTasks().map((nxTask) => {
|
|
53
|
+
const command = `npx nx run ${nxTask.target.project}:${nxTask.target.target} --configuration=production`;
|
|
54
|
+
return {
|
|
55
|
+
name: nxTask.target.project,
|
|
56
|
+
type: nxTask.target.target,
|
|
57
|
+
command: command.trim(),
|
|
58
|
+
options: { shell: true },
|
|
59
|
+
priority: common_1.TaskPriority.Longest,
|
|
60
|
+
};
|
|
61
|
+
});
|
|
62
|
+
const createdTasks = yield client.createTasks(run.id, { tasks });
|
|
63
|
+
debug(createdTasks);
|
|
64
|
+
const closeRun = yield client.closeRun(run.id);
|
|
65
|
+
debug(closeRun);
|
|
66
|
+
}
|
|
67
|
+
// 3. Execute tasks
|
|
68
|
+
const result = yield client.runTasks(run.id);
|
|
69
|
+
if (result.completed) {
|
|
70
|
+
// if failFast set to false, runTasks will continue without throwing errors.
|
|
71
|
+
completed = true;
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
catch (e) {
|
|
75
|
+
console.error(e);
|
|
76
|
+
}
|
|
77
|
+
finally {
|
|
78
|
+
// 4. See results
|
|
79
|
+
console.log('--------------------------------------------------');
|
|
80
|
+
console.log(` tskmgr run: http://localhost:4200/runs/${run.id}`);
|
|
81
|
+
console.log('--------------------------------------------------');
|
|
82
|
+
console.log(`${completed ? 'COMPLETED!' : 'FAILED!'}`);
|
|
83
|
+
process.exit(completed ? 0 : 1);
|
|
84
|
+
}
|
|
85
|
+
}))();
|
|
86
|
+
function getNxTasks() {
|
|
87
|
+
const graphFileName = (0, uuid_1.v4)() + '.json';
|
|
88
|
+
// In CI environment use npx nx affected --graph=${graphFileName} --target=lint command. run-many is just for demo purpose.
|
|
89
|
+
(0, child_process_1.execSync)(`npx nx run-many --graph=lint-${graphFileName} --target=lint`);
|
|
90
|
+
const lintJson = (0, devkit_1.readJsonFile)(`lint-${graphFileName}`);
|
|
91
|
+
(0, fs_1.unlinkSync)(`lint-${graphFileName}`);
|
|
92
|
+
const lintTasks = Object.values(lintJson.tasks.tasks);
|
|
93
|
+
(0, child_process_1.execSync)(`npx nx run-many --graph=test-${graphFileName} --target=test`);
|
|
94
|
+
const testJson = (0, devkit_1.readJsonFile)(`test-${graphFileName}`);
|
|
95
|
+
(0, fs_1.unlinkSync)(`test-${graphFileName}`);
|
|
96
|
+
const testTasks = Object.values(testJson.tasks.tasks);
|
|
97
|
+
(0, child_process_1.execSync)(`npx nx run-many --graph=build-${graphFileName} --target=build`);
|
|
98
|
+
const buildJson = (0, devkit_1.readJsonFile)(`build-${graphFileName}`);
|
|
99
|
+
(0, fs_1.unlinkSync)(`build-${graphFileName}`);
|
|
100
|
+
const buildTasks = Object.values(buildJson.tasks.tasks);
|
|
101
|
+
(0, child_process_1.execSync)(`npx nx run-many --graph=e2e-${graphFileName} --target=e2e`);
|
|
102
|
+
const e2eJson = (0, devkit_1.readJsonFile)(`e2e-${graphFileName}`);
|
|
103
|
+
(0, fs_1.unlinkSync)(`e2e-${graphFileName}`);
|
|
104
|
+
const e2eTasks = Object.values(e2eJson.tasks.tasks);
|
|
105
|
+
return [...lintTasks, ...testTasks, ...buildTasks, ...e2eTasks];
|
|
106
|
+
}
|
|
107
|
+
function dataCallback(task, data, cached) {
|
|
108
|
+
// > nx run frontend:lint [existing outputs match the cache, left as is]
|
|
109
|
+
// > nx run client:lint [local cache]
|
|
110
|
+
if ((data.startsWith(`> nx run ${task.name}:${task.type}`) &&
|
|
111
|
+
data.endsWith('[existing outputs match the cache, left as is]')) ||
|
|
112
|
+
data.endsWith('[local cache]')) {
|
|
113
|
+
cached();
|
|
114
|
+
}
|
|
115
|
+
console.log(`[stdout] ${data}`);
|
|
116
|
+
}
|
|
117
|
+
function errorCallback(task, data) {
|
|
118
|
+
console.log(`[stderr] ${data}`);
|
|
119
|
+
}
|
|
120
|
+
//# sourceMappingURL=client-example.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client-example.js","sourceRoot":"","sources":["../../../../../libs/client/src/lib/client-example.ts"],"names":[],"mappings":";AAAA;;;;;;;;;GASG;;;;;;;;;;;AAEH,iDAAyC;AACzC,2CAAwE;AAExE,qDAAiD;AACjD,+BAAkC;AAClC,iCAA0B;AAC1B,uCAA0C;AAC1C,2BAAgC;AAChC,MAAM,KAAK,GAAG,IAAA,eAAK,EAAC,uBAAuB,CAAC,CAAC;AAE7C,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,CAAC,IAAI,CAAC,UAAU,CAAC,YAAY,IAAI,CAAC,IAAI,IAAI,IAAI,CAAC,IAAI,EAAE,CAAC;QACpD,IAAI,CAAC,QAAQ,CAAC,gDAAgD,CAAC,CAAC;QAClE,IAAI,CAAC,QAAQ,CAAC,eAAe,CAAC,EAC9B,CAAC;QACD,MAAM,EAAE,CAAC;IACX,CAAC;IAED,OAAO,CAAC,GAAG,CAAC,YAAY,IAAI,EAAE,CAAC,CAAC;AAClC,CAAC;AAED,SAAS,aAAa,CAAC,IAAU,EAAE,IAAY;IAC7C,OAAO,CAAC,GAAG,CAAC,YAAY,IAAI,EAAE,CAAC,CAAC;AAClC,CAAC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ClientFactory = void 0;
|
|
4
|
+
const client_1 = require("./client");
|
|
5
|
+
const common_1 = require("@tskmgr/common");
|
|
6
|
+
class ClientFactory {
|
|
7
|
+
static createNew(baseUrl, //
|
|
8
|
+
runnerId, options) {
|
|
9
|
+
return new client_1.Client(common_1.ApiUrl.create(baseUrl), //
|
|
10
|
+
runnerId, Object.assign(Object.assign({}, client_1.Client.DefaultOptions), options));
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
exports.ClientFactory = ClientFactory;
|
|
14
|
+
//# sourceMappingURL=client-factory.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client-factory.js","sourceRoot":"","sources":["../../../../../libs/client/src/lib/client-factory.ts"],"names":[],"mappings":";;;AAAA,qCAAkC;AAElC,2CAAwC;AAExC,MAAa,aAAa;IACjB,MAAM,CAAC,SAAS,CACrB,OAAe,EAAE,EAAE;IACnB,QAAgB,EAChB,OAAuB;QAEvB,OAAO,IAAI,eAAM,CACf,eAAM,CAAC,MAAM,CAAC,OAAO,CAAC,EAAE,EAAE;QAC1B,QAAQ,kCACH,eAAM,CAAC,cAAc,GAAK,OAAO,EACvC,CAAC;IACJ,CAAC;CACF;AAZD,sCAYC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
import { Task } from '@tskmgr/common';
|
|
3
|
+
import { SpawnOptionsWithoutStdio } from 'child_process';
|
|
4
|
+
export interface ClientOptions {
|
|
5
|
+
parallel?: number;
|
|
6
|
+
dataCallback?: (task: Task, data: string, cached: () => void) => void;
|
|
7
|
+
errorCallback?: (task: Task, data: string) => void;
|
|
8
|
+
pollingDelayMs?: number;
|
|
9
|
+
retryDelayMs?: number;
|
|
10
|
+
retryCount?: number;
|
|
11
|
+
spawnOptions?: SpawnOptionsWithoutStdio;
|
|
12
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client-options.js","sourceRoot":"","sources":["../../../../../libs/client/src/lib/client-options.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { ApiUrl, Run, CompleteTaskDto, CreateRunRequestDto, CreateTasksDto, StartTaskDto, StartTaskResponseDto, Task, File as File_, SetLeaderResponseDto, CreateFileRequestDto } from '@tskmgr/common';
|
|
2
|
+
import { RunTasksResult } from './run-tasks-result';
|
|
3
|
+
import { ClientOptions } from './client-options';
|
|
4
|
+
export declare class Client {
|
|
5
|
+
private readonly apiUrl;
|
|
6
|
+
private readonly runnerId;
|
|
7
|
+
private readonly options;
|
|
8
|
+
static readonly DefaultOptions: ClientOptions;
|
|
9
|
+
constructor(apiUrl: ApiUrl, runnerId: string, options: ClientOptions);
|
|
10
|
+
createRun(params: CreateRunRequestDto): Promise<Run>;
|
|
11
|
+
closeRun(runId: number): Promise<Run>;
|
|
12
|
+
abortRun(runId: number): Promise<Run>;
|
|
13
|
+
failRun(runId: number): Promise<Run>;
|
|
14
|
+
setLeader(runId: number): Promise<SetLeaderResponseDto>;
|
|
15
|
+
createTasks(runId: number, params: CreateTasksDto): Promise<Task[]>;
|
|
16
|
+
startTask(runId: number, params: StartTaskDto): Promise<StartTaskResponseDto>;
|
|
17
|
+
runTasks(runId: number): Promise<RunTasksResult>;
|
|
18
|
+
completeTask(taskId: number, params: CompleteTaskDto): Promise<Task>;
|
|
19
|
+
failTask(taskId: number): Promise<Task>;
|
|
20
|
+
uploadRunFile(runId: number, path: string, params: CreateFileRequestDto): Promise<File_>;
|
|
21
|
+
uploadTaskFile(taskId: number, path: string, params: CreateFileRequestDto): Promise<File_>;
|
|
22
|
+
private uploadFile;
|
|
23
|
+
private defaultParallelTaskRunner;
|
|
24
|
+
}
|
|
@@ -0,0 +1,247 @@
|
|
|
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.Client = void 0;
|
|
13
|
+
const utils_1 = require("./utils");
|
|
14
|
+
const run_tasks_result_1 = require("./run-tasks-result");
|
|
15
|
+
const fs_1 = require("fs");
|
|
16
|
+
const debug_1 = require("debug");
|
|
17
|
+
const promises_1 = require("node:fs/promises");
|
|
18
|
+
const debug = (0, debug_1.default)('tskmgr:client');
|
|
19
|
+
class Client {
|
|
20
|
+
constructor(apiUrl, runnerId, options) {
|
|
21
|
+
this.apiUrl = apiUrl;
|
|
22
|
+
this.runnerId = runnerId;
|
|
23
|
+
this.options = options;
|
|
24
|
+
}
|
|
25
|
+
createRun(params) {
|
|
26
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
27
|
+
const res = yield fetch(this.apiUrl.createRunUrl(), {
|
|
28
|
+
headers: { 'Content-Type': 'application/json' },
|
|
29
|
+
method: 'POST',
|
|
30
|
+
body: JSON.stringify(params),
|
|
31
|
+
});
|
|
32
|
+
return yield (0, utils_1.checkStatus)(res).json();
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
closeRun(runId) {
|
|
36
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
37
|
+
const res = yield fetch(this.apiUrl.closeRunUrl(runId), {
|
|
38
|
+
headers: { 'Content-Type': 'application/json' },
|
|
39
|
+
method: 'PUT',
|
|
40
|
+
});
|
|
41
|
+
return yield (0, utils_1.checkStatus)(res).json();
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
abortRun(runId) {
|
|
45
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
46
|
+
const res = yield fetch(this.apiUrl.abortRunUrl(runId), {
|
|
47
|
+
headers: { 'Content-Type': 'application/json' },
|
|
48
|
+
method: 'PUT',
|
|
49
|
+
});
|
|
50
|
+
return yield (0, utils_1.checkStatus)(res).json();
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
failRun(runId) {
|
|
54
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
55
|
+
const res = yield fetch(this.apiUrl.failRunUrl(runId), {
|
|
56
|
+
headers: { 'Content-Type': 'application/json' },
|
|
57
|
+
method: 'PUT',
|
|
58
|
+
});
|
|
59
|
+
return yield (0, utils_1.checkStatus)(res).json();
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
setLeader(runId) {
|
|
63
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
64
|
+
const params = { runnerId: this.runnerId };
|
|
65
|
+
const res = yield fetch(this.apiUrl.setLeaderUrl(runId), {
|
|
66
|
+
headers: { 'Content-Type': 'application/json' },
|
|
67
|
+
method: 'PUT',
|
|
68
|
+
body: JSON.stringify(params),
|
|
69
|
+
});
|
|
70
|
+
return yield (0, utils_1.checkStatus)(res).json();
|
|
71
|
+
});
|
|
72
|
+
}
|
|
73
|
+
createTasks(runId, params) {
|
|
74
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
75
|
+
const res = yield fetch(this.apiUrl.createTasksUrl(runId), {
|
|
76
|
+
headers: { 'Content-Type': 'application/json' },
|
|
77
|
+
method: 'POST',
|
|
78
|
+
body: JSON.stringify(params),
|
|
79
|
+
});
|
|
80
|
+
return yield (0, utils_1.checkStatus)(res).json();
|
|
81
|
+
});
|
|
82
|
+
}
|
|
83
|
+
startTask(runId, params) {
|
|
84
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
85
|
+
const res = yield fetch(this.apiUrl.startTaskUrl(runId), {
|
|
86
|
+
headers: { 'Content-Type': 'application/json' },
|
|
87
|
+
method: 'PUT',
|
|
88
|
+
body: JSON.stringify(params),
|
|
89
|
+
});
|
|
90
|
+
return yield (0, utils_1.checkStatus)(res).json();
|
|
91
|
+
});
|
|
92
|
+
}
|
|
93
|
+
runTasks(runId) {
|
|
94
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
95
|
+
const taskRunners = [];
|
|
96
|
+
for (let i = 0; i < this.options.parallel; i++) {
|
|
97
|
+
taskRunners.push(this.defaultParallelTaskRunner(runId, i));
|
|
98
|
+
}
|
|
99
|
+
const taskResults = yield Promise.all(taskRunners);
|
|
100
|
+
return new run_tasks_result_1.RunTasksResult(taskResults.flatMap((x) => x));
|
|
101
|
+
});
|
|
102
|
+
}
|
|
103
|
+
completeTask(taskId, params) {
|
|
104
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
105
|
+
const res = yield fetch(this.apiUrl.completeTaskUrl(taskId), {
|
|
106
|
+
headers: { 'Content-Type': 'application/json' },
|
|
107
|
+
method: 'PUT',
|
|
108
|
+
body: JSON.stringify(params),
|
|
109
|
+
});
|
|
110
|
+
return yield (0, utils_1.checkStatus)(res).json();
|
|
111
|
+
});
|
|
112
|
+
}
|
|
113
|
+
failTask(taskId) {
|
|
114
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
115
|
+
const res = yield fetch(this.apiUrl.failTaskUrl(taskId), {
|
|
116
|
+
headers: { 'Content-Type': 'application/json' },
|
|
117
|
+
method: 'PUT',
|
|
118
|
+
});
|
|
119
|
+
return yield (0, utils_1.checkStatus)(res).json();
|
|
120
|
+
});
|
|
121
|
+
}
|
|
122
|
+
uploadRunFile(runId, path, params) {
|
|
123
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
124
|
+
return this.uploadFile(this.apiUrl.createFileRunUrl(runId), path, params);
|
|
125
|
+
});
|
|
126
|
+
}
|
|
127
|
+
uploadTaskFile(taskId, path, params) {
|
|
128
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
129
|
+
return this.uploadFile(this.apiUrl.createFileTaskUrl(taskId), path, params);
|
|
130
|
+
});
|
|
131
|
+
}
|
|
132
|
+
uploadFile(url, path, params) {
|
|
133
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
134
|
+
const formData = new FormData();
|
|
135
|
+
const blob = new Blob([yield (0, promises_1.readFile)(path)]);
|
|
136
|
+
formData.append('file', blob, path);
|
|
137
|
+
if (params.type) {
|
|
138
|
+
formData.append('type', params.type);
|
|
139
|
+
}
|
|
140
|
+
if (params.description) {
|
|
141
|
+
formData.append('description', params.description);
|
|
142
|
+
}
|
|
143
|
+
const res = yield fetch(url, {
|
|
144
|
+
method: 'POST',
|
|
145
|
+
body: formData,
|
|
146
|
+
});
|
|
147
|
+
return yield (0, utils_1.checkStatus)(res).json();
|
|
148
|
+
});
|
|
149
|
+
}
|
|
150
|
+
defaultParallelTaskRunner(runId, parallelId) {
|
|
151
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
152
|
+
const logInfo = `[${this.runnerId}:${parallelId}]`;
|
|
153
|
+
const taskResults = [];
|
|
154
|
+
let _continue = true;
|
|
155
|
+
debug(`${logInfo} parallel task runner started`);
|
|
156
|
+
while (_continue) {
|
|
157
|
+
const res = yield this.startTask(runId, { runnerId: this.runnerId });
|
|
158
|
+
if (!res.continue) {
|
|
159
|
+
debug(`${logInfo} continue set to false`);
|
|
160
|
+
_continue = false;
|
|
161
|
+
}
|
|
162
|
+
if (!res.continue && !res.task) {
|
|
163
|
+
debug(`${logInfo} continue set to false and no task, exiting`);
|
|
164
|
+
continue;
|
|
165
|
+
}
|
|
166
|
+
if (!res.task) {
|
|
167
|
+
debug(`${logInfo} polling for new tasks in ${this.options.pollingDelayMs} ms`);
|
|
168
|
+
yield (0, utils_1.delay)(this.options.pollingDelayMs);
|
|
169
|
+
continue;
|
|
170
|
+
}
|
|
171
|
+
const { run, task } = res;
|
|
172
|
+
debug(`${logInfo} received task: ${task.id}`);
|
|
173
|
+
let cached = false;
|
|
174
|
+
let completed = false;
|
|
175
|
+
let writable = false;
|
|
176
|
+
let childProcess;
|
|
177
|
+
let error;
|
|
178
|
+
const taskLogFilename = (0, utils_1.getTaskLogFilename)(task.id);
|
|
179
|
+
const writeStream = (0, fs_1.createWriteStream)(taskLogFilename);
|
|
180
|
+
writeStream.on('open', () => (writable = true));
|
|
181
|
+
const dataHandler = (data) => {
|
|
182
|
+
this.options.dataCallback(task, data, () => (cached = true));
|
|
183
|
+
if (writable) {
|
|
184
|
+
writeStream.write(`[${new Date().toISOString()}] ${data}\n`);
|
|
185
|
+
}
|
|
186
|
+
};
|
|
187
|
+
const errorHandler = (data) => {
|
|
188
|
+
this.options.errorCallback(task, data);
|
|
189
|
+
if (writable) {
|
|
190
|
+
writeStream.write(`[${new Date().toISOString()}] ${data}\n`);
|
|
191
|
+
}
|
|
192
|
+
};
|
|
193
|
+
debug(`${logInfo} starting task: ${task.id}`);
|
|
194
|
+
try {
|
|
195
|
+
childProcess = yield (0, utils_1.spawnAsync)(task.command, task.arguments, Object.assign(Object.assign({}, task.options), this.options.spawnOptions), {
|
|
196
|
+
dataCallback: dataHandler,
|
|
197
|
+
errorCallback: errorHandler,
|
|
198
|
+
});
|
|
199
|
+
completed = true;
|
|
200
|
+
debug(`${logInfo} completed task: ${task.id}`);
|
|
201
|
+
}
|
|
202
|
+
catch (err) {
|
|
203
|
+
console.error(`${logInfo} failed task: ${task.id} with error: ${err}`);
|
|
204
|
+
error = err;
|
|
205
|
+
if (run.failFast) {
|
|
206
|
+
// TODO: should abort all running tasks by current client
|
|
207
|
+
debug(`${logInfo} fail fast enabled, aborting`);
|
|
208
|
+
throw err;
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
finally {
|
|
212
|
+
taskResults.push({ run, task, childProcess, completed, error });
|
|
213
|
+
if (completed) {
|
|
214
|
+
yield this.completeTask(task.id, { cached });
|
|
215
|
+
debug(`${logInfo} completed status for task: ${task.id} sent`);
|
|
216
|
+
}
|
|
217
|
+
else {
|
|
218
|
+
yield this.failTask(task.id);
|
|
219
|
+
debug(`${logInfo} failed status for task: ${task.id} sent`);
|
|
220
|
+
}
|
|
221
|
+
writeStream.end();
|
|
222
|
+
writeStream.close();
|
|
223
|
+
yield this.uploadTaskFile(task.id, taskLogFilename, {
|
|
224
|
+
type: 'log',
|
|
225
|
+
description: `Log for task ${task.id}`,
|
|
226
|
+
});
|
|
227
|
+
debug(`${logInfo} uploaded file for task: ${task.id} sent`);
|
|
228
|
+
(0, fs_1.unlinkSync)(taskLogFilename);
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
debug(`${logInfo} parallel task runner completed`);
|
|
232
|
+
return taskResults;
|
|
233
|
+
});
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
exports.Client = Client;
|
|
237
|
+
Client.DefaultOptions = {
|
|
238
|
+
parallel: 1,
|
|
239
|
+
// eslint-disable-next-line @typescript-eslint/no-empty-function
|
|
240
|
+
dataCallback: (task, data, cached) => { },
|
|
241
|
+
// eslint-disable-next-line @typescript-eslint/no-empty-function
|
|
242
|
+
errorCallback: (task, data) => { },
|
|
243
|
+
pollingDelayMs: 5000,
|
|
244
|
+
retryDelayMs: 5000,
|
|
245
|
+
retryCount: 2,
|
|
246
|
+
};
|
|
247
|
+
//# sourceMappingURL=client.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client.js","sourceRoot":"","sources":["../../../../../libs/client/src/lib/client.ts"],"names":[],"mappings":";;;;;;;;;;;;AAeA,mCAA6E;AAC7E,yDAAoD;AAGpD,2BAAmD;AACnD,iCAA0B;AAC1B,+CAA4C;AAG5C,MAAM,KAAK,GAAG,IAAA,eAAK,EAAC,eAAe,CAAC,CAAC;AAErC,MAAa,MAAM;IAYjB,YACmB,MAAc,EACd,QAAgB,EAChB,OAAsB;QAFtB,WAAM,GAAN,MAAM,CAAQ;QACd,aAAQ,GAAR,QAAQ,CAAQ;QAChB,YAAO,GAAP,OAAO,CAAe;IACtC,CAAC;IAES,SAAS,CAAC,MAA2B;;YAChD,MAAM,GAAG,GAAG,MAAM,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,YAAY,EAAE,EAAE;gBAClD,OAAO,EAAE,EAAE,cAAc,EAAE,kBAAkB,EAAE;gBAC/C,MAAM,EAAE,MAAM;gBACd,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC;aAC7B,CAAC,CAAC;YAEH,OAAO,MAAM,IAAA,mBAAW,EAAC,GAAG,CAAC,CAAC,IAAI,EAAE,CAAC;QACvC,CAAC;KAAA;IAEY,QAAQ,CAAC,KAAa;;YACjC,MAAM,GAAG,GAAG,MAAM,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,WAAW,CAAC,KAAK,CAAC,EAAE;gBACtD,OAAO,EAAE,EAAE,cAAc,EAAE,kBAAkB,EAAE;gBAC/C,MAAM,EAAE,KAAK;aACd,CAAC,CAAC;YAEH,OAAO,MAAM,IAAA,mBAAW,EAAC,GAAG,CAAC,CAAC,IAAI,EAAE,CAAC;QACvC,CAAC;KAAA;IAEY,QAAQ,CAAC,KAAa;;YACjC,MAAM,GAAG,GAAG,MAA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AK,CAAC,GAAG,OAAO,4BAA4B,IAAI,CAAC,EAAE,OAAO,CAAC,CAAC;oBAC9D,CAAC;oBAED,WAAW,CAAC,GAAG,EAAE,CAAC;oBAClB,WAAW,CAAC,KAAK,EAAE,CAAC;oBAEpB,MAAM,IAAI,CAAC,cAAc,CAAC,IAAI,CAAC,EAAE,EAAE,eAAe,EAAE;wBAClD,IAAI,EAAE,KAAK;wBACX,WAAW,EAAE,gBAAgB,IAAI,CAAC,EAAE,EAAE;qBACvC,CAAC,CAAC;oBAEH,KAAK,CAAC,GAAG,OAAO,4BAA4B,IAAI,CAAC,EAAE,OAAO,CAAC,CAAC;oBAC5D,IAAA,eAAU,EAAC,eAAe,CAAC,CAAC;gBAC9B,CAAC;YACH,CAAC;YAED,KAAK,CAAC,GAAG,OAAO,iCAAiC,CAAC,CAAC;YAEnD,OAAO,WAAW,CAAC;QACrB,CAAC;KAAA;;AA3PH,wBA4PC;AA3PwB,qBAAc,GAAkB;IACrD,QAAQ,EAAE,CAAC;IACX,gEAAgE;IAChE,YAAY,EAAE,CAAC,IAAI,EAAE,IAAI,EAAE,MAAM,EAAE,EAAE,GAAE,CAAC;IACxC,gEAAgE;IAChE,aAAa,EAAE,CAAC,IAAI,EAAE,IAAI,EAAE,EAAE,GAAE,CAAC;IACjC,cAAc,EAAE,IAAI;IACpB,YAAY,EAAE,IAAI;IAClB,UAAU,EAAE,CAAC;CACd,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { TaskResult } from './task-result';
|
|
2
|
+
export declare class RunTasksResult {
|
|
3
|
+
readonly tasks: TaskResult[];
|
|
4
|
+
readonly completedTasks: TaskResult[];
|
|
5
|
+
readonly failedTasks: TaskResult[];
|
|
6
|
+
readonly completed: boolean;
|
|
7
|
+
readonly failed: boolean;
|
|
8
|
+
constructor(tasks: TaskResult[]);
|
|
9
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.RunTasksResult = void 0;
|
|
4
|
+
class RunTasksResult {
|
|
5
|
+
constructor(tasks) {
|
|
6
|
+
this.tasks = tasks;
|
|
7
|
+
this.completedTasks = tasks.filter((x) => x.completed);
|
|
8
|
+
this.failedTasks = tasks.filter((x) => !x.completed);
|
|
9
|
+
this.completed = this.failedTasks.length === 0;
|
|
10
|
+
this.failed = this.failedTasks.length > 0;
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
exports.RunTasksResult = RunTasksResult;
|
|
14
|
+
//# sourceMappingURL=run-tasks-result.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"run-tasks-result.js","sourceRoot":"","sources":["../../../../../libs/client/src/lib/run-tasks-result.ts"],"names":[],"mappings":";;;AAEA,MAAa,cAAc;IAOzB,YAA4B,KAAmB;QAAnB,UAAK,GAAL,KAAK,CAAc;QAC7C,IAAI,CAAC,cAAc,GAAG,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC;QACvD,IAAI,CAAC,WAAW,GAAG,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC;QAErD,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC,WAAW,CAAC,MAAM,KAAK,CAAC,CAAC;QAC/C,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC,WAAW,CAAC,MAAM,GAAG,CAAC,CAAC;IAC5C,CAAC;CACF;AAdD,wCAcC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"task-result.js","sourceRoot":"","sources":["../../../../../libs/client/src/lib/task-result.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
import { ChildProcess, SpawnOptionsWithoutStdio } from 'child_process';
|
|
3
|
+
export interface SpawnAsyncOptions {
|
|
4
|
+
dataCallback?: (data: string) => void;
|
|
5
|
+
errorCallback?: (data: string) => void;
|
|
6
|
+
}
|
|
7
|
+
export declare function spawnAsync(command: string, args?: ReadonlyArray<string>, options?: SpawnOptionsWithoutStdio, logging?: SpawnAsyncOptions): Promise<ChildProcess>;
|
|
8
|
+
export declare function delay(ms: number): Promise<void>;
|
|
9
|
+
export declare function getTaskLogFilename(taskId: number): string;
|
|
10
|
+
export declare class HTTPResponseError extends Error {
|
|
11
|
+
readonly response: any;
|
|
12
|
+
constructor(response: any);
|
|
13
|
+
}
|
|
14
|
+
export declare const checkStatus: (response: any) => any;
|