@allurereport/core 3.0.0-beta.21 → 3.0.0-beta.23
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/dist/qualityGate/qualityGate.js +13 -6
- package/dist/qualityGate/rules.js +6 -7
- package/dist/report.js +37 -11
- package/dist/store/store.js +1 -1
- package/package.json +21 -18
|
@@ -58,7 +58,7 @@ export class QualityGate {
|
|
|
58
58
|
if (fastFailed) {
|
|
59
59
|
break;
|
|
60
60
|
}
|
|
61
|
-
for (const [key,
|
|
61
|
+
for (const [key, expected] of Object.entries(ruleset)) {
|
|
62
62
|
if (key === "filter" || key === "id" || key === "fastFail") {
|
|
63
63
|
continue;
|
|
64
64
|
}
|
|
@@ -66,21 +66,28 @@ export class QualityGate {
|
|
|
66
66
|
if (!rule) {
|
|
67
67
|
throw new Error(`Rule ${key} is not provided. Make sure you have provided it in the "use" field of the quality gate config!`);
|
|
68
68
|
}
|
|
69
|
+
const trsToValidate = ruleset.filter ? trs.filter(ruleset.filter) : trs;
|
|
69
70
|
const ruleId = ruleset.id ? [ruleset.id, rule.rule].join("/") : rule.rule;
|
|
70
71
|
const result = await rule.validate({
|
|
71
|
-
|
|
72
|
-
|
|
72
|
+
trs: trsToValidate,
|
|
73
|
+
state: {
|
|
74
|
+
getResult: () => state?.getResult?.(ruleId),
|
|
75
|
+
setResult: (value) => state?.setResult?.(ruleId, value),
|
|
76
|
+
},
|
|
77
|
+
expected,
|
|
73
78
|
knownIssues,
|
|
74
|
-
state: state?.getResult?.(ruleId),
|
|
75
79
|
});
|
|
76
|
-
state?.setResult(ruleId, result.actual);
|
|
77
80
|
if (result.success) {
|
|
78
81
|
continue;
|
|
79
82
|
}
|
|
80
83
|
results.push({
|
|
81
84
|
...result,
|
|
85
|
+
expected,
|
|
82
86
|
rule: ruleset.id ? [ruleset.id, rule.rule].join("/") : rule.rule,
|
|
83
|
-
message: rule.message(
|
|
87
|
+
message: rule.message({
|
|
88
|
+
actual: result.actual,
|
|
89
|
+
expected,
|
|
90
|
+
}),
|
|
84
91
|
});
|
|
85
92
|
if (ruleset.fastFail) {
|
|
86
93
|
fastFailed = true;
|
|
@@ -3,27 +3,27 @@ import { bold } from "yoctocolors";
|
|
|
3
3
|
export const maxFailuresRule = {
|
|
4
4
|
rule: "maxFailures",
|
|
5
5
|
message: ({ actual, expected }) => `The number of failed tests ${bold(String(actual))} exceeds the allowed threshold value ${bold(String(expected))}`,
|
|
6
|
-
validate: async ({ trs, knownIssues, expected, state
|
|
6
|
+
validate: async ({ trs, knownIssues, expected, state }) => {
|
|
7
7
|
const knownIssuesHistoryIds = knownIssues.map(({ historyId }) => historyId);
|
|
8
8
|
const unknown = trs.filter((tr) => !tr.historyId || !knownIssuesHistoryIds.includes(tr.historyId));
|
|
9
9
|
const failedTrs = unknown.filter(filterUnsuccessful);
|
|
10
|
-
const actual = failedTrs.length + state;
|
|
10
|
+
const actual = failedTrs.length + (state.getResult() ?? 0);
|
|
11
|
+
state.setResult(actual);
|
|
11
12
|
return {
|
|
12
13
|
success: actual <= expected,
|
|
13
14
|
actual,
|
|
14
|
-
expected,
|
|
15
15
|
};
|
|
16
16
|
},
|
|
17
17
|
};
|
|
18
18
|
export const minTestsCountRule = {
|
|
19
19
|
rule: "minTestsCount",
|
|
20
20
|
message: ({ actual, expected }) => `The total number of tests ${bold(String(actual))} is less than the expected threshold value ${bold(String(expected))}`,
|
|
21
|
-
validate: async ({ trs, expected, state
|
|
22
|
-
const actual = trs.length + state;
|
|
21
|
+
validate: async ({ trs, expected, state }) => {
|
|
22
|
+
const actual = trs.length + (state.getResult() ?? 0);
|
|
23
|
+
state.setResult(actual);
|
|
23
24
|
return {
|
|
24
25
|
success: actual >= expected,
|
|
25
26
|
actual,
|
|
26
|
-
expected,
|
|
27
27
|
};
|
|
28
28
|
},
|
|
29
29
|
};
|
|
@@ -38,7 +38,6 @@ export const successRateRule = {
|
|
|
38
38
|
return {
|
|
39
39
|
success: rate >= expected,
|
|
40
40
|
actual: rate,
|
|
41
|
-
expected,
|
|
42
41
|
};
|
|
43
42
|
},
|
|
44
43
|
};
|
package/dist/report.js
CHANGED
|
@@ -25,6 +25,8 @@ import { lstat, mkdtemp, opendir, readdir, realpath, rename, rm, writeFile } fro
|
|
|
25
25
|
import { tmpdir } from "node:os";
|
|
26
26
|
import { basename, dirname, join, resolve } from "node:path";
|
|
27
27
|
import { promisify } from "node:util";
|
|
28
|
+
import pLimit from "p-limit";
|
|
29
|
+
import ProgressBar from "progress";
|
|
28
30
|
import ZipWriteStream from "zip-stream";
|
|
29
31
|
import { AllureLocalHistory, createHistory } from "./history.js";
|
|
30
32
|
import { DefaultPluginState, PluginFiles } from "./plugin.js";
|
|
@@ -105,6 +107,7 @@ export class AllureReport {
|
|
|
105
107
|
});
|
|
106
108
|
};
|
|
107
109
|
this.start = async () => {
|
|
110
|
+
const repoData = await __classPrivateFieldGet(this, _AllureReport_store, "f").repoData();
|
|
108
111
|
await __classPrivateFieldGet(this, _AllureReport_store, "f").readHistory();
|
|
109
112
|
if (__classPrivateFieldGet(this, _AllureReport_executionStage, "f") === "running") {
|
|
110
113
|
throw new Error("the report is already started");
|
|
@@ -113,10 +116,11 @@ export class AllureReport {
|
|
|
113
116
|
throw new Error("the report is already stopped, the restart isn't supported at the moment");
|
|
114
117
|
}
|
|
115
118
|
__classPrivateFieldSet(this, _AllureReport_executionStage, "running", "f");
|
|
116
|
-
if (__classPrivateFieldGet(this, _AllureReport_allureServiceClient, "f") && __classPrivateFieldGet(this, _AllureReport_instances, "a", _AllureReport_publish_get)) {
|
|
119
|
+
if (__classPrivateFieldGet(this, _AllureReport_allureServiceClient, "f") && __classPrivateFieldGet(this, _AllureReport_instances, "a", _AllureReport_publish_get) && repoData?.branch) {
|
|
117
120
|
const { url } = await __classPrivateFieldGet(this, _AllureReport_allureServiceClient, "f").createReport({
|
|
118
121
|
reportUuid: this.reportUuid,
|
|
119
122
|
reportName: __classPrivateFieldGet(this, _AllureReport_reportName, "f"),
|
|
123
|
+
branch: repoData.branch,
|
|
120
124
|
});
|
|
121
125
|
this.reportUrl = url;
|
|
122
126
|
}
|
|
@@ -311,6 +315,9 @@ export class AllureReport {
|
|
|
311
315
|
if (__classPrivateFieldGet(this, _AllureReport_executionStage, "f") !== "running") {
|
|
312
316
|
throw new Error(initRequired);
|
|
313
317
|
}
|
|
318
|
+
const testResults = await __classPrivateFieldGet(this, _AllureReport_store, "f").allTestResults();
|
|
319
|
+
const testCases = await __classPrivateFieldGet(this, _AllureReport_store, "f").allTestCases();
|
|
320
|
+
const historyDataPoint = createHistory(this.reportUuid, __classPrivateFieldGet(this, _AllureReport_reportName, "f"), testCases, testResults, this.reportUrl);
|
|
314
321
|
__classPrivateFieldGet(this, _AllureReport_realtimeSubscriber, "f").offAll();
|
|
315
322
|
__classPrivateFieldSet(this, _AllureReport_executionStage, "done", "f");
|
|
316
323
|
if (__classPrivateFieldGet(this, _AllureReport_stage, "f")) {
|
|
@@ -319,10 +326,20 @@ export class AllureReport {
|
|
|
319
326
|
}
|
|
320
327
|
await __classPrivateFieldGet(this, _AllureReport_eachPlugin, "f").call(this, false, async (plugin, context) => {
|
|
321
328
|
await plugin.done?.(context, __classPrivateFieldGet(this, _AllureReport_store, "f"));
|
|
329
|
+
});
|
|
330
|
+
await __classPrivateFieldGet(this, _AllureReport_eachPlugin, "f").call(this, false, async (plugin, context) => {
|
|
322
331
|
if (__classPrivateFieldGet(this, _AllureReport_allureServiceClient, "f") && context.publish) {
|
|
323
332
|
const pluginFiles = (await context.state.get("files")) ?? {};
|
|
324
|
-
|
|
325
|
-
|
|
333
|
+
const pluginFilesEntries = Object.entries(pluginFiles);
|
|
334
|
+
const progressBar = pluginFilesEntries?.length > 0
|
|
335
|
+
? new ProgressBar(`Publishing "${context.id}" report [:bar] :current/:total`, {
|
|
336
|
+
total: pluginFilesEntries.length,
|
|
337
|
+
width: 20,
|
|
338
|
+
})
|
|
339
|
+
: undefined;
|
|
340
|
+
const limitFn = pLimit(50);
|
|
341
|
+
const fns = pluginFilesEntries.map(([filename, filepath]) => limitFn(async () => {
|
|
342
|
+
if (/^(data|widgets|index\.html$|summary\.json$)/.test(filename)) {
|
|
326
343
|
await __classPrivateFieldGet(this, _AllureReport_allureServiceClient, "f").addReportFile({
|
|
327
344
|
reportUuid: this.reportUuid,
|
|
328
345
|
pluginId: context.id,
|
|
@@ -336,7 +353,10 @@ export class AllureReport {
|
|
|
336
353
|
filepath,
|
|
337
354
|
});
|
|
338
355
|
}
|
|
339
|
-
|
|
356
|
+
progressBar?.tick?.();
|
|
357
|
+
}));
|
|
358
|
+
progressBar?.render?.();
|
|
359
|
+
await Promise.all(fns);
|
|
340
360
|
}
|
|
341
361
|
const summary = await plugin?.info?.(context, __classPrivateFieldGet(this, _AllureReport_store, "f"));
|
|
342
362
|
if (!summary) {
|
|
@@ -344,7 +364,7 @@ export class AllureReport {
|
|
|
344
364
|
}
|
|
345
365
|
summary.pullRequestHref = __classPrivateFieldGet(this, _AllureReport_ci, "f")?.pullRequestUrl;
|
|
346
366
|
summary.jobHref = __classPrivateFieldGet(this, _AllureReport_ci, "f")?.jobRunUrl;
|
|
347
|
-
if (context.publish) {
|
|
367
|
+
if (context.publish && this.reportUrl) {
|
|
348
368
|
summary.remoteHref = `${this.reportUrl}/${context.id}/`;
|
|
349
369
|
remoteHrefs.push(summary.remoteHref);
|
|
350
370
|
}
|
|
@@ -354,9 +374,21 @@ export class AllureReport {
|
|
|
354
374
|
});
|
|
355
375
|
await context.reportFiles.addFile("summary.json", Buffer.from(JSON.stringify(summary)));
|
|
356
376
|
});
|
|
377
|
+
if (summaries.length > 1) {
|
|
378
|
+
const summaryPath = await generateSummary(__classPrivateFieldGet(this, _AllureReport_output, "f"), summaries);
|
|
379
|
+
const publishedReports = __classPrivateFieldGet(this, _AllureReport_plugins, "f").map((plugin) => !!plugin?.options?.publish).filter(Boolean);
|
|
380
|
+
if (__classPrivateFieldGet(this, _AllureReport_instances, "a", _AllureReport_publish_get) && summaryPath && publishedReports.length > 1) {
|
|
381
|
+
await __classPrivateFieldGet(this, _AllureReport_allureServiceClient, "f")?.addReportFile({
|
|
382
|
+
reportUuid: this.reportUuid,
|
|
383
|
+
filename: "index.html",
|
|
384
|
+
filepath: summaryPath,
|
|
385
|
+
});
|
|
386
|
+
}
|
|
387
|
+
}
|
|
357
388
|
if (__classPrivateFieldGet(this, _AllureReport_instances, "a", _AllureReport_publish_get)) {
|
|
358
389
|
await __classPrivateFieldGet(this, _AllureReport_allureServiceClient, "f")?.completeReport({
|
|
359
390
|
reportUuid: this.reportUuid,
|
|
391
|
+
historyPoint: historyDataPoint,
|
|
360
392
|
});
|
|
361
393
|
}
|
|
362
394
|
let outputDirFiles = [];
|
|
@@ -386,9 +418,6 @@ export class AllureReport {
|
|
|
386
418
|
catch (ignored) { }
|
|
387
419
|
}
|
|
388
420
|
if (__classPrivateFieldGet(this, _AllureReport_history, "f")) {
|
|
389
|
-
const testResults = await __classPrivateFieldGet(this, _AllureReport_store, "f").allTestResults();
|
|
390
|
-
const testCases = await __classPrivateFieldGet(this, _AllureReport_store, "f").allTestCases();
|
|
391
|
-
const historyDataPoint = createHistory(this.reportUuid, __classPrivateFieldGet(this, _AllureReport_reportName, "f"), testCases, testResults, this.reportUrl);
|
|
392
421
|
try {
|
|
393
422
|
await __classPrivateFieldGet(this, _AllureReport_store, "f").appendHistory(historyDataPoint);
|
|
394
423
|
}
|
|
@@ -404,9 +433,6 @@ export class AllureReport {
|
|
|
404
433
|
}
|
|
405
434
|
}
|
|
406
435
|
}
|
|
407
|
-
if (summaries.length > 1) {
|
|
408
|
-
await generateSummary(__classPrivateFieldGet(this, _AllureReport_output, "f"), summaries);
|
|
409
|
-
}
|
|
410
436
|
if (remoteHrefs.length > 0) {
|
|
411
437
|
console.info("Next reports have been published:");
|
|
412
438
|
remoteHrefs.forEach((href) => {
|
package/dist/store/store.js
CHANGED
|
@@ -144,7 +144,7 @@ export class DefaultAllureStore {
|
|
|
144
144
|
return [];
|
|
145
145
|
}
|
|
146
146
|
const repoData = await this.repoData();
|
|
147
|
-
__classPrivateFieldSet(this, _DefaultAllureStore_historyPoints, (await __classPrivateFieldGet(this, _DefaultAllureStore_history, "f").readHistory(repoData
|
|
147
|
+
__classPrivateFieldSet(this, _DefaultAllureStore_historyPoints, (await __classPrivateFieldGet(this, _DefaultAllureStore_history, "f").readHistory(repoData.branch)) ?? [], "f");
|
|
148
148
|
__classPrivateFieldGet(this, _DefaultAllureStore_historyPoints, "f").sort(compareBy("timestamp", reverse(ordinal())));
|
|
149
149
|
return __classPrivateFieldGet(this, _DefaultAllureStore_historyPoints, "f");
|
|
150
150
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@allurereport/core",
|
|
3
|
-
"version": "3.0.0-beta.
|
|
3
|
+
"version": "3.0.0-beta.23",
|
|
4
4
|
"description": "Collection of generic Allure utilities used across the entire project",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"allure"
|
|
@@ -25,26 +25,28 @@
|
|
|
25
25
|
"test": "vitest run"
|
|
26
26
|
},
|
|
27
27
|
"dependencies": {
|
|
28
|
-
"@allurereport/ci": "3.0.0-beta.
|
|
29
|
-
"@allurereport/core-api": "3.0.0-beta.
|
|
30
|
-
"@allurereport/plugin-allure2": "3.0.0-beta.
|
|
31
|
-
"@allurereport/plugin-api": "3.0.0-beta.
|
|
32
|
-
"@allurereport/plugin-awesome": "3.0.0-beta.
|
|
33
|
-
"@allurereport/plugin-classic": "3.0.0-beta.
|
|
34
|
-
"@allurereport/plugin-csv": "3.0.0-beta.
|
|
35
|
-
"@allurereport/plugin-dashboard": "3.0.0-beta.
|
|
36
|
-
"@allurereport/plugin-jira": "3.0.0-beta.
|
|
37
|
-
"@allurereport/plugin-log": "3.0.0-beta.
|
|
38
|
-
"@allurereport/plugin-progress": "3.0.0-beta.
|
|
39
|
-
"@allurereport/plugin-slack": "3.0.0-beta.
|
|
40
|
-
"@allurereport/plugin-testplan": "3.0.0-beta.
|
|
41
|
-
"@allurereport/reader": "3.0.0-beta.
|
|
42
|
-
"@allurereport/reader-api": "3.0.0-beta.
|
|
43
|
-
"@allurereport/service": "3.0.0-beta.
|
|
44
|
-
"@allurereport/summary": "3.0.0-beta.
|
|
28
|
+
"@allurereport/ci": "3.0.0-beta.23",
|
|
29
|
+
"@allurereport/core-api": "3.0.0-beta.23",
|
|
30
|
+
"@allurereport/plugin-allure2": "3.0.0-beta.23",
|
|
31
|
+
"@allurereport/plugin-api": "3.0.0-beta.23",
|
|
32
|
+
"@allurereport/plugin-awesome": "3.0.0-beta.23",
|
|
33
|
+
"@allurereport/plugin-classic": "3.0.0-beta.23",
|
|
34
|
+
"@allurereport/plugin-csv": "3.0.0-beta.23",
|
|
35
|
+
"@allurereport/plugin-dashboard": "3.0.0-beta.23",
|
|
36
|
+
"@allurereport/plugin-jira": "3.0.0-beta.23",
|
|
37
|
+
"@allurereport/plugin-log": "3.0.0-beta.23",
|
|
38
|
+
"@allurereport/plugin-progress": "3.0.0-beta.23",
|
|
39
|
+
"@allurereport/plugin-slack": "3.0.0-beta.23",
|
|
40
|
+
"@allurereport/plugin-testplan": "3.0.0-beta.23",
|
|
41
|
+
"@allurereport/reader": "3.0.0-beta.23",
|
|
42
|
+
"@allurereport/reader-api": "3.0.0-beta.23",
|
|
43
|
+
"@allurereport/service": "3.0.0-beta.23",
|
|
44
|
+
"@allurereport/summary": "3.0.0-beta.23",
|
|
45
45
|
"handlebars": "^4.7.8",
|
|
46
46
|
"markdown-it": "^14.1.0",
|
|
47
47
|
"node-stream-zip": "^1.15.0",
|
|
48
|
+
"p-limit": "^7.2.0",
|
|
49
|
+
"progress": "^2.0.3",
|
|
48
50
|
"yoctocolors": "^2.1.1",
|
|
49
51
|
"zip-stream": "^7.0.2"
|
|
50
52
|
},
|
|
@@ -54,6 +56,7 @@
|
|
|
54
56
|
"@types/handlebars": "^4.1.0",
|
|
55
57
|
"@types/markdown-it": "^14.1.2",
|
|
56
58
|
"@types/node": "^20.17.9",
|
|
59
|
+
"@types/progress": "^2",
|
|
57
60
|
"@types/zip-stream": "^7.0.0",
|
|
58
61
|
"@typescript-eslint/eslint-plugin": "^8.0.0",
|
|
59
62
|
"@typescript-eslint/parser": "^8.0.0",
|