@allurereport/core 3.0.0-beta.20 → 3.0.0-beta.22
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/report.js +43 -12
- package/dist/store/store.js +4 -2
- package/package.json +21 -17
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
|
}
|
|
@@ -139,7 +143,7 @@ export class AllureReport {
|
|
|
139
143
|
});
|
|
140
144
|
});
|
|
141
145
|
this.dumpState = async () => {
|
|
142
|
-
const { testResults, testCases, fixtures, attachments: attachmentsLinks, environments, globalAttachments = [], globalErrors = [], indexAttachmentByTestResult = {}, indexTestResultByHistoryId = {}, indexTestResultByTestCase = {}, indexLatestEnvTestResultByHistoryId = {}, indexAttachmentByFixture = {}, indexFixturesByTestResult = {}, indexKnownByHistoryId = {}, } = __classPrivateFieldGet(this, _AllureReport_store, "f").dumpState();
|
|
146
|
+
const { testResults, testCases, fixtures, attachments: attachmentsLinks, environments, globalAttachments = [], globalErrors = [], indexAttachmentByTestResult = {}, indexTestResultByHistoryId = {}, indexTestResultByTestCase = {}, indexLatestEnvTestResultByHistoryId = {}, indexAttachmentByFixture = {}, indexFixturesByTestResult = {}, indexKnownByHistoryId = {}, qualityGateResultsByRules = {}, } = __classPrivateFieldGet(this, _AllureReport_store, "f").dumpState();
|
|
143
147
|
const allAttachments = await __classPrivateFieldGet(this, _AllureReport_store, "f").allAttachments();
|
|
144
148
|
const dumpArchive = new ZipWriteStream({
|
|
145
149
|
zlib: { level: 5 },
|
|
@@ -197,6 +201,9 @@ export class AllureReport {
|
|
|
197
201
|
await addEntry(Buffer.from(JSON.stringify(indexKnownByHistoryId)), {
|
|
198
202
|
name: AllureStoreDumpFiles.IndexKnownByHistoryId,
|
|
199
203
|
});
|
|
204
|
+
await addEntry(Buffer.from(JSON.stringify(qualityGateResultsByRules)), {
|
|
205
|
+
name: AllureStoreDumpFiles.QualityGateResultsByRules,
|
|
206
|
+
});
|
|
200
207
|
for (const attachment of allAttachments) {
|
|
201
208
|
const content = await __classPrivateFieldGet(this, _AllureReport_store, "f").attachmentContentById(attachment.id);
|
|
202
209
|
if (!content) {
|
|
@@ -239,6 +246,7 @@ export class AllureReport {
|
|
|
239
246
|
const indexAttachmentsByFixtureEntry = await dump.entryData(AllureStoreDumpFiles.IndexAttachmentsByFixture);
|
|
240
247
|
const indexFixturesByTestResultEntry = await dump.entryData(AllureStoreDumpFiles.IndexFixturesByTestResult);
|
|
241
248
|
const indexKnownByHistoryIdEntry = await dump.entryData(AllureStoreDumpFiles.IndexKnownByHistoryId);
|
|
249
|
+
const qualityGateResultsByRulesEntry = await dump.entryData(AllureStoreDumpFiles.QualityGateResultsByRules);
|
|
242
250
|
const attachmentsEntries = Object.entries(await dump.entries()).reduce((acc, [entryName, entry]) => {
|
|
243
251
|
switch (entryName) {
|
|
244
252
|
case AllureStoreDumpFiles.Attachments:
|
|
@@ -256,6 +264,7 @@ export class AllureReport {
|
|
|
256
264
|
case AllureStoreDumpFiles.IndexAttachmentsByFixture:
|
|
257
265
|
case AllureStoreDumpFiles.IndexFixturesByTestResult:
|
|
258
266
|
case AllureStoreDumpFiles.IndexKnownByHistoryId:
|
|
267
|
+
case AllureStoreDumpFiles.QualityGateResultsByRules:
|
|
259
268
|
return acc;
|
|
260
269
|
default:
|
|
261
270
|
return Object.assign(acc, {
|
|
@@ -279,6 +288,7 @@ export class AllureReport {
|
|
|
279
288
|
indexAttachmentByFixture: JSON.parse(indexAttachmentsByFixtureEntry.toString("utf8")),
|
|
280
289
|
indexFixturesByTestResult: JSON.parse(indexFixturesByTestResultEntry.toString("utf8")),
|
|
281
290
|
indexKnownByHistoryId: JSON.parse(indexKnownByHistoryIdEntry.toString("utf8")),
|
|
291
|
+
qualityGateResultsByRules: JSON.parse(qualityGateResultsByRulesEntry.toString("utf8")),
|
|
282
292
|
};
|
|
283
293
|
const stageTempDir = await mkdtemp(join(tmpdir(), basename(stage, ".zip")));
|
|
284
294
|
const resultsAttachments = {};
|
|
@@ -305,6 +315,9 @@ export class AllureReport {
|
|
|
305
315
|
if (__classPrivateFieldGet(this, _AllureReport_executionStage, "f") !== "running") {
|
|
306
316
|
throw new Error(initRequired);
|
|
307
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);
|
|
308
321
|
__classPrivateFieldGet(this, _AllureReport_realtimeSubscriber, "f").offAll();
|
|
309
322
|
__classPrivateFieldSet(this, _AllureReport_executionStage, "done", "f");
|
|
310
323
|
if (__classPrivateFieldGet(this, _AllureReport_stage, "f")) {
|
|
@@ -313,10 +326,18 @@ export class AllureReport {
|
|
|
313
326
|
}
|
|
314
327
|
await __classPrivateFieldGet(this, _AllureReport_eachPlugin, "f").call(this, false, async (plugin, context) => {
|
|
315
328
|
await plugin.done?.(context, __classPrivateFieldGet(this, _AllureReport_store, "f"));
|
|
329
|
+
});
|
|
330
|
+
await __classPrivateFieldGet(this, _AllureReport_eachPlugin, "f").call(this, false, async (plugin, context) => {
|
|
316
331
|
if (__classPrivateFieldGet(this, _AllureReport_allureServiceClient, "f") && context.publish) {
|
|
317
332
|
const pluginFiles = (await context.state.get("files")) ?? {};
|
|
318
|
-
|
|
319
|
-
|
|
333
|
+
const pluginFilesEntries = Object.entries(pluginFiles);
|
|
334
|
+
const progressBar = new ProgressBar(`Publishing "${context.id}" report [:bar] :current/:total`, {
|
|
335
|
+
total: pluginFilesEntries.length,
|
|
336
|
+
width: 20,
|
|
337
|
+
});
|
|
338
|
+
const limitFn = pLimit(50);
|
|
339
|
+
const fns = pluginFilesEntries.map(([filename, filepath]) => limitFn(async () => {
|
|
340
|
+
if (/^(data|widgets|index\.html$|summary\.json$)/.test(filename)) {
|
|
320
341
|
await __classPrivateFieldGet(this, _AllureReport_allureServiceClient, "f").addReportFile({
|
|
321
342
|
reportUuid: this.reportUuid,
|
|
322
343
|
pluginId: context.id,
|
|
@@ -330,7 +351,10 @@ export class AllureReport {
|
|
|
330
351
|
filepath,
|
|
331
352
|
});
|
|
332
353
|
}
|
|
333
|
-
|
|
354
|
+
progressBar.tick();
|
|
355
|
+
}));
|
|
356
|
+
progressBar.render();
|
|
357
|
+
await Promise.all(fns);
|
|
334
358
|
}
|
|
335
359
|
const summary = await plugin?.info?.(context, __classPrivateFieldGet(this, _AllureReport_store, "f"));
|
|
336
360
|
if (!summary) {
|
|
@@ -338,7 +362,7 @@ export class AllureReport {
|
|
|
338
362
|
}
|
|
339
363
|
summary.pullRequestHref = __classPrivateFieldGet(this, _AllureReport_ci, "f")?.pullRequestUrl;
|
|
340
364
|
summary.jobHref = __classPrivateFieldGet(this, _AllureReport_ci, "f")?.jobRunUrl;
|
|
341
|
-
if (context.publish) {
|
|
365
|
+
if (context.publish && this.reportUrl) {
|
|
342
366
|
summary.remoteHref = `${this.reportUrl}/${context.id}/`;
|
|
343
367
|
remoteHrefs.push(summary.remoteHref);
|
|
344
368
|
}
|
|
@@ -348,9 +372,21 @@ export class AllureReport {
|
|
|
348
372
|
});
|
|
349
373
|
await context.reportFiles.addFile("summary.json", Buffer.from(JSON.stringify(summary)));
|
|
350
374
|
});
|
|
375
|
+
if (summaries.length > 1) {
|
|
376
|
+
const summaryPath = await generateSummary(__classPrivateFieldGet(this, _AllureReport_output, "f"), summaries);
|
|
377
|
+
const publishedReports = __classPrivateFieldGet(this, _AllureReport_plugins, "f").map((plugin) => !!plugin?.options?.publish).filter(Boolean);
|
|
378
|
+
if (__classPrivateFieldGet(this, _AllureReport_instances, "a", _AllureReport_publish_get) && summaryPath && publishedReports.length > 1) {
|
|
379
|
+
await __classPrivateFieldGet(this, _AllureReport_allureServiceClient, "f")?.addReportFile({
|
|
380
|
+
reportUuid: this.reportUuid,
|
|
381
|
+
filename: "index.html",
|
|
382
|
+
filepath: summaryPath,
|
|
383
|
+
});
|
|
384
|
+
}
|
|
385
|
+
}
|
|
351
386
|
if (__classPrivateFieldGet(this, _AllureReport_instances, "a", _AllureReport_publish_get)) {
|
|
352
387
|
await __classPrivateFieldGet(this, _AllureReport_allureServiceClient, "f")?.completeReport({
|
|
353
388
|
reportUuid: this.reportUuid,
|
|
389
|
+
historyPoint: historyDataPoint,
|
|
354
390
|
});
|
|
355
391
|
}
|
|
356
392
|
let outputDirFiles = [];
|
|
@@ -380,9 +416,6 @@ export class AllureReport {
|
|
|
380
416
|
catch (ignored) { }
|
|
381
417
|
}
|
|
382
418
|
if (__classPrivateFieldGet(this, _AllureReport_history, "f")) {
|
|
383
|
-
const testResults = await __classPrivateFieldGet(this, _AllureReport_store, "f").allTestResults();
|
|
384
|
-
const testCases = await __classPrivateFieldGet(this, _AllureReport_store, "f").allTestCases();
|
|
385
|
-
const historyDataPoint = createHistory(this.reportUuid, __classPrivateFieldGet(this, _AllureReport_reportName, "f"), testCases, testResults, this.reportUrl);
|
|
386
419
|
try {
|
|
387
420
|
await __classPrivateFieldGet(this, _AllureReport_store, "f").appendHistory(historyDataPoint);
|
|
388
421
|
}
|
|
@@ -398,9 +431,6 @@ export class AllureReport {
|
|
|
398
431
|
}
|
|
399
432
|
}
|
|
400
433
|
}
|
|
401
|
-
if (summaries.length > 1) {
|
|
402
|
-
await generateSummary(__classPrivateFieldGet(this, _AllureReport_output, "f"), summaries);
|
|
403
|
-
}
|
|
404
434
|
if (remoteHrefs.length > 0) {
|
|
405
435
|
console.info("Next reports have been published:");
|
|
406
436
|
remoteHrefs.forEach((href) => {
|
|
@@ -445,6 +475,7 @@ export class AllureReport {
|
|
|
445
475
|
reportName: __classPrivateFieldGet(this, _AllureReport_reportName, "f"),
|
|
446
476
|
state: pluginState,
|
|
447
477
|
reportFiles: pluginFiles,
|
|
478
|
+
reportUrl: this.reportUrl,
|
|
448
479
|
ci: __classPrivateFieldGet(this, _AllureReport_ci, "f"),
|
|
449
480
|
};
|
|
450
481
|
try {
|
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
|
}
|
|
@@ -502,6 +502,7 @@ export class DefaultAllureStore {
|
|
|
502
502
|
indexAttachmentByFixture: {},
|
|
503
503
|
indexFixturesByTestResult: {},
|
|
504
504
|
indexKnownByHistoryId: {},
|
|
505
|
+
qualityGateResultsByRules: __classPrivateFieldGet(this, _DefaultAllureStore_qualityGateResultsByRules, "f"),
|
|
505
506
|
};
|
|
506
507
|
this.indexLatestEnvTestResultByHistoryId.forEach((envMap) => {
|
|
507
508
|
envMap.forEach((tr, historyId) => {
|
|
@@ -529,7 +530,7 @@ export class DefaultAllureStore {
|
|
|
529
530
|
return storeDump;
|
|
530
531
|
}
|
|
531
532
|
async restoreState(stateDump, attachmentsContents = {}) {
|
|
532
|
-
const { testResults, attachments, testCases, fixtures, reportVariables, environments, globalAttachments = [], globalErrors = [], indexAttachmentByTestResult = {}, indexTestResultByHistoryId = {}, indexTestResultByTestCase = {}, indexLatestEnvTestResultByHistoryId = {}, indexAttachmentByFixture = {}, indexFixturesByTestResult = {}, indexKnownByHistoryId = {}, } = stateDump;
|
|
533
|
+
const { testResults, attachments, testCases, fixtures, reportVariables, environments, globalAttachments = [], globalErrors = [], indexAttachmentByTestResult = {}, indexTestResultByHistoryId = {}, indexTestResultByTestCase = {}, indexLatestEnvTestResultByHistoryId = {}, indexAttachmentByFixture = {}, indexFixturesByTestResult = {}, indexKnownByHistoryId = {}, qualityGateResultsByRules = {}, } = stateDump;
|
|
533
534
|
updateMapWithRecord(__classPrivateFieldGet(this, _DefaultAllureStore_testResults, "f"), testResults);
|
|
534
535
|
updateMapWithRecord(__classPrivateFieldGet(this, _DefaultAllureStore_attachments, "f"), attachments);
|
|
535
536
|
updateMapWithRecord(__classPrivateFieldGet(this, _DefaultAllureStore_testCases, "f"), testCases);
|
|
@@ -614,6 +615,7 @@ export class DefaultAllureStore {
|
|
|
614
615
|
}
|
|
615
616
|
hidePreviousAttempt(this.indexLatestEnvTestResultByHistoryId, tr);
|
|
616
617
|
});
|
|
618
|
+
Object.assign(__classPrivateFieldGet(this, _DefaultAllureStore_qualityGateResultsByRules, "f"), qualityGateResultsByRules);
|
|
617
619
|
}
|
|
618
620
|
}
|
|
619
621
|
_DefaultAllureStore_testResults = new WeakMap(), _DefaultAllureStore_attachments = new WeakMap(), _DefaultAllureStore_attachmentContents = new WeakMap(), _DefaultAllureStore_testCases = new WeakMap(), _DefaultAllureStore_metadata = new WeakMap(), _DefaultAllureStore_history = new WeakMap(), _DefaultAllureStore_known = new WeakMap(), _DefaultAllureStore_fixtures = new WeakMap(), _DefaultAllureStore_defaultLabels = new WeakMap(), _DefaultAllureStore_environment = new WeakMap(), _DefaultAllureStore_environmentsConfig = new WeakMap(), _DefaultAllureStore_reportVariables = new WeakMap(), _DefaultAllureStore_realtimeDispatcher = new WeakMap(), _DefaultAllureStore_realtimeSubscriber = new WeakMap(), _DefaultAllureStore_globalAttachments = new WeakMap(), _DefaultAllureStore_globalErrors = new WeakMap(), _DefaultAllureStore_globalExitCode = new WeakMap(), _DefaultAllureStore_qualityGateResultsByRules = new WeakMap(), _DefaultAllureStore_historyPoints = new WeakMap(), _DefaultAllureStore_repoData = new WeakMap(), _DefaultAllureStore_environments = new WeakMap(), _DefaultAllureStore_instances = new WeakSet(), _DefaultAllureStore_addEnvironments = function _DefaultAllureStore_addEnvironments(envs) {
|
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.22",
|
|
4
4
|
"description": "Collection of generic Allure utilities used across the entire project",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"allure"
|
|
@@ -25,25 +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-
|
|
37
|
-
"@allurereport/plugin-
|
|
38
|
-
"@allurereport/plugin-
|
|
39
|
-
"@allurereport/plugin-
|
|
40
|
-
"@allurereport/
|
|
41
|
-
"@allurereport/reader
|
|
42
|
-
"@allurereport/
|
|
43
|
-
"@allurereport/
|
|
28
|
+
"@allurereport/ci": "3.0.0-beta.22",
|
|
29
|
+
"@allurereport/core-api": "3.0.0-beta.22",
|
|
30
|
+
"@allurereport/plugin-allure2": "3.0.0-beta.22",
|
|
31
|
+
"@allurereport/plugin-api": "3.0.0-beta.22",
|
|
32
|
+
"@allurereport/plugin-awesome": "3.0.0-beta.22",
|
|
33
|
+
"@allurereport/plugin-classic": "3.0.0-beta.22",
|
|
34
|
+
"@allurereport/plugin-csv": "3.0.0-beta.22",
|
|
35
|
+
"@allurereport/plugin-dashboard": "3.0.0-beta.22",
|
|
36
|
+
"@allurereport/plugin-jira": "3.0.0-beta.22",
|
|
37
|
+
"@allurereport/plugin-log": "3.0.0-beta.22",
|
|
38
|
+
"@allurereport/plugin-progress": "3.0.0-beta.22",
|
|
39
|
+
"@allurereport/plugin-slack": "3.0.0-beta.22",
|
|
40
|
+
"@allurereport/plugin-testplan": "3.0.0-beta.22",
|
|
41
|
+
"@allurereport/reader": "3.0.0-beta.22",
|
|
42
|
+
"@allurereport/reader-api": "3.0.0-beta.22",
|
|
43
|
+
"@allurereport/service": "3.0.0-beta.22",
|
|
44
|
+
"@allurereport/summary": "3.0.0-beta.22",
|
|
44
45
|
"handlebars": "^4.7.8",
|
|
45
46
|
"markdown-it": "^14.1.0",
|
|
46
47
|
"node-stream-zip": "^1.15.0",
|
|
48
|
+
"p-limit": "^7.2.0",
|
|
49
|
+
"progress": "^2.0.3",
|
|
47
50
|
"yoctocolors": "^2.1.1",
|
|
48
51
|
"zip-stream": "^7.0.2"
|
|
49
52
|
},
|
|
@@ -53,6 +56,7 @@
|
|
|
53
56
|
"@types/handlebars": "^4.1.0",
|
|
54
57
|
"@types/markdown-it": "^14.1.2",
|
|
55
58
|
"@types/node": "^20.17.9",
|
|
59
|
+
"@types/progress": "^2",
|
|
56
60
|
"@types/zip-stream": "^7.0.0",
|
|
57
61
|
"@typescript-eslint/eslint-plugin": "^8.0.0",
|
|
58
62
|
"@typescript-eslint/parser": "^8.0.0",
|