@allurereport/core 3.13.2 → 3.14.1

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
@@ -33,22 +33,21 @@ 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";
37
36
  import { environmentIdentityById, environmentIdentityByName } from "./utils/environment.js";
38
37
  import { measurePerf, PERF_METRIC_NAMES, PERF_METRIC_PREFIXES, startPerfSpan, writePerfMetrics } from "./utils/perf.js";
39
38
  import { RealtimeChannel } from "./utils/realtimeChannel.js";
40
39
  import { RealtimeUpdateScheduler } from "./utils/realtimeUpdateScheduler.js";
41
40
  import { resolveDumpAttachmentPath, UnsafeDumpPathError } from "./utils/safeDumpPath.js";
42
41
  const { version } = JSON.parse(readFileSync(new URL("../package.json", import.meta.url), "utf8"));
43
- const initRequired = "report is not initialised. Call the start() method first.";
44
- const defaultReadConcurrency = 64;
45
- const maxReadConcurrency = 256;
42
+ const INIT_REQUIRED_ERROR_MESSAGE = "report is not initialised. Call the start() method first.";
43
+ const DEFAULT_READ_CONCURRENCY = 64;
44
+ const MAX_READ_CONCURRENCY = 256;
46
45
  const readConcurrency = () => {
47
46
  const parsed = Number.parseInt(process.env.ALLURE_READ_CONCURRENCY ?? "", 10);
48
47
  if (!Number.isFinite(parsed)) {
49
- return defaultReadConcurrency;
48
+ return DEFAULT_READ_CONCURRENCY;
50
49
  }
51
- return Math.min(maxReadConcurrency, Math.max(1, parsed));
50
+ return Math.min(MAX_READ_CONCURRENCY, Math.max(1, parsed));
52
51
  };
53
52
  const clonePluginSummary = (summary) => structuredClone(summary);
