@allurereport/core 3.0.0-beta.17 → 3.0.0-beta.19
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/api.d.ts +3 -1
- package/dist/config.js +2 -1
- package/dist/history.js +2 -4
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/qualityGate/index.d.ts +2 -0
- package/dist/qualityGate/index.js +2 -0
- package/dist/qualityGate/qualityGate.d.ts +21 -0
- package/dist/qualityGate/qualityGate.js +96 -0
- package/dist/qualityGate/rules.d.ts +5 -0
- package/dist/qualityGate/rules.js +45 -0
- package/dist/report.d.ts +17 -4
- package/dist/report.js +239 -35
- package/dist/store/store.d.ts +13 -5
- package/dist/store/store.js +262 -51
- package/dist/utils/event.d.ts +38 -9
- package/dist/utils/event.js +101 -25
- package/package.json +24 -20
- package/dist/qualityGate.d.ts +0 -25
- package/dist/qualityGate.js +0 -116
package/dist/report.js
CHANGED
|
@@ -9,45 +9,54 @@ 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_eventEmitter,
|
|
12
|
+
var _AllureReport_instances, _AllureReport_reportName, _AllureReport_reportVariables, _AllureReport_ci, _AllureReport_store, _AllureReport_readers, _AllureReport_plugins, _AllureReport_reportFiles, _AllureReport_eventEmitter, _AllureReport_realtimeSubscriber, _AllureReport_realtimeDispatcher, _AllureReport_realTime, _AllureReport_output, _AllureReport_history, _AllureReport_allureServiceClient, _AllureReport_qualityGate, _AllureReport_stage, _AllureReport_stageTempDirs, _AllureReport_state, _AllureReport_executionStage, _AllureReport_publish_get, _AllureReport_update, _AllureReport_eachPlugin, _AllureReport_getPluginState;
|
|
13
13
|
import { detect } from "@allurereport/ci";
|
|
14
|
+
import { AllureStoreDumpFiles, } from "@allurereport/plugin-api";
|
|
14
15
|
import { allure1, allure2, attachments, cucumberjson, junitXml, readXcResultBundle } from "@allurereport/reader";
|
|
15
16
|
import { PathResultFile } from "@allurereport/reader-api";
|
|
16
17
|
import { AllureRemoteHistory, AllureServiceClient, KnownError, UnknownError } from "@allurereport/service";
|
|
17
18
|
import { generateSummary } from "@allurereport/summary";
|
|
19
|
+
import ZipReadStream from "node-stream-zip";
|
|
18
20
|
import console from "node:console";
|
|
19
21
|
import { randomUUID } from "node:crypto";
|
|
20
22
|
import { EventEmitter } from "node:events";
|
|
21
|
-
import { readFileSync } from "node:fs";
|
|
22
|
-
import { lstat, opendir, readdir, realpath, rename, rm } from "node:fs/promises";
|
|
23
|
-
import {
|
|
23
|
+
import { createReadStream, createWriteStream, existsSync, readFileSync } from "node:fs";
|
|
24
|
+
import { lstat, mkdtemp, opendir, readdir, realpath, rename, rm, writeFile } from "node:fs/promises";
|
|
25
|
+
import { tmpdir } from "node:os";
|
|
26
|
+
import { basename, dirname, join, resolve } from "node:path";
|
|
27
|
+
import { promisify } from "node:util";
|
|
28
|
+
import ZipWriteStream from "zip-stream";
|
|
24
29
|
import { AllureLocalHistory, createHistory } from "./history.js";
|
|
25
30
|
import { DefaultPluginState, PluginFiles } from "./plugin.js";
|
|
26
|
-
import { QualityGate } from "./qualityGate.js";
|
|
31
|
+
import { QualityGate } from "./qualityGate/index.js";
|
|
27
32
|
import { DefaultAllureStore } from "./store/store.js";
|
|
28
|
-
import {
|
|
33
|
+
import { RealtimeEventsDispatcher, RealtimeSubscriber } from "./utils/event.js";
|
|
29
34
|
const { version } = JSON.parse(readFileSync(new URL("../package.json", import.meta.url), "utf8"));
|
|
30
35
|
const initRequired = "report is not initialised. Call the start() method first.";
|
|
31
36
|
export class AllureReport {
|
|
32
37
|
constructor(opts) {
|
|
33
38
|
_AllureReport_instances.add(this);
|
|
34
39
|
_AllureReport_reportName.set(this, void 0);
|
|
40
|
+
_AllureReport_reportVariables.set(this, void 0);
|
|
35
41
|
_AllureReport_ci.set(this, void 0);
|
|
36
42
|
_AllureReport_store.set(this, void 0);
|
|
37
43
|
_AllureReport_readers.set(this, void 0);
|
|
38
44
|
_AllureReport_plugins.set(this, void 0);
|
|
39
45
|
_AllureReport_reportFiles.set(this, void 0);
|
|
40
46
|
_AllureReport_eventEmitter.set(this, void 0);
|
|
41
|
-
|
|
42
|
-
|
|
47
|
+
_AllureReport_realtimeSubscriber.set(this, void 0);
|
|
48
|
+
_AllureReport_realtimeDispatcher.set(this, void 0);
|
|
43
49
|
_AllureReport_realTime.set(this, void 0);
|
|
44
50
|
_AllureReport_output.set(this, void 0);
|
|
45
51
|
_AllureReport_history.set(this, void 0);
|
|
46
52
|
_AllureReport_allureServiceClient.set(this, void 0);
|
|
53
|
+
_AllureReport_qualityGate.set(this, void 0);
|
|
54
|
+
_AllureReport_stage.set(this, void 0);
|
|
55
|
+
_AllureReport_stageTempDirs.set(this, []);
|
|
47
56
|
_AllureReport_state.set(this, void 0);
|
|
48
|
-
|
|
57
|
+
_AllureReport_executionStage.set(this, "init");
|
|
49
58
|
this.readDirectory = async (resultsDir) => {
|
|
50
|
-
if (__classPrivateFieldGet(this,
|
|
59
|
+
if (__classPrivateFieldGet(this, _AllureReport_executionStage, "f") !== "running") {
|
|
51
60
|
throw new Error(initRequired);
|
|
52
61
|
}
|
|
53
62
|
const resultsDirPath = resolve(resultsDir);
|
|
@@ -68,13 +77,13 @@ export class AllureReport {
|
|
|
68
77
|
}
|
|
69
78
|
};
|
|
70
79
|
this.readFile = async (resultsFile) => {
|
|
71
|
-
if (__classPrivateFieldGet(this,
|
|
80
|
+
if (__classPrivateFieldGet(this, _AllureReport_executionStage, "f") !== "running") {
|
|
72
81
|
throw new Error(initRequired);
|
|
73
82
|
}
|
|
74
83
|
await this.readResult(new PathResultFile(resultsFile));
|
|
75
84
|
};
|
|
76
85
|
this.readResult = async (data) => {
|
|
77
|
-
if (__classPrivateFieldGet(this,
|
|
86
|
+
if (__classPrivateFieldGet(this, _AllureReport_executionStage, "f") !== "running") {
|
|
78
87
|
throw new Error(initRequired);
|
|
79
88
|
}
|
|
80
89
|
for (const reader of __classPrivateFieldGet(this, _AllureReport_readers, "f")) {
|
|
@@ -87,15 +96,23 @@ export class AllureReport {
|
|
|
87
96
|
catch (ignored) { }
|
|
88
97
|
}
|
|
89
98
|
};
|
|
99
|
+
this.validate = async (params) => {
|
|
100
|
+
const { trs, knownIssues, state } = params;
|
|
101
|
+
return __classPrivateFieldGet(this, _AllureReport_qualityGate, "f").validate({
|
|
102
|
+
trs: trs.filter(Boolean),
|
|
103
|
+
knownIssues,
|
|
104
|
+
state,
|
|
105
|
+
});
|
|
106
|
+
};
|
|
90
107
|
this.start = async () => {
|
|
91
108
|
await __classPrivateFieldGet(this, _AllureReport_store, "f").readHistory();
|
|
92
|
-
if (__classPrivateFieldGet(this,
|
|
109
|
+
if (__classPrivateFieldGet(this, _AllureReport_executionStage, "f") === "running") {
|
|
93
110
|
throw new Error("the report is already started");
|
|
94
111
|
}
|
|
95
|
-
if (__classPrivateFieldGet(this,
|
|
112
|
+
if (__classPrivateFieldGet(this, _AllureReport_executionStage, "f") === "done") {
|
|
96
113
|
throw new Error("the report is already stopped, the restart isn't supported at the moment");
|
|
97
114
|
}
|
|
98
|
-
__classPrivateFieldSet(this,
|
|
115
|
+
__classPrivateFieldSet(this, _AllureReport_executionStage, "running", "f");
|
|
99
116
|
if (__classPrivateFieldGet(this, _AllureReport_allureServiceClient, "f") && __classPrivateFieldGet(this, _AllureReport_instances, "a", _AllureReport_publish_get)) {
|
|
100
117
|
const { url } = await __classPrivateFieldGet(this, _AllureReport_allureServiceClient, "f").createReport({
|
|
101
118
|
reportUuid: this.reportUuid,
|
|
@@ -104,31 +121,196 @@ export class AllureReport {
|
|
|
104
121
|
this.reportUrl = url;
|
|
105
122
|
}
|
|
106
123
|
await __classPrivateFieldGet(this, _AllureReport_eachPlugin, "f").call(this, true, async (plugin, context) => {
|
|
107
|
-
await plugin.start?.(context, __classPrivateFieldGet(this, _AllureReport_store, "f"), __classPrivateFieldGet(this,
|
|
124
|
+
await plugin.start?.(context, __classPrivateFieldGet(this, _AllureReport_store, "f"), __classPrivateFieldGet(this, _AllureReport_realtimeSubscriber, "f"));
|
|
108
125
|
});
|
|
109
126
|
if (__classPrivateFieldGet(this, _AllureReport_realTime, "f")) {
|
|
110
127
|
await __classPrivateFieldGet(this, _AllureReport_update, "f").call(this);
|
|
111
|
-
__classPrivateFieldGet(this,
|
|
128
|
+
__classPrivateFieldGet(this, _AllureReport_realtimeSubscriber, "f").onAll(async () => {
|
|
112
129
|
await __classPrivateFieldGet(this, _AllureReport_update, "f").call(this);
|
|
113
130
|
});
|
|
114
131
|
}
|
|
115
132
|
};
|
|
116
133
|
_AllureReport_update.set(this, async () => {
|
|
117
|
-
if (__classPrivateFieldGet(this,
|
|
134
|
+
if (__classPrivateFieldGet(this, _AllureReport_executionStage, "f") !== "running") {
|
|
118
135
|
return;
|
|
119
136
|
}
|
|
120
137
|
await __classPrivateFieldGet(this, _AllureReport_eachPlugin, "f").call(this, false, async (plugin, context) => {
|
|
121
138
|
await plugin.update?.(context, __classPrivateFieldGet(this, _AllureReport_store, "f"));
|
|
122
139
|
});
|
|
123
140
|
});
|
|
141
|
+
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();
|
|
143
|
+
const allAttachments = await __classPrivateFieldGet(this, _AllureReport_store, "f").allAttachments();
|
|
144
|
+
const dumpArchive = new ZipWriteStream({
|
|
145
|
+
zlib: { level: 5 },
|
|
146
|
+
});
|
|
147
|
+
const addEntry = promisify(dumpArchive.entry.bind(dumpArchive));
|
|
148
|
+
const dumpArchiveWriteStream = createWriteStream(`${__classPrivateFieldGet(this, _AllureReport_stage, "f")}.zip`);
|
|
149
|
+
const promise = new Promise((res, rej) => {
|
|
150
|
+
dumpArchive.on("error", (err) => rej(err));
|
|
151
|
+
dumpArchiveWriteStream.on("finish", () => res(void 0));
|
|
152
|
+
dumpArchiveWriteStream.on("error", (err) => rej(err));
|
|
153
|
+
});
|
|
154
|
+
dumpArchive.pipe(dumpArchiveWriteStream);
|
|
155
|
+
await addEntry(Buffer.from(JSON.stringify(testResults)), {
|
|
156
|
+
name: AllureStoreDumpFiles.TestResults,
|
|
157
|
+
});
|
|
158
|
+
await addEntry(Buffer.from(JSON.stringify(testCases)), {
|
|
159
|
+
name: AllureStoreDumpFiles.TestCases,
|
|
160
|
+
});
|
|
161
|
+
await addEntry(Buffer.from(JSON.stringify(fixtures)), {
|
|
162
|
+
name: AllureStoreDumpFiles.Fixtures,
|
|
163
|
+
});
|
|
164
|
+
await addEntry(Buffer.from(JSON.stringify(attachmentsLinks)), {
|
|
165
|
+
name: AllureStoreDumpFiles.Attachments,
|
|
166
|
+
});
|
|
167
|
+
await addEntry(Buffer.from(JSON.stringify(environments)), {
|
|
168
|
+
name: AllureStoreDumpFiles.Environments,
|
|
169
|
+
});
|
|
170
|
+
await addEntry(Buffer.from(JSON.stringify(__classPrivateFieldGet(this, _AllureReport_reportVariables, "f"))), {
|
|
171
|
+
name: AllureStoreDumpFiles.ReportVariables,
|
|
172
|
+
});
|
|
173
|
+
await addEntry(Buffer.from(JSON.stringify(globalAttachments)), {
|
|
174
|
+
name: AllureStoreDumpFiles.GlobalAttachments,
|
|
175
|
+
});
|
|
176
|
+
await addEntry(Buffer.from(JSON.stringify(globalErrors)), {
|
|
177
|
+
name: AllureStoreDumpFiles.GlobalErrors,
|
|
178
|
+
});
|
|
179
|
+
await addEntry(Buffer.from(JSON.stringify(indexAttachmentByTestResult)), {
|
|
180
|
+
name: AllureStoreDumpFiles.IndexAttachmentsByTestResults,
|
|
181
|
+
});
|
|
182
|
+
await addEntry(Buffer.from(JSON.stringify(indexTestResultByHistoryId)), {
|
|
183
|
+
name: AllureStoreDumpFiles.IndexTestResultsByHistoryId,
|
|
184
|
+
});
|
|
185
|
+
await addEntry(Buffer.from(JSON.stringify(indexTestResultByTestCase)), {
|
|
186
|
+
name: AllureStoreDumpFiles.IndexTestResultsByTestCase,
|
|
187
|
+
});
|
|
188
|
+
await addEntry(Buffer.from(JSON.stringify(indexLatestEnvTestResultByHistoryId)), {
|
|
189
|
+
name: AllureStoreDumpFiles.IndexLatestEnvTestResultsByHistoryId,
|
|
190
|
+
});
|
|
191
|
+
await addEntry(Buffer.from(JSON.stringify(indexAttachmentByFixture)), {
|
|
192
|
+
name: AllureStoreDumpFiles.IndexAttachmentsByFixture,
|
|
193
|
+
});
|
|
194
|
+
await addEntry(Buffer.from(JSON.stringify(indexFixturesByTestResult)), {
|
|
195
|
+
name: AllureStoreDumpFiles.IndexFixturesByTestResult,
|
|
196
|
+
});
|
|
197
|
+
await addEntry(Buffer.from(JSON.stringify(indexKnownByHistoryId)), {
|
|
198
|
+
name: AllureStoreDumpFiles.IndexKnownByHistoryId,
|
|
199
|
+
});
|
|
200
|
+
for (const attachment of allAttachments) {
|
|
201
|
+
const content = await __classPrivateFieldGet(this, _AllureReport_store, "f").attachmentContentById(attachment.id);
|
|
202
|
+
if (!content) {
|
|
203
|
+
continue;
|
|
204
|
+
}
|
|
205
|
+
if (content instanceof PathResultFile) {
|
|
206
|
+
await addEntry(createReadStream(content.path), {
|
|
207
|
+
name: attachment.id,
|
|
208
|
+
});
|
|
209
|
+
}
|
|
210
|
+
else {
|
|
211
|
+
await addEntry(await content.asBuffer(), {
|
|
212
|
+
name: attachment.id,
|
|
213
|
+
});
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
dumpArchive.finalize();
|
|
217
|
+
return promise;
|
|
218
|
+
};
|
|
219
|
+
this.restoreState = async (stages) => {
|
|
220
|
+
for (const stage of stages) {
|
|
221
|
+
if (!existsSync(stage)) {
|
|
222
|
+
continue;
|
|
223
|
+
}
|
|
224
|
+
const dump = new ZipReadStream.async({
|
|
225
|
+
file: stage,
|
|
226
|
+
});
|
|
227
|
+
const testResultsEntry = await dump.entryData(AllureStoreDumpFiles.TestResults);
|
|
228
|
+
const testCasesEntry = await dump.entryData(AllureStoreDumpFiles.TestCases);
|
|
229
|
+
const fixturesEntry = await dump.entryData(AllureStoreDumpFiles.Fixtures);
|
|
230
|
+
const attachmentsEntry = await dump.entryData(AllureStoreDumpFiles.Attachments);
|
|
231
|
+
const environmentsEntry = await dump.entryData(AllureStoreDumpFiles.Environments);
|
|
232
|
+
const reportVariablesEntry = await dump.entryData(AllureStoreDumpFiles.ReportVariables);
|
|
233
|
+
const globalAttachmentsEntry = await dump.entryData(AllureStoreDumpFiles.GlobalAttachments);
|
|
234
|
+
const globalErrorsEntry = await dump.entryData(AllureStoreDumpFiles.GlobalErrors);
|
|
235
|
+
const indexAttachmentsEntry = await dump.entryData(AllureStoreDumpFiles.IndexAttachmentsByTestResults);
|
|
236
|
+
const indexTestResultsByHistoryId = await dump.entryData(AllureStoreDumpFiles.IndexTestResultsByHistoryId);
|
|
237
|
+
const indexTestResultsByTestCaseEntry = await dump.entryData(AllureStoreDumpFiles.IndexTestResultsByTestCase);
|
|
238
|
+
const indexLatestEnvTestResultsByHistoryIdEntry = await dump.entryData(AllureStoreDumpFiles.IndexLatestEnvTestResultsByHistoryId);
|
|
239
|
+
const indexAttachmentsByFixtureEntry = await dump.entryData(AllureStoreDumpFiles.IndexAttachmentsByFixture);
|
|
240
|
+
const indexFixturesByTestResultEntry = await dump.entryData(AllureStoreDumpFiles.IndexFixturesByTestResult);
|
|
241
|
+
const indexKnownByHistoryIdEntry = await dump.entryData(AllureStoreDumpFiles.IndexKnownByHistoryId);
|
|
242
|
+
const attachmentsEntries = Object.entries(await dump.entries()).reduce((acc, [entryName, entry]) => {
|
|
243
|
+
switch (entryName) {
|
|
244
|
+
case AllureStoreDumpFiles.Attachments:
|
|
245
|
+
case AllureStoreDumpFiles.TestResults:
|
|
246
|
+
case AllureStoreDumpFiles.TestCases:
|
|
247
|
+
case AllureStoreDumpFiles.Fixtures:
|
|
248
|
+
case AllureStoreDumpFiles.Environments:
|
|
249
|
+
case AllureStoreDumpFiles.ReportVariables:
|
|
250
|
+
case AllureStoreDumpFiles.GlobalAttachments:
|
|
251
|
+
case AllureStoreDumpFiles.GlobalErrors:
|
|
252
|
+
case AllureStoreDumpFiles.IndexAttachmentsByTestResults:
|
|
253
|
+
case AllureStoreDumpFiles.IndexTestResultsByHistoryId:
|
|
254
|
+
case AllureStoreDumpFiles.IndexTestResultsByTestCase:
|
|
255
|
+
case AllureStoreDumpFiles.IndexLatestEnvTestResultsByHistoryId:
|
|
256
|
+
case AllureStoreDumpFiles.IndexAttachmentsByFixture:
|
|
257
|
+
case AllureStoreDumpFiles.IndexFixturesByTestResult:
|
|
258
|
+
case AllureStoreDumpFiles.IndexKnownByHistoryId:
|
|
259
|
+
return acc;
|
|
260
|
+
default:
|
|
261
|
+
return Object.assign(acc, {
|
|
262
|
+
[entryName]: entry,
|
|
263
|
+
});
|
|
264
|
+
}
|
|
265
|
+
}, {});
|
|
266
|
+
const dumpState = {
|
|
267
|
+
testResults: JSON.parse(testResultsEntry.toString("utf8")),
|
|
268
|
+
testCases: JSON.parse(testCasesEntry.toString("utf8")),
|
|
269
|
+
fixtures: JSON.parse(fixturesEntry.toString("utf8")),
|
|
270
|
+
attachments: JSON.parse(attachmentsEntry.toString("utf8")),
|
|
271
|
+
environments: JSON.parse(environmentsEntry.toString("utf8")),
|
|
272
|
+
reportVariables: JSON.parse(reportVariablesEntry.toString("utf8")),
|
|
273
|
+
globalAttachments: JSON.parse(globalAttachmentsEntry.toString("utf8")),
|
|
274
|
+
globalErrors: JSON.parse(globalErrorsEntry.toString("utf8")),
|
|
275
|
+
indexAttachmentByTestResult: JSON.parse(indexAttachmentsEntry.toString("utf8")),
|
|
276
|
+
indexTestResultByHistoryId: JSON.parse(indexTestResultsByHistoryId.toString("utf8")),
|
|
277
|
+
indexTestResultByTestCase: JSON.parse(indexTestResultsByTestCaseEntry.toString("utf8")),
|
|
278
|
+
indexLatestEnvTestResultByHistoryId: JSON.parse(indexLatestEnvTestResultsByHistoryIdEntry.toString("utf8")),
|
|
279
|
+
indexAttachmentByFixture: JSON.parse(indexAttachmentsByFixtureEntry.toString("utf8")),
|
|
280
|
+
indexFixturesByTestResult: JSON.parse(indexFixturesByTestResultEntry.toString("utf8")),
|
|
281
|
+
indexKnownByHistoryId: JSON.parse(indexKnownByHistoryIdEntry.toString("utf8")),
|
|
282
|
+
};
|
|
283
|
+
const stageTempDir = await mkdtemp(join(tmpdir(), basename(stage, ".zip")));
|
|
284
|
+
const resultsAttachments = {};
|
|
285
|
+
__classPrivateFieldGet(this, _AllureReport_stageTempDirs, "f").push(stageTempDir);
|
|
286
|
+
try {
|
|
287
|
+
for (const [attachmentId] of Object.entries(attachmentsEntries)) {
|
|
288
|
+
const attachmentContentEntry = await dump.entryData(attachmentId);
|
|
289
|
+
const attachmentFilePath = join(stageTempDir, attachmentId);
|
|
290
|
+
await writeFile(attachmentFilePath, attachmentContentEntry);
|
|
291
|
+
resultsAttachments[attachmentId] = new PathResultFile(attachmentFilePath, attachmentId);
|
|
292
|
+
}
|
|
293
|
+
}
|
|
294
|
+
catch (err) {
|
|
295
|
+
console.error(`Can't restore state from "${stage}", continuing without it`);
|
|
296
|
+
console.error(err);
|
|
297
|
+
}
|
|
298
|
+
await __classPrivateFieldGet(this, _AllureReport_store, "f").restoreState(dumpState, resultsAttachments);
|
|
299
|
+
console.info(`Successfully restored state from "${stage}"`);
|
|
300
|
+
}
|
|
301
|
+
};
|
|
124
302
|
this.done = async () => {
|
|
125
303
|
const summaries = [];
|
|
126
304
|
const remoteHrefs = [];
|
|
127
|
-
if (__classPrivateFieldGet(this,
|
|
305
|
+
if (__classPrivateFieldGet(this, _AllureReport_executionStage, "f") !== "running") {
|
|
128
306
|
throw new Error(initRequired);
|
|
129
307
|
}
|
|
130
|
-
__classPrivateFieldGet(this,
|
|
131
|
-
__classPrivateFieldSet(this,
|
|
308
|
+
__classPrivateFieldGet(this, _AllureReport_realtimeSubscriber, "f").offAll();
|
|
309
|
+
__classPrivateFieldSet(this, _AllureReport_executionStage, "done", "f");
|
|
310
|
+
if (__classPrivateFieldGet(this, _AllureReport_stage, "f")) {
|
|
311
|
+
await this.dumpState();
|
|
312
|
+
return;
|
|
313
|
+
}
|
|
132
314
|
await __classPrivateFieldGet(this, _AllureReport_eachPlugin, "f").call(this, false, async (plugin, context) => {
|
|
133
315
|
await plugin.done?.(context, __classPrivateFieldGet(this, _AllureReport_store, "f"));
|
|
134
316
|
if (__classPrivateFieldGet(this, _AllureReport_allureServiceClient, "f") && context.publish) {
|
|
@@ -155,7 +337,7 @@ export class AllureReport {
|
|
|
155
337
|
return;
|
|
156
338
|
}
|
|
157
339
|
summary.pullRequestHref = __classPrivateFieldGet(this, _AllureReport_ci, "f")?.pullRequestUrl;
|
|
158
|
-
summary.jobHref = __classPrivateFieldGet(this, _AllureReport_ci, "f")?.
|
|
340
|
+
summary.jobHref = __classPrivateFieldGet(this, _AllureReport_ci, "f")?.jobRunUrl;
|
|
159
341
|
if (context.publish) {
|
|
160
342
|
summary.remoteHref = `${this.reportUrl}/${context.id}/`;
|
|
161
343
|
remoteHrefs.push(summary.remoteHref);
|
|
@@ -171,7 +353,11 @@ export class AllureReport {
|
|
|
171
353
|
reportUuid: this.reportUuid,
|
|
172
354
|
});
|
|
173
355
|
}
|
|
174
|
-
|
|
356
|
+
let outputDirFiles = [];
|
|
357
|
+
try {
|
|
358
|
+
outputDirFiles = await readdir(__classPrivateFieldGet(this, _AllureReport_output, "f"));
|
|
359
|
+
}
|
|
360
|
+
catch (ignored) { }
|
|
175
361
|
if (outputDirFiles.length === 0) {
|
|
176
362
|
return;
|
|
177
363
|
}
|
|
@@ -187,6 +373,12 @@ export class AllureReport {
|
|
|
187
373
|
}
|
|
188
374
|
await rm(reportPath, { recursive: true });
|
|
189
375
|
}
|
|
376
|
+
for (const dir of __classPrivateFieldGet(this, _AllureReport_stageTempDirs, "f")) {
|
|
377
|
+
try {
|
|
378
|
+
await rm(dir, { recursive: true });
|
|
379
|
+
}
|
|
380
|
+
catch (ignored) { }
|
|
381
|
+
}
|
|
190
382
|
if (__classPrivateFieldGet(this, _AllureReport_history, "f")) {
|
|
191
383
|
const testResults = await __classPrivateFieldGet(this, _AllureReport_store, "f").allTestResults();
|
|
192
384
|
const testCases = await __classPrivateFieldGet(this, _AllureReport_store, "f").allTestCases();
|
|
@@ -215,6 +407,11 @@ export class AllureReport {
|
|
|
215
407
|
console.info(`- ${href}`);
|
|
216
408
|
});
|
|
217
409
|
}
|
|
410
|
+
if (!__classPrivateFieldGet(this, _AllureReport_qualityGate, "f")) {
|
|
411
|
+
return;
|
|
412
|
+
}
|
|
413
|
+
const qualityGateResults = await __classPrivateFieldGet(this, _AllureReport_store, "f").qualityGateResults();
|
|
414
|
+
await writeFile(join(__classPrivateFieldGet(this, _AllureReport_output, "f"), "quality-gate.json"), JSON.stringify(qualityGateResults));
|
|
218
415
|
};
|
|
219
416
|
_AllureReport_eachPlugin.set(this, async (initState, consumer) => {
|
|
220
417
|
if (initState) {
|
|
@@ -261,52 +458,59 @@ export class AllureReport {
|
|
|
261
458
|
}
|
|
262
459
|
}
|
|
263
460
|
});
|
|
264
|
-
|
|
265
|
-
await __classPrivateFieldGet(this, _AllureReport_qualityGate, "f").validate(__classPrivateFieldGet(this, _AllureReport_store, "f"));
|
|
266
|
-
};
|
|
267
|
-
const { name, readers = [allure1, allure2, cucumberjson, junitXml, attachments], plugins = [], known, reportFiles, qualityGate, realTime, historyPath, defaultLabels = {}, variables = {}, environments, output, allureService: allureServiceConfig, } = opts;
|
|
461
|
+
const { name, readers = [allure1, allure2, cucumberjson, junitXml, attachments], plugins = [], known, reportFiles, realTime, historyPath, defaultLabels = {}, variables = {}, environment, environments, output, qualityGate, stage, allureService: allureServiceConfig, } = opts;
|
|
268
462
|
__classPrivateFieldSet(this, _AllureReport_allureServiceClient, allureServiceConfig?.url ? new AllureServiceClient(allureServiceConfig) : undefined, "f");
|
|
269
463
|
this.reportUuid = randomUUID();
|
|
270
464
|
__classPrivateFieldSet(this, _AllureReport_ci, detect(), "f");
|
|
271
465
|
const reportTitleSuffix = __classPrivateFieldGet(this, _AllureReport_ci, "f")?.pullRequestName ?? __classPrivateFieldGet(this, _AllureReport_ci, "f")?.jobRunName;
|
|
272
466
|
__classPrivateFieldSet(this, _AllureReport_reportName, [name, reportTitleSuffix].filter(Boolean).join(" – "), "f");
|
|
467
|
+
__classPrivateFieldSet(this, _AllureReport_reportVariables, variables, "f");
|
|
273
468
|
__classPrivateFieldSet(this, _AllureReport_eventEmitter, new EventEmitter(), "f");
|
|
274
|
-
__classPrivateFieldSet(this,
|
|
469
|
+
__classPrivateFieldSet(this, _AllureReport_realtimeDispatcher, new RealtimeEventsDispatcher(__classPrivateFieldGet(this, _AllureReport_eventEmitter, "f")), "f");
|
|
470
|
+
__classPrivateFieldSet(this, _AllureReport_realtimeSubscriber, new RealtimeSubscriber(__classPrivateFieldGet(this, _AllureReport_eventEmitter, "f")), "f");
|
|
275
471
|
__classPrivateFieldSet(this, _AllureReport_realTime, realTime, "f");
|
|
472
|
+
__classPrivateFieldSet(this, _AllureReport_stage, stage, "f");
|
|
276
473
|
if (__classPrivateFieldGet(this, _AllureReport_allureServiceClient, "f")) {
|
|
277
474
|
__classPrivateFieldSet(this, _AllureReport_history, new AllureRemoteHistory(__classPrivateFieldGet(this, _AllureReport_allureServiceClient, "f")), "f");
|
|
278
475
|
}
|
|
279
476
|
else if (historyPath) {
|
|
280
477
|
__classPrivateFieldSet(this, _AllureReport_history, new AllureLocalHistory(historyPath), "f");
|
|
281
478
|
}
|
|
479
|
+
if (qualityGate) {
|
|
480
|
+
__classPrivateFieldSet(this, _AllureReport_qualityGate, new QualityGate(qualityGate), "f");
|
|
481
|
+
}
|
|
282
482
|
__classPrivateFieldSet(this, _AllureReport_store, new DefaultAllureStore({
|
|
283
|
-
|
|
483
|
+
realtimeSubscriber: __classPrivateFieldGet(this, _AllureReport_realtimeSubscriber, "f"),
|
|
484
|
+
realtimeDispatcher: __classPrivateFieldGet(this, _AllureReport_realtimeDispatcher, "f"),
|
|
284
485
|
reportVariables: variables,
|
|
285
486
|
environmentsConfig: environments,
|
|
286
487
|
history: __classPrivateFieldGet(this, _AllureReport_history, "f"),
|
|
287
488
|
known,
|
|
288
489
|
defaultLabels,
|
|
490
|
+
environment,
|
|
289
491
|
}), "f");
|
|
290
492
|
__classPrivateFieldSet(this, _AllureReport_readers, [...readers], "f");
|
|
291
493
|
__classPrivateFieldSet(this, _AllureReport_plugins, [...plugins], "f");
|
|
292
494
|
__classPrivateFieldSet(this, _AllureReport_reportFiles, reportFiles, "f");
|
|
293
495
|
__classPrivateFieldSet(this, _AllureReport_output, output, "f");
|
|
294
|
-
__classPrivateFieldSet(this, _AllureReport_qualityGate, new QualityGate(qualityGate), "f");
|
|
295
496
|
__classPrivateFieldSet(this, _AllureReport_history, __classPrivateFieldGet(this, _AllureReport_allureServiceClient, "f")
|
|
296
497
|
? new AllureRemoteHistory(__classPrivateFieldGet(this, _AllureReport_allureServiceClient, "f"))
|
|
297
498
|
: new AllureLocalHistory(historyPath), "f");
|
|
298
499
|
}
|
|
500
|
+
get hasQualityGate() {
|
|
501
|
+
return !!__classPrivateFieldGet(this, _AllureReport_qualityGate, "f");
|
|
502
|
+
}
|
|
299
503
|
get store() {
|
|
300
504
|
return __classPrivateFieldGet(this, _AllureReport_store, "f");
|
|
301
505
|
}
|
|
302
|
-
get
|
|
303
|
-
return __classPrivateFieldGet(this,
|
|
506
|
+
get realtimeSubscriber() {
|
|
507
|
+
return __classPrivateFieldGet(this, _AllureReport_realtimeSubscriber, "f");
|
|
304
508
|
}
|
|
305
|
-
get
|
|
306
|
-
return __classPrivateFieldGet(this,
|
|
509
|
+
get realtimeDispatcher() {
|
|
510
|
+
return __classPrivateFieldGet(this, _AllureReport_realtimeDispatcher, "f");
|
|
307
511
|
}
|
|
308
512
|
}
|
|
309
|
-
_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_eventEmitter = new WeakMap(),
|
|
513
|
+
_AllureReport_reportName = new WeakMap(), _AllureReport_reportVariables = new WeakMap(), _AllureReport_ci = new WeakMap(), _AllureReport_store = new WeakMap(), _AllureReport_readers = new WeakMap(), _AllureReport_plugins = new WeakMap(), _AllureReport_reportFiles = new WeakMap(), _AllureReport_eventEmitter = new WeakMap(), _AllureReport_realtimeSubscriber = new WeakMap(), _AllureReport_realtimeDispatcher = new WeakMap(), _AllureReport_realTime = new WeakMap(), _AllureReport_output = new WeakMap(), _AllureReport_history = new WeakMap(), _AllureReport_allureServiceClient = new WeakMap(), _AllureReport_qualityGate = new WeakMap(), _AllureReport_stage = new WeakMap(), _AllureReport_stageTempDirs = new WeakMap(), _AllureReport_state = new WeakMap(), _AllureReport_executionStage = new WeakMap(), _AllureReport_update = new WeakMap(), _AllureReport_eachPlugin = new WeakMap(), _AllureReport_instances = new WeakSet(), _AllureReport_publish_get = function _AllureReport_publish_get() {
|
|
310
514
|
return __classPrivateFieldGet(this, _AllureReport_plugins, "f").some(({ enabled, options }) => enabled && options.publish);
|
|
311
515
|
}, _AllureReport_getPluginState = function _AllureReport_getPluginState(init, id) {
|
|
312
516
|
return init ? new DefaultPluginState({}) : __classPrivateFieldGet(this, _AllureReport_state, "f")?.[id];
|
package/dist/store/store.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { type AllureHistory, type AttachmentLink, type DefaultLabelsConfig, type EnvironmentsConfig, type HistoryDataPoint, type HistoryTestResult, type KnownTestFailure, type RepoData, type ReportVariables, type TestCase, type TestEnvGroup, type TestFixtureResult, type TestResult } from "@allurereport/core-api";
|
|
2
|
-
import { type AllureStore, type ResultFile, type TestResultFilter } from "@allurereport/plugin-api";
|
|
1
|
+
import { type AllureHistory, type AttachmentLink, type DefaultLabelsConfig, type EnvironmentsConfig, type HistoryDataPoint, type HistoryTestResult, type KnownTestFailure, type RepoData, type ReportVariables, type TestCase, type TestEnvGroup, type TestError, type TestFixtureResult, type TestResult } from "@allurereport/core-api";
|
|
2
|
+
import { type AllureStore, type AllureStoreDump, type ExitCode, type QualityGateValidationResult, type RealtimeEventsDispatcher, type RealtimeSubscriber, type ResultFile, type TestResultFilter } from "@allurereport/plugin-api";
|
|
3
3
|
import type { RawFixtureResult, RawMetadata, RawTestResult, ReaderContext, ResultsVisitor } from "@allurereport/reader-api";
|
|
4
|
-
|
|
5
|
-
|
|
4
|
+
export declare const mapToObject: <K extends string | number | symbol, T = any>(map: Map<K, T>) => Record<K, T>;
|
|
5
|
+
export declare const mergeMapWithRecord: <K extends string | number | symbol, T = any>(map: Map<K, T>, record: Record<K, T>) => Map<K, T>;
|
|
6
6
|
export declare class DefaultAllureStore implements AllureStore, ResultsVisitor {
|
|
7
7
|
#private;
|
|
8
8
|
readonly indexTestResultByTestCase: Map<string, TestResult[]>;
|
|
@@ -15,14 +15,20 @@ export declare class DefaultAllureStore implements AllureStore, ResultsVisitor {
|
|
|
15
15
|
constructor(params?: {
|
|
16
16
|
history?: AllureHistory;
|
|
17
17
|
known?: KnownTestFailure[];
|
|
18
|
-
|
|
18
|
+
realtimeDispatcher?: RealtimeEventsDispatcher;
|
|
19
|
+
realtimeSubscriber?: RealtimeSubscriber;
|
|
19
20
|
defaultLabels?: DefaultLabelsConfig;
|
|
21
|
+
environment?: string;
|
|
20
22
|
environmentsConfig?: EnvironmentsConfig;
|
|
21
23
|
reportVariables?: ReportVariables;
|
|
22
24
|
});
|
|
23
25
|
readHistory(): Promise<HistoryDataPoint[]>;
|
|
24
26
|
appendHistory(history: HistoryDataPoint): Promise<void>;
|
|
25
27
|
repoData(): Promise<RepoData | undefined>;
|
|
28
|
+
qualityGateResults(): Promise<QualityGateValidationResult[]>;
|
|
29
|
+
globalExitCode(): Promise<ExitCode | undefined>;
|
|
30
|
+
allGlobalErrors(): Promise<TestError[]>;
|
|
31
|
+
allGlobalAttachments(): Promise<AttachmentLink[]>;
|
|
26
32
|
visitTestResult(raw: RawTestResult, context: ReaderContext): Promise<void>;
|
|
27
33
|
visitTestFixtureResult(result: RawFixtureResult, context: ReaderContext): Promise<void>;
|
|
28
34
|
visitAttachmentFile(resultFile: ResultFile, context: ReaderContext): Promise<void>;
|
|
@@ -68,4 +74,6 @@ export declare class DefaultAllureStore implements AllureStore, ResultsVisitor {
|
|
|
68
74
|
envVariables(env: string): Promise<{
|
|
69
75
|
[x: string]: string;
|
|
70
76
|
}>;
|
|
77
|
+
dumpState(): AllureStoreDump;
|
|
78
|
+
restoreState(stateDump: AllureStoreDump, attachmentsContents?: Record<string, ResultFile>): Promise<void>;
|
|
71
79
|
}
|