@allurereport/core 3.0.0-beta.23 → 3.0.0-beta.25
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/report.js +25 -8
- 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
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
|
}
|
|
@@ -339,6 +340,9 @@ export class AllureReport {
|
|
|
339
340
|
: undefined;
|
|
340
341
|
const limitFn = pLimit(50);
|
|
341
342
|
const fns = pluginFilesEntries.map(([filename, filepath]) => limitFn(async () => {
|
|
343
|
+
if (cancelledPluginsIds.has(context.id)) {
|
|
344
|
+
return;
|
|
345
|
+
}
|
|
342
346
|
if (/^(data|widgets|index\.html$|summary\.json$)/.test(filename)) {
|
|
343
347
|
await __classPrivateFieldGet(this, _AllureReport_allureServiceClient, "f").addReportFile({
|
|
344
348
|
reportUuid: this.reportUuid,
|
|
@@ -356,7 +360,18 @@ export class AllureReport {
|
|
|
356
360
|
progressBar?.tick?.();
|
|
357
361
|
}));
|
|
358
362
|
progressBar?.render?.();
|
|
359
|
-
|
|
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
|
+
}
|
|
360
375
|
}
|
|
361
376
|
const summary = await plugin?.info?.(context, __classPrivateFieldGet(this, _AllureReport_store, "f"));
|
|
362
377
|
if (!summary) {
|
|
@@ -364,7 +379,7 @@ export class AllureReport {
|
|
|
364
379
|
}
|
|
365
380
|
summary.pullRequestHref = __classPrivateFieldGet(this, _AllureReport_ci, "f")?.pullRequestUrl;
|
|
366
381
|
summary.jobHref = __classPrivateFieldGet(this, _AllureReport_ci, "f")?.jobRunUrl;
|
|
367
|
-
if (context.publish && this.reportUrl) {
|
|
382
|
+
if (context.publish && this.reportUrl && !cancelledPluginsIds.has(context.id)) {
|
|
368
383
|
summary.remoteHref = `${this.reportUrl}/${context.id}/`;
|
|
369
384
|
remoteHrefs.push(summary.remoteHref);
|
|
370
385
|
}
|
|
@@ -376,7 +391,9 @@ export class AllureReport {
|
|
|
376
391
|
});
|
|
377
392
|
if (summaries.length > 1) {
|
|
378
393
|
const summaryPath = await generateSummary(__classPrivateFieldGet(this, _AllureReport_output, "f"), summaries);
|
|
379
|
-
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);
|
|
380
397
|
if (__classPrivateFieldGet(this, _AllureReport_instances, "a", _AllureReport_publish_get) && summaryPath && publishedReports.length > 1) {
|
|
381
398
|
await __classPrivateFieldGet(this, _AllureReport_allureServiceClient, "f")?.addReportFile({
|
|
382
399
|
reportUuid: this.reportUuid,
|
|
@@ -504,7 +521,7 @@ export class AllureReport {
|
|
|
504
521
|
__classPrivateFieldSet(this, _AllureReport_realTime, realTime, "f");
|
|
505
522
|
__classPrivateFieldSet(this, _AllureReport_stage, stage, "f");
|
|
506
523
|
if (__classPrivateFieldGet(this, _AllureReport_allureServiceClient, "f")) {
|
|
507
|
-
__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");
|
|
508
525
|
}
|
|
509
526
|
else if (historyPath) {
|
|
510
527
|
__classPrivateFieldSet(this, _AllureReport_history, new AllureLocalHistory(historyPath), "f");
|
|
@@ -527,7 +544,7 @@ export class AllureReport {
|
|
|
527
544
|
__classPrivateFieldSet(this, _AllureReport_reportFiles, reportFiles, "f");
|
|
528
545
|
__classPrivateFieldSet(this, _AllureReport_output, output, "f");
|
|
529
546
|
__classPrivateFieldSet(this, _AllureReport_history, __classPrivateFieldGet(this, _AllureReport_allureServiceClient, "f")
|
|
530
|
-
? new AllureRemoteHistory(__classPrivateFieldGet(this, _AllureReport_allureServiceClient, "f"))
|
|
547
|
+
? new AllureRemoteHistory(__classPrivateFieldGet(this, _AllureReport_allureServiceClient, "f"), __classPrivateFieldGet(this, _AllureReport_ci, "f")?.jobRunBranch)
|
|
531
548
|
: new AllureLocalHistory(historyPath), "f");
|
|
532
549
|
}
|
|
533
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.25",
|
|
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.25",
|
|
29
|
+
"@allurereport/core-api": "3.0.0-beta.25",
|
|
30
|
+
"@allurereport/plugin-allure2": "3.0.0-beta.25",
|
|
31
|
+
"@allurereport/plugin-api": "3.0.0-beta.25",
|
|
32
|
+
"@allurereport/plugin-awesome": "3.0.0-beta.25",
|
|
33
|
+
"@allurereport/plugin-classic": "3.0.0-beta.25",
|
|
34
|
+
"@allurereport/plugin-csv": "3.0.0-beta.25",
|
|
35
|
+
"@allurereport/plugin-dashboard": "3.0.0-beta.25",
|
|
36
|
+
"@allurereport/plugin-jira": "3.0.0-beta.25",
|
|
37
|
+
"@allurereport/plugin-log": "3.0.0-beta.25",
|
|
38
|
+
"@allurereport/plugin-progress": "3.0.0-beta.25",
|
|
39
|
+
"@allurereport/plugin-slack": "3.0.0-beta.25",
|
|
40
|
+
"@allurereport/plugin-testplan": "3.0.0-beta.25",
|
|
41
|
+
"@allurereport/reader": "3.0.0-beta.25",
|
|
42
|
+
"@allurereport/reader-api": "3.0.0-beta.25",
|
|
43
|
+
"@allurereport/service": "3.0.0-beta.25",
|
|
44
|
+
"@allurereport/summary": "3.0.0-beta.25",
|
|
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
|
-
};
|