54
53
  const remoteReportParams = (ci) => {
@@ -124,12 +123,36 @@ export class AllureReport {
124
123
  const client = __classPrivateFieldGet(this, _AllureReport_allureServiceClient, "f");
125
124
  const linksByPluginId = {};
126
125
  const summariesSnapshot = __classPrivateFieldGet(this, _AllureReport_cloneSummariesByPluginId, "f").call(this);
127
- 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
+ const uploadProgressMessage = reportsToPublish.length === 1 ? `Publishing "${reportsToPublish[0].pluginId}" report` : "Publishing reports";
127
+ const totalFilesToUpload = reportsToPublish.reduce((acc, report) => acc + Object.keys(report.files).length, 0);
128
+ const progressStep = Math.max(1, Math.ceil(totalFilesToUpload / 20));
128
129
  let summariesMutated = false;
129
130
  let reportCreated = false;
130
131
  let publishErrorMessage = "Report upload has failed, the report won't be published";
132
+ let uploadedFiles = 0;
133
+ let nextProgressLogAt = 0;
134
+ let lastProgressLog = -1;
131
135
  const endPublishPerfSpan = startPerfSpan(PERF_METRIC_NAMES.publishUploadTotal);
136
+ const logUploadProgress = (force = false) => {
137
+ if (force && uploadedFiles === lastProgressLog) {
138
+ return;
139
+ }
140
+ if (!force && uploadedFiles < nextProgressLogAt && uploadedFiles !== totalFilesToUpload) {
141
+ return;
142
+ }
143
+ if (!force && uploadedFiles === lastProgressLog) {
144
+ return;
145
+ }
146
+ console.info(`[AllureReport]: ${uploadProgressMessage}: ${uploadedFiles}/${totalFilesToUpload} files uploaded`);
147
+ lastProgressLog = uploadedFiles;
148
+ nextProgressLogAt = Math.min(totalFilesToUpload, uploadedFiles + progressStep);
149
+ };
150
+ const incrementUploadProgress = (delta = 1) => {
151
+ uploadedFiles = Math.min(totalFilesToUpload, uploadedFiles + delta);
152
+ logUploadProgress();
153
+ };
132
154
  try {
155
+ logUploadProgress(true);
133
156
  await client.createReport({
134
157
  reportUuid: this.reportUuid,
135
158
  reportName: this.reportName,
@@ -138,11 +161,12 @@ export class AllureReport {
138
161
  reportCreated = true;
139
162
  for (const report of reportsToPublish) {
140
163
  publishErrorMessage = `Plugin "${report.pluginId}" upload has failed, the plugin won't be published`;
164
+ const reportFiles = Object.fromEntries(Object.entries(report.files).filter(([filename]) => filename !== "summary.json"));
141
165
  const uploadResult = await measurePerf(`${PERF_METRIC_PREFIXES.publishUploadPlugin}${report.pluginId}`, () => client.uploadReport({
142
166
  reportUuid: this.reportUuid,
143
167
  pluginId: report.pluginId,
144
- files: Object.fromEntries(Object.entries(report.files).filter(([filename]) => filename !== "summary.json")),
145
- onProgress: () => uploadProgressBar.tick(),
168
+ files: reportFiles,
169
+ onProgress: incrementUploadProgress,
146
170
  }));
147
171
  if (uploadResult.indexHref) {
148
172
  linksByPluginId[report.pluginId] = uploadResult.indexHref;
@@ -167,15 +191,13 @@ export class AllureReport {
167
191
  reportUuid: this.reportUuid,
168
192
  pluginId: updatedReport.pluginId,
169
193
  files: { "summary.json": summaryFilepath },
170
- onProgress: () => uploadProgressBar.tick(),
194
+ onProgress: incrementUploadProgress,
171
195
  });
172
196
  }
173
197
  publishErrorMessage = "Report summary upload has failed, the report won't be published";
174
198
  const summaryHref = __classPrivateFieldGet(this, _AllureReport_summaryPath, "f")
175
- ? (await client.uploadReport({
176
- reportUuid: this.reportUuid,
177
- files: { "index.html": __classPrivateFieldGet(this, _AllureReport_summaryPath, "f") },
178
- })).indexHref
199
+ ? (await client.uploadReport({ reportUuid: this.reportUuid, files: { "index.html": __classPrivateFieldGet(this, _AllureReport_summaryPath, "f") } }))
200
+ .indexHref
179
201
  : undefined;
180
202
  publishErrorMessage = "Report completion has failed, the report won't be published";
181
203
  await client.completeReport({
@@ -189,6 +211,7 @@ export class AllureReport {
189
211
  __classPrivateFieldGet(this, _AllureReport_publishedRemoteHrefs, "f").add(summaryHref);
190
212
  }
191
213
  __classPrivateFieldSet(this, _AllureReport_published, true, "f");
214
+ logUploadProgress(true);
192
215
  }
193
216
  catch (err) {
194
217
  if (reportCreated) {
@@ -203,12 +226,11 @@ export class AllureReport {
203
226
  }
204
227
  finally {
205
228
  endPublishPerfSpan();
206
- uploadProgressBar.terminate();
207
229
  }
208
230
  });
209
231
  this.readDirectory = async (resultsDir) => measurePerf(PERF_METRIC_NAMES.generateReadResults, async () => {
210
232
  if (__classPrivateFieldGet(this, _AllureReport_executionStage, "f") !== "running") {
211
- throw new Error(initRequired);
233
+ throw new Error(INIT_REQUIRED_ERROR_MESSAGE);
212
234
  }
213
235
  const resultsDirPath = resolve(resultsDir);
214
236
  if (await readXcResultBundle(__classPrivateFieldGet(this, _AllureReport_store, "f"), resultsDirPath)) {
@@ -235,13 +257,13 @@ export class AllureReport {
235
257
  });
236
258
  this.readFile = async (resultsFile) => measurePerf(PERF_METRIC_NAMES.generateReadResults, async () => {
237
259
  if (__classPrivateFieldGet(this, _AllureReport_executionStage, "f") !== "running") {
238
- throw new Error(initRequired);
260
+ throw new Error(INIT_REQUIRED_ERROR_MESSAGE);
239
261
  }
240
262
  await this.readResult(new PathResultFile(resultsFile));
241
263
  });
242
264
  this.readResult = async (data) => {
243
265
  if (__classPrivateFieldGet(this, _AllureReport_executionStage, "f") !== "running") {
244
- throw new Error(initRequired);
266
+ throw new Error(INIT_REQUIRED_ERROR_MESSAGE);
245
267
  }
246
268
  for (const reader of __classPrivateFieldGet(this, _AllureReport_readers, "f")) {
247
269
  try {
@@ -681,7 +703,7 @@ export class AllureReport {
681
703
  this.done = async () => {
682
704
  const summaries = [];
683
705
  if (__classPrivateFieldGet(this, _AllureReport_executionStage, "f") !== "running") {
684
- throw new Error(initRequired);
706
+ throw new Error(INIT_REQUIRED_ERROR_MESSAGE);
685
707
  }
686
708
  try {
687
709
  const testResults = await __classPrivateFieldGet(this, _AllureReport_store, "f").allTestResults();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@allurereport/core",
3
- "version": "3.13.2",
3
+ "version": "3.14.1",
4
4
  "description": "Collection of generic Allure utilities used across the entire project",
5
5
  "keywords": [
6
6
  "allure"
@@ -25,25 +25,25 @@
25
25
  "lint:fix": "oxlint --import-plugin --fix src test features stories"
26
26
  },
27
27
  "dependencies": {
28
- "@allurereport/ci": "3.13.2",
29
- "@allurereport/core-api": "3.13.2",
30
- "@allurereport/plugin-agent": "3.13.2",
31
- "@allurereport/plugin-allure2": "3.13.2",
32
- "@allurereport/plugin-api": "3.13.2",
33
- "@allurereport/plugin-awesome": "3.13.2",
34
- "@allurereport/plugin-classic": "3.13.2",
35
- "@allurereport/plugin-csv": "3.13.2",
36
- "@allurereport/plugin-dashboard": "3.13.2",
37
- "@allurereport/plugin-jira": "3.13.2",
38
- "@allurereport/plugin-log": "3.13.2",
39
- "@allurereport/plugin-progress": "3.13.2",
40
- "@allurereport/plugin-slack": "3.13.2",
41
- "@allurereport/plugin-testops": "3.13.2",
42
- "@allurereport/plugin-testplan": "3.13.2",
43
- "@allurereport/reader": "3.13.2",
44
- "@allurereport/reader-api": "3.13.2",
45
- "@allurereport/service": "3.13.2",
46
- "@allurereport/summary": "3.13.2",
28
+ "@allurereport/ci": "3.14.1",
29
+ "@allurereport/core-api": "3.14.1",
30
+ "@allurereport/plugin-agent": "3.14.1",
31
+ "@allurereport/plugin-allure2": "3.14.1",
32
+ "@allurereport/plugin-api": "3.14.1",
33
+ "@allurereport/plugin-awesome": "3.14.1",
34
+ "@allurereport/plugin-classic": "3.14.1",
35
+ "@allurereport/plugin-csv": "3.14.1",
36
+ "@allurereport/plugin-dashboard": "3.14.1",
37
+ "@allurereport/plugin-jira": "3.14.1",
38
+ "@allurereport/plugin-log": "3.14.1",
39
+ "@allurereport/plugin-progress": "3.14.1",
40
+ "@allurereport/plugin-slack": "3.14.1",
41
+ "@allurereport/plugin-testops": "3.14.1",
42
+ "@allurereport/plugin-testplan": "3.14.1",
43
+ "@allurereport/reader": "3.14.1",
44
+ "@allurereport/reader-api": "3.14.1",
45
+ "@allurereport/service": "3.14.1",
46
+ "@allurereport/summary": "3.14.1",
47
47
  "glob": "^13.0.6",
48
48
  "handlebars": "^4.7.9",
49
49
  "node-stream-zip": "^1.15.0",
@@ -1,4 +0,0 @@
1
- export declare const createUploadProgressBarCounter: (message: string, total: number) => {
2
- tick: () => void;
3
- terminate: () => void;
4
- };
package/dist/utils/cli.js DELETED
@@ -1,41 +0,0 @@
1
- import { blue, bold, cyan } from "yoctocolors";
2
- const noopUploadProgressBar = {
3
- tick: () => { },
4
- terminate: () => { },
5
- };
6
- const isSilentLogLevel = () => {
7
- const level = process.env.LOG_LEVEL ?? process.env.ALLURE_LOG_LEVEL;
8
- return level === "silent";
9
- };
10
- export const createUploadProgressBarCounter = (message, total) => {
11
- if (isSilentLogLevel() || total === 0 || !process.stderr.isTTY) {
12
- return noopUploadProgressBar;
13
- }
14
- const width = 20;
15
- const prefix = cyan(bold("[AllureReport]:"));
16
- let current = 0;
17
- let terminated = false;
18
- const render = () => {
19
- const ratio = total === 0 ? 1 : current / total;
20
- const complete = Math.min(width, Math.round(ratio * width));
21
- const bar = `${"=".repeat(complete)}${"-".repeat(width - complete)}`;
22
- process.stderr.write(`\r${prefix} ${blue(message)} [${bar}] ${current}/${total}`);
23
- };
24
- render();
25
- return {
26
- tick: () => {
27
- if (terminated) {
28
- return;
29
- }
30
- current = Math.min(current + 1, total);
31
- render();
32
- },
33
- terminate: () => {
34
- if (terminated) {
35
- return;
36
- }
37
- terminated = true;
38
- process.stderr.write("\n");
39
- },
40
- };
41
- };