@allurereport/core 3.8.1 → 3.9.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,11 +9,12 @@ 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_reportName, _AllureReport_ci, _AllureReport_store, _AllureReport_readers, _AllureReport_plugins, _AllureReport_reportFiles, _AllureReport_realtimeChannel, _AllureReport_realtimeUpdateScheduler, _AllureReport_realTime, _AllureReport_hideLabels, _AllureReport_output, _AllureReport_history, _AllureReport_allureServiceClient, _AllureReport_qualityGate, _AllureReport_dump, _AllureReport_categories, _AllureReport_environments, _AllureReport_globalAttachments, _AllureReport_dumpTempDirs, _AllureReport_state, _AllureReport_executionStage, _AllureReport_publish_get, _AllureReport_runRealtimeUpdate, _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_allureServiceClient, _AllureReport_qualityGate, _AllureReport_dump, _AllureReport_categories, _AllureReport_environments, _AllureReport_globalAttachments, _AllureReport_dumpTempDirs, _AllureReport_state, _AllureReport_executionStage, _AllureReport_historyDataPoint, _AllureReport_summaryPath, _AllureReport_summariesByPluginId, _AllureReport_publishedRemoteHrefs, _AllureReport_published, _AllureReport_publish, _AllureReport_runRealtimeUpdate, _AllureReport_getReportsToPublish, _AllureReport_cleanupFailedRemoteReport, _AllureReport_logPublishError, _AllureReport_applyPublishLinksToSummaries, _AllureReport_cloneSummariesByPluginId, _AllureReport_writeSummaryFiles, _AllureReport_generateRootSummary, _AllureReport_eachPlugin, _AllureReport_getPluginState;
13
13
  import console from "node:console";
14
14
  import { randomUUID } from "node:crypto";
15
- import { createWriteStream, existsSync, readFileSync } from "node:fs";
16
- import { lstat, mkdtemp, opendir, readdir, realpath, rename, rm, writeFile } from "node:fs/promises";
15
+ import { once } from "node:events";
16
+ import { createReadStream, createWriteStream, existsSync, readFileSync } from "node:fs";
17
+ import { lstat, mkdtemp, readdir, realpath, rename, rm, writeFile } from "node:fs/promises";
17
18
  import { tmpdir } from "node:os";
18
19
  import { basename, dirname, join, resolve, sep } from "node:path";
19
20
  import { promisify } from "node:util";
@@ -22,33 +23,52 @@ import { normalizeCategoriesConfig } from "@allurereport/core-api";
22
23
  import { AllureStoreDumpFiles, } from "@allurereport/plugin-api";
23
24
  import { allure1, allure2, attachments, cucumberjson, junitXml, readXcResultBundle } from "@allurereport/reader";
24
25
  import { PathResultFile } from "@allurereport/reader-api";
25
- import { AllureLegacyServiceClient, AllureRemoteHistory, AllureServiceClient, KnownError, UnknownError, } from "@allurereport/service";
26
+ import { AllureRemoteHistory, AllureServiceClient, AllureTestOpsClient, KnownError, UnknownError, } from "@allurereport/service";
26
27
  import { generateSummary } from "@allurereport/summary";
27
28
  import { glob } from "glob";
28
29
  import ZipReadStream from "node-stream-zip";
29
30
  import pLimit from "p-limit";
30
- import ProgressBar from "progress";
31
31
  import ZipWriteStream from "zip-stream";
32
32
  import { AllureLocalHistory, createHistory } from "./history.js";
33
33
  import { DefaultPluginState, PluginFiles } from "./plugin.js";
34
34
  import { QualityGate } from "./qualityGate/index.js";
35
35
  import { DefaultAllureStore } from "./store/store.js";
36
+ import { createUploadProgressBarCounter } from "./utils/cli.js";
36
37
  import { environmentIdentityById, environmentIdentityByName } from "./utils/environment.js";
37
38
  import { RealtimeChannel } from "./utils/realtimeChannel.js";
38
39
  import { RealtimeUpdateScheduler } from "./utils/realtimeUpdateScheduler.js";
39
40
  import { resolveDumpAttachmentPath, UnsafeDumpPathError } from "./utils/safeDumpPath.js";
40
41
  const { version } = JSON.parse(readFileSync(new URL("../package.json", import.meta.url), "utf8"));
41
42
  const initRequired = "report is not initialised. Call the start() method first.";
43
+ const defaultReadConcurrency = 64;
44
+ const maxReadConcurrency = 256;
45
+ const readConcurrency = () => {
46
+ const parsed = Number.parseInt(process.env.ALLURE_READ_CONCURRENCY ?? "", 10);
47
+ if (!Number.isFinite(parsed)) {
48
+ return defaultReadConcurrency;
49
+ }
50
+ return Math.min(maxReadConcurrency, Math.max(1, parsed));
51
+ };
52
+ const clonePluginSummary = (summary) => structuredClone(summary);
42
53
  const remoteReportParams = (ci) => {
43
54
  const repo = ci?.repoName;
44
55
  const branch = ci?.jobRunBranch;
45
56
  return repo && branch ? { repo, branch } : {};
46
57
  };
47
58
  const errorDetails = (err) => (err instanceof Error ? (err.stack ?? err.message) : String(err));
