@allurereport/core 3.16.0 → 3.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/dist/report.js CHANGED
@@ -9,14 +9,14 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
9
9
  if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
10
10
  return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
11
11
  };
12
- var _AllureReport_instances, _AllureReport_ci, _AllureReport_store, _AllureReport_readers, _AllureReport_plugins, _AllureReport_reportFiles, _AllureReport_realtimeChannel, _AllureReport_realtimeUpdateScheduler, _AllureReport_realTime, _AllureReport_hideLabels, _AllureReport_output, _AllureReport_history, _AllureReport_appendHistory, _AllureReport_allureServiceClient, _AllureReport_qualityGate, _AllureReport_dump, _AllureReport_categories, _AllureReport_environments, _AllureReport_globalAttachments, _AllureReport_knownIssuesPath, _AllureReport_dumpTempDirs, _AllureReport_state, _AllureReport_executionStage, _AllureReport_historyDataPoint, _AllureReport_summaryPath, _AllureReport_testResultsRegistryPath, _AllureReport_summariesByPluginId, _AllureReport_publishedRemoteHrefs, _AllureReport_published, _AllureReport_endGeneratePerfSpan, _AllureReport_publish, _AllureReport_runRealtimeUpdate, _AllureReport_restoreStateDumps, _AllureReport_getReportsToPublish, _AllureReport_cleanupFailedRemoteReport, _AllureReport_logPublishError, _AllureReport_applyPublishLinksToSummaries, _AllureReport_cloneSummariesByPluginId, _AllureReport_writeSummaryFiles, _AllureReport_writeTestResultRegistry, _AllureReport_generateRootSummary, _AllureReport_finishGeneratePerfSpan, _AllureReport_finishPerfMetrics, _AllureReport_eachPlugin, _AllureReport_getPluginState;
12
+ var _AllureReport_instances, _AllureReport_ci, _AllureReport_store, _AllureReport_readers, _AllureReport_plugins, _AllureReport_reportFiles, _AllureReport_realtimeChannel, _AllureReport_realtimeUpdateScheduler, _AllureReport_realTime, _AllureReport_hideLabels, _AllureReport_output, _AllureReport_history, _AllureReport_appendHistory, _AllureReport_allureServiceClient, _AllureReport_qualityGate, _AllureReport_dump, _AllureReport_categories, _AllureReport_environments, _AllureReport_globalAttachments, _AllureReport_knownIssuesPath, _AllureReport_dumpTempDirs, _AllureReport_cwd, _AllureReport_state, _AllureReport_executionStage, _AllureReport_historyDataPoint, _AllureReport_summaryPath, _AllureReport_testResultsRegistryPath, _AllureReport_summariesByPluginId, _AllureReport_publishedRemoteHrefs, _AllureReport_artifactFilesByPath, _AllureReport_published, _AllureReport_endGeneratePerfSpan, _AllureReport_createHistoryDataPoint, _AllureReport_ingestSelfPerfMetrics, _AllureReport_publish, _AllureReport_getCwd, _AllureReport_runRealtimeUpdate, _AllureReport_recordArtifact, _AllureReport_restoreStateDumps, _AllureReport_getReportsToPublish, _AllureReport_cleanupFailedRemoteReport, _AllureReport_logPublishError, _AllureReport_applyPublishLinksToSummaries, _AllureReport_cloneSummariesByPluginId, _AllureReport_writeSummaryFiles, _AllureReport_writeTestResultRegistry, _AllureReport_getRootRemoteReportFiles, _AllureReport_writeQualityGateFiles, _AllureReport_finishArtifactsManifest, _AllureReport_generateRootSummary, _AllureReport_finishGeneratePerfSpan, _AllureReport_finishPerfMetrics, _AllureReport_eachPlugin, _AllureReport_getPluginState;
13
13
  import console from "node:console";
14
14
  import { randomUUID } from "node:crypto";
15
15
  import { once } from "node:events";
16
16
  import { createReadStream, createWriteStream, existsSync, readFileSync } from "node:fs";
17
17
  import { lstat, mkdtemp, readdir, realpath, rename, rm, writeFile } from "node:fs/promises";
18
18
  import { tmpdir } from "node:os";
19
- import { basename, dirname, join, resolve, sep } from "node:path";
19
+ import { basename, dirname, join, resolve } from "node:path";
20
20
  import { promisify } from "node:util";
21
21
  import { detect } from "@allurereport/ci";
22
22
  import { createProgressLogger } from "@allurereport/cli-commons";
@@ -31,12 +31,13 @@ import ZipReadStream from "node-stream-zip";
31
31
  import pLimit from "p-limit";
32
32
  import ZipWriteStream from "zip-stream";
33
33
  import { AllureLocalHistory, createHistory } from "./history.js";
34
- import { writeKnownIssues } from "./known.js";
35
34
  import { DefaultPluginState, PluginFiles } from "./plugin.js";
36
35
  import { QualityGate } from "./qualityGate/index.js";
36
+ import { writeKnownIssues } from "./resolutions.js";
37
37
  import { DefaultAllureStore } from "./store/store.js";
38
+ import { ARTIFACTS_MANIFEST_FILENAME, createReportArtifact, deduplicateDumpInputs, } from "./utils/artifacts.js";
38
39
  import { environmentIdentityById, environmentIdentityByName } from "./utils/environment.js";
39
- import { measurePerf, PERF_METRIC_NAMES, PERF_METRIC_PREFIXES, startPerfSpan, writePerfMetrics } from "./utils/perf.js";
40
+ import { getPerfMetricsResults, isPerfMetricsEnabled, measurePerf, PERF_METRIC_NAMES, PERF_METRIC_PREFIXES, perfMetricsFileName, startPerfSpan, writePerfMetrics, } from "./utils/perf.js";
40
41
  import { RealtimeChannel } from "./utils/realtimeChannel.js";
