@testomatio/reporter 2.0.0-beta.3-gaxios → 2.0.0-beta.3-xml
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/adapter/nightwatch.js +5 -5
- package/lib/adapter/webdriver.d.ts +1 -1
- package/lib/bin/cli.js +7 -6
- package/lib/bin/reportXml.js +4 -2
- package/lib/bin/startTest.js +3 -2
- package/lib/bin/uploadArtifacts.js +5 -4
- package/lib/data-storage.d.ts +1 -1
- package/lib/junit-adapter/csharp.d.ts +1 -0
- package/lib/junit-adapter/csharp.js +11 -1
- package/lib/pipe/bitbucket.d.ts +0 -2
- package/lib/pipe/bitbucket.js +19 -21
- package/lib/pipe/gitlab.d.ts +0 -2
- package/lib/pipe/gitlab.js +8 -27
- package/lib/pipe/testomatio.d.ts +1 -2
- package/lib/pipe/testomatio.js +63 -72
- package/lib/reporter.d.ts +12 -12
- package/lib/services/artifacts.d.ts +1 -1
- package/lib/services/key-values.d.ts +1 -1
- package/lib/services/logger.d.ts +1 -1
- package/lib/utils/utils.d.ts +2 -0
- package/lib/utils/utils.js +20 -4
- package/lib/xmlReader.js +38 -11
- package/package.json +6 -5
- package/src/adapter/nightwatch.js +1 -1
- package/src/adapter/webdriver.js +1 -1
- package/src/bin/cli.js +2 -1
- package/src/bin/reportXml.js +4 -1
- package/src/bin/startTest.js +2 -1
- package/src/bin/uploadArtifacts.js +2 -1
- package/src/junit-adapter/csharp.js +13 -1
- package/src/pipe/bitbucket.js +24 -22
- package/src/pipe/gitlab.js +8 -27
- package/src/pipe/testomatio.js +93 -92
- package/src/utils/utils.js +14 -1
- package/src/xmlReader.js +47 -11
|
@@ -5,7 +5,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
const client_js_1 = __importDefault(require("../client.js"));
|
|
7
7
|
const config_js_1 = require("../config.js");
|
|
8
|
-
const
|
|
8
|
+
const constants_js_1 = require("../constants.js");
|
|
9
9
|
const utils_js_1 = require("../utils/utils.js");
|
|
10
10
|
const apiKey = config_js_1.config.TESTOMATIO;
|
|
11
11
|
const client = new client_js_1.default({ apiKey });
|
|
@@ -29,14 +29,14 @@ module.exports = {
|
|
|
29
29
|
let status;
|
|
30
30
|
switch (test.status) {
|
|
31
31
|
case 'pass':
|
|
32
|
-
status =
|
|
32
|
+
status = constants_js_1.STATUS.PASSED;
|
|
33
33
|
break;
|
|
34
34
|
case 'fail':
|
|
35
|
-
status =
|
|
35
|
+
status = constants_js_1.STATUS.FAILED;
|
|
36
36
|
break;
|
|
37
37
|
// probably not required (because skipped tests are in separate array), but just in case
|
|
38
38
|
case 'skip':
|
|
39
|
-
status =
|
|
39
|
+
status = constants_js_1.STATUS.SKIPPED;
|
|
40
40
|
console.info('Skipped test is in completed tests array:', test, 'Not expected behavior.');
|
|
41
41
|
break;
|
|
42
42
|
default:
|
|
@@ -58,7 +58,7 @@ module.exports = {
|
|
|
58
58
|
}
|
|
59
59
|
// just array with skipped tests titles, no any other info
|
|
60
60
|
for (const testTitle of skippedTests) {
|
|
61
|
-
client.addTestRun(
|
|
61
|
+
client.addTestRun(constants_js_1.STATUS.SKIPPED, {
|
|
62
62
|
suite_title: suiteTitle,
|
|
63
63
|
tags,
|
|
64
64
|
rid: `${testModule.uuid || ''}_${testTitle || ''}`,
|
|
@@ -19,6 +19,6 @@ declare class WebdriverReporter extends WDIOReporter {
|
|
|
19
19
|
*/
|
|
20
20
|
addBddScenario(scenario: import("../../types/types.js").WebdriverIOScenario): Promise<import("../../types/types.js").PipeResult[]>;
|
|
21
21
|
}
|
|
22
|
-
import WDIOReporter from '@wdio/reporter';
|
|
22
|
+
import { default as WDIOReporter } from '@wdio/reporter';
|
|
23
23
|
import TestomatClient from '../client.js';
|
|
24
24
|
import { RunnerStats } from '@wdio/reporter';
|
package/lib/bin/cli.js
CHANGED
|
@@ -11,17 +11,18 @@ const debug_1 = __importDefault(require("debug"));
|
|
|
11
11
|
const client_js_1 = __importDefault(require("../client.js"));
|
|
12
12
|
const xmlReader_js_1 = __importDefault(require("../xmlReader.js"));
|
|
13
13
|
const constants_js_1 = require("../constants.js");
|
|
14
|
-
const package_json_1 = require("../../package.json");
|
|
15
|
-
const config_js_1 = require("../config.js");
|
|
16
14
|
const utils_js_1 = require("../utils/utils.js");
|
|
15
|
+
const config_js_1 = require("../config.js");
|
|
16
|
+
const utils_js_2 = require("../utils/utils.js");
|
|
17
17
|
const picocolors_1 = __importDefault(require("picocolors"));
|
|
18
18
|
const filesize_1 = require("filesize");
|
|
19
19
|
const dotenv_1 = __importDefault(require("dotenv"));
|
|
20
20
|
const debug = (0, debug_1.default)('@testomatio/reporter:xml-cli');
|
|
21
|
-
|
|
21
|
+
const version = (0, utils_js_1.getPackageVersion)();
|
|
22
|
+
console.log(picocolors_1.default.cyan(picocolors_1.default.bold(` 🤩 Testomat.io Reporter v${version}`)));
|
|
22
23
|
const program = new commander_1.Command();
|
|
23
24
|
program
|
|
24
|
-
.version(
|
|
25
|
+
.version(version)
|
|
25
26
|
.option('--env-file <envfile>', 'Load environment variables from env file')
|
|
26
27
|
.hook('preAction', thisCommand => {
|
|
27
28
|
const opts = thisCommand.opts();
|
|
@@ -48,7 +49,7 @@ program
|
|
|
48
49
|
.command('finish')
|
|
49
50
|
.description('Finish Run by its ID')
|
|
50
51
|
.action(async () => {
|
|
51
|
-
process.env.TESTOMATIO_RUN ||= (0,
|
|
52
|
+
process.env.TESTOMATIO_RUN ||= (0, utils_js_2.readLatestRunId)();
|
|
52
53
|
if (!process.env.TESTOMATIO_RUN) {
|
|
53
54
|
console.log('TESTOMATIO_RUN environment variable must be set or restored from a previous run.');
|
|
54
55
|
return process.exit(1);
|
|
@@ -180,7 +181,7 @@ program
|
|
|
180
181
|
.action(async (opts) => {
|
|
181
182
|
const apiKey = config_js_1.config.TESTOMATIO;
|
|
182
183
|
process.env.TESTOMATIO_DISABLE_ARTIFACTS = '';
|
|
183
|
-
const runId = process.env.TESTOMATIO_RUN || process.env.runId || (0,
|
|
184
|
+
const runId = process.env.TESTOMATIO_RUN || process.env.runId || (0, utils_js_2.readLatestRunId)();
|
|
184
185
|
if (!runId) {
|
|
185
186
|
console.log('TESTOMATIO_RUN environment variable must be set or restored from a previous run.');
|
|
186
187
|
return process.exit(1);
|
package/lib/bin/reportXml.js
CHANGED
|
@@ -10,10 +10,12 @@ const glob_1 = require("glob");
|
|
|
10
10
|
const debug_1 = __importDefault(require("debug"));
|
|
11
11
|
const constants_js_1 = require("../constants.js");
|
|
12
12
|
const xmlReader_js_1 = __importDefault(require("../xmlReader.js"));
|
|
13
|
-
const
|
|
13
|
+
const utils_js_1 = require("../utils/utils.js");
|
|
14
14
|
const dotenv_1 = __importDefault(require("dotenv"));
|
|
15
|
+
const path_1 = __importDefault(require("path"));
|
|
16
|
+
const version = (0, utils_js_1.getPackageVersion)();
|
|
15
17
|
const debug = (0, debug_1.default)('@testomatio/reporter:xml-cli');
|
|
16
|
-
console.log(picocolors_1.default.cyan(picocolors_1.default.bold(` 🤩 Testomat.io XML Reporter v${
|
|
18
|
+
console.log(picocolors_1.default.cyan(picocolors_1.default.bold(` 🤩 Testomat.io XML Reporter v${version}`)));
|
|
17
19
|
const program = new commander_1.Command();
|
|
18
20
|
program
|
|
19
21
|
.arguments('<pattern>')
|
package/lib/bin/startTest.js
CHANGED
|
@@ -9,10 +9,11 @@ const commander_1 = require("commander");
|
|
|
9
9
|
const picocolors_1 = __importDefault(require("picocolors"));
|
|
10
10
|
const client_js_1 = __importDefault(require("../client.js"));
|
|
11
11
|
const constants_js_1 = require("../constants.js");
|
|
12
|
-
const
|
|
12
|
+
const utils_js_1 = require("../utils/utils.js");
|
|
13
13
|
const config_js_1 = require("../config.js");
|
|
14
14
|
const dotenv_1 = __importDefault(require("dotenv"));
|
|
15
|
-
|
|
15
|
+
const version = (0, utils_js_1.getPackageVersion)();
|
|
16
|
+
console.log(picocolors_1.default.cyan(picocolors_1.default.bold(` 🤩 Testomat.io Reporter v${version}`)));
|
|
16
17
|
const program = new commander_1.Command();
|
|
17
18
|
program
|
|
18
19
|
.option('-c, --command <cmd>', 'Test runner command')
|
|
@@ -9,12 +9,13 @@ const picocolors_1 = __importDefault(require("picocolors"));
|
|
|
9
9
|
const debug_1 = __importDefault(require("debug"));
|
|
10
10
|
const client_js_1 = __importDefault(require("../client.js"));
|
|
11
11
|
const constants_js_1 = require("../constants.js");
|
|
12
|
-
const package_json_1 = require("../../package.json");
|
|
13
|
-
const config_js_1 = require("../config.js");
|
|
14
12
|
const utils_js_1 = require("../utils/utils.js");
|
|
13
|
+
const config_js_1 = require("../config.js");
|
|
14
|
+
const utils_js_2 = require("../utils/utils.js");
|
|
15
15
|
const dotenv_1 = __importDefault(require("dotenv"));
|
|
16
16
|
const debug = (0, debug_1.default)('@testomatio/reporter:upload-cli');
|
|
17
|
-
|
|
17
|
+
const version = (0, utils_js_1.getPackageVersion)();
|
|
18
|
+
console.log(picocolors_1.default.cyan(picocolors_1.default.bold(` 🤩 Testomat.io Reporter v${version}`)));
|
|
18
19
|
const program = new commander_1.Command();
|
|
19
20
|
program
|
|
20
21
|
.option('--env-file <envfile>', 'Load environment variables from env file')
|
|
@@ -28,7 +29,7 @@ program
|
|
|
28
29
|
}
|
|
29
30
|
const apiKey = config_js_1.config.TESTOMATIO;
|
|
30
31
|
process.env.TESTOMATIO_DISABLE_ARTIFACTS = '';
|
|
31
|
-
const runId = process.env.TESTOMATIO_RUN || process.env.runId || (0,
|
|
32
|
+
const runId = process.env.TESTOMATIO_RUN || process.env.runId || (0, utils_js_2.readLatestRunId)();
|
|
32
33
|
if (!runId) {
|
|
33
34
|
console.log('TESTOMATIO_RUN environment variable must be set or restored from a previous run.');
|
|
34
35
|
return process.exit(1);
|
package/lib/data-storage.d.ts
CHANGED
|
@@ -3,6 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const path_1 = __importDefault(require("path"));
|
|
6
7
|
const adapter_js_1 = __importDefault(require("./adapter.js"));
|
|
7
8
|
class CSharpAdapter extends adapter_js_1.default {
|
|
8
9
|
formatTest(t) {
|
|
@@ -12,9 +13,18 @@ class CSharpAdapter extends adapter_js_1.default {
|
|
|
12
13
|
t.example = { ...example[1].split(',') };
|
|
13
14
|
const suite = t.suite_title.split('.');
|
|
14
15
|
t.suite_title = suite.pop();
|
|
15
|
-
t.file =
|
|
16
|
+
t.file = namespaceToFileName(t.file);
|
|
16
17
|
t.title = title.trim();
|
|
17
18
|
return t;
|
|
18
19
|
}
|
|
20
|
+
getFilePath(t) {
|
|
21
|
+
const fileName = namespaceToFileName(t.file);
|
|
22
|
+
return fileName;
|
|
23
|
+
}
|
|
19
24
|
}
|
|
20
25
|
module.exports = CSharpAdapter;
|
|
26
|
+
function namespaceToFileName(fileName) {
|
|
27
|
+
const fileParts = fileName.split('.');
|
|
28
|
+
fileParts[fileParts.length - 1] = fileParts[fileParts.length - 1]?.replace(/\$.*/, '');
|
|
29
|
+
return `${fileParts.join(path_1.default.sep)}.cs`;
|
|
30
|
+
}
|
package/lib/pipe/bitbucket.d.ts
CHANGED
|
@@ -11,7 +11,6 @@ export class BitbucketPipe {
|
|
|
11
11
|
tests: any[];
|
|
12
12
|
token: any;
|
|
13
13
|
hiddenCommentData: string;
|
|
14
|
-
client: Gaxios;
|
|
15
14
|
cleanLog(log: any): Promise<string>;
|
|
16
15
|
prepareRun(): Promise<void>;
|
|
17
16
|
createRun(): Promise<void>;
|
|
@@ -22,4 +21,3 @@ export class BitbucketPipe {
|
|
|
22
21
|
}
|
|
23
22
|
export type Pipe = import("../../types/types.js").Pipe;
|
|
24
23
|
export type TestData = import("../../types/types.js").TestData;
|
|
25
|
-
import { Gaxios } from 'gaxios';
|
package/lib/pipe/bitbucket.js
CHANGED
|
@@ -40,7 +40,7 @@ exports.BitbucketPipe = void 0;
|
|
|
40
40
|
const constants_js_1 = require("../constants.js");
|
|
41
41
|
const utils_js_1 = require("../utils/utils.js");
|
|
42
42
|
const pipe_utils_js_1 = require("../utils/pipe_utils.js");
|
|
43
|
-
const
|
|
43
|
+
const axios_1 = __importDefault(require("axios"));
|
|
44
44
|
const picocolors_1 = __importDefault(require("picocolors"));
|
|
45
45
|
const humanize_duration_1 = __importDefault(require("humanize-duration"));
|
|
46
46
|
const lodash_merge_1 = __importDefault(require("lodash.merge"));
|
|
@@ -69,13 +69,6 @@ class BitbucketPipe {
|
|
|
69
69
|
return;
|
|
70
70
|
}
|
|
71
71
|
this.isEnabled = true;
|
|
72
|
-
this.client = new gaxios_1.Gaxios({
|
|
73
|
-
baseURL: 'https://api.bitbucket.org/2.0',
|
|
74
|
-
headers: {
|
|
75
|
-
'Content-Type': 'application/json',
|
|
76
|
-
'Authorization': `Bearer ${this.token}`
|
|
77
|
-
}
|
|
78
|
-
});
|
|
79
72
|
debug('Bitbucket Pipe: Enabled');
|
|
80
73
|
}
|
|
81
74
|
async cleanLog(log) {
|
|
@@ -175,17 +168,18 @@ class BitbucketPipe {
|
|
|
175
168
|
}
|
|
176
169
|
// Construct Bitbucket API URL for comments
|
|
177
170
|
// eslint-disable-next-line max-len
|
|
178
|
-
const commentsRequestURL =
|
|
171
|
+
const commentsRequestURL = `https://api.bitbucket.org/2.0/repositories/${this.ENV.BITBUCKET_WORKSPACE}/${this.ENV.BITBUCKET_REPO_SLUG}/pullrequests/${this.ENV.BITBUCKET_PR_ID}/comments`;
|
|
179
172
|
// Delete previous report
|
|
180
|
-
await deletePreviousReport(
|
|
173
|
+
await deletePreviousReport(axios_1.default, commentsRequestURL, this.hiddenCommentData, this.token);
|
|
181
174
|
// Add current report
|
|
182
175
|
debug(`Adding comment via URL: ${commentsRequestURL}`);
|
|
183
176
|
debug(`Final Bitbucket API call body: ${body}`);
|
|
184
177
|
try {
|
|
185
|
-
const addCommentResponse = await
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
178
|
+
const addCommentResponse = await axios_1.default.post(commentsRequestURL, { content: { raw: body } }, {
|
|
179
|
+
headers: {
|
|
180
|
+
Authorization: `Bearer ${this.token}`,
|
|
181
|
+
'Content-Type': 'application/json',
|
|
182
|
+
},
|
|
189
183
|
});
|
|
190
184
|
const commentID = addCommentResponse.data.id;
|
|
191
185
|
// eslint-disable-next-line max-len
|
|
@@ -204,15 +198,17 @@ class BitbucketPipe {
|
|
|
204
198
|
updateRun() { }
|
|
205
199
|
}
|
|
206
200
|
exports.BitbucketPipe = BitbucketPipe;
|
|
207
|
-
async function deletePreviousReport(
|
|
201
|
+
async function deletePreviousReport(axiosInstance, commentsRequestURL, hiddenCommentData, token) {
|
|
208
202
|
if (process.env.BITBUCKET_KEEP_OUTDATED_REPORTS)
|
|
209
203
|
return;
|
|
210
204
|
// Get comments
|
|
211
205
|
let comments = [];
|
|
212
206
|
try {
|
|
213
|
-
const response = await
|
|
214
|
-
|
|
215
|
-
|
|
207
|
+
const response = await axiosInstance.get(commentsRequestURL, {
|
|
208
|
+
headers: {
|
|
209
|
+
Authorization: `Bearer ${token}`,
|
|
210
|
+
'Content-Type': 'application/json',
|
|
211
|
+
},
|
|
216
212
|
});
|
|
217
213
|
comments = response.data.values;
|
|
218
214
|
}
|
|
@@ -227,9 +223,11 @@ async function deletePreviousReport(client, commentsRequestURL, hiddenCommentDat
|
|
|
227
223
|
try {
|
|
228
224
|
// Delete previous comment
|
|
229
225
|
const deleteCommentURL = `${commentsRequestURL}/${comment.id}`;
|
|
230
|
-
await
|
|
231
|
-
|
|
232
|
-
|
|
226
|
+
await axiosInstance.delete(deleteCommentURL, {
|
|
227
|
+
headers: {
|
|
228
|
+
Authorization: `Bearer ${token}`,
|
|
229
|
+
'Content-Type': 'application/json',
|
|
230
|
+
},
|
|
233
231
|
});
|
|
234
232
|
}
|
|
235
233
|
catch (e) {
|
package/lib/pipe/gitlab.d.ts
CHANGED
|
@@ -14,7 +14,6 @@ declare class GitLabPipe {
|
|
|
14
14
|
tests: any[];
|
|
15
15
|
token: any;
|
|
16
16
|
hiddenCommentData: string;
|
|
17
|
-
client: Gaxios;
|
|
18
17
|
prepareRun(): Promise<void>;
|
|
19
18
|
createRun(): Promise<void>;
|
|
20
19
|
addTest(test: any): void;
|
|
@@ -22,4 +21,3 @@ declare class GitLabPipe {
|
|
|
22
21
|
toString(): string;
|
|
23
22
|
updateRun(): void;
|
|
24
23
|
}
|
|
25
|
-
import { Gaxios } from 'gaxios';
|
package/lib/pipe/gitlab.js
CHANGED
|
@@ -4,7 +4,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
const debug_1 = __importDefault(require("debug"));
|
|
7
|
-
const
|
|
7
|
+
const axios_1 = __importDefault(require("axios"));
|
|
8
8
|
const picocolors_1 = __importDefault(require("picocolors"));
|
|
9
9
|
const humanize_duration_1 = __importDefault(require("humanize-duration"));
|
|
10
10
|
const lodash_merge_1 = __importDefault(require("lodash.merge"));
|
|
@@ -39,12 +39,6 @@ class GitLabPipe {
|
|
|
39
39
|
return;
|
|
40
40
|
}
|
|
41
41
|
this.isEnabled = true;
|
|
42
|
-
this.client = new gaxios_1.Gaxios({
|
|
43
|
-
baseURL: 'https://gitlab.com/api/v4',
|
|
44
|
-
headers: {
|
|
45
|
-
'Content-Type': 'application/json',
|
|
46
|
-
}
|
|
47
|
-
});
|
|
48
42
|
debug('GitLab Pipe: Enabled');
|
|
49
43
|
}
|
|
50
44
|
// TODO: to using SET opts as argument => prepareRun(opts)
|
|
@@ -132,18 +126,13 @@ class GitLabPipe {
|
|
|
132
126
|
body += '\n</details>';
|
|
133
127
|
}
|
|
134
128
|
// eslint-disable-next-line max-len
|
|
135
|
-
const commentsRequestURL =
|
|
129
|
+
const commentsRequestURL = `https://gitlab.com/api/v4/projects/${this.ENV.CI_PROJECT_ID}/merge_requests/${this.ENV.CI_MERGE_REQUEST_IID}/notes`;
|
|
136
130
|
// delete previous report
|
|
137
|
-
await deletePreviousReport(
|
|
131
|
+
await deletePreviousReport(axios_1.default, commentsRequestURL, this.hiddenCommentData, this.token);
|
|
138
132
|
// add current report
|
|
139
133
|
debug(`Adding comment via url: ${commentsRequestURL}`);
|
|
140
134
|
try {
|
|
141
|
-
const addCommentResponse = await
|
|
142
|
-
method: 'POST',
|
|
143
|
-
url: commentsRequestURL,
|
|
144
|
-
params: { access_token: this.token },
|
|
145
|
-
data: { body }
|
|
146
|
-
});
|
|
135
|
+
const addCommentResponse = await axios_1.default.post(`${commentsRequestURL}?access_token=${this.token}`, { body });
|
|
147
136
|
const commentID = addCommentResponse.data.id;
|
|
148
137
|
// eslint-disable-next-line max-len
|
|
149
138
|
const commentURL = `${this.ENV.CI_PROJECT_URL}/-/merge_requests/${this.ENV.CI_MERGE_REQUEST_IID}#note_${commentID}`;
|
|
@@ -160,17 +149,13 @@ class GitLabPipe {
|
|
|
160
149
|
}
|
|
161
150
|
updateRun() { }
|
|
162
151
|
}
|
|
163
|
-
async function deletePreviousReport(
|
|
152
|
+
async function deletePreviousReport(axiosInstance, commentsRequestURL, hiddenCommentData, token) {
|
|
164
153
|
if (process.env.GITLAB_KEEP_OUTDATED_REPORTS)
|
|
165
154
|
return;
|
|
166
155
|
// get comments
|
|
167
156
|
let comments = [];
|
|
168
157
|
try {
|
|
169
|
-
const response = await
|
|
170
|
-
method: 'GET',
|
|
171
|
-
url: commentsRequestURL,
|
|
172
|
-
params: { access_token: token }
|
|
173
|
-
});
|
|
158
|
+
const response = await axiosInstance.get(`${commentsRequestURL}?access_token=${token}`);
|
|
174
159
|
comments = response.data;
|
|
175
160
|
}
|
|
176
161
|
catch (e) {
|
|
@@ -183,12 +168,8 @@ async function deletePreviousReport(client, commentsRequestURL, hiddenCommentDat
|
|
|
183
168
|
if (comment.body.includes(hiddenCommentData)) {
|
|
184
169
|
try {
|
|
185
170
|
// delete previous comment
|
|
186
|
-
const deleteCommentURL = `${commentsRequestURL}/${comment.id}`;
|
|
187
|
-
await
|
|
188
|
-
method: 'DELETE',
|
|
189
|
-
url: deleteCommentURL,
|
|
190
|
-
params: { access_token: token }
|
|
191
|
-
});
|
|
171
|
+
const deleteCommentURL = `${commentsRequestURL}/${comment.id}?access_token=${token}`;
|
|
172
|
+
await axiosInstance.delete(deleteCommentURL);
|
|
192
173
|
}
|
|
193
174
|
catch (e) {
|
|
194
175
|
console.warn(`Can't delete previously added comment with testomat.io report. Ignore.`);
|
package/lib/pipe/testomatio.d.ts
CHANGED
|
@@ -31,7 +31,7 @@ declare class TestomatioPipe implements Pipe {
|
|
|
31
31
|
groupTitle: any;
|
|
32
32
|
env: string;
|
|
33
33
|
label: string;
|
|
34
|
-
|
|
34
|
+
axios: import("axios").AxiosInstance;
|
|
35
35
|
proceed: string;
|
|
36
36
|
jiraId: string;
|
|
37
37
|
runId: any;
|
|
@@ -68,4 +68,3 @@ declare class TestomatioPipe implements Pipe {
|
|
|
68
68
|
toString(): string;
|
|
69
69
|
#private;
|
|
70
70
|
}
|
|
71
|
-
import { Gaxios } from 'gaxios';
|
package/lib/pipe/testomatio.js
CHANGED
|
@@ -5,7 +5,10 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
const debug_1 = __importDefault(require("debug"));
|
|
7
7
|
const picocolors_1 = __importDefault(require("picocolors"));
|
|
8
|
-
|
|
8
|
+
// Retry interceptor function
|
|
9
|
+
const axios_retry_1 = __importDefault(require("axios-retry"));
|
|
10
|
+
// Default axios instance
|
|
11
|
+
const axios_1 = __importDefault(require("axios"));
|
|
9
12
|
const json_cycle_1 = __importDefault(require("json-cycle"));
|
|
10
13
|
const constants_js_1 = require("../constants.js");
|
|
11
14
|
const utils_js_1 = require("../utils/utils.js");
|
|
@@ -51,30 +54,42 @@ class TestomatioPipe {
|
|
|
51
54
|
this.groupTitle = params.groupTitle || process.env.TESTOMATIO_RUNGROUP_TITLE;
|
|
52
55
|
this.env = process.env.TESTOMATIO_ENV;
|
|
53
56
|
this.label = process.env.TESTOMATIO_LABEL;
|
|
54
|
-
// Create a new instance of
|
|
55
|
-
this.
|
|
57
|
+
// Create a new instance of axios with a custom config
|
|
58
|
+
this.axios = axios_1.default.create({
|
|
56
59
|
baseURL: `${this.url.trim()}`,
|
|
57
60
|
timeout: constants_js_1.AXIOS_TIMEOUT,
|
|
58
|
-
proxy: proxy
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
61
|
+
proxy: proxy
|
|
62
|
+
? {
|
|
63
|
+
host: proxy.hostname,
|
|
64
|
+
port: parseInt(proxy.port, 10),
|
|
65
|
+
protocol: proxy.protocol,
|
|
66
|
+
}
|
|
67
|
+
: false,
|
|
68
|
+
});
|
|
69
|
+
// Pass the axios instance to the retry function
|
|
70
|
+
(0, axios_retry_1.default)(this.axios, {
|
|
71
|
+
// do not use retries for unit tests
|
|
72
|
+
retries: constants_js_1.REPORTER_REQUEST_RETRIES.retriesPerRequest, // Number of retries
|
|
73
|
+
shouldResetTimeout: true,
|
|
74
|
+
retryCondition: error => {
|
|
75
|
+
if (!error.response)
|
|
76
|
+
return false;
|
|
77
|
+
switch (error.response?.status) {
|
|
78
|
+
case 400: // Bad request (probably wrong API key)
|
|
79
|
+
case 404: // Test not matched
|
|
80
|
+
case 429: // Rate limit exceeded
|
|
81
|
+
case 500: // Internal server error
|
|
65
82
|
return false;
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
case 404: // Test not matched
|
|
69
|
-
case 429: // Rate limit exceeded
|
|
70
|
-
case 500: // Internal server error
|
|
71
|
-
return false;
|
|
72
|
-
default:
|
|
73
|
-
break;
|
|
74
|
-
}
|
|
75
|
-
return error.response?.status >= 401; // Retry on 401+ and 5xx
|
|
83
|
+
default:
|
|
84
|
+
break;
|
|
76
85
|
}
|
|
77
|
-
|
|
86
|
+
return error.response?.status >= 401; // Retry on 401+ and 5xx
|
|
87
|
+
},
|
|
88
|
+
retryDelay: () => constants_js_1.REPORTER_REQUEST_RETRIES.retryTimeout, // sum = 15sec
|
|
89
|
+
onRetry: async (retryCount, error) => {
|
|
90
|
+
this.retriesTimestamps.push(Date.now());
|
|
91
|
+
debug(`${error.message || `Request failed ${error.status}`}. Retry #${retryCount} ...`);
|
|
92
|
+
},
|
|
78
93
|
});
|
|
79
94
|
this.isEnabled = true;
|
|
80
95
|
// do not finish this run (for parallel testing)
|
|
@@ -109,14 +124,11 @@ class TestomatioPipe {
|
|
|
109
124
|
if (!q) {
|
|
110
125
|
return;
|
|
111
126
|
}
|
|
112
|
-
const resp = await this.
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
if (Array.isArray(resp.data?.tests) && resp.data?.tests?.length > 0) {
|
|
118
|
-
(0, utils_js_1.foundedTestLog)(constants_js_1.APP_PREFIX, resp.data.tests);
|
|
119
|
-
return resp.data.tests;
|
|
127
|
+
const resp = await this.axios.get('/api/test_grep', q);
|
|
128
|
+
const { data } = resp;
|
|
129
|
+
if (Array.isArray(data?.tests) && data?.tests?.length > 0) {
|
|
130
|
+
(0, utils_js_1.foundedTestLog)(constants_js_1.APP_PREFIX, data.tests);
|
|
131
|
+
return data.tests;
|
|
120
132
|
}
|
|
121
133
|
console.log(constants_js_1.APP_PREFIX, `⛔ No tests found for your --filter --> ${type}=${id}`);
|
|
122
134
|
}
|
|
@@ -138,6 +150,7 @@ class TestomatioPipe {
|
|
|
138
150
|
let buildUrl = process.env.BUILD_URL || process.env.CI_JOB_URL || process.env.CIRCLE_BUILD_URL;
|
|
139
151
|
// GitHub Actions Url
|
|
140
152
|
if (!buildUrl && process.env.GITHUB_RUN_ID) {
|
|
153
|
+
// eslint-disable-next-line max-len
|
|
141
154
|
buildUrl = `${process.env.GITHUB_SERVER_URL}/${process.env.GITHUB_REPOSITORY}/actions/runs/${process.env.GITHUB_RUN_ID}`;
|
|
142
155
|
}
|
|
143
156
|
// Azure DevOps Url
|
|
@@ -167,23 +180,16 @@ class TestomatioPipe {
|
|
|
167
180
|
if (this.runId) {
|
|
168
181
|
this.store.runId = this.runId;
|
|
169
182
|
debug(`Run with id ${this.runId} already created, updating...`);
|
|
170
|
-
const resp = await this.
|
|
171
|
-
method: 'PUT',
|
|
172
|
-
url: `/api/reporter/${this.runId}`,
|
|
173
|
-
data: runParams
|
|
174
|
-
});
|
|
183
|
+
const resp = await this.axios.put(`/api/reporter/${this.runId}`, runParams);
|
|
175
184
|
if (resp.data.artifacts)
|
|
176
185
|
(0, pipe_utils_js_1.setS3Credentials)(resp.data.artifacts);
|
|
177
186
|
return;
|
|
178
187
|
}
|
|
179
188
|
debug('Creating run...');
|
|
180
189
|
try {
|
|
181
|
-
const resp = await this.
|
|
182
|
-
method: 'POST',
|
|
183
|
-
url: '/api/reporter',
|
|
184
|
-
data: runParams,
|
|
190
|
+
const resp = await this.axios.post(`/api/reporter`, runParams, {
|
|
185
191
|
maxContentLength: Infinity,
|
|
186
|
-
|
|
192
|
+
maxBodyLength: Infinity,
|
|
187
193
|
});
|
|
188
194
|
this.runId = resp.data.uid;
|
|
189
195
|
this.runUrl = `${this.url}/${resp.data.url.split('/').splice(3).join('/')}`;
|
|
@@ -199,7 +205,6 @@ class TestomatioPipe {
|
|
|
199
205
|
}
|
|
200
206
|
catch (err) {
|
|
201
207
|
const errorText = err.response?.data?.message || err.message;
|
|
202
|
-
debug('Error creating run', err);
|
|
203
208
|
console.log(errorText || err);
|
|
204
209
|
if (!this.apiKey)
|
|
205
210
|
console.error('Testomat.io API key is not set');
|
|
@@ -240,15 +245,7 @@ class TestomatioPipe {
|
|
|
240
245
|
}
|
|
241
246
|
const json = json_cycle_1.default.stringify(data);
|
|
242
247
|
debug('Adding test', json);
|
|
243
|
-
return this.
|
|
244
|
-
method: 'POST',
|
|
245
|
-
url: `/api/reporter/${this.runId}/testrun`,
|
|
246
|
-
data: json,
|
|
247
|
-
headers: {
|
|
248
|
-
'Content-Type': 'application/json',
|
|
249
|
-
},
|
|
250
|
-
maxContentLength: Infinity
|
|
251
|
-
}).catch(err => {
|
|
248
|
+
return this.axios.post(`/api/reporter/${this.runId}/testrun`, json, axiosAddTestrunRequestConfig).catch(err => {
|
|
252
249
|
this.requestFailures++;
|
|
253
250
|
this.notReportedTestsCount++;
|
|
254
251
|
if (err.response) {
|
|
@@ -293,19 +290,9 @@ class TestomatioPipe {
|
|
|
293
290
|
// get tests from batch and clear batch
|
|
294
291
|
const testsToSend = this.batch.tests.splice(0);
|
|
295
292
|
debug('📨 Batch upload', testsToSend.length, 'tests');
|
|
296
|
-
return this.
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
data: {
|
|
300
|
-
api_key: this.apiKey,
|
|
301
|
-
tests: testsToSend,
|
|
302
|
-
batch_index: this.batch.batchIndex
|
|
303
|
-
},
|
|
304
|
-
headers: {
|
|
305
|
-
'Content-Type': 'application/json',
|
|
306
|
-
},
|
|
307
|
-
maxContentLength: Infinity
|
|
308
|
-
}).catch(err => {
|
|
293
|
+
return this.axios
|
|
294
|
+
.post(`/api/reporter/${this.runId}/testrun`, { api_key: this.apiKey, tests: testsToSend, batch_index: this.batch.batchIndex }, axiosAddTestrunRequestConfig)
|
|
295
|
+
.catch(err => {
|
|
309
296
|
this.requestFailures++;
|
|
310
297
|
this.notReportedTestsCount += testsToSend.length;
|
|
311
298
|
if (err.response) {
|
|
@@ -379,16 +366,12 @@ class TestomatioPipe {
|
|
|
379
366
|
status_event += '_parallel';
|
|
380
367
|
try {
|
|
381
368
|
if (this.runId && !this.proceed) {
|
|
382
|
-
await this.
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
status_event,
|
|
389
|
-
detach: params.detach,
|
|
390
|
-
tests: params.tests,
|
|
391
|
-
}
|
|
369
|
+
await this.axios.put(`/api/reporter/${this.runId}`, {
|
|
370
|
+
api_key: this.apiKey,
|
|
371
|
+
duration: params.duration,
|
|
372
|
+
status_event,
|
|
373
|
+
detach: params.detach,
|
|
374
|
+
tests: params.tests,
|
|
392
375
|
});
|
|
393
376
|
if (this.runUrl) {
|
|
394
377
|
console.log(constants_js_1.APP_PREFIX, '📊 Report Saved. Report URL:', picocolors_1.default.magenta(this.runUrl));
|
|
@@ -444,4 +427,12 @@ function printCreateIssue(err) {
|
|
|
444
427
|
console.log('```');
|
|
445
428
|
});
|
|
446
429
|
}
|
|
430
|
+
const axiosAddTestrunRequestConfig = {
|
|
431
|
+
maxContentLength: Infinity,
|
|
432
|
+
maxBodyLength: Infinity,
|
|
433
|
+
headers: {
|
|
434
|
+
// Overwrite Axios's automatically set Content-Type
|
|
435
|
+
'Content-Type': 'application/json',
|
|
436
|
+
},
|
|
437
|
+
};
|
|
447
438
|
module.exports = TestomatioPipe;
|