59
+ const closeReadStream = async (stream) => {
60
+ if (stream.closed) {
61
+ return;
62
+ }
63
+ const closed = once(stream, "close").then(() => undefined);
64
+ if (!stream.destroyed) {
65
+ stream.destroy();
66
+ }
67
+ await closed.catch(() => undefined);
68
+ };
48
69
  export class AllureReport {
49
70
  constructor(opts) {
50
71
  _AllureReport_instances.add(this);
51
- _AllureReport_reportName.set(this, void 0);
52
72
  _AllureReport_ci.set(this, void 0);
53
73
  _AllureReport_store.set(this, void 0);
54
74
  _AllureReport_readers.set(this, void 0);
@@ -69,6 +89,119 @@ export class AllureReport {
69
89
  _AllureReport_dumpTempDirs.set(this, []);
70
90
  _AllureReport_state.set(this, void 0);
71
91
  _AllureReport_executionStage.set(this, "init");
92
+ _AllureReport_historyDataPoint.set(this, void 0);
93
+ _AllureReport_summaryPath.set(this, void 0);
94
+ _AllureReport_summariesByPluginId.set(this, new Map());
95
+ _AllureReport_publishedRemoteHrefs.set(this, new Set());
96
+ _AllureReport_published.set(this, false);
97
+ _AllureReport_publish.set(this, async () => {
98
+ if (__classPrivateFieldGet(this, _AllureReport_published, "f")) {
99
+ return;
100
+ }
101
+ if (__classPrivateFieldGet(this, _AllureReport_executionStage, "f") !== "done") {
102
+ throw new Error("report is not completed. Call the done() method first.");
103
+ }
104
+ let historyPoint = __classPrivateFieldGet(this, _AllureReport_historyDataPoint, "f");
105
+ if (!historyPoint) {
106
+ const allTrs = await __classPrivateFieldGet(this, _AllureReport_store, "f").allTestResults();
107
+ const allTcs = await __classPrivateFieldGet(this, _AllureReport_store, "f").allTestCases();
108
+ historyPoint = createHistory(this.reportUuid, this.reportName, allTcs, allTrs, this.reportUrl);
109
+ __classPrivateFieldSet(this, _AllureReport_historyDataPoint, historyPoint, "f");
110
+ }
111
+ await __classPrivateFieldGet(this, _AllureReport_writeSummaryFiles, "f").call(this);
112
+ await __classPrivateFieldGet(this, _AllureReport_generateRootSummary, "f").call(this);
113
+ if (__classPrivateFieldGet(this, _AllureReport_realTime, "f") || !__classPrivateFieldGet(this, _AllureReport_allureServiceClient, "f")) {
114
+ __classPrivateFieldSet(this, _AllureReport_published, true, "f");
115
+ return;
116
+ }
117
+ const reportsToPublish = (await __classPrivateFieldGet(this, _AllureReport_getReportsToPublish, "f").call(this)).filter((report) => report.publish && Object.keys(report.files).length > 0);
118
+ if (reportsToPublish.length === 0) {
119
+ __classPrivateFieldSet(this, _AllureReport_published, true, "f");
120
+ return;
121
+ }
122
+ const client = __classPrivateFieldGet(this, _AllureReport_allureServiceClient, "f");
123
+ const linksByPluginId = {};
124
+ const summariesSnapshot = __classPrivateFieldGet(this, _AllureReport_cloneSummariesByPluginId, "f").call(this);
125
+ const uploadProgressBar = createUploadProgressBarCounter(reportsToPublish.length === 1 ? `Publishing "${reportsToPublish[0].pluginId}" report` : "Publishing reports", reportsToPublish.reduce((acc, report) => acc + Object.keys(report.files).length, 0));
126
+ let summariesMutated = false;
127
+ let reportCreated = false;
128
+ let publishErrorMessage = "Report upload has failed, the report won't be published";
129
+ try {
130
+ await client.createReport({
131
+ reportUuid: this.reportUuid,
132
+ reportName: this.reportName,
133
+ ...remoteReportParams(__classPrivateFieldGet(this, _AllureReport_ci, "f")),
134
+ });
135
+ reportCreated = true;
136
+ for (const report of reportsToPublish) {
137
+ publishErrorMessage = `Plugin "${report.pluginId}" upload has failed, the plugin won't be published`;
138
+ const uploadResult = await client.uploadReport({
139
+ reportUuid: this.reportUuid,
140
+ pluginId: report.pluginId,
141
+ files: Object.fromEntries(Object.entries(report.files).filter(([filename]) => filename !== "summary.json")),
142
+ onProgress: () => uploadProgressBar.tick(),
143
+ });
144
+ if (uploadResult.indexHref) {
145
+ linksByPluginId[report.pluginId] = uploadResult.indexHref;
146
+ }
147
+ }
148
+ const changedPluginIds = __classPrivateFieldGet(this, _AllureReport_applyPublishLinksToSummaries, "f").call(this, linksByPluginId);
149
+ summariesMutated = changedPluginIds.size > 0;
150
+ if (changedPluginIds.size > 0) {
151
+ await __classPrivateFieldGet(this, _AllureReport_writeSummaryFiles, "f").call(this);
152
+ await __classPrivateFieldGet(this, _AllureReport_generateRootSummary, "f").call(this);
153
+ }
154
+ const updatedReports = await __classPrivateFieldGet(this, _AllureReport_getReportsToPublish, "f").call(this);
155
+ const updatedReportsByPluginId = new Map(updatedReports.map((report) => [report.pluginId, report]));
156
+ for (const report of reportsToPublish) {
157
+ const updatedReport = updatedReportsByPluginId.get(report.pluginId) ?? report;
158
+ const summaryFilepath = updatedReport.files["summary.json"];
159
+ if (!summaryFilepath) {
160
+ continue;
161
+ }
162
+ publishErrorMessage = `Plugin "${report.pluginId}" summary upload has failed, the plugin won't be published`;
163
+ await client.uploadReport({
164
+ reportUuid: this.reportUuid,
165
+ pluginId: updatedReport.pluginId,
166
+ files: { "summary.json": summaryFilepath },
167
+ onProgress: () => uploadProgressBar.tick(),
168
+ });
169
+ }
170
+ publishErrorMessage = "Report summary upload has failed, the report won't be published";
171
+ const summaryHref = __classPrivateFieldGet(this, _AllureReport_summaryPath, "f")
172
+ ? (await client.uploadReport({
173
+ reportUuid: this.reportUuid,
174
+ files: { "index.html": __classPrivateFieldGet(this, _AllureReport_summaryPath, "f") },
175
+ })).indexHref
176
+ : undefined;
177
+ publishErrorMessage = "Report completion has failed, the report won't be published";
178
+ await client.completeReport({
179
+ reportUuid: this.reportUuid,
180
+ historyPoint,
181
+ });
182
+ Object.values(linksByPluginId)
183
+ .filter(Boolean)
184
+ .forEach((href) => __classPrivateFieldGet(this, _AllureReport_publishedRemoteHrefs, "f").add(href));
185
+ if (summaryHref) {
186
+ __classPrivateFieldGet(this, _AllureReport_publishedRemoteHrefs, "f").add(summaryHref);
187
+ }
188
+ __classPrivateFieldSet(this, _AllureReport_published, true, "f");
189
+ }
190
+ catch (err) {
191
+ if (reportCreated) {
192
+ await __classPrivateFieldGet(this, _AllureReport_cleanupFailedRemoteReport, "f").call(this, client);
193
+ }
194
+ if (summariesMutated) {
195
+ __classPrivateFieldSet(this, _AllureReport_summariesByPluginId, summariesSnapshot, "f");
196
+ await __classPrivateFieldGet(this, _AllureReport_writeSummaryFiles, "f").call(this);
197
+ await __classPrivateFieldGet(this, _AllureReport_generateRootSummary, "f").call(this);
198
+ }
199
+ __classPrivateFieldGet(this, _AllureReport_logPublishError, "f").call(this, publishErrorMessage, err);
200
+ }
201
+ finally {
202
+ uploadProgressBar.terminate();
203
+ }
204
+ });
72
205
  this.readDirectory = async (resultsDir) => {
73
206
  if (__classPrivateFieldGet(this, _AllureReport_executionStage, "f") !== "running") {
74
207
  throw new Error(initRequired);
@@ -77,14 +210,20 @@ export class AllureReport {
77
210
  if (await readXcResultBundle(__classPrivateFieldGet(this, _AllureReport_store, "f"), resultsDirPath)) {
78
211
  return;
79
212
  }
80
- const dir = await opendir(resultsDirPath);
81
213
  try {
82
- for await (const dirent of dir) {
83
- if (dirent.isFile()) {
84
- const path = await realpath(join(dirent.parentPath ?? dirent.path, dirent.name));
214
+ const entries = (await readdir(resultsDirPath, { withFileTypes: true }))
215
+ .filter((dirent) => dirent.isFile())
216
+ .sort((a, b) => a.name.localeCompare(b.name));
217
+ const limit = pLimit(readConcurrency());
218
+ await Promise.all(entries.map((dirent) => limit(async () => {
219
+ try {
220
+ const path = await realpath(join(resultsDirPath, dirent.name));
85
221
  await this.readResult(new PathResultFile(path, dirent.name));
86
222
  }
87
- }
223
+ catch (e) {
224
+ console.error(`can't read result file ${dirent.name}`, e);
225
+ }
226
+ })));
88
227
  }
89
228
  catch (e) {
90
229
  console.error("can't read directory", e);
@@ -102,6 +241,9 @@ export class AllureReport {
102
241
  }
103
242
  for (const reader of __classPrivateFieldGet(this, _AllureReport_readers, "f")) {
104
243
  try {
244
+ if (reader.matches && !(await reader.matches(data))) {
245
+ continue;
246
+ }
105
247
  const processed = await reader.read(__classPrivateFieldGet(this, _AllureReport_store, "f"), data);
106
248
  if (processed) {
107
249
  return;
@@ -125,7 +267,6 @@ export class AllureReport {
125
267
  });
126
268
  };
127
269
  this.start = async () => {
128
- const remoteParams = remoteReportParams(__classPrivateFieldGet(this, _AllureReport_ci, "f"));
129
270
  await __classPrivateFieldGet(this, _AllureReport_store, "f").readHistory();
130
271
  if (__classPrivateFieldGet(this, _AllureReport_executionStage, "f") === "running") {
131
272
  throw new Error("the report is already started");
@@ -152,14 +293,6 @@ export class AllureReport {
152
293
  __classPrivateFieldGet(this, _AllureReport_realtimeChannel, "f").dispatcher.sendGlobalAttachment(new PathResultFile(absoluteFilePath, originalFileName), originalFileName);
153
294
  }
154
295
  }
155
- if (__classPrivateFieldGet(this, _AllureReport_allureServiceClient, "f") && __classPrivateFieldGet(this, _AllureReport_instances, "a", _AllureReport_publish_get)) {
156
- const url = await __classPrivateFieldGet(this, _AllureReport_allureServiceClient, "f").createReport({
157
- reportUuid: this.reportUuid,
158
- reportName: __classPrivateFieldGet(this, _AllureReport_reportName, "f"),
159
- ...remoteParams,
160
- });
161
- this.reportUrl = url.href;
162
- }
163
296
  await __classPrivateFieldGet(this, _AllureReport_eachPlugin, "f").call(this, true, async (plugin, context) => {
164
297
  await plugin.start?.(context, __classPrivateFieldGet(this, _AllureReport_store, "f"), __classPrivateFieldGet(this, _AllureReport_realtimeChannel, "f").subscriber);
165
298
  });
@@ -224,7 +357,7 @@ export class AllureReport {
224
357
  const addJsonDumpEntry = async (entryName, value) => {
225
358
  await addRequiredDumpEntry(Buffer.from(JSON.stringify(value)), entryName);
226
359
  };
227
- const dumpJsonEntries = ({ testResults, testCases, fixtures, attachments, environments, reportVariables, checkResults = [], globalAttachmentIds = [], globalErrors = [], indexAttachmentByTestResult = {}, indexTestResultByHistoryId = {}, indexTestResultByTestCase = {}, indexLatestEnvTestResultByHistoryId = {}, indexAttachmentByFixture = {}, indexFixturesByTestResult = {}, indexKnownByHistoryId = {}, qualityGateResults = [], }) => [
360
+ const dumpJsonEntries = ({ testResults, testCases, fixtures, attachments, environments, reportVariables, checkResults = [], globalAttachmentIds = [], globalErrors = [], indexAttachmentByTestResult = {}, indexTestResultByHistoryId = {}, indexTestResultByTestCase = {}, indexAttachmentByFixture = {}, indexFixturesByTestResult = {}, indexKnownByHistoryId = {}, qualityGateResults = [], testResultIdsIngestOrder = [], }) => [
228
361
  [AllureStoreDumpFiles.TestResults, testResults],
229
362
  [AllureStoreDumpFiles.TestCases, testCases],
230
363
  [AllureStoreDumpFiles.Fixtures, fixtures],
@@ -237,11 +370,11 @@ export class AllureReport {
237
370
  [AllureStoreDumpFiles.IndexAttachmentsByTestResults, indexAttachmentByTestResult],
238
371
  [AllureStoreDumpFiles.IndexTestResultsByHistoryId, indexTestResultByHistoryId],
239
372
  [AllureStoreDumpFiles.IndexTestResultsByTestCase, indexTestResultByTestCase],
240
- [AllureStoreDumpFiles.IndexLatestEnvTestResultsByHistoryId, indexLatestEnvTestResultByHistoryId],
241
373
  [AllureStoreDumpFiles.IndexAttachmentsByFixture, indexAttachmentByFixture],
242
374
  [AllureStoreDumpFiles.IndexFixturesByTestResult, indexFixturesByTestResult],
243
375
  [AllureStoreDumpFiles.IndexKnownByHistoryId, indexKnownByHistoryId],
244
376
  [AllureStoreDumpFiles.QualityGateResults, qualityGateResults],
377
+ [AllureStoreDumpFiles.TestResultIngestOrder, testResultIdsIngestOrder],
245
378
  ];
246
379
  let dumpError;
247
380
  dumpArchive.pipe(dumpArchiveWriteStream);
@@ -259,6 +392,15 @@ export class AllureReport {
259
392
  skipAttachment("attachment content is missing");
260
393
  continue;
261
394
  }
395
+ if (content instanceof PathResultFile) {
396
+ const stream = createReadStream(content.path);
397
+ const err = await addDumpEntry(stream, attachment.id);
398
+ if (err) {
399
+ await closeReadStream(stream);
400
+ skipAttachment(`failed to add attachment entry: ${errMessage(err)}`);
401
+ }
402
+ continue;
403
+ }
262
404
  const data = await content.asBuffer();
263
405
  if (data === undefined) {
264
406
  skipAttachment("attachment content is missing");
@@ -350,11 +492,11 @@ export class AllureReport {
350
492
  const indexAttachmentsEntry = await requiredEntryData(AllureStoreDumpFiles.IndexAttachmentsByTestResults);
351
493
  const indexTestResultsByHistoryId = await requiredEntryData(AllureStoreDumpFiles.IndexTestResultsByHistoryId);
352
494
  const indexTestResultsByTestCaseEntry = await requiredEntryData(AllureStoreDumpFiles.IndexTestResultsByTestCase);
353
- const indexLatestEnvTestResultsByHistoryIdEntry = await requiredEntryData(AllureStoreDumpFiles.IndexLatestEnvTestResultsByHistoryId);
354
495
  const indexAttachmentsByFixtureEntry = await requiredEntryData(AllureStoreDumpFiles.IndexAttachmentsByFixture);
355
496
  const indexFixturesByTestResultEntry = await requiredEntryData(AllureStoreDumpFiles.IndexFixturesByTestResult);
356
497
  const indexKnownByHistoryIdEntry = await requiredEntryData(AllureStoreDumpFiles.IndexKnownByHistoryId);
357
498
  const qualityGateResultsEntry = await requiredEntryData(AllureStoreDumpFiles.QualityGateResults);
499
+ const testResultIngestOrderEntry = await optionalEntryData(AllureStoreDumpFiles.TestResultIngestOrder);
358
500
  const attachmentsLinks = JSON.parse(attachmentsEntry.toString("utf8"));
359
501
  const attachmentsEntries = dumpEntriesList.reduce((acc, [entryName, entry]) => {
360
502
  switch (entryName) {
@@ -370,11 +512,11 @@ export class AllureReport {
370
512
  case AllureStoreDumpFiles.IndexAttachmentsByTestResults:
371
513
  case AllureStoreDumpFiles.IndexTestResultsByHistoryId:
372
514
  case AllureStoreDumpFiles.IndexTestResultsByTestCase:
373
- case AllureStoreDumpFiles.IndexLatestEnvTestResultsByHistoryId:
374
515
  case AllureStoreDumpFiles.IndexAttachmentsByFixture:
375
516
  case AllureStoreDumpFiles.IndexFixturesByTestResult:
376
517
  case AllureStoreDumpFiles.IndexKnownByHistoryId:
377
518
  case AllureStoreDumpFiles.QualityGateResults:
519
+ case AllureStoreDumpFiles.TestResultIngestOrder:
378
520
  return acc;
379
521
  default:
380
522
  if (entry.isDirectory || !attachmentsLinks[entryName] || attachmentsLinks[entryName].missed) {
@@ -398,11 +540,13 @@ export class AllureReport {
398
540
  indexAttachmentByTestResult: JSON.parse(indexAttachmentsEntry.toString("utf8")),
399
541
  indexTestResultByHistoryId: JSON.parse(indexTestResultsByHistoryId.toString("utf8")),
400
542
  indexTestResultByTestCase: JSON.parse(indexTestResultsByTestCaseEntry.toString("utf8")),
401
- indexLatestEnvTestResultByHistoryId: JSON.parse(indexLatestEnvTestResultsByHistoryIdEntry.toString("utf8")),
402
543
  indexAttachmentByFixture: JSON.parse(indexAttachmentsByFixtureEntry.toString("utf8")),
403
544
  indexFixturesByTestResult: JSON.parse(indexFixturesByTestResultEntry.toString("utf8")),
404
545
  indexKnownByHistoryId: JSON.parse(indexKnownByHistoryIdEntry.toString("utf8")),
405
546
  qualityGateResults: JSON.parse(qualityGateResultsEntry.toString("utf8")),
547
+ testResultIdsIngestOrder: testResultIngestOrderEntry
548
+ ? JSON.parse(testResultIngestOrderEntry.toString("utf8"))
549
+ : [],
406
550
  };
407
551
  const dumpTempDir = await mkdtemp(join(tmpdir(), basename(dump, ".zip")));
408
552
  const resultsAttachments = {};
@@ -450,17 +594,89 @@ export class AllureReport {
450
594
  }
451
595
  }
452
596
  };
597
+ _AllureReport_getReportsToPublish.set(this, async () => {
598
+ const reports = [];
599
+ for (const { enabled, id, options } of __classPrivateFieldGet(this, _AllureReport_plugins, "f")) {
600
+ if (!enabled) {
601
+ continue;
602
+ }
603
+ const files = (await __classPrivateFieldGet(this, _AllureReport_state, "f")?.[id]?.get("files")) ?? {};
604
+ reports.push({
605
+ pluginId: id,
606
+ publish: !!options?.publish,
607
+ files,
608
+ });
609
+ }
610
+ return reports;
611
+ });
612
+ _AllureReport_cleanupFailedRemoteReport.set(this, async (client) => {
613
+ try {
614
+ await client.deleteReport({
615
+ reportUuid: this.reportUuid,
616
+ });
617
+ }
618
+ catch (cleanupError) {
619
+ console.error("Failed to clean up failed report upload");
620
+ console.error(errorDetails(cleanupError));
621
+ }
622
+ });
623
+ _AllureReport_logPublishError.set(this, (message, err) => {
624
+ console.error(message);
625
+ if (err instanceof KnownError) {
626
+ console.error(err.message);
627
+ }
628
+ else {
629
+ console.error(errorDetails(err));
630
+ }
631
+ });
632
+ _AllureReport_applyPublishLinksToSummaries.set(this, (linksByPluginId) => {
633
+ const changedPluginIds = new Set();
634
+ if (__classPrivateFieldGet(this, _AllureReport_summariesByPluginId, "f").size === 0) {
635
+ return changedPluginIds;
636
+ }
637
+ for (const [pluginId, remoteHref] of Object.entries(linksByPluginId)) {
638
+ const summary = __classPrivateFieldGet(this, _AllureReport_summariesByPluginId, "f").get(pluginId);
639
+ if (summary && remoteHref) {
640
+ summary.remoteHref = remoteHref;
641
+ changedPluginIds.add(pluginId);
642
+ }
643
+ }
644
+ return changedPluginIds;
645
+ });
646
+ _AllureReport_cloneSummariesByPluginId.set(this, () => new Map([...__classPrivateFieldGet(this, _AllureReport_summariesByPluginId, "f")].map(([pluginId, summary]) => [pluginId, clonePluginSummary(summary)])));
647
+ _AllureReport_writeSummaryFiles.set(this, async (pluginIds) => {
648
+ if (__classPrivateFieldGet(this, _AllureReport_summariesByPluginId, "f").size === 0) {
649
+ return;
650
+ }
651
+ const pluginIdsSet = pluginIds ? new Set(pluginIds) : undefined;
652
+ await __classPrivateFieldGet(this, _AllureReport_eachPlugin, "f").call(this, false, async (_plugin, context) => {
653
+ if (pluginIdsSet && !pluginIdsSet.has(context.id)) {
654
+ return;
655
+ }
656
+ const summary = __classPrivateFieldGet(this, _AllureReport_summariesByPluginId, "f").get(context.id);
657
+ if (!summary) {
658
+ return;
659
+ }
660
+ await context.reportFiles.addFile("summary.json", Buffer.from(JSON.stringify(summary)));
661
+ });
662
+ });
663
+ _AllureReport_generateRootSummary.set(this, async () => {
664
+ const summaries = [...__classPrivateFieldGet(this, _AllureReport_summariesByPluginId, "f").values()].map(clonePluginSummary);
665
+ if (summaries.length > 1) {
666
+ __classPrivateFieldSet(this, _AllureReport_summaryPath, await generateSummary(__classPrivateFieldGet(this, _AllureReport_output, "f"), summaries), "f");
667
+ }
668
+ else {
669
+ __classPrivateFieldSet(this, _AllureReport_summaryPath, undefined, "f");
670
+ }
671
+ });
453
672
  this.done = async () => {
454
673
  const summaries = [];
455
- const remoteHrefs = new Set();
456
- const remoteHrefsByPluginId = {};
457
- const cancelledPluginsIds = new Set();
458
674
  if (__classPrivateFieldGet(this, _AllureReport_executionStage, "f") !== "running") {
459
675
  throw new Error(initRequired);
460
676
  }
461
677
  const testResults = await __classPrivateFieldGet(this, _AllureReport_store, "f").allTestResults();
462
678
  const testCases = await __classPrivateFieldGet(this, _AllureReport_store, "f").allTestCases();
463
- const historyDataPoint = createHistory(this.reportUuid, __classPrivateFieldGet(this, _AllureReport_reportName, "f"), testCases, testResults, this.reportUrl);
679
+ __classPrivateFieldSet(this, _AllureReport_historyDataPoint, createHistory(this.reportUuid, this.reportName, testCases, testResults, this.reportUrl), "f");
464
680
  __classPrivateFieldGet(this, _AllureReport_realtimeChannel, "f").close();
465
681
  try {
466
682
  await __classPrivateFieldGet(this, _AllureReport_realtimeUpdateScheduler, "f").close();
@@ -477,70 +693,6 @@ export class AllureReport {
477
693
  await plugin.done?.(context, __classPrivateFieldGet(this, _AllureReport_store, "f"));
478
694
  });
479
695
  await __classPrivateFieldGet(this, _AllureReport_eachPlugin, "f").call(this, false, async (plugin, context) => {
480
- if (__classPrivateFieldGet(this, _AllureReport_allureServiceClient, "f") && context.publish) {
481
- const pluginFiles = (await context.state.get("files")) ?? {};
482
- const pluginFilesEntries = Object.entries(pluginFiles);
483
- const progressBar = pluginFilesEntries?.length > 0
484
- ? new ProgressBar(`Publishing "${context.id}" report [:bar] :current/:total`, {
485
- total: pluginFilesEntries.length,
486
- width: 20,
487
- })
488
- : undefined;
489
- const limitFn = pLimit(50);
490
- const uploadAbortController = new AbortController();
491
- const fns = pluginFilesEntries.map(([filename, filepath]) => limitFn(async () => {
492
- if (cancelledPluginsIds.has(context.id) || uploadAbortController.signal.aborted) {
493
- return;
494
- }
495
- if (/^(data|widgets|index\.html$|summary\.json$)/.test(filename)) {
496
- const uploadedFileUrl = await __classPrivateFieldGet(this, _AllureReport_allureServiceClient, "f").addReportFile({
497
- reportUuid: this.reportUuid,
498
- pluginId: context.id,
499
- filename,
500
- filepath,
501
- signal: uploadAbortController.signal,
502
- });
503
- if (cancelledPluginsIds.has(context.id) || uploadAbortController.signal.aborted) {
504
- return;
505
- }
506
- if (filename === "index.html") {
507
- remoteHrefsByPluginId[context.id] = uploadedFileUrl;
508
- remoteHrefs.add(uploadedFileUrl);
509
- }
510
- }
511
- else {
512
- await __classPrivateFieldGet(this, _AllureReport_allureServiceClient, "f").addReportAsset({
513
- filename,
514
- filepath,
515
- signal: uploadAbortController.signal,
516
- });
517
- }
518
- if (cancelledPluginsIds.has(context.id) || uploadAbortController.signal.aborted) {
519
- return;
520
- }
521
- progressBar?.tick?.();
522
- }));
523
- progressBar?.render?.();
524
- try {
525
- await Promise.all(fns);
526
- }
527
- catch (err) {
528
- cancelledPluginsIds.add(context.id);
529
- uploadAbortController.abort();
530
- await Promise.allSettled(fns);
531
- const pluginRemoteHref = remoteHrefsByPluginId[context.id];
532
- if (pluginRemoteHref) {
533
- remoteHrefs.delete(pluginRemoteHref);
534
- delete remoteHrefsByPluginId[context.id];
535
- }
536
- await __classPrivateFieldGet(this, _AllureReport_allureServiceClient, "f").deleteReport({
537
- reportUuid: this.reportUuid,
538
- pluginId: context.id,
539
- });
540
- console.error(`Plugin "${context.id}" upload has failed, the plugin won't be published`);
541
- console.error(err);
542
- }
543
- }
544
696
  const summary = await plugin?.info?.(context, __classPrivateFieldGet(this, _AllureReport_store, "f"));
545
697
  if (!summary) {
546
698
  return;
@@ -548,38 +700,15 @@ export class AllureReport {
548
700
  summary.pluginId = context.id;
549
701
  summary.pullRequestHref = __classPrivateFieldGet(this, _AllureReport_ci, "f")?.pullRequestUrl;
550
702
  summary.jobHref = __classPrivateFieldGet(this, _AllureReport_ci, "f")?.jobRunUrl;
551
- if (context.publish && !cancelledPluginsIds.has(context.id)) {
552
- summary.remoteHref =
553
- remoteHrefsByPluginId[context.id] ?? (this.reportUrl ? `${this.reportUrl}/${context.id}/` : undefined);
554
- if (summary.remoteHref) {
555
- remoteHrefs.add(summary.remoteHref);
556
- }
557
- }
558
703
  summaries.push({
559
704
  ...summary,
560
705
  href: `${context.id}/`,
561
706
  });
562
- await context.reportFiles.addFile("summary.json", Buffer.from(JSON.stringify(summary)));
563
707
  });
564
- if (summaries.length > 1) {
565
- const summaryPath = await generateSummary(__classPrivateFieldGet(this, _AllureReport_output, "f"), summaries);
566
- const publishedReports = __classPrivateFieldGet(this, _AllureReport_plugins, "f")
567
- .map((plugin) => !!plugin?.options?.publish && !cancelledPluginsIds.has(plugin.id))
568
- .filter(Boolean);
569
- if (__classPrivateFieldGet(this, _AllureReport_instances, "a", _AllureReport_publish_get) && summaryPath && publishedReports.length > 1) {
570
- await __classPrivateFieldGet(this, _AllureReport_allureServiceClient, "f")?.addReportFile({
571
- reportUuid: this.reportUuid,
572
- filename: "index.html",
573
- filepath: summaryPath,
574
- });
575
- }
576
- }
577
- if (__classPrivateFieldGet(this, _AllureReport_instances, "a", _AllureReport_publish_get)) {
578
- await __classPrivateFieldGet(this, _AllureReport_allureServiceClient, "f")?.completeReport({
579
- reportUuid: this.reportUuid,
580
- historyPoint: historyDataPoint,
581
- });
582
- }
708
+ __classPrivateFieldSet(this, _AllureReport_summariesByPluginId, new Map(summaries
709
+ .filter((summary) => !!summary.pluginId)
710
+ .map((summary) => [summary.pluginId, summary])), "f");
711
+ await __classPrivateFieldGet(this, _AllureReport_publish, "f").call(this);
583
712
  let outputDirFiles = [];
584
713
  try {
585
714
  outputDirFiles = await readdir(__classPrivateFieldGet(this, _AllureReport_output, "f"));
@@ -609,7 +738,7 @@ export class AllureReport {
609
738
  }
610
739
  if (__classPrivateFieldGet(this, _AllureReport_history, "f")) {
611
740
  try {
612
- await __classPrivateFieldGet(this, _AllureReport_store, "f").appendHistory(historyDataPoint);
741
+ await __classPrivateFieldGet(this, _AllureReport_store, "f").appendHistory(__classPrivateFieldGet(this, _AllureReport_historyDataPoint, "f"));
613
742
  }
614
743
  catch (err) {
615
744
  if (err instanceof KnownError) {
@@ -623,9 +752,9 @@ export class AllureReport {
623
752
  }
624
753
  }
625
754
  }
626
- if (remoteHrefs.size > 0) {
755
+ if (__classPrivateFieldGet(this, _AllureReport_publishedRemoteHrefs, "f").size > 0) {
627
756
  console.info("Next reports have been published:");
628
- remoteHrefs.forEach((href) => {
757
+ __classPrivateFieldGet(this, _AllureReport_publishedRemoteHrefs, "f").forEach((href) => {
629
758
  console.info(`- ${href}`);
630
759
  });
631
760
  }
@@ -664,11 +793,12 @@ export class AllureReport {
664
793
  publish: !!options?.publish,
665
794
  allureVersion: version,
666
795
  reportUuid: this.reportUuid,
667
- reportName: __classPrivateFieldGet(this, _AllureReport_reportName, "f"),
796
+ reportName: this.reportName,
668
797
  hideLabels: __classPrivateFieldGet(this, _AllureReport_hideLabels, "f"),
669
798
  state: pluginState,
670
799
  reportFiles: pluginFiles,
671
800
  reportUrl: this.reportUrl,
801
+ realTime: !!__classPrivateFieldGet(this, _AllureReport_realTime, "f"),
672
802
  output: __classPrivateFieldGet(this, _AllureReport_output, "f"),
673
803
  ci: __classPrivateFieldGet(this, _AllureReport_ci, "f"),
674
804
  categories: __classPrivateFieldGet(this, _AllureReport_categories, "f"),
@@ -676,6 +806,7 @@ export class AllureReport {
676
806
  };
677
807
  try {
678
808
  await consumer.call(this, plugin, pluginContext);
809
+ this.reportUrl = pluginContext.reportUrl ?? this.reportUrl;
679
810
  if (initState) {
680
811
  __classPrivateFieldGet(this, _AllureReport_state, "f")[id] = pluginState;
681
812
  }
@@ -685,19 +816,23 @@ export class AllureReport {
685
816
  }
686
817
  }
687
818
  });
688
- const { name, readers = [allure1, allure2, cucumberjson, junitXml, attachments], plugins = [], known, reportFiles, realTime, historyPath, historyLimit, defaultLabels = {}, variables = {}, environment, allowedEnvironments, environments, output, hideLabels, qualityGate, dump, categories, allureService: allureServiceConfig, globalAttachments, } = opts;
689
- if (allureServiceConfig?.accessToken) {
690
- if (allureServiceConfig?.legacy) {
691
- __classPrivateFieldSet(this, _AllureReport_allureServiceClient, new AllureLegacyServiceClient(allureServiceConfig), "f");
692
- }
693
- else {
694
- __classPrivateFieldSet(this, _AllureReport_allureServiceClient, new AllureServiceClient(allureServiceConfig), "f");
695
- }
819
+ const { name, readers = [allure1, allure2, cucumberjson, junitXml, attachments], plugins = [], known, reportFiles, realTime, historyPath, historyLimit, defaultLabels = {}, variables = {}, environment, allowedEnvironments, environments, output, hideLabels, qualityGate, dump, categories, allureService, globalAttachments, } = opts;
820
+ const allureServiceAccessToken = allureService?.accessToken;
821
+ if (allureServiceAccessToken) {
822
+ const allureServiceClientConfig = {
823
+ ...allureService,
824
+ accessToken: allureServiceAccessToken,
825
+ };
826
+ __classPrivateFieldSet(this, _AllureReport_allureServiceClient, allureServiceAccessToken.startsWith("ato1.")
827
+ ? new AllureTestOpsClient(allureServiceClientConfig)
828
+ : allureServiceAccessToken.startsWith("ars1.")
829
+ ? new AllureServiceClient(allureServiceClientConfig)
830
+ : undefined, "f");
696
831
  }
697
832
  this.reportUuid = randomUUID();
698
833
  __classPrivateFieldSet(this, _AllureReport_ci, detect(), "f");
699
834
  const reportTitleSuffix = __classPrivateFieldGet(this, _AllureReport_ci, "f")?.pullRequestName ?? __classPrivateFieldGet(this, _AllureReport_ci, "f")?.jobRunName;
700
- __classPrivateFieldSet(this, _AllureReport_reportName, [name, reportTitleSuffix].filter(Boolean).join(" – "), "f");
835
+ this.reportName = [name, reportTitleSuffix].filter(Boolean).join(" – ");
701
836
  __classPrivateFieldSet(this, _AllureReport_realtimeChannel, new RealtimeChannel(), "f");
702
837
  __classPrivateFieldSet(this, _AllureReport_realtimeUpdateScheduler, new RealtimeUpdateScheduler(__classPrivateFieldGet(this, _AllureReport_runRealtimeUpdate, "f")), "f");
703
838
  __classPrivateFieldSet(this, _AllureReport_realTime, realTime, "f");
@@ -751,8 +886,6 @@ export class AllureReport {
751
886
  return __classPrivateFieldGet(this, _AllureReport_realtimeChannel, "f").dispatcher;
752
887
  }
753
888
  }
754
- _AllureReport_reportName = new WeakMap(), _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_allureServiceClient = new WeakMap(), _AllureReport_qualityGate = new WeakMap(), _AllureReport_dump = new WeakMap(), _AllureReport_categories = new WeakMap(), _AllureReport_environments = new WeakMap(), _AllureReport_globalAttachments = new WeakMap(), _AllureReport_dumpTempDirs = new WeakMap(), _AllureReport_state = new WeakMap(), _AllureReport_executionStage = new WeakMap(), _AllureReport_runRealtimeUpdate = new WeakMap(), _AllureReport_eachPlugin = new WeakMap(), _AllureReport_instances = new WeakSet(), _AllureReport_publish_get = function _AllureReport_publish_get() {
755
- return __classPrivateFieldGet(this, _AllureReport_plugins, "f").some(({ enabled, options }) => enabled && options.publish);
756
- }, _AllureReport_getPluginState = function _AllureReport_getPluginState(init, id) {
889
+ _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_allureServiceClient = new WeakMap(), _AllureReport_qualityGate = new WeakMap(), _AllureReport_dump = new WeakMap(), _AllureReport_categories = new WeakMap(), _AllureReport_environments = new WeakMap(), _AllureReport_globalAttachments = new WeakMap(), _AllureReport_dumpTempDirs = new WeakMap(), _AllureReport_state = new WeakMap(), _AllureReport_executionStage = new WeakMap(), _AllureReport_historyDataPoint = new WeakMap(), _AllureReport_summaryPath = new WeakMap(), _AllureReport_summariesByPluginId = new WeakMap(), _AllureReport_publishedRemoteHrefs = new WeakMap(), _AllureReport_published = new WeakMap(), _AllureReport_publish = new WeakMap(), _AllureReport_runRealtimeUpdate = 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_generateRootSummary = new WeakMap(), _AllureReport_eachPlugin = new WeakMap(), _AllureReport_instances = new WeakSet(), _AllureReport_getPluginState = function _AllureReport_getPluginState(init, id) {
757
890
  return init ? new DefaultPluginState({}) : __classPrivateFieldGet(this, _AllureReport_state, "f")?.[id];
758
891
  };
@@ -54,7 +54,7 @@ export const testResultRawToState = (stateData, raw, context) => {
54
54
  flaky: raw.flaky ?? false,
55
55
  muted: raw.muted ?? false,
56
56
  known: raw.known ?? false,
57
- hidden: false,
57
+ isRetry: false,
58
58
  labels,
59
59
  steps: convertSteps(stateData, raw.steps).convertedSteps,
60
60
  parameters,