41
42
  import { RealtimeUpdateScheduler } from "./utils/realtimeUpdateScheduler.js";
42
43
  import { resolveDumpAttachmentPath, UnsafeDumpPathError } from "./utils/safeDumpPath.js";
@@ -45,6 +46,12 @@ const INIT_REQUIRED_ERROR_MESSAGE = "report is not initialised. Call the start()
45
46
  const DEFAULT_READ_CONCURRENCY = 64;
46
47
  const MAX_READ_CONCURRENCY = 256;
47
48
  const TEST_RESULTS_REGISTRY_FILENAME = "test-results.json";
49
+ const QUALITY_GATE_RESULTS_FILENAME = "quality-gate.json";
50
+ const ROOT_INTEGRATION_FILENAMES = new Set([
51
+ TEST_RESULTS_REGISTRY_FILENAME,
52
+ QUALITY_GATE_RESULTS_FILENAME,
53
+ ARTIFACTS_MANIFEST_FILENAME,
54
+ ]);
48
55
  const readConcurrency = () => {
49
56
  const parsed = Number.parseInt(process.env.ALLURE_READ_CONCURRENCY ?? "", 10);
50
57
  if (!Number.isFinite(parsed)) {
@@ -92,6 +99,7 @@ export class AllureReport {
92
99
  _AllureReport_globalAttachments.set(this, void 0);
93
100
  _AllureReport_knownIssuesPath.set(this, void 0);
94
101
  _AllureReport_dumpTempDirs.set(this, []);
102
+ _AllureReport_cwd.set(this, void 0);
95
103
  _AllureReport_state.set(this, void 0);
96
104
  _AllureReport_executionStage.set(this, "init");
97
105
  _AllureReport_historyDataPoint.set(this, void 0);
@@ -99,8 +107,28 @@ export class AllureReport {
99
107
  _AllureReport_testResultsRegistryPath.set(this, void 0);
100
108
  _AllureReport_summariesByPluginId.set(this, new Map());
101
109
  _AllureReport_publishedRemoteHrefs.set(this, new Set());
110
+ _AllureReport_artifactFilesByPath.set(this, new Map());
102
111
  _AllureReport_published.set(this, false);
103
112
  _AllureReport_endGeneratePerfSpan.set(this, void 0);
113
+ _AllureReport_createHistoryDataPoint.set(this, async () => {
114
+ const allTrs = await __classPrivateFieldGet(this, _AllureReport_store, "f").allTestResults();
115
+ const allTcs = await __classPrivateFieldGet(this, _AllureReport_store, "f").allTestCases();
116
+ return createHistory(this.reportUuid, this.reportName, allTcs, allTrs, this.reportUrl, await __classPrivateFieldGet(this, _AllureReport_store, "f").allMetrics());
117
+ });
118
+ _AllureReport_ingestSelfPerfMetrics.set(this, async () => {
119
+ if (!isPerfMetricsEnabled()) {
120
+ return;
121
+ }
122
+ const results = getPerfMetricsResults();
123
+ if (results.length === 0) {
124
+ return;
125
+ }
126
+ const originalFileName = perfMetricsFileName(this.reportUuid);
127
+ await __classPrivateFieldGet(this, _AllureReport_store, "f").visitMetrics(results, {
128
+ readerId: "api",
129
+ metadata: { originalFileName },
130
+ });
131
+ });
104
132
  _AllureReport_publish.set(this, async () => {
105
133
  if (__classPrivateFieldGet(this, _AllureReport_published, "f")) {
106
134
  return;
@@ -110,12 +138,13 @@ export class AllureReport {
110
138
  }
111
139
  let historyPoint = __classPrivateFieldGet(this, _AllureReport_historyDataPoint, "f");
112
140
  if (!historyPoint) {
113
- const allTrs = await __classPrivateFieldGet(this, _AllureReport_store, "f").allTestResults();
114
- const allTcs = await __classPrivateFieldGet(this, _AllureReport_store, "f").allTestCases();
115
- historyPoint = createHistory(this.reportUuid, this.reportName, allTcs, allTrs, this.reportUrl);
141
+ historyPoint = await __classPrivateFieldGet(this, _AllureReport_createHistoryDataPoint, "f").call(this);
116
142
  __classPrivateFieldSet(this, _AllureReport_historyDataPoint, historyPoint, "f");
117
143
  }
118
144
  await __classPrivateFieldGet(this, _AllureReport_writeTestResultRegistry, "f").call(this);
145
+ if (__classPrivateFieldGet(this, _AllureReport_qualityGate, "f")) {
146
+ await __classPrivateFieldGet(this, _AllureReport_writeQualityGateFiles, "f").call(this);
147
+ }
119
148
  await __classPrivateFieldGet(this, _AllureReport_writeSummaryFiles, "f").call(this);
120
149
  await __classPrivateFieldGet(this, _AllureReport_generateRootSummary, "f").call(this);
121
150
  if (__classPrivateFieldGet(this, _AllureReport_realTime, "f") || !__classPrivateFieldGet(this, _AllureReport_allureServiceClient, "f")) {
@@ -131,8 +160,9 @@ export class AllureReport {
131
160
  const linksByPluginId = {};
132
161
  const summariesSnapshot = __classPrivateFieldGet(this, _AllureReport_cloneSummariesByPluginId, "f").call(this);
133
162
  const uploadProgressMessage = reportsToPublish.length === 1 ? `Publishing "${reportsToPublish[0].pluginId}" report` : "Publishing reports";
163
+ const rootRemoteReportFiles = __classPrivateFieldGet(this, _AllureReport_getRootRemoteReportFiles, "f").call(this);
134
164
  const totalFilesToUpload = reportsToPublish.reduce((acc, report) => acc + Object.keys(report.files).length, 0) +
135
- (__classPrivateFieldGet(this, _AllureReport_testResultsRegistryPath, "f") ? 1 : 0);
165
+ Object.keys(rootRemoteReportFiles).length;
136
166
  let summariesMutated = false;
137
167
  let reportCreated = false;
138
168
  let publishErrorMessage = "Report upload has failed, the report won't be published";
@@ -167,11 +197,11 @@ export class AllureReport {
167
197
  linksByPluginId[report.pluginId] = uploadResult.indexHref;
168
198
  }
169
199
  }
170
- if (__classPrivateFieldGet(this, _AllureReport_testResultsRegistryPath, "f")) {
200
+ if (Object.keys(rootRemoteReportFiles).length > 0) {
171
201
  publishErrorMessage = "Test results registry upload has failed, the report won't be published";
172
202
  await client.uploadReport({
173
203
  reportUuid: this.reportUuid,
174
- files: { [TEST_RESULTS_REGISTRY_FILENAME]: __classPrivateFieldGet(this, _AllureReport_testResultsRegistryPath, "f") },
204
+ files: rootRemoteReportFiles,
175
205
  onProgress: incrementUploadProgress,
176
206
  });
177
207
  }
@@ -283,12 +313,7 @@ export class AllureReport {
283
313
  }
284
314
  };
285
315
  this.validate = async (params) => {
286
- const { trs, knownIssues, state, environment } = params;
287
- const currentKnownIssues = await __classPrivateFieldGet(this, _AllureReport_store, "f").allKnownIssues();
288
- const effectiveKnownIssues = new Map();
289
- [...knownIssues, ...currentKnownIssues].forEach((issue) => {
290
- effectiveKnownIssues.set(issue.historyId, issue);
291
- });
316
+ const { trs, state, environment } = params;
292
317
  const qualityGateEnvironment = environment === undefined
293
318
  ? undefined
294
319
  : (environmentIdentityById(__classPrivateFieldGet(this, _AllureReport_environments, "f"), environment)?.name ??
@@ -296,11 +321,16 @@ export class AllureReport {
296
321
  environment);
297
322
  return __classPrivateFieldGet(this, _AllureReport_qualityGate, "f").validate({
298
323
  trs: trs.filter(Boolean),
299
- knownIssues: [...effectiveKnownIssues.values()],
300
324
  state,
325
+ metrics: await __classPrivateFieldGet(this, _AllureReport_store, "f").allMetrics(),
326
+ previousHistory: (await __classPrivateFieldGet(this, _AllureReport_store, "f").allHistoryDataPoints()).filter(({ uuid }) => uuid !== this.reportUuid),
301
327
  environment: qualityGateEnvironment,
302
328
  });
303
329
  };
330
+ _AllureReport_getCwd.set(this, () => {
331
+ __classPrivateFieldSet(this, _AllureReport_cwd, __classPrivateFieldGet(this, _AllureReport_cwd, "f") ?? resolve(process.cwd()), "f");
332
+ return __classPrivateFieldGet(this, _AllureReport_cwd, "f");
333
+ });
304
334
  this.start = async () => {
305
335
  await __classPrivateFieldGet(this, _AllureReport_store, "f").readHistory();
306
336
  if (__classPrivateFieldGet(this, _AllureReport_executionStage, "f") === "running") {
@@ -311,22 +341,17 @@ export class AllureReport {
311
341
  }
312
342
  __classPrivateFieldSet(this, _AllureReport_executionStage, "running", "f");
313
343
  __classPrivateFieldSet(this, _AllureReport_endGeneratePerfSpan, startPerfSpan(PERF_METRIC_NAMES.generateTotal), "f");
314
- const cwd = resolve(process.cwd());
315
- const cwdWithSep = cwd.endsWith(sep) ? cwd : `${cwd}${sep}`;
316
344
  if (__classPrivateFieldGet(this, _AllureReport_globalAttachments, "f")?.length) {
345
+ const cwd = __classPrivateFieldGet(this, _AllureReport_getCwd, "f").call(this);
317
346
  const matchedFiles = new Set();
318
347
  for (const pattern of __classPrivateFieldGet(this, _AllureReport_globalAttachments, "f")) {
319
348
  const files = await glob(pattern, { cwd, nodir: true, absolute: true });
320
- files.forEach((filePath) => matchedFiles.add(filePath));
349
+ files.forEach((filePath) => matchedFiles.add(resolve(cwd, filePath)));
321
350
  }
322
- for (const filePath of matchedFiles) {
323
- const absoluteFilePath = resolve(filePath);
324
- const isInsideCwd = absoluteFilePath === cwd || absoluteFilePath.startsWith(cwdWithSep);
325
- if (!isInsideCwd) {
326
- continue;
327
- }
351
+ for (const absoluteFilePath of matchedFiles) {
328
352
  const originalFileName = basename(absoluteFilePath);
329
353
  __classPrivateFieldGet(this, _AllureReport_realtimeChannel, "f").dispatcher.sendGlobalAttachment(new PathResultFile(absoluteFilePath, originalFileName), originalFileName);
354
+ __classPrivateFieldGet(this, _AllureReport_recordArtifact, "f").call(this, absoluteFilePath, originalFileName);
330
355
  }
331
356
  }
332
357
  await __classPrivateFieldGet(this, _AllureReport_eachPlugin, "f").call(this, true, async (plugin, context) => {
@@ -393,7 +418,7 @@ export class AllureReport {
393
418
  const addJsonDumpEntry = async (entryName, value) => {
394
419
  await addRequiredDumpEntry(Buffer.from(JSON.stringify(value)), entryName);
395
420
  };
396
- const dumpJsonEntries = ({ testResults, testCases, fixtures, attachments, environments, reportVariables, checkResults = {}, globalAttachmentIds = [], globalErrors = [], indexAttachmentByTestResult = {}, indexTestResultByHistoryId = {}, indexTestResultByTestCase = {}, indexAttachmentByFixture = {}, indexFixturesByTestResult = {}, knownIssues = {}, qualityGateResults = [], testResultIdsIngestOrder = [], }) => [
421
+ const dumpJsonEntries = ({ testResults, testCases, fixtures, attachments, environments, reportVariables, checkResults = {}, globalAttachmentIds = [], globalErrors = [], indexAttachmentByTestResult = {}, indexTestResultByHistoryId = {}, indexTestResultByTestCase = {}, indexTestResultByResolutionIssue = {}, indexAttachmentByFixture = {}, indexFixturesByTestResult = {}, resolutionIssues = {}, qualityGateResults = [], testResultIdsIngestOrder = [], metrics = [], }) => [
397
422
  [AllureStoreDumpFiles.TestResults, testResults],
398
423
  [AllureStoreDumpFiles.TestCases, testCases],
399
424
  [AllureStoreDumpFiles.Fixtures, fixtures],
@@ -401,16 +426,18 @@ export class AllureReport {
401
426
  [AllureStoreDumpFiles.CheckResults, checkResults],
402
427
  [AllureStoreDumpFiles.Environments, environments],
403
428
  [AllureStoreDumpFiles.ReportVariables, reportVariables],
404
- [AllureStoreDumpFiles.KnownIssues, knownIssues],
429
+ [AllureStoreDumpFiles.ResolutionIssues, resolutionIssues],
405
430
  [AllureStoreDumpFiles.GlobalAttachments, globalAttachmentIds],
406
431
  [AllureStoreDumpFiles.GlobalErrors, globalErrors],
407
432
  [AllureStoreDumpFiles.IndexAttachmentsByTestResults, indexAttachmentByTestResult],
408
433
  [AllureStoreDumpFiles.IndexTestResultsByHistoryId, indexTestResultByHistoryId],
409
434
  [AllureStoreDumpFiles.IndexTestResultsByTestCase, indexTestResultByTestCase],
435
+ [AllureStoreDumpFiles.IndexTestResultsByResolutionIssue, indexTestResultByResolutionIssue],
410
436
  [AllureStoreDumpFiles.IndexAttachmentsByFixture, indexAttachmentByFixture],
411
437
  [AllureStoreDumpFiles.IndexFixturesByTestResult, indexFixturesByTestResult],
412
438
  [AllureStoreDumpFiles.QualityGateResults, qualityGateResults],
413
439
  [AllureStoreDumpFiles.TestResultIngestOrder, testResultIdsIngestOrder],
440
+ [AllureStoreDumpFiles.Metrics, metrics],
414
441
  ];
415
442
  let dumpError;
416
443
  dumpArchive.pipe(dumpArchiveWriteStream);
@@ -478,10 +505,18 @@ export class AllureReport {
478
505
  };
479
506
  this.restoreState = async (dumps) => {
480
507
  __classPrivateFieldGet(this, _AllureReport_store, "f").resetIngestOrder();
481
- await __classPrivateFieldGet(this, _AllureReport_restoreStateDumps, "f").call(this, dumps);
508
+ await __classPrivateFieldGet(this, _AllureReport_restoreStateDumps, "f").call(this, dumps.map((path) => ({ artifactPath: path, path })));
482
509
  };
510
+ _AllureReport_recordArtifact.set(this, (filePath, name = basename(filePath)) => {
511
+ const artifact = createReportArtifact(filePath, __classPrivateFieldGet(this, _AllureReport_getCwd, "f").call(this), name);
512
+ if (!__classPrivateFieldGet(this, _AllureReport_artifactFilesByPath, "f").has(artifact.path)) {
513
+ __classPrivateFieldGet(this, _AllureReport_artifactFilesByPath, "f").set(artifact.path, artifact);
514
+ }
515
+ });
483
516
  _AllureReport_restoreStateDumps.set(this, async (dumps) => measurePerf(PERF_METRIC_NAMES.restoreStateTotal, async () => {
484
- for (const dump of dumps) {
517
+ let restoredCount = 0;
518
+ for (const { artifactPath, path: dump, recordArtifact = true } of deduplicateDumpInputs(dumps, __classPrivateFieldGet(this, _AllureReport_getCwd, "f").call(this))) {
519
+ const artifactFilePath = artifactPath ?? dump;
485
520
  await measurePerf(PERF_METRIC_NAMES.restoreStateDump, async () => {
486
521
  if (!existsSync(dump)) {
487
522
  console.error(`Failed to restore state from "${dump}", continuing without it`);
@@ -510,14 +545,24 @@ export class AllureReport {
510
545
  entryName.toLowerCase().endsWith(".zip"));
511
546
  if (nestedDumpEntries.length > 0) {
512
547
  const nestedDumpsTempDir = await mkdtemp(join(tmpdir(), `${basename(dump, ".zip")}-nested-`));
513
- const nestedDumpPaths = [];
548
+ const nestedDumps = [];
514
549
  __classPrivateFieldGet(this, _AllureReport_dumpTempDirs, "f").push(nestedDumpsTempDir);
515
550
  for (const [entryName] of nestedDumpEntries) {
516
- const nestedDumpPath = join(nestedDumpsTempDir, `${nestedDumpPaths.length}-${basename(entryName)}`);
551
+ const nestedDumpPath = join(nestedDumpsTempDir, `${nestedDumps.length}-${basename(entryName)}`);
517
552
  await writeFile(nestedDumpPath, await dumpArchive.entryData(entryName));
518
- nestedDumpPaths.push(nestedDumpPath);
553
+ nestedDumps.push({
554
+ artifactPath: artifactFilePath,
555
+ path: nestedDumpPath,
556
+ recordArtifact: false,
557
+ });
558
+ }
559
+ const nestedRestoredCount = await __classPrivateFieldGet(this, _AllureReport_restoreStateDumps, "f").call(this, nestedDumps);
560
+ if (nestedRestoredCount > 0) {
561
+ restoredCount += 1;
562
+ if (recordArtifact) {
563
+ __classPrivateFieldGet(this, _AllureReport_recordArtifact, "f").call(this, artifactFilePath);
564
+ }
519
565
  }
520
- await __classPrivateFieldGet(this, _AllureReport_restoreStateDumps, "f").call(this, nestedDumpPaths);
521
566
  return;
522
567
  }
523
568
  }
@@ -533,11 +578,13 @@ export class AllureReport {
533
578
  const indexAttachmentsEntry = await requiredEntryData(AllureStoreDumpFiles.IndexAttachmentsByTestResults);
534
579
  const indexTestResultsByHistoryId = await requiredEntryData(AllureStoreDumpFiles.IndexTestResultsByHistoryId);
535
580
  const indexTestResultsByTestCaseEntry = await requiredEntryData(AllureStoreDumpFiles.IndexTestResultsByTestCase);
581
+ const indexTestResultsByResolutionIssueEntry = await optionalEntryData(AllureStoreDumpFiles.IndexTestResultsByResolutionIssue);
536
582
  const indexAttachmentsByFixtureEntry = await requiredEntryData(AllureStoreDumpFiles.IndexAttachmentsByFixture);
537
583
  const indexFixturesByTestResultEntry = await requiredEntryData(AllureStoreDumpFiles.IndexFixturesByTestResult);
538
- const knownIssuesEntry = await requiredEntryData(AllureStoreDumpFiles.KnownIssues);
584
+ const resolutionIssuesEntry = await optionalEntryData(AllureStoreDumpFiles.ResolutionIssues);
539
585
  const qualityGateResultsEntry = await requiredEntryData(AllureStoreDumpFiles.QualityGateResults);
540
586
  const testResultIngestOrderEntry = await optionalEntryData(AllureStoreDumpFiles.TestResultIngestOrder);
587
+ const metricsEntry = await optionalEntryData(AllureStoreDumpFiles.Metrics);
541
588
  const attachmentsLinks = JSON.parse(attachmentsEntry.toString("utf8"));
542
589
  const attachmentsEntries = dumpEntriesList.reduce((acc, [entryName, entry]) => {
543
590
  switch (entryName) {
@@ -548,16 +595,18 @@ export class AllureReport {
548
595
  case AllureStoreDumpFiles.Fixtures:
549
596
  case AllureStoreDumpFiles.Environments:
550
597
  case AllureStoreDumpFiles.ReportVariables:
551
- case AllureStoreDumpFiles.KnownIssues:
598
+ case AllureStoreDumpFiles.ResolutionIssues:
552
599
  case AllureStoreDumpFiles.GlobalAttachments:
553
600
  case AllureStoreDumpFiles.GlobalErrors:
554
601
  case AllureStoreDumpFiles.IndexAttachmentsByTestResults:
555
602
  case AllureStoreDumpFiles.IndexTestResultsByHistoryId:
556
603
  case AllureStoreDumpFiles.IndexTestResultsByTestCase:
604
+ case AllureStoreDumpFiles.IndexTestResultsByResolutionIssue:
557
605
  case AllureStoreDumpFiles.IndexAttachmentsByFixture:
558
606
  case AllureStoreDumpFiles.IndexFixturesByTestResult:
559
607
  case AllureStoreDumpFiles.QualityGateResults:
560
608
  case AllureStoreDumpFiles.TestResultIngestOrder:
609
+ case AllureStoreDumpFiles.Metrics:
561
610
  return acc;
562
611
  default:
563
612
  if (entry.isDirectory || !attachmentsLinks[entryName] || attachmentsLinks[entryName].missed) {
@@ -581,13 +630,17 @@ export class AllureReport {
581
630
  indexAttachmentByTestResult: JSON.parse(indexAttachmentsEntry.toString("utf8")),
582
631
  indexTestResultByHistoryId: JSON.parse(indexTestResultsByHistoryId.toString("utf8")),
583
632
  indexTestResultByTestCase: JSON.parse(indexTestResultsByTestCaseEntry.toString("utf8")),
633
+ indexTestResultByResolutionIssue: indexTestResultsByResolutionIssueEntry
634
+ ? JSON.parse(indexTestResultsByResolutionIssueEntry.toString("utf8"))
635
+ : {},
584
636
  indexAttachmentByFixture: JSON.parse(indexAttachmentsByFixtureEntry.toString("utf8")),
585
637
  indexFixturesByTestResult: JSON.parse(indexFixturesByTestResultEntry.toString("utf8")),
586
- knownIssues: JSON.parse(knownIssuesEntry.toString("utf8")),
638
+ resolutionIssues: resolutionIssuesEntry ? JSON.parse(resolutionIssuesEntry.toString("utf8")) : {},
587
639
  qualityGateResults: JSON.parse(qualityGateResultsEntry.toString("utf8")),
588
640
  testResultIdsIngestOrder: testResultIngestOrderEntry
589
641
  ? JSON.parse(testResultIngestOrderEntry.toString("utf8"))
590
642
  : [],
643
+ metrics: metricsEntry ? JSON.parse(metricsEntry.toString("utf8")) : [],
591
644
  };
592
645
  const dumpTempDir = await mkdtemp(join(tmpdir(), basename(dump, ".zip")));
593
646
  const resultsAttachments = {};
@@ -614,6 +667,10 @@ export class AllureReport {
614
667
  });
615
668
  await measurePerf(PERF_METRIC_NAMES.restoreStateStoreRestore, async () => __classPrivateFieldGet(this, _AllureReport_store, "f").restoreState(dumpState, resultsAttachments));
616
669
  console.info(`Successfully restored state from "${dump}"`);
670
+ restoredCount += 1;
671
+ if (recordArtifact) {
672
+ __classPrivateFieldGet(this, _AllureReport_recordArtifact, "f").call(this, artifactFilePath);
673
+ }
617
674
  }
618
675
  catch (err) {
619
676
  restoreError = err;
@@ -637,6 +694,7 @@ export class AllureReport {
637
694
  }
638
695
  });
639
696
  }
697
+ return restoredCount;
640
698
  }));
641
699
  _AllureReport_getReportsToPublish.set(this, async () => {
642
700
  const reports = [];
@@ -709,6 +767,25 @@ export class AllureReport {
709
767
  const registry = createTestResultRegistry(testResults);
710
768
  __classPrivateFieldSet(this, _AllureReport_testResultsRegistryPath, await __classPrivateFieldGet(this, _AllureReport_reportFiles, "f").addFile(TEST_RESULTS_REGISTRY_FILENAME, Buffer.from(JSON.stringify(registry))), "f");
711
769
  });
770
+ _AllureReport_getRootRemoteReportFiles.set(this, () => ({
771
+ ...(__classPrivateFieldGet(this, _AllureReport_testResultsRegistryPath, "f") ? { [TEST_RESULTS_REGISTRY_FILENAME]: __classPrivateFieldGet(this, _AllureReport_testResultsRegistryPath, "f") } : {}),
772
+ }));
773
+ _AllureReport_writeQualityGateFiles.set(this, async () => {
774
+ const qualityGateResults = await __classPrivateFieldGet(this, _AllureReport_store, "f").qualityGateResults();
775
+ await __classPrivateFieldGet(this, _AllureReport_reportFiles, "f").addFile(QUALITY_GATE_RESULTS_FILENAME, Buffer.from(JSON.stringify(qualityGateResults)));
776
+ });
777
+ _AllureReport_finishArtifactsManifest.set(this, async () => {
778
+ if (__classPrivateFieldGet(this, _AllureReport_artifactFilesByPath, "f").size === 0) {
779
+ return;
780
+ }
781
+ const manifest = [...__classPrivateFieldGet(this, _AllureReport_artifactFilesByPath, "f").values()];
782
+ try {
783
+ await writeFile(join(__classPrivateFieldGet(this, _AllureReport_output, "f"), ARTIFACTS_MANIFEST_FILENAME), JSON.stringify(manifest));
784
+ }
785
+ catch (err) {
786
+ console.error("Failed to write Allure artifacts manifest", err);
787
+ }
788
+ });
712
789
  _AllureReport_generateRootSummary.set(this, async () => {
713
790
  const summaries = [...__classPrivateFieldGet(this, _AllureReport_summariesByPluginId, "f").values()].map(clonePluginSummary);
714
791
  if (summaries.length > 1) {
@@ -724,9 +801,6 @@ export class AllureReport {
724
801
  throw new Error(INIT_REQUIRED_ERROR_MESSAGE);
725
802
  }
726
803
  try {
727
- const testResults = await __classPrivateFieldGet(this, _AllureReport_store, "f").allTestResults();
728
- const testCases = await __classPrivateFieldGet(this, _AllureReport_store, "f").allTestCases();
729
- __classPrivateFieldSet(this, _AllureReport_historyDataPoint, createHistory(this.reportUuid, this.reportName, testCases, testResults, this.reportUrl), "f");
730
804
  __classPrivateFieldGet(this, _AllureReport_realtimeChannel, "f").close();
731
805
  try {
732
806
  await __classPrivateFieldGet(this, _AllureReport_realtimeUpdateScheduler, "f").close();
@@ -747,6 +821,8 @@ export class AllureReport {
747
821
  });
748
822
  });
749
823
  __classPrivateFieldGet(this, _AllureReport_finishGeneratePerfSpan, "f").call(this);
824
+ await __classPrivateFieldGet(this, _AllureReport_ingestSelfPerfMetrics, "f").call(this);
825
+ __classPrivateFieldSet(this, _AllureReport_historyDataPoint, await __classPrivateFieldGet(this, _AllureReport_createHistoryDataPoint, "f").call(this), "f");
750
826
  await __classPrivateFieldGet(this, _AllureReport_eachPlugin, "f").call(this, false, async (plugin, context) => {
751
827
  const summary = await plugin?.info?.(context, __classPrivateFieldGet(this, _AllureReport_store, "f"));
752
828
  if (!summary) {
@@ -781,7 +857,7 @@ export class AllureReport {
781
857
  const reportPath = join(__classPrivateFieldGet(this, _AllureReport_output, "f"), outputDirectoryEntries[0].file);
782
858
  const reportContent = await readdir(reportPath);
783
859
  for (const entry of reportContent) {
784
- if (entry === TEST_RESULTS_REGISTRY_FILENAME) {
860
+ if (ROOT_INTEGRATION_FILENAMES.has(entry)) {
785
861
  continue;
786
862
  }
787
863
  const currentFilePath = join(reportPath, entry);
@@ -790,6 +866,7 @@ export class AllureReport {
790
866
  }
791
867
  await rm(reportPath, { recursive: true });
792
868
  }
869
+ await __classPrivateFieldGet(this, _AllureReport_finishArtifactsManifest, "f").call(this);
793
870
  for (const dir of __classPrivateFieldGet(this, _AllureReport_dumpTempDirs, "f")) {
794
871
  try {
795
872
  await rm(dir, { recursive: true });
@@ -818,11 +895,6 @@ export class AllureReport {
818
895
  console.info(`- ${href}`);
819
896
  });
820
897
  }
821
- if (!__classPrivateFieldGet(this, _AllureReport_qualityGate, "f")) {
822
- return;
823
- }
824
- const qualityGateResults = await __classPrivateFieldGet(this, _AllureReport_store, "f").qualityGateResultsByEnv();
825
- await writeFile(join(__classPrivateFieldGet(this, _AllureReport_output, "f"), "quality-gate.json"), JSON.stringify(qualityGateResults));
826
898
  }
827
899
  finally {
828
900
  await __classPrivateFieldGet(this, _AllureReport_finishPerfMetrics, "f").call(this);
@@ -835,7 +907,7 @@ export class AllureReport {
835
907
  _AllureReport_finishPerfMetrics.set(this, async () => {
836
908
  __classPrivateFieldGet(this, _AllureReport_finishGeneratePerfSpan, "f").call(this);
837
909
  try {
838
- await writePerfMetrics(__classPrivateFieldGet(this, _AllureReport_output, "f"));
910
+ await writePerfMetrics(__classPrivateFieldGet(this, _AllureReport_output, "f"), perfMetricsFileName(this.reportUuid));
839
911
  }
840
912
  catch (err) {
841
913
  console.error("Failed to write Allure performance metrics", err);
@@ -893,7 +965,7 @@ export class AllureReport {
893
965
  }
894
966
  }
895
967
  });
896
- const { name, readers = [allure1, allure2, cucumberjson, junitXml, attachments], plugins = [], known, knownIssues, knownIssuesPath, reportFiles, realTime, historyPath, historyLimit, appendHistory, defaultLabels = {}, variables = {}, environment, allowedEnvironments, environments, output, hideLabels, qualityGate, dump, categories, allureService, globalAttachments, } = opts;
968
+ const { name, readers = [allure1, allure2, cucumberjson, junitXml, attachments], plugins = [], resolutions, reportFiles, realTime, historyPath, historyLimit, appendHistory, defaultLabels = {}, variables = {}, environment, allowedEnvironments, environments, output, hideLabels, qualityGate, performance, dump, categories, allureService, globalAttachments, cwd, } = opts;
897
969
  const allureServiceAccessToken = allureService?.accessToken;
898
970
  if (allureServiceAccessToken) {
899
971
  const allureServiceClientConfig = {
@@ -907,6 +979,7 @@ export class AllureReport {
907
979
  : undefined, "f");
908
980
  }
909
981
  this.reportUuid = randomUUID();
982
+ __classPrivateFieldSet(this, _AllureReport_cwd, cwd ? resolve(cwd) : undefined, "f");
910
983
  __classPrivateFieldSet(this, _AllureReport_ci, detect(), "f");
911
984
  const reportTitleSuffix = __classPrivateFieldGet(this, _AllureReport_ci, "f")?.pullRequestName ?? __classPrivateFieldGet(this, _AllureReport_ci, "f")?.jobRunName;
912
985
  this.reportName = [name, reportTitleSuffix].filter(Boolean).join(" – ");
@@ -918,7 +991,7 @@ export class AllureReport {
918
991
  __classPrivateFieldSet(this, _AllureReport_environments, environments ?? {}, "f");
919
992
  __classPrivateFieldSet(this, _AllureReport_globalAttachments, globalAttachments, "f");
920
993
  __classPrivateFieldSet(this, _AllureReport_appendHistory, appendHistory ?? true, "f");
921
- __classPrivateFieldSet(this, _AllureReport_knownIssuesPath, knownIssuesPath, "f");
994
+ __classPrivateFieldSet(this, _AllureReport_knownIssuesPath, resolutions?.knownIssuesPath, "f");
922
995
  if (qualityGate) {
923
996
  __classPrivateFieldSet(this, _AllureReport_qualityGate, new QualityGate(qualityGate), "f");
924
997
  }
@@ -942,11 +1015,11 @@ export class AllureReport {
942
1015
  reportVariables: variables,
943
1016
  environmentsConfig: environments,
944
1017
  history: __classPrivateFieldGet(this, _AllureReport_history, "f"),
945
- known,
946
- knownIssuesConfig: knownIssues,
1018
+ resolutionsConfig: resolutions,
947
1019
  defaultLabels,
948
1020
  environment,
949
1021
  allowedEnvironments,
1022
+ performance,
950
1023
  }), "f");
951
1024
  __classPrivateFieldSet(this, _AllureReport_readers, [...readers], "f");
952
1025
  __classPrivateFieldSet(this, _AllureReport_plugins, [...plugins], "f");
@@ -966,6 +1039,6 @@ export class AllureReport {
966
1039
  return __classPrivateFieldGet(this, _AllureReport_realtimeChannel, "f").dispatcher;
967
1040
  }
968
1041
  }
969
- _AllureReport_ci = new WeakMap(), _AllureReport_store = new WeakMap(), _AllureReport_readers = new WeakMap(), _AllureReport_plugins = new WeakMap(), _AllureReport_reportFiles = new WeakMap(), _AllureReport_realtimeChannel = new WeakMap(), _AllureReport_realtimeUpdateScheduler = new WeakMap(), _AllureReport_realTime = new WeakMap(), _AllureReport_hideLabels = new WeakMap(), _AllureReport_output = new WeakMap(), _AllureReport_history = new WeakMap(), _AllureReport_appendHistory = new WeakMap(), _AllureReport_allureServiceClient = new WeakMap(), _AllureReport_qualityGate = new WeakMap(), _AllureReport_dump = new WeakMap(), _AllureReport_categories = new WeakMap(), _AllureReport_environments = new WeakMap(), _AllureReport_globalAttachments = new WeakMap(), _AllureReport_knownIssuesPath = new WeakMap(), _AllureReport_dumpTempDirs = new WeakMap(), _AllureReport_state = new WeakMap(), _AllureReport_executionStage = new WeakMap(), _AllureReport_historyDataPoint = new WeakMap(), _AllureReport_summaryPath = new WeakMap(), _AllureReport_testResultsRegistryPath = new WeakMap(), _AllureReport_summariesByPluginId = new WeakMap(), _AllureReport_publishedRemoteHrefs = new WeakMap(), _AllureReport_published = new WeakMap(), _AllureReport_endGeneratePerfSpan = new WeakMap(), _AllureReport_publish = new WeakMap(), _AllureReport_runRealtimeUpdate = new WeakMap(), _AllureReport_restoreStateDumps = new WeakMap(), _AllureReport_getReportsToPublish = new WeakMap(), _AllureReport_cleanupFailedRemoteReport = new WeakMap(), _AllureReport_logPublishError = new WeakMap(), _AllureReport_applyPublishLinksToSummaries = new WeakMap(), _AllureReport_cloneSummariesByPluginId = new WeakMap(), _AllureReport_writeSummaryFiles = new WeakMap(), _AllureReport_writeTestResultRegistry = new WeakMap(), _AllureReport_generateRootSummary = new WeakMap(), _AllureReport_finishGeneratePerfSpan = new WeakMap(), _AllureReport_finishPerfMetrics = new WeakMap(), _AllureReport_eachPlugin = new WeakMap(), _AllureReport_instances = new WeakSet(), _AllureReport_getPluginState = function _AllureReport_getPluginState(init, id) {
1042
+ _AllureReport_ci = new WeakMap(), _AllureReport_store = new WeakMap(), _AllureReport_readers = new WeakMap(), _AllureReport_plugins = new WeakMap(), _AllureReport_reportFiles = new WeakMap(), _AllureReport_realtimeChannel = new WeakMap(), _AllureReport_realtimeUpdateScheduler = new WeakMap(), _AllureReport_realTime = new WeakMap(), _AllureReport_hideLabels = new WeakMap(), _AllureReport_output = new WeakMap(), _AllureReport_history = new WeakMap(), _AllureReport_appendHistory = new WeakMap(), _AllureReport_allureServiceClient = new WeakMap(), _AllureReport_qualityGate = new WeakMap(), _AllureReport_dump = new WeakMap(), _AllureReport_categories = new WeakMap(), _AllureReport_environments = new WeakMap(), _AllureReport_globalAttachments = new WeakMap(), _AllureReport_knownIssuesPath = new WeakMap(), _AllureReport_dumpTempDirs = new WeakMap(), _AllureReport_cwd = new WeakMap(), _AllureReport_state = new WeakMap(), _AllureReport_executionStage = new WeakMap(), _AllureReport_historyDataPoint = new WeakMap(), _AllureReport_summaryPath = new WeakMap(), _AllureReport_testResultsRegistryPath = new WeakMap(), _AllureReport_summariesByPluginId = new WeakMap(), _AllureReport_publishedRemoteHrefs = new WeakMap(), _AllureReport_artifactFilesByPath = new WeakMap(), _AllureReport_published = new WeakMap(), _AllureReport_endGeneratePerfSpan = new WeakMap(), _AllureReport_createHistoryDataPoint = new WeakMap(), _AllureReport_ingestSelfPerfMetrics = new WeakMap(), _AllureReport_publish = new WeakMap(), _AllureReport_getCwd = new WeakMap(), _AllureReport_runRealtimeUpdate = new WeakMap(), _AllureReport_recordArtifact = new WeakMap(), _AllureReport_restoreStateDumps = new WeakMap(), _AllureReport_getReportsToPublish = new WeakMap(), _AllureReport_cleanupFailedRemoteReport = new WeakMap(), _AllureReport_logPublishError = new WeakMap(), _AllureReport_applyPublishLinksToSummaries = new WeakMap(), _AllureReport_cloneSummariesByPluginId = new WeakMap(), _AllureReport_writeSummaryFiles = new WeakMap(), _AllureReport_writeTestResultRegistry = new WeakMap(), _AllureReport_getRootRemoteReportFiles = new WeakMap(), _AllureReport_writeQualityGateFiles = new WeakMap(), _AllureReport_finishArtifactsManifest = new WeakMap(), _AllureReport_generateRootSummary = new WeakMap(), _AllureReport_finishGeneratePerfSpan = new WeakMap(), _AllureReport_finishPerfMetrics = new WeakMap(), _AllureReport_eachPlugin = new WeakMap(), _AllureReport_instances = new WeakSet(), _AllureReport_getPluginState = function _AllureReport_getPluginState(init, id) {
970
1043
  return init ? new DefaultPluginState({}) : __classPrivateFieldGet(this, _AllureReport_state, "f")?.[id];
971
1044
  };
@@ -0,0 +1,8 @@
1
+ import type { ResolutionRule, ResolutionsConfig, TestResult } from "@allurereport/core-api";
2
+ import type { AllureStore } from "@allurereport/plugin-api";
3
+ export declare const DEFAULT_KNOWN_ISSUES_PATH = "known-issues.json";
4
+ export declare const validateResolutionsConfig: (config?: ResolutionsConfig) => void;
5
+ export declare const getResolutionByRules: (testResult: TestResult, config?: ResolutionsConfig) => ResolutionRule | undefined;
6
+ export declare const isIgnoredFailure: (testResult: TestResult) => boolean;
7
+ export declare const resolveExactIssuesFilePath: (pathOrDir: string | undefined, label: string) => Promise<string | undefined>;
8
+ export declare const writeKnownIssues: (store: AllureStore, knownIssuesPath?: string) => Promise<void>;