@uuv/runner-commons 2.16.3 → 2.17.0

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/CHANGELOG.md CHANGED
@@ -1,3 +1,17 @@
1
+ # [2.17.0](https://github.com/Orange-OpenSource/uuv/compare/runner-commons-v2.16.4...runner-commons-v2.17.0) (2024-07-02)
2
+
3
+
4
+ ### Features
5
+
6
+ * introduce ipc-server to send uuv event, [#664](https://github.com/Orange-OpenSource/uuv/issues/664) ([270ac38](https://github.com/Orange-OpenSource/uuv/commit/270ac388a7abf17b0c296d029d6e12bd66a4f521))
7
+
8
+ ## [2.16.4](https://github.com/Orange-OpenSource/uuv/compare/runner-commons-v2.16.3...runner-commons-v2.16.4) (2024-06-27)
9
+
10
+
11
+ ### Bug Fixes
12
+
13
+ * **runner-cypress:** update testing-library monorepo ([bcedb57](https://github.com/Orange-OpenSource/uuv/commit/bcedb5749fd5f062cfb283bedabfe8ad87668c67))
14
+
1
15
  ## [2.16.3](https://github.com/Orange-OpenSource/uuv/compare/runner-commons-v2.16.2...runner-commons-v2.16.3) (2024-06-16)
2
16
 
3
17
 
@@ -12,11 +12,13 @@ class UUVCliEngine {
12
12
  this.runner = runner;
13
13
  }
14
14
  async execute() {
15
+ let ipcServerProcess;
15
16
  try {
16
17
  helper_1.UUVCliHelper.printBanner(this.runner.name, this.runner.getCurrentVersion());
17
18
  this.checkArguments();
18
19
  const options = helper_1.UUVCliHelper.extractArgs(this.runner.projectDir, this.runner.defaultBrowser);
19
20
  helper_1.UUVCliHelper.printVariables(options);
21
+ ipcServerProcess = helper_1.UUVCliHelper.startIpcServer();
20
22
  await this.runner.prepare(options);
21
23
  console.info(chalk_1.default.blueBright(`Executing UUV command ${options.command}...`));
22
24
  switch (options.command) {
@@ -35,6 +37,11 @@ class UUVCliEngine {
35
37
  console.error(chalk_1.default.red(e));
36
38
  process.exit(1);
37
39
  }
40
+ finally {
41
+ if (ipcServerProcess) {
42
+ helper_1.UUVCliHelper.stopIpcServer(ipcServerProcess);
43
+ }
44
+ }
38
45
  }
39
46
  checkArguments() {
40
47
  helper_1.UUVCliHelper.checkTargetCommand();
@@ -1,4 +1,6 @@
1
+ /// <reference types="node" />
1
2
  import { UUVCliOptions } from "./options";
3
+ import cp from "child_process";
2
4
  export declare class UUVCliHelper {
3
5
  /**
4
6
  * Print runner banner
@@ -9,4 +11,6 @@ export declare class UUVCliHelper {
9
11
  private static getTargetCommand;
10
12
  static extractArgs(projectDir: string, defaultBrowser: any): Partial<UUVCliOptions>;
11
13
  static printVariables(options: Partial<UUVCliOptions>): void;
14
+ static startIpcServer(): cp.ChildProcess;
15
+ static stopIpcServer(ipcServerProcess: cp.ChildProcess): boolean;
12
16
  }
@@ -9,6 +9,7 @@ const figlet_1 = __importDefault(require("figlet"));
9
9
  const minimist_1 = __importDefault(require("minimist"));
10
10
  const path_1 = __importDefault(require("path"));
11
11
  const lodash_1 = require("lodash");
12
+ const child_process_1 = __importDefault(require("child_process"));
12
13
  class UUVCliHelper {
13
14
  /**
14
15
  * Print runner banner
@@ -50,6 +51,10 @@ class UUVCliHelper {
50
51
  const env = argv.env ? JSON.parse(argv.env.replace(/'/g, "\"")) : {};
51
52
  const targetTestFile = argv.targetTestFile ? argv.targetTestFile : null;
52
53
  const reportDir = path_1.default.join(projectDir, "reports");
54
+ // eslint-disable-next-line dot-notation
55
+ process.env["ENABLE_TEAMCITY_LOGGING"] = env.enableTeamcityLogging;
56
+ // eslint-disable-next-line dot-notation
57
+ process.env["ENABLE_VSCODE_LISTENER"] = env.enableVsCodeListener;
53
58
  return {
54
59
  // eslint-disable-next-line dot-notation
55
60
  baseUrl: process.env["UUV_BASE_URL"],
@@ -87,5 +92,11 @@ class UUVCliHelper {
87
92
  }
88
93
  console.debug("\n");
89
94
  }
95
+ static startIpcServer() {
96
+ return child_process_1.default.fork(path_1.default.join(__dirname, "start-ipc-server"));
97
+ }
98
+ static stopIpcServer(ipcServerProcess) {
99
+ return ipcServerProcess.kill();
100
+ }
90
101
  }
91
102
  exports.UUVCliHelper = UUVCliHelper;
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,21 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const event_1 = require("../runner/event");
4
+ async function createIPCServer() {
5
+ return new Promise((resolve) => {
6
+ // eslint-disable-next-line @typescript-eslint/no-var-requires
7
+ const ipcServer = require("node-ipc").default;
8
+ ipcServer.config.id = event_1.UUV_IPC_SERVER_NAME;
9
+ ipcServer.config.retry = 1500;
10
+ ipcServer.config.silent = true;
11
+ ipcServer.serve(() => {
12
+ ipcServer.server.on("message", (message) => {
13
+ ipcServer.server.broadcast("message", message);
14
+ });
15
+ console.log("UUV Server Started");
16
+ resolve(ipcServer);
17
+ });
18
+ ipcServer.server.start();
19
+ });
20
+ }
21
+ createIPCServer();
package/dist/index.d.ts CHANGED
@@ -3,6 +3,7 @@ export * from "./step-definition-generator/generate-step-definitions";
3
3
  export * from "./step-definition-generator/generate-step-definitions-documentation";
4
4
  export * from "./runner/step-definitions/_constant";
5
5
  export * from "./runner/step-definitions/_i-context";
6
+ export * from "./runner/event";
6
7
  import key from "./assets/i18n/web/template.json";
7
8
  export { key };
8
9
  export { AccessibleRole } from "./step-definition-generator/accessible-role";
package/dist/index.js CHANGED
@@ -23,6 +23,7 @@ __exportStar(require("./step-definition-generator/generate-step-definitions"), e
23
23
  __exportStar(require("./step-definition-generator/generate-step-definitions-documentation"), exports);
24
24
  __exportStar(require("./runner/step-definitions/_constant"), exports);
25
25
  __exportStar(require("./runner/step-definitions/_i-context"), exports);
26
+ __exportStar(require("./runner/event"), exports);
26
27
  const template_json_1 = __importDefault(require("./assets/i18n/web/template.json"));
27
28
  exports.key = template_json_1.default;
28
29
  var accessible_role_1 = require("./step-definition-generator/accessible-role");
@@ -0,0 +1,16 @@
1
+ import { UUVEventTestFailed, UUVEventTestFinished, UUVEventTestIgnored, UUVEventTestStarted, UUVEventTestSuiteFinished, UUVEventTestSuiteStarted } from "./model";
2
+ export declare class UUVEventEmitter {
3
+ private static instance;
4
+ ipc: any;
5
+ constructor();
6
+ static createInstance(): Promise<unknown>;
7
+ static getInstance(): UUVEventEmitter;
8
+ emitProgressStart(): void;
9
+ emitTestSuiteStarted(event: UUVEventTestSuiteStarted): void;
10
+ emitTestStarted(event: UUVEventTestStarted): void;
11
+ emitTestFailed(event: UUVEventTestFailed): void;
12
+ emitTestIgnored(event: UUVEventTestIgnored): void;
13
+ emitTestFinished(event: UUVEventTestFinished): void;
14
+ emitTestSuiteFinished(event: UUVEventTestSuiteFinished): void;
15
+ emitProgressFinish(): void;
16
+ }
@@ -0,0 +1,77 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.UUVEventEmitter = void 0;
4
+ /* eslint-disable quotes */
5
+ const model_1 = require("./model");
6
+ class UUVEventEmitter {
7
+ static instance;
8
+ ipc;
9
+ constructor() {
10
+ // eslint-disable-next-line @typescript-eslint/no-var-requires
11
+ this.ipc = require('node-ipc').default;
12
+ this.ipc.config.id = model_1.UUV_IPC_PUBLISHER;
13
+ this.ipc.config.retry = 1500;
14
+ this.ipc.config.silent = true;
15
+ }
16
+ static async createInstance() {
17
+ return new Promise((resolve) => {
18
+ UUVEventEmitter.instance = new UUVEventEmitter();
19
+ UUVEventEmitter.instance.ipc.connectTo(model_1.UUV_IPC_SERVER_NAME, () => {
20
+ UUVEventEmitter.instance.ipc.of[model_1.UUV_IPC_SERVER_NAME].on('connect', () => {
21
+ console.debug("Publisher connected to UUV Server");
22
+ resolve("ok");
23
+ });
24
+ });
25
+ });
26
+ }
27
+ static getInstance() {
28
+ return UUVEventEmitter.instance;
29
+ }
30
+ emitProgressStart() {
31
+ this.ipc.of[model_1.UUV_IPC_SERVER_NAME].emit('message', {
32
+ type: model_1.UUVEventType.PROGRESS_START
33
+ });
34
+ }
35
+ emitTestSuiteStarted(event) {
36
+ this.ipc.of[model_1.UUV_IPC_SERVER_NAME].emit('message', {
37
+ type: model_1.UUVEventType.TEST_SUITE_STARTED,
38
+ data: event
39
+ });
40
+ }
41
+ emitTestStarted(event) {
42
+ this.ipc.of[model_1.UUV_IPC_SERVER_NAME].emit('message', {
43
+ type: model_1.UUVEventType.TEST_STARTED,
44
+ data: event
45
+ });
46
+ }
47
+ emitTestFailed(event) {
48
+ this.ipc.of[model_1.UUV_IPC_SERVER_NAME].emit('message', {
49
+ type: model_1.UUVEventType.TEST_FAILED,
50
+ data: event
51
+ });
52
+ }
53
+ emitTestIgnored(event) {
54
+ this.ipc.of[model_1.UUV_IPC_SERVER_NAME].emit('message', {
55
+ type: model_1.UUVEventType.TEST_IGNORED,
56
+ data: event
57
+ });
58
+ }
59
+ emitTestFinished(event) {
60
+ this.ipc.of[model_1.UUV_IPC_SERVER_NAME].emit('message', {
61
+ type: model_1.UUVEventType.TEST_FINISHED,
62
+ data: event
63
+ });
64
+ }
65
+ emitTestSuiteFinished(event) {
66
+ this.ipc.of[model_1.UUV_IPC_SERVER_NAME].emit('message', {
67
+ type: model_1.UUVEventType.TEST_SUITE_FINISHED,
68
+ data: event
69
+ });
70
+ }
71
+ emitProgressFinish() {
72
+ this.ipc.of[model_1.UUV_IPC_SERVER_NAME].emit('message', {
73
+ type: model_1.UUVEventType.PROGRESS_FINISH
74
+ });
75
+ }
76
+ }
77
+ exports.UUVEventEmitter = UUVEventEmitter;
@@ -0,0 +1,4 @@
1
+ export * from "./model";
2
+ export * from "./event-emitter";
3
+ export * from "./listener/event-listener-helper";
4
+ export * from "./listener/teamcity-listener";
@@ -0,0 +1,20 @@
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("./model"), exports);
18
+ __exportStar(require("./event-emitter"), exports);
19
+ __exportStar(require("./listener/event-listener-helper"), exports);
20
+ __exportStar(require("./listener/teamcity-listener"), exports);
@@ -0,0 +1,3 @@
1
+ export declare class UUVListenerHelper {
2
+ static build(): Promise<void>;
3
+ }
@@ -0,0 +1,15 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.UUVListenerHelper = void 0;
4
+ const event_emitter_1 = require("../event-emitter");
5
+ const teamcity_listener_1 = require("./teamcity-listener");
6
+ class UUVListenerHelper {
7
+ static async build() {
8
+ await event_emitter_1.UUVEventEmitter.createInstance();
9
+ // eslint-disable-next-line dot-notation
10
+ if (process.env["ENABLE_TEAMCITY_LOGGING"] === "true") {
11
+ await new teamcity_listener_1.TeamCityUUVEventListener();
12
+ }
13
+ }
14
+ }
15
+ exports.UUVListenerHelper = UUVListenerHelper;
@@ -0,0 +1,12 @@
1
+ /**
2
+ * Listener that write teamcity log
3
+ */
4
+ export declare class TeamCityUUVEventListener {
5
+ constructor();
6
+ logTeamCity(line: any): void;
7
+ teamcityFlowId(name: any): string;
8
+ teamcityFlowIdAndParentFlowId(name: any, parentName: any): string;
9
+ teamcityAddName(name: any): string;
10
+ teamcityAddDuration(duration: any): string;
11
+ teamcityAddCustomField(fieldName: any, value: any): string;
12
+ }
@@ -0,0 +1,81 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.TeamCityUUVEventListener = void 0;
4
+ const model_1 = require("../model");
5
+ /**
6
+ * Listener that write teamcity log
7
+ */
8
+ class TeamCityUUVEventListener {
9
+ constructor() {
10
+ // eslint-disable-next-line @typescript-eslint/no-var-requires
11
+ const ipc = require("node-ipc").default;
12
+ ipc.config.id = "uuvIpcTeamcity";
13
+ ipc.config.retry = 1500;
14
+ ipc.config.silent = true;
15
+ ipc.connectTo(model_1.UUV_IPC_SERVER_NAME, () => {
16
+ ipc.of[model_1.UUV_IPC_SERVER_NAME].on("connect", () => {
17
+ console.log("Teamcity connected to UUV Server");
18
+ });
19
+ ipc.of[model_1.UUV_IPC_SERVER_NAME].on("message", (message) => {
20
+ let data;
21
+ switch (message.type) {
22
+ case model_1.UUVEventType.PROGRESS_START:
23
+ this.logTeamCity("##teamcity[progressStart 'Running UUV Tests']");
24
+ break;
25
+ case model_1.UUVEventType.TEST_SUITE_STARTED:
26
+ data = message.data;
27
+ this.logTeamCity(`##teamcity[testSuiteStarted ${this.teamcityAddName(data.testSuiteName)} ${this.teamcityFlowId(data.testSuiteName)} ${this.teamcityAddCustomField("locationHint", "suite://" + data.testSuitelocation)} ]`);
28
+ break;
29
+ case model_1.UUVEventType.TEST_STARTED:
30
+ data = message.data;
31
+ this.logTeamCity(`##teamcity[testStarted ${this.teamcityAddName(data.testName)} ${this.teamcityFlowIdAndParentFlowId(data.testName, data.testSuiteName)} ${this.teamcityAddCustomField("locationHint", "test://" + data.testSuitelocation)} ]`);
32
+ break;
33
+ case model_1.UUVEventType.TEST_FINISHED:
34
+ data = message.data;
35
+ // eslint-disable-next-line max-len
36
+ this.logTeamCity(`##teamcity[testFinished ${this.teamcityAddName(data.testName)} ${this.teamcityFlowIdAndParentFlowId(data.testName, data.testSuiteName)} ${this.teamcityAddDuration(data.duration)} ]`);
37
+ break;
38
+ case model_1.UUVEventType.TEST_FAILED:
39
+ data = message.data;
40
+ // eslint-disable-next-line max-len
41
+ this.logTeamCity(`##teamcity[testFailed ${this.teamcityAddName(data.testName)} ${this.teamcityFlowIdAndParentFlowId(data.testName, data.testSuiteName)} type='comparisonFailure' message='Test failed' ]`);
42
+ // eslint-disable-next-line max-len
43
+ this.logTeamCity(`##teamcity[testFinished ${this.teamcityAddName(data.testName)} ${this.teamcityFlowIdAndParentFlowId(data.testName, data.testSuiteName)} ${this.teamcityAddDuration(data.duration)} ]`);
44
+ break;
45
+ case model_1.UUVEventType.TEST_IGNORED:
46
+ data = message.data;
47
+ // eslint-disable-next-line max-len
48
+ this.logTeamCity(`##teamcity[testIgnored ${this.teamcityAddName(data.testName)} ${this.teamcityFlowIdAndParentFlowId(data.testName, data.testSuiteName)} ]`);
49
+ break;
50
+ case model_1.UUVEventType.TEST_SUITE_FINISHED:
51
+ data = message.data;
52
+ // eslint-disable-next-line max-len
53
+ this.logTeamCity(`##teamcity[testSuiteFinished ${this.teamcityAddName(data.testSuiteName)} ${this.teamcityFlowId(data.testSuiteName)}]`);
54
+ break;
55
+ case model_1.UUVEventType.PROGRESS_FINISH:
56
+ this.logTeamCity("##teamcity[progressFinish 'Running UUV Tests']");
57
+ break;
58
+ }
59
+ });
60
+ });
61
+ }
62
+ logTeamCity(line) {
63
+ console.log("newReal" + line);
64
+ }
65
+ teamcityFlowId(name) {
66
+ return "flowId='" + name.replaceAll("'", "|'") + "'";
67
+ }
68
+ teamcityFlowIdAndParentFlowId(name, parentName) {
69
+ return "flowId='" + name.replaceAll("'", "|'") + "' parent='" + parentName.replaceAll("'", "|'") + "'";
70
+ }
71
+ teamcityAddName(name) {
72
+ return "name='" + name.replaceAll("'", "|'") + "'";
73
+ }
74
+ teamcityAddDuration(duration) {
75
+ return `duration='${duration}'`;
76
+ }
77
+ teamcityAddCustomField(fieldName, value) {
78
+ return `${fieldName}='${value}'`;
79
+ }
80
+ }
81
+ exports.TeamCityUUVEventListener = TeamCityUUVEventListener;
@@ -0,0 +1,47 @@
1
+ export declare const UUV_IPC_SERVER_NAME = "uuvIpcServer";
2
+ export declare const UUV_IPC_PUBLISHER = "uuvIpcPublisher";
3
+ export interface UUVEvent {
4
+ type: UUVEventType;
5
+ data: UUVEventProgressStart | UUVEventTestSuiteStarted | UUVEventTestStarted | UUVEventTestFinished | UUVEventTestFailed | UUVEventTestIgnored | UUVEventTestSuiteFinished | UUVEventProgressFinish;
6
+ }
7
+ export declare enum UUVEventType {
8
+ PROGRESS_START = "progressStart",
9
+ TEST_SUITE_STARTED = "testSuiteStarted",
10
+ TEST_STARTED = "testStarted",
11
+ TEST_FINISHED = "testFinished",
12
+ TEST_FAILED = "testFailed",
13
+ TEST_IGNORED = "testIgnored",
14
+ TEST_SUITE_FINISHED = "testSuiteFinished",
15
+ PROGRESS_FINISH = "progressFinish"
16
+ }
17
+ export interface UUVEventProgressStart {
18
+ }
19
+ export interface UUVEventTestSuiteStarted {
20
+ testSuiteName: string;
21
+ testSuitelocation: string;
22
+ }
23
+ export interface UUVEventTestStarted {
24
+ testName: string;
25
+ testSuiteName: string;
26
+ testSuitelocation: string;
27
+ }
28
+ export interface UUVEventTestFinished {
29
+ testName: string;
30
+ testSuiteName: string;
31
+ duration: number;
32
+ }
33
+ export interface UUVEventTestFailed {
34
+ testName: string;
35
+ testSuiteName: string;
36
+ duration: number;
37
+ }
38
+ export interface UUVEventTestIgnored {
39
+ testName: string;
40
+ testSuiteName: string;
41
+ duration?: number;
42
+ }
43
+ export interface UUVEventTestSuiteFinished {
44
+ testSuiteName: string;
45
+ }
46
+ export interface UUVEventProgressFinish {
47
+ }
@@ -0,0 +1,16 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.UUVEventType = exports.UUV_IPC_PUBLISHER = exports.UUV_IPC_SERVER_NAME = void 0;
4
+ exports.UUV_IPC_SERVER_NAME = "uuvIpcServer";
5
+ exports.UUV_IPC_PUBLISHER = "uuvIpcPublisher";
6
+ var UUVEventType;
7
+ (function (UUVEventType) {
8
+ UUVEventType["PROGRESS_START"] = "progressStart";
9
+ UUVEventType["TEST_SUITE_STARTED"] = "testSuiteStarted";
10
+ UUVEventType["TEST_STARTED"] = "testStarted";
11
+ UUVEventType["TEST_FINISHED"] = "testFinished";
12
+ UUVEventType["TEST_FAILED"] = "testFailed";
13
+ UUVEventType["TEST_IGNORED"] = "testIgnored";
14
+ UUVEventType["TEST_SUITE_FINISHED"] = "testSuiteFinished";
15
+ UUVEventType["PROGRESS_FINISH"] = "progressFinish";
16
+ })(UUVEventType || (exports.UUVEventType = UUVEventType = {}));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@uuv/runner-commons",
3
- "version": "2.16.3",
3
+ "version": "2.17.0",
4
4
  "type": "commonjs",
5
5
  "author": "Louis Fredice NJAKO MOLOM (https://github.com/luifr10) & Stanley SERVICAL (https://github.com/stanlee974)",
6
6
  "description": "A common lib for uuv",
@@ -72,6 +72,7 @@
72
72
  "chalk": "^4.1.2",
73
73
  "figlet": "1.7.0",
74
74
  "lodash": "^4.17.21",
75
- "minimist": "1.2.8"
75
+ "minimist": "1.2.8",
76
+ "node-ipc": "^11.1.0"
76
77
  }
77
78
  }