@allurereport/core 3.0.0-beta.22 → 3.0.0-beta.24
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/config.d.ts +5 -3
- package/dist/config.js +50 -9
- package/dist/history.js +2 -1
- package/dist/index.d.ts +0 -1
- package/dist/index.js +0 -1
- package/dist/qualityGate/qualityGate.js +13 -6
- package/dist/qualityGate/rules.js +6 -7
- package/dist/report.js +33 -14
- package/dist/store/store.d.ts +2 -2
- package/dist/store/store.js +29 -23
- package/package.json +19 -18
- package/dist/utils/git.d.ts +0 -2
- package/dist/utils/git.js +0 -46
package/dist/config.d.ts
CHANGED
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
import type { Config } from "@allurereport/plugin-api";
|
|
2
2
|
import type { FullConfig, PluginInstance } from "./api.js";
|
|
3
|
-
export declare const getPluginId: (key: string) => string;
|
|
4
|
-
export declare const findConfig: (cwd: string, configPath?: string) => Promise<string | undefined>;
|
|
5
3
|
export interface ConfigOverride {
|
|
6
4
|
name?: Config["name"];
|
|
7
5
|
output?: Config["output"];
|
|
@@ -9,11 +7,15 @@ export interface ConfigOverride {
|
|
|
9
7
|
knownIssuesPath?: Config["knownIssuesPath"];
|
|
10
8
|
plugins?: Config["plugins"];
|
|
11
9
|
}
|
|
10
|
+
export declare const getPluginId: (key: string) => string;
|
|
11
|
+
export declare const findConfig: (cwd: string, configPath?: string) => Promise<string | undefined>;
|
|
12
12
|
export declare const validateConfig: (config: Config) => {
|
|
13
13
|
valid: boolean;
|
|
14
14
|
fields: string[];
|
|
15
15
|
};
|
|
16
|
-
export declare const
|
|
16
|
+
export declare const loadYamlConfig: (configPath: string) => Promise<Config>;
|
|
17
|
+
export declare const loadJsonConfig: (configPath: string) => Promise<Config>;
|
|
18
|
+
export declare const loadJsConfig: (configPath: string) => Promise<Config>;
|
|
17
19
|
export declare const resolveConfig: (config: Config, override?: ConfigOverride) => Promise<FullConfig>;
|
|
18
20
|
export declare const readConfig: (cwd?: string, configPath?: string, override?: ConfigOverride) => Promise<FullConfig>;
|
|
19
21
|
export declare const getPluginInstance: (config: FullConfig, predicate: (plugin: PluginInstance) => boolean) => PluginInstance | undefined;
|
package/dist/config.js
CHANGED
|
@@ -1,16 +1,17 @@
|
|
|
1
1
|
import * as console from "node:console";
|
|
2
|
-
import { stat } from "node:fs/promises";
|
|
2
|
+
import { readFile, stat } from "node:fs/promises";
|
|
3
3
|
import { resolve } from "node:path";
|
|
4
4
|
import * as process from "node:process";
|
|
5
|
+
import { parse } from "yaml";
|
|
5
6
|
import { readKnownIssues } from "./known.js";
|
|
6
7
|
import { FileSystemReportFiles } from "./plugin.js";
|
|
7
8
|
import { importWrapper } from "./utils/module.js";
|
|
8
9
|
import { normalizeImportPath } from "./utils/path.js";
|
|
10
|
+
const CONFIG_FILENAMES = ["allurerc.js", "allurerc.mjs", "allurerc.json"];
|
|
11
|
+
const DEFAULT_CONFIG = {};
|
|
9
12
|
export const getPluginId = (key) => {
|
|
10
13
|
return key.replace(/^@.*\//, "").replace(/[/\\]/g, "-");
|
|
11
14
|
};
|
|
12
|
-
const configNames = ["allurerc.js", "allurerc.mjs"];
|
|
13
|
-
const defaultConfig = {};
|
|
14
15
|
export const findConfig = async (cwd, configPath) => {
|
|
15
16
|
if (configPath) {
|
|
16
17
|
const resolved = resolve(cwd, configPath);
|
|
@@ -25,8 +26,8 @@ export const findConfig = async (cwd, configPath) => {
|
|
|
25
26
|
}
|
|
26
27
|
throw new Error(`invalid config path ${resolved}: not a regular file`);
|
|
27
28
|
}
|
|
28
|
-
for (const
|
|
29
|
-
const resolved = resolve(cwd,
|
|
29
|
+
for (const configFilename of CONFIG_FILENAMES) {
|
|
30
|
+
const resolved = resolve(cwd, configFilename);
|
|
30
31
|
try {
|
|
31
32
|
const stats = await stat(resolved);
|
|
32
33
|
if (stats.isFile()) {
|
|
@@ -57,7 +58,33 @@ export const validateConfig = (config) => {
|
|
|
57
58
|
fields: unsupportedFields,
|
|
58
59
|
};
|
|
59
60
|
};
|
|
60
|
-
export const
|
|
61
|
+
export const loadYamlConfig = async (configPath) => {
|
|
62
|
+
try {
|
|
63
|
+
const rawConfig = await readFile(configPath, "utf-8");
|
|
64
|
+
const parsedConfig = parse(rawConfig);
|
|
65
|
+
return parsedConfig || DEFAULT_CONFIG;
|
|
66
|
+
}
|
|
67
|
+
catch (err) {
|
|
68
|
+
if (err?.code === "ENOENT") {
|
|
69
|
+
return DEFAULT_CONFIG;
|
|
70
|
+
}
|
|
71
|
+
throw err;
|
|
72
|
+
}
|
|
73
|
+
};
|
|
74
|
+
export const loadJsonConfig = async (configPath) => {
|
|
75
|
+
try {
|
|
76
|
+
const rawConfig = await readFile(configPath, "utf-8");
|
|
77
|
+
const parsedConfig = JSON.parse(rawConfig);
|
|
78
|
+
return parsedConfig || DEFAULT_CONFIG;
|
|
79
|
+
}
|
|
80
|
+
catch (err) {
|
|
81
|
+
if (err?.code === "ENOENT") {
|
|
82
|
+
return DEFAULT_CONFIG;
|
|
83
|
+
}
|
|
84
|
+
throw err;
|
|
85
|
+
}
|
|
86
|
+
};
|
|
87
|
+
export const loadJsConfig = async (configPath) => {
|
|
61
88
|
return (await import(normalizeImportPath(configPath))).default;
|
|
62
89
|
};
|
|
63
90
|
export const resolveConfig = async (config, override = {}) => {
|
|
@@ -98,9 +125,23 @@ export const resolveConfig = async (config, override = {}) => {
|
|
|
98
125
|
};
|
|
99
126
|
};
|
|
100
127
|
export const readConfig = async (cwd = process.cwd(), configPath, override) => {
|
|
101
|
-
const cfg = await findConfig(cwd, configPath);
|
|
102
|
-
|
|
103
|
-
|
|
128
|
+
const cfg = (await findConfig(cwd, configPath)) ?? "";
|
|
129
|
+
let config;
|
|
130
|
+
switch (true) {
|
|
131
|
+
case /allurerc\.json$/.test(cfg):
|
|
132
|
+
config = await loadJsonConfig(cfg);
|
|
133
|
+
break;
|
|
134
|
+
case /allurerc\.ya?ml$/.test(cfg):
|
|
135
|
+
config = await loadYamlConfig(cfg);
|
|
136
|
+
break;
|
|
137
|
+
case /allurerc\.(m|c)?js$/.test(cfg):
|
|
138
|
+
config = await loadJsConfig(cfg);
|
|
139
|
+
break;
|
|
140
|
+
default:
|
|
141
|
+
config = DEFAULT_CONFIG;
|
|
142
|
+
}
|
|
143
|
+
const fullConfig = await resolveConfig(config, override);
|
|
144
|
+
return fullConfig;
|
|
104
145
|
};
|
|
105
146
|
export const getPluginInstance = (config, predicate) => {
|
|
106
147
|
return config?.plugins?.find(predicate);
|
package/dist/history.js
CHANGED
|
@@ -4,11 +4,12 @@ import { isFileNotFoundError } from "./utils/misc.js";
|
|
|
4
4
|
const createHistoryItems = (testResults) => {
|
|
5
5
|
return testResults
|
|
6
6
|
.filter((tr) => tr.historyId)
|
|
7
|
-
.map(({ id, name, fullName, historyId, status, error: { message, trace } = {}, start, stop, duration, labels }) => {
|
|
7
|
+
.map(({ id, name, fullName, environment, historyId, status, error: { message, trace } = {}, start, stop, duration, labels, }) => {
|
|
8
8
|
return {
|
|
9
9
|
id,
|
|
10
10
|
name,
|
|
11
11
|
fullName,
|
|
12
|
+
environment,
|
|
12
13
|
status,
|
|
13
14
|
message,
|
|
14
15
|
trace,
|
package/dist/index.d.ts
CHANGED
|
@@ -2,7 +2,6 @@ export type * from "./api.js";
|
|
|
2
2
|
export * from "./utils/misc.js";
|
|
3
3
|
export * from "./utils/crypto.js";
|
|
4
4
|
export * from "./utils/path.js";
|
|
5
|
-
export * from "./utils/git.js";
|
|
6
5
|
export * from "./utils/new.js";
|
|
7
6
|
export * from "./utils/flaky.js";
|
|
8
7
|
export * from "./history.js";
|
package/dist/index.js
CHANGED
|
@@ -58,7 +58,7 @@ export class QualityGate {
|
|
|
58
58
|
if (fastFailed) {
|
|
59
59
|
break;
|
|
60
60
|
}
|
|
61
|
-
for (const [key,
|
|
61
|
+
for (const [key, expected] of Object.entries(ruleset)) {
|
|
62
62
|
if (key === "filter" || key === "id" || key === "fastFail") {
|
|
63
63
|
continue;
|
|
64
64
|
}
|
|
@@ -66,21 +66,28 @@ export class QualityGate {
|
|
|
66
66
|
if (!rule) {
|
|
67
67
|
throw new Error(`Rule ${key} is not provided. Make sure you have provided it in the "use" field of the quality gate config!`);
|
|
68
68
|
}
|
|
69
|
+
const trsToValidate = ruleset.filter ? trs.filter(ruleset.filter) : trs;
|
|
69
70
|
const ruleId = ruleset.id ? [ruleset.id, rule.rule].join("/") : rule.rule;
|
|
70
71
|
const result = await rule.validate({
|
|
71
|
-
|
|
72
|
-
|
|
72
|
+
trs: trsToValidate,
|
|
73
|
+
state: {
|
|
74
|
+
getResult: () => state?.getResult?.(ruleId),
|
|
75
|
+
setResult: (value) => state?.setResult?.(ruleId, value),
|
|
76
|
+
},
|
|
77
|
+
expected,
|
|
73
78
|
knownIssues,
|
|
74
|
-
state: state?.getResult?.(ruleId),
|
|
75
79
|
});
|
|
76
|
-
state?.setResult(ruleId, result.actual);
|
|
77
80
|
if (result.success) {
|
|
78
81
|
continue;
|
|
79
82
|
}
|
|
80
83
|
results.push({
|
|
81
84
|
...result,
|
|
85
|
+
expected,
|
|
82
86
|
rule: ruleset.id ? [ruleset.id, rule.rule].join("/") : rule.rule,
|
|
83
|
-
message: rule.message(
|
|
87
|
+
message: rule.message({
|
|
88
|
+
actual: result.actual,
|
|
89
|
+
expected,
|
|
90
|
+
}),
|
|
84
91
|
});
|
|
85
92
|
if (ruleset.fastFail) {
|
|
86
93
|
fastFailed = true;
|
|
@@ -3,27 +3,27 @@ import { bold } from "yoctocolors";
|
|
|
3
3
|
export const maxFailuresRule = {
|
|
4
4
|
rule: "maxFailures",
|
|
5
5
|
message: ({ actual, expected }) => `The number of failed tests ${bold(String(actual))} exceeds the allowed threshold value ${bold(String(expected))}`,
|
|
6
|
-
validate: async ({ trs, knownIssues, expected, state
|
|
6
|
+
validate: async ({ trs, knownIssues, expected, state }) => {
|
|
7
7
|
const knownIssuesHistoryIds = knownIssues.map(({ historyId }) => historyId);
|
|
8
8
|
const unknown = trs.filter((tr) => !tr.historyId || !knownIssuesHistoryIds.includes(tr.historyId));
|
|
9
9
|
const failedTrs = unknown.filter(filterUnsuccessful);
|
|
10
|
-
const actual = failedTrs.length + state;
|
|
10
|
+
const actual = failedTrs.length + (state.getResult() ?? 0);
|
|
11
|
+
state.setResult(actual);
|
|
11
12
|
return {
|
|
12
13
|
success: actual <= expected,
|
|
13
14
|
actual,
|
|
14
|
-
expected,
|
|
15
15
|
};
|
|
16
16
|
},
|
|
17
17
|
};
|
|
18
18
|
export const minTestsCountRule = {
|
|
19
19
|
rule: "minTestsCount",
|
|
20
20
|
message: ({ actual, expected }) => `The total number of tests ${bold(String(actual))} is less than the expected threshold value ${bold(String(expected))}`,
|
|
21
|
-
validate: async ({ trs, expected, state
|
|
22
|
-
const actual = trs.length + state;
|
|
21
|
+
validate: async ({ trs, expected, state }) => {
|
|
22
|
+
const actual = trs.length + (state.getResult() ?? 0);
|
|
23
|
+
state.setResult(actual);
|
|
23
24
|
return {
|
|
24
25
|
success: actual >= expected,
|
|
25
26
|
actual,
|
|
26
|
-
expected,
|
|
27
27
|
};
|
|
28
28
|
},
|
|
29
29
|
};
|
|
@@ -38,7 +38,6 @@ export const successRateRule = {
|
|
|
38
38
|
return {
|
|
39
39
|
success: rate >= expected,
|
|
40
40
|
actual: rate,
|
|
41
|
-
expected,
|
|
42
41
|
};
|
|
43
42
|
},
|
|
44
43
|
};
|
package/dist/report.js
CHANGED
|
@@ -107,7 +107,7 @@ export class AllureReport {
|
|
|
107
107
|
});
|
|
108
108
|
};
|
|
109
109
|
this.start = async () => {
|
|
110
|
-
const
|
|
110
|
+
const branch = __classPrivateFieldGet(this, _AllureReport_ci, "f")?.jobRunBranch;
|
|
111
111
|
await __classPrivateFieldGet(this, _AllureReport_store, "f").readHistory();
|
|
112
112
|
if (__classPrivateFieldGet(this, _AllureReport_executionStage, "f") === "running") {
|
|
113
113
|
throw new Error("the report is already started");
|
|
@@ -116,11 +116,11 @@ export class AllureReport {
|
|
|
116
116
|
throw new Error("the report is already stopped, the restart isn't supported at the moment");
|
|
117
117
|
}
|
|
118
118
|
__classPrivateFieldSet(this, _AllureReport_executionStage, "running", "f");
|
|
119
|
-
if (__classPrivateFieldGet(this, _AllureReport_allureServiceClient, "f") && __classPrivateFieldGet(this, _AllureReport_instances, "a", _AllureReport_publish_get) &&
|
|
119
|
+
if (__classPrivateFieldGet(this, _AllureReport_allureServiceClient, "f") && __classPrivateFieldGet(this, _AllureReport_instances, "a", _AllureReport_publish_get) && branch) {
|
|
120
120
|
const { url } = await __classPrivateFieldGet(this, _AllureReport_allureServiceClient, "f").createReport({
|
|
121
121
|
reportUuid: this.reportUuid,
|
|
122
122
|
reportName: __classPrivateFieldGet(this, _AllureReport_reportName, "f"),
|
|
123
|
-
branch
|
|
123
|
+
branch,
|
|
124
124
|
});
|
|
125
125
|
this.reportUrl = url;
|
|
126
126
|
}
|
|
@@ -312,6 +312,7 @@ export class AllureReport {
|
|
|
312
312
|
this.done = async () => {
|
|
313
313
|
const summaries = [];
|
|
314
314
|
const remoteHrefs = [];
|
|
315
|
+
const cancelledPluginsIds = new Set();
|
|
315
316
|
if (__classPrivateFieldGet(this, _AllureReport_executionStage, "f") !== "running") {
|
|
316
317
|
throw new Error(initRequired);
|
|
317
318
|
}
|
|
@@ -331,12 +332,17 @@ export class AllureReport {
|
|
|
331
332
|
if (__classPrivateFieldGet(this, _AllureReport_allureServiceClient, "f") && context.publish) {
|
|
332
333
|
const pluginFiles = (await context.state.get("files")) ?? {};
|
|
333
334
|
const pluginFilesEntries = Object.entries(pluginFiles);
|
|
334
|
-
const progressBar =
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
335
|
+
const progressBar = pluginFilesEntries?.length > 0
|
|
336
|
+
? new ProgressBar(`Publishing "${context.id}" report [:bar] :current/:total`, {
|
|
337
|
+
total: pluginFilesEntries.length,
|
|
338
|
+
width: 20,
|
|
339
|
+
})
|
|
340
|
+
: undefined;
|
|
338
341
|
const limitFn = pLimit(50);
|
|
339
342
|
const fns = pluginFilesEntries.map(([filename, filepath]) => limitFn(async () => {
|
|
343
|
+
if (cancelledPluginsIds.has(context.id)) {
|
|
344
|
+
return;
|
|
345
|
+
}
|
|
340
346
|
if (/^(data|widgets|index\.html$|summary\.json$)/.test(filename)) {
|
|
341
347
|
await __classPrivateFieldGet(this, _AllureReport_allureServiceClient, "f").addReportFile({
|
|
342
348
|
reportUuid: this.reportUuid,
|
|
@@ -351,10 +357,21 @@ export class AllureReport {
|
|
|
351
357
|
filepath,
|
|
352
358
|
});
|
|
353
359
|
}
|
|
354
|
-
progressBar
|
|
360
|
+
progressBar?.tick?.();
|
|
355
361
|
}));
|
|
356
|
-
progressBar
|
|
357
|
-
|
|
362
|
+
progressBar?.render?.();
|
|
363
|
+
try {
|
|
364
|
+
await Promise.all(fns);
|
|
365
|
+
}
|
|
366
|
+
catch (err) {
|
|
367
|
+
cancelledPluginsIds.add(context.id);
|
|
368
|
+
await __classPrivateFieldGet(this, _AllureReport_allureServiceClient, "f").deleteReport({
|
|
369
|
+
reportUuid: this.reportUuid,
|
|
370
|
+
pluginId: context.id,
|
|
371
|
+
});
|
|
372
|
+
console.error(`Plugin "${context.id}" upload has failed, the plugin won't be published`);
|
|
373
|
+
console.error(err);
|
|
374
|
+
}
|
|
358
375
|
}
|
|
359
376
|
const summary = await plugin?.info?.(context, __classPrivateFieldGet(this, _AllureReport_store, "f"));
|
|
360
377
|
if (!summary) {
|
|
@@ -362,7 +379,7 @@ export class AllureReport {
|
|
|
362
379
|
}
|
|
363
380
|
summary.pullRequestHref = __classPrivateFieldGet(this, _AllureReport_ci, "f")?.pullRequestUrl;
|
|
364
381
|
summary.jobHref = __classPrivateFieldGet(this, _AllureReport_ci, "f")?.jobRunUrl;
|
|
365
|
-
if (context.publish && this.reportUrl) {
|
|
382
|
+
if (context.publish && this.reportUrl && !cancelledPluginsIds.has(context.id)) {
|
|
366
383
|
summary.remoteHref = `${this.reportUrl}/${context.id}/`;
|
|
367
384
|
remoteHrefs.push(summary.remoteHref);
|
|
368
385
|
}
|
|
@@ -374,7 +391,9 @@ export class AllureReport {
|
|
|
374
391
|
});
|
|
375
392
|
if (summaries.length > 1) {
|
|
376
393
|
const summaryPath = await generateSummary(__classPrivateFieldGet(this, _AllureReport_output, "f"), summaries);
|
|
377
|
-
const publishedReports = __classPrivateFieldGet(this, _AllureReport_plugins, "f")
|
|
394
|
+
const publishedReports = __classPrivateFieldGet(this, _AllureReport_plugins, "f")
|
|
395
|
+
.map((plugin) => !!plugin?.options?.publish && !cancelledPluginsIds.has(plugin.id))
|
|
396
|
+
.filter(Boolean);
|
|
378
397
|
if (__classPrivateFieldGet(this, _AllureReport_instances, "a", _AllureReport_publish_get) && summaryPath && publishedReports.length > 1) {
|
|
379
398
|
await __classPrivateFieldGet(this, _AllureReport_allureServiceClient, "f")?.addReportFile({
|
|
380
399
|
reportUuid: this.reportUuid,
|
|
@@ -502,7 +521,7 @@ export class AllureReport {
|
|
|
502
521
|
__classPrivateFieldSet(this, _AllureReport_realTime, realTime, "f");
|
|
503
522
|
__classPrivateFieldSet(this, _AllureReport_stage, stage, "f");
|
|
504
523
|
if (__classPrivateFieldGet(this, _AllureReport_allureServiceClient, "f")) {
|
|
505
|
-
__classPrivateFieldSet(this, _AllureReport_history, new AllureRemoteHistory(__classPrivateFieldGet(this, _AllureReport_allureServiceClient, "f")), "f");
|
|
524
|
+
__classPrivateFieldSet(this, _AllureReport_history, new AllureRemoteHistory(__classPrivateFieldGet(this, _AllureReport_allureServiceClient, "f"), __classPrivateFieldGet(this, _AllureReport_ci, "f")?.jobRunBranch), "f");
|
|
506
525
|
}
|
|
507
526
|
else if (historyPath) {
|
|
508
527
|
__classPrivateFieldSet(this, _AllureReport_history, new AllureLocalHistory(historyPath), "f");
|
|
@@ -525,7 +544,7 @@ export class AllureReport {
|
|
|
525
544
|
__classPrivateFieldSet(this, _AllureReport_reportFiles, reportFiles, "f");
|
|
526
545
|
__classPrivateFieldSet(this, _AllureReport_output, output, "f");
|
|
527
546
|
__classPrivateFieldSet(this, _AllureReport_history, __classPrivateFieldGet(this, _AllureReport_allureServiceClient, "f")
|
|
528
|
-
? new AllureRemoteHistory(__classPrivateFieldGet(this, _AllureReport_allureServiceClient, "f"))
|
|
547
|
+
? new AllureRemoteHistory(__classPrivateFieldGet(this, _AllureReport_allureServiceClient, "f"), __classPrivateFieldGet(this, _AllureReport_ci, "f")?.jobRunBranch)
|
|
529
548
|
: new AllureLocalHistory(historyPath), "f");
|
|
530
549
|
}
|
|
531
550
|
get hasQualityGate() {
|
package/dist/store/store.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type AllureHistory, type AttachmentLink, type DefaultLabelsConfig, type EnvironmentsConfig, type HistoryDataPoint, type HistoryTestResult, type KnownTestFailure, type
|
|
1
|
+
import { type AllureHistory, type AttachmentLink, type DefaultLabelsConfig, type EnvironmentsConfig, type HistoryDataPoint, type HistoryTestResult, type KnownTestFailure, type ReportVariables, type Statistic, type TestCase, type TestEnvGroup, type TestError, type TestFixtureResult, type TestResult } from "@allurereport/core-api";
|
|
2
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
4
|
export declare const mapToObject: <K extends string | number | symbol, T = any>(map: Map<K, T>) => Record<K, T>;
|
|
@@ -24,7 +24,6 @@ export declare class DefaultAllureStore implements AllureStore, ResultsVisitor {
|
|
|
24
24
|
});
|
|
25
25
|
readHistory(): Promise<HistoryDataPoint[]>;
|
|
26
26
|
appendHistory(history: HistoryDataPoint): Promise<void>;
|
|
27
|
-
repoData(): Promise<RepoData | undefined>;
|
|
28
27
|
qualityGateResults(): Promise<QualityGateValidationResult[]>;
|
|
29
28
|
globalExitCode(): Promise<ExitCode | undefined>;
|
|
30
29
|
allGlobalErrors(): Promise<TestError[]>;
|
|
@@ -44,6 +43,7 @@ export declare class DefaultAllureStore implements AllureStore, ResultsVisitor {
|
|
|
44
43
|
allMetadata(): Promise<Record<string, any>>;
|
|
45
44
|
allFixtures(): Promise<TestFixtureResult[]>;
|
|
46
45
|
allHistoryDataPoints(): Promise<HistoryDataPoint[]>;
|
|
46
|
+
allHistoryDataPointsByEnvironment(environment: string): Promise<HistoryDataPoint[]>;
|
|
47
47
|
allKnownIssues(): Promise<KnownTestFailure[]>;
|
|
48
48
|
allNewTestResults(): Promise<TestResult[]>;
|
|
49
49
|
testCaseById(tcId: string): Promise<TestCase | undefined>;
|
package/dist/store/store.js
CHANGED
|
@@ -9,11 +9,10 @@ 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 _DefaultAllureStore_instances, _DefaultAllureStore_testResults, _DefaultAllureStore_attachments, _DefaultAllureStore_attachmentContents, _DefaultAllureStore_testCases, _DefaultAllureStore_metadata, _DefaultAllureStore_history, _DefaultAllureStore_known, _DefaultAllureStore_fixtures, _DefaultAllureStore_defaultLabels, _DefaultAllureStore_environment, _DefaultAllureStore_environmentsConfig, _DefaultAllureStore_reportVariables, _DefaultAllureStore_realtimeDispatcher, _DefaultAllureStore_realtimeSubscriber, _DefaultAllureStore_globalAttachments, _DefaultAllureStore_globalErrors, _DefaultAllureStore_globalExitCode, _DefaultAllureStore_qualityGateResultsByRules, _DefaultAllureStore_historyPoints,
|
|
12
|
+
var _DefaultAllureStore_instances, _DefaultAllureStore_testResults, _DefaultAllureStore_attachments, _DefaultAllureStore_attachmentContents, _DefaultAllureStore_testCases, _DefaultAllureStore_metadata, _DefaultAllureStore_history, _DefaultAllureStore_known, _DefaultAllureStore_fixtures, _DefaultAllureStore_defaultLabels, _DefaultAllureStore_environment, _DefaultAllureStore_environmentsConfig, _DefaultAllureStore_reportVariables, _DefaultAllureStore_realtimeDispatcher, _DefaultAllureStore_realtimeSubscriber, _DefaultAllureStore_globalAttachments, _DefaultAllureStore_globalErrors, _DefaultAllureStore_globalExitCode, _DefaultAllureStore_qualityGateResultsByRules, _DefaultAllureStore_historyPoints, _DefaultAllureStore_environments, _DefaultAllureStore_addEnvironments;
|
|
13
13
|
import { DEFAULT_ENVIRONMENT, compareBy, getWorstStatus, htrsByTr, matchEnvironment, nullsLast, ordinal, reverse, } from "@allurereport/core-api";
|
|
14
14
|
import { md5, } from "@allurereport/plugin-api";
|
|
15
15
|
import { isFlaky } from "../utils/flaky.js";
|
|
16
|
-
import { getGitBranch, getGitRepoName } from "../utils/git.js";
|
|
17
16
|
import { getStatusTransition } from "../utils/new.js";
|
|
18
17
|
import { testFixtureResultRawToState, testResultRawToState } from "./convert.js";
|
|
19
18
|
const index = (indexMap, key, ...items) => {
|
|
@@ -92,7 +91,6 @@ export class DefaultAllureStore {
|
|
|
92
91
|
_DefaultAllureStore_globalExitCode.set(this, void 0);
|
|
93
92
|
_DefaultAllureStore_qualityGateResultsByRules.set(this, {});
|
|
94
93
|
_DefaultAllureStore_historyPoints.set(this, []);
|
|
95
|
-
_DefaultAllureStore_repoData.set(this, void 0);
|
|
96
94
|
_DefaultAllureStore_environments.set(this, []);
|
|
97
95
|
const { history, known = [], realtimeDispatcher, realtimeSubscriber, defaultLabels = {}, environment, environmentsConfig = {}, reportVariables = {}, } = params ?? {};
|
|
98
96
|
const environments = Object.keys(environmentsConfig)
|
|
@@ -143,8 +141,7 @@ export class DefaultAllureStore {
|
|
|
143
141
|
if (!__classPrivateFieldGet(this, _DefaultAllureStore_history, "f")) {
|
|
144
142
|
return [];
|
|
145
143
|
}
|
|
146
|
-
|
|
147
|
-
__classPrivateFieldSet(this, _DefaultAllureStore_historyPoints, (await __classPrivateFieldGet(this, _DefaultAllureStore_history, "f").readHistory(repoData.branch)) ?? [], "f");
|
|
144
|
+
__classPrivateFieldSet(this, _DefaultAllureStore_historyPoints, (await __classPrivateFieldGet(this, _DefaultAllureStore_history, "f").readHistory()) ?? [], "f");
|
|
148
145
|
__classPrivateFieldGet(this, _DefaultAllureStore_historyPoints, "f").sort(compareBy("timestamp", reverse(ordinal())));
|
|
149
146
|
return __classPrivateFieldGet(this, _DefaultAllureStore_historyPoints, "f");
|
|
150
147
|
}
|
|
@@ -152,24 +149,8 @@ export class DefaultAllureStore {
|
|
|
152
149
|
if (!__classPrivateFieldGet(this, _DefaultAllureStore_history, "f")) {
|
|
153
150
|
return;
|
|
154
151
|
}
|
|
155
|
-
const repoData = await this.repoData();
|
|
156
152
|
__classPrivateFieldGet(this, _DefaultAllureStore_historyPoints, "f").push(history);
|
|
157
|
-
await __classPrivateFieldGet(this, _DefaultAllureStore_history, "f").appendHistory(history
|
|
158
|
-
}
|
|
159
|
-
async repoData() {
|
|
160
|
-
if (__classPrivateFieldGet(this, _DefaultAllureStore_repoData, "f")) {
|
|
161
|
-
return __classPrivateFieldGet(this, _DefaultAllureStore_repoData, "f");
|
|
162
|
-
}
|
|
163
|
-
try {
|
|
164
|
-
__classPrivateFieldSet(this, _DefaultAllureStore_repoData, {
|
|
165
|
-
name: await getGitRepoName(),
|
|
166
|
-
branch: await getGitBranch(),
|
|
167
|
-
}, "f");
|
|
168
|
-
return __classPrivateFieldGet(this, _DefaultAllureStore_repoData, "f");
|
|
169
|
-
}
|
|
170
|
-
catch (err) {
|
|
171
|
-
return undefined;
|
|
172
|
-
}
|
|
153
|
+
await __classPrivateFieldGet(this, _DefaultAllureStore_history, "f").appendHistory(history);
|
|
173
154
|
}
|
|
174
155
|
async qualityGateResults() {
|
|
175
156
|
return Object.values(__classPrivateFieldGet(this, _DefaultAllureStore_qualityGateResultsByRules, "f"));
|
|
@@ -295,6 +276,31 @@ export class DefaultAllureStore {
|
|
|
295
276
|
async allHistoryDataPoints() {
|
|
296
277
|
return __classPrivateFieldGet(this, _DefaultAllureStore_historyPoints, "f");
|
|
297
278
|
}
|
|
279
|
+
async allHistoryDataPointsByEnvironment(environment) {
|
|
280
|
+
return __classPrivateFieldGet(this, _DefaultAllureStore_historyPoints, "f").reduce((result, dp) => {
|
|
281
|
+
const filteredTestResults = [];
|
|
282
|
+
for (const tr of Object.values(dp.testResults)) {
|
|
283
|
+
const hasLabels = tr.labels && tr.labels.length > 0;
|
|
284
|
+
const trEnvironment = tr.environment ??
|
|
285
|
+
(hasLabels ? matchEnvironment(__classPrivateFieldGet(this, _DefaultAllureStore_environmentsConfig, "f"), tr) : undefined);
|
|
286
|
+
if (trEnvironment === environment) {
|
|
287
|
+
filteredTestResults.push(tr);
|
|
288
|
+
}
|
|
289
|
+
}
|
|
290
|
+
const hasNoEnvironmentTestResults = filteredTestResults.length === 0;
|
|
291
|
+
result.push({
|
|
292
|
+
...dp,
|
|
293
|
+
testResults: hasNoEnvironmentTestResults
|
|
294
|
+
? {}
|
|
295
|
+
: filteredTestResults.reduce((acc, tr) => {
|
|
296
|
+
acc[tr.historyId] = tr;
|
|
297
|
+
return acc;
|
|
298
|
+
}, {}),
|
|
299
|
+
knownTestCaseIds: hasNoEnvironmentTestResults ? [] : filteredTestResults.map((tr) => tr.id),
|
|
300
|
+
});
|
|
301
|
+
return result;
|
|
302
|
+
}, []);
|
|
303
|
+
}
|
|
298
304
|
async allKnownIssues() {
|
|
299
305
|
return __classPrivateFieldGet(this, _DefaultAllureStore_known, "f");
|
|
300
306
|
}
|
|
@@ -618,7 +624,7 @@ export class DefaultAllureStore {
|
|
|
618
624
|
Object.assign(__classPrivateFieldGet(this, _DefaultAllureStore_qualityGateResultsByRules, "f"), qualityGateResultsByRules);
|
|
619
625
|
}
|
|
620
626
|
}
|
|
621
|
-
_DefaultAllureStore_testResults = new WeakMap(), _DefaultAllureStore_attachments = new WeakMap(), _DefaultAllureStore_attachmentContents = new WeakMap(), _DefaultAllureStore_testCases = new WeakMap(), _DefaultAllureStore_metadata = new WeakMap(), _DefaultAllureStore_history = new WeakMap(), _DefaultAllureStore_known = new WeakMap(), _DefaultAllureStore_fixtures = new WeakMap(), _DefaultAllureStore_defaultLabels = new WeakMap(), _DefaultAllureStore_environment = new WeakMap(), _DefaultAllureStore_environmentsConfig = new WeakMap(), _DefaultAllureStore_reportVariables = new WeakMap(), _DefaultAllureStore_realtimeDispatcher = new WeakMap(), _DefaultAllureStore_realtimeSubscriber = new WeakMap(), _DefaultAllureStore_globalAttachments = new WeakMap(), _DefaultAllureStore_globalErrors = new WeakMap(), _DefaultAllureStore_globalExitCode = new WeakMap(), _DefaultAllureStore_qualityGateResultsByRules = new WeakMap(), _DefaultAllureStore_historyPoints = new WeakMap(),
|
|
627
|
+
_DefaultAllureStore_testResults = new WeakMap(), _DefaultAllureStore_attachments = new WeakMap(), _DefaultAllureStore_attachmentContents = new WeakMap(), _DefaultAllureStore_testCases = new WeakMap(), _DefaultAllureStore_metadata = new WeakMap(), _DefaultAllureStore_history = new WeakMap(), _DefaultAllureStore_known = new WeakMap(), _DefaultAllureStore_fixtures = new WeakMap(), _DefaultAllureStore_defaultLabels = new WeakMap(), _DefaultAllureStore_environment = new WeakMap(), _DefaultAllureStore_environmentsConfig = new WeakMap(), _DefaultAllureStore_reportVariables = new WeakMap(), _DefaultAllureStore_realtimeDispatcher = new WeakMap(), _DefaultAllureStore_realtimeSubscriber = new WeakMap(), _DefaultAllureStore_globalAttachments = new WeakMap(), _DefaultAllureStore_globalErrors = new WeakMap(), _DefaultAllureStore_globalExitCode = new WeakMap(), _DefaultAllureStore_qualityGateResultsByRules = new WeakMap(), _DefaultAllureStore_historyPoints = new WeakMap(), _DefaultAllureStore_environments = new WeakMap(), _DefaultAllureStore_instances = new WeakSet(), _DefaultAllureStore_addEnvironments = function _DefaultAllureStore_addEnvironments(envs) {
|
|
622
628
|
if (__classPrivateFieldGet(this, _DefaultAllureStore_environments, "f").length === 0) {
|
|
623
629
|
__classPrivateFieldGet(this, _DefaultAllureStore_environments, "f").push(DEFAULT_ENVIRONMENT);
|
|
624
630
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@allurereport/core",
|
|
3
|
-
"version": "3.0.0-beta.
|
|
3
|
+
"version": "3.0.0-beta.24",
|
|
4
4
|
"description": "Collection of generic Allure utilities used across the entire project",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"allure"
|
|
@@ -25,28 +25,29 @@
|
|
|
25
25
|
"test": "vitest run"
|
|
26
26
|
},
|
|
27
27
|
"dependencies": {
|
|
28
|
-
"@allurereport/ci": "3.0.0-beta.
|
|
29
|
-
"@allurereport/core-api": "3.0.0-beta.
|
|
30
|
-
"@allurereport/plugin-allure2": "3.0.0-beta.
|
|
31
|
-
"@allurereport/plugin-api": "3.0.0-beta.
|
|
32
|
-
"@allurereport/plugin-awesome": "3.0.0-beta.
|
|
33
|
-
"@allurereport/plugin-classic": "3.0.0-beta.
|
|
34
|
-
"@allurereport/plugin-csv": "3.0.0-beta.
|
|
35
|
-
"@allurereport/plugin-dashboard": "3.0.0-beta.
|
|
36
|
-
"@allurereport/plugin-jira": "3.0.0-beta.
|
|
37
|
-
"@allurereport/plugin-log": "3.0.0-beta.
|
|
38
|
-
"@allurereport/plugin-progress": "3.0.0-beta.
|
|
39
|
-
"@allurereport/plugin-slack": "3.0.0-beta.
|
|
40
|
-
"@allurereport/plugin-testplan": "3.0.0-beta.
|
|
41
|
-
"@allurereport/reader": "3.0.0-beta.
|
|
42
|
-
"@allurereport/reader-api": "3.0.0-beta.
|
|
43
|
-
"@allurereport/service": "3.0.0-beta.
|
|
44
|
-
"@allurereport/summary": "3.0.0-beta.
|
|
28
|
+
"@allurereport/ci": "3.0.0-beta.24",
|
|
29
|
+
"@allurereport/core-api": "3.0.0-beta.24",
|
|
30
|
+
"@allurereport/plugin-allure2": "3.0.0-beta.24",
|
|
31
|
+
"@allurereport/plugin-api": "3.0.0-beta.24",
|
|
32
|
+
"@allurereport/plugin-awesome": "3.0.0-beta.24",
|
|
33
|
+
"@allurereport/plugin-classic": "3.0.0-beta.24",
|
|
34
|
+
"@allurereport/plugin-csv": "3.0.0-beta.24",
|
|
35
|
+
"@allurereport/plugin-dashboard": "3.0.0-beta.24",
|
|
36
|
+
"@allurereport/plugin-jira": "3.0.0-beta.24",
|
|
37
|
+
"@allurereport/plugin-log": "3.0.0-beta.24",
|
|
38
|
+
"@allurereport/plugin-progress": "3.0.0-beta.24",
|
|
39
|
+
"@allurereport/plugin-slack": "3.0.0-beta.24",
|
|
40
|
+
"@allurereport/plugin-testplan": "3.0.0-beta.24",
|
|
41
|
+
"@allurereport/reader": "3.0.0-beta.24",
|
|
42
|
+
"@allurereport/reader-api": "3.0.0-beta.24",
|
|
43
|
+
"@allurereport/service": "3.0.0-beta.24",
|
|
44
|
+
"@allurereport/summary": "3.0.0-beta.24",
|
|
45
45
|
"handlebars": "^4.7.8",
|
|
46
46
|
"markdown-it": "^14.1.0",
|
|
47
47
|
"node-stream-zip": "^1.15.0",
|
|
48
48
|
"p-limit": "^7.2.0",
|
|
49
49
|
"progress": "^2.0.3",
|
|
50
|
+
"yaml": "^2.8.1",
|
|
50
51
|
"yoctocolors": "^2.1.1",
|
|
51
52
|
"zip-stream": "^7.0.2"
|
|
52
53
|
},
|
package/dist/utils/git.d.ts
DELETED
package/dist/utils/git.js
DELETED
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
import { spawn } from "node:child_process";
|
|
2
|
-
import { basename } from "node:path";
|
|
3
|
-
export const getGitBranch = (cwd) => {
|
|
4
|
-
return new Promise((resolve, reject) => {
|
|
5
|
-
const git = spawn("git", ["rev-parse", "--abbrev-ref", "HEAD"], { cwd });
|
|
6
|
-
let output = "";
|
|
7
|
-
let errorOutput = "";
|
|
8
|
-
git.stdout.on("data", (data) => {
|
|
9
|
-
output += data;
|
|
10
|
-
});
|
|
11
|
-
git.stderr.on("data", (data) => {
|
|
12
|
-
errorOutput += data;
|
|
13
|
-
});
|
|
14
|
-
git.on("close", (code) => {
|
|
15
|
-
if (code !== 0) {
|
|
16
|
-
return reject(new Error(errorOutput || "Git command failed"));
|
|
17
|
-
}
|
|
18
|
-
return resolve(output.trim());
|
|
19
|
-
});
|
|
20
|
-
git.on("error", (err) => {
|
|
21
|
-
return reject(err);
|
|
22
|
-
});
|
|
23
|
-
});
|
|
24
|
-
};
|
|
25
|
-
export const getGitRepoName = (cwd) => {
|
|
26
|
-
return new Promise((resolve, reject) => {
|
|
27
|
-
const git = spawn("git", ["rev-parse", "--show-toplevel"], { cwd });
|
|
28
|
-
let output = "";
|
|
29
|
-
let errorOutput = "";
|
|
30
|
-
git.stdout.on("data", (data) => {
|
|
31
|
-
output += data;
|
|
32
|
-
});
|
|
33
|
-
git.stderr.on("data", (data) => {
|
|
34
|
-
errorOutput += data;
|
|
35
|
-
});
|
|
36
|
-
git.on("close", (code) => {
|
|
37
|
-
if (code !== 0) {
|
|
38
|
-
return reject(new Error(errorOutput || "Git command failed"));
|
|
39
|
-
}
|
|
40
|
-
return resolve(basename(output.trim()));
|
|
41
|
-
});
|
|
42
|
-
git.on("error", (err) => {
|
|
43
|
-
return reject(err);
|
|
44
|
-
});
|
|
45
|
-
});
|
|
46
|
-
};
|