@allurereport/plugin-testops 3.16.1 → 3.18.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -11,6 +11,7 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
|
|
|
11
11
|
};
|
|
12
12
|
var _LaunchGitFlow_instances, _LaunchGitFlow_ci, _LaunchGitFlow_gitFlow, _LaunchGitFlow_ancestorLimit, _LaunchGitFlow_logger, _LaunchGitFlow_classify;
|
|
13
13
|
import { collectGitFacts, isGitAvailable } from "@allurereport/git";
|
|
14
|
+
import { applyGitFactsOverrides } from "../utils/ciOverrides.js";
|
|
14
15
|
import { buildGitFlowContext, shouldAttachGitFlow } from "./context.js";
|
|
15
16
|
import { projectLaunchGitContext } from "./projection.js";
|
|
16
17
|
export class LaunchGitFlow {
|
|
@@ -29,11 +30,18 @@ export class LaunchGitFlow {
|
|
|
29
30
|
if (!shouldAttachGitFlow(__classPrivateFieldGet(this, _LaunchGitFlow_gitFlow, "f"))) {
|
|
30
31
|
return undefined;
|
|
31
32
|
}
|
|
32
|
-
|
|
33
|
-
|
|
33
|
+
const gitAvailable = isGitAvailable();
|
|
34
|
+
const collected = gitAvailable ? collectGitFacts({ ancestorLimit: __classPrivateFieldGet(this, _LaunchGitFlow_ancestorLimit, "f") }) : undefined;
|
|
35
|
+
const facts = applyGitFactsOverrides(collected);
|
|
36
|
+
if (!facts?.commit) {
|
|
37
|
+
if (!gitAvailable) {
|
|
38
|
+
__classPrivateFieldGet(this, _LaunchGitFlow_logger, "f").warn("git CLI is not available; continuing upload without git context");
|
|
39
|
+
}
|
|
40
|
+
else {
|
|
41
|
+
__classPrivateFieldGet(this, _LaunchGitFlow_logger, "f").warn("Git Flow metadata could not be collected; continuing upload without git context");
|
|
42
|
+
}
|
|
34
43
|
return undefined;
|
|
35
44
|
}
|
|
36
|
-
const facts = collectGitFacts({ ancestorLimit: __classPrivateFieldGet(this, _LaunchGitFlow_ancestorLimit, "f") });
|
|
37
45
|
const gitFlowContext = buildGitFlowContext({
|
|
38
46
|
ci: __classPrivateFieldGet(this, _LaunchGitFlow_ci, "f"),
|
|
39
47
|
facts,
|
|
@@ -1,2 +1,3 @@
|
|
|
1
|
-
import type
|
|
1
|
+
import { type CiDescriptor, type GitFacts } from "@allurereport/core-api";
|
|
2
2
|
export declare const applyCiOverrides: (ci: CiDescriptor) => CiDescriptor;
|
|
3
|
+
export declare const applyGitFactsOverrides: (facts: GitFacts | undefined) => GitFacts | undefined;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { env } from "node:process";
|
|
2
|
-
|
|
2
|
+
import { GitProvider } from "@allurereport/core-api";
|
|
3
|
+
const OVERRIDABLE_STRING_FIELDS = [
|
|
3
4
|
["jobUid", "ALLURE_JOB_UID"],
|
|
4
5
|
["jobUrl", "ALLURE_JOB_URL"],
|
|
5
6
|
["jobName", "ALLURE_JOB_NAME"],
|
|
@@ -7,14 +8,122 @@ const OVERRIDABLE_FIELDS = [
|
|
|
7
8
|
["jobRunUrl", "ALLURE_JOB_RUN_URL"],
|
|
8
9
|
["jobRunName", "ALLURE_JOB_RUN_NAME"],
|
|
9
10
|
["jobRunBranch", "ALLURE_JOB_RUN_BRANCH"],
|
|
11
|
+
["sourceBranch", "ALLURE_CI_SOURCE_BRANCH"],
|
|
12
|
+
["targetBranch", "ALLURE_CI_TARGET_BRANCH"],
|
|
13
|
+
["pullRequestName", "ALLURE_CI_PULL_REQUEST_TITLE"],
|
|
14
|
+
["pullRequestUrl", "ALLURE_CI_PULL_REQUEST_URL"],
|
|
10
15
|
];
|
|
16
|
+
const GIT_PROVIDER_VALUES = new Set(Object.values(GitProvider));
|
|
17
|
+
const nonBlank = (value) => {
|
|
18
|
+
const trimmed = value?.trim();
|
|
19
|
+
return trimmed ? trimmed : undefined;
|
|
20
|
+
};
|
|
21
|
+
const parseGitProvider = (value) => {
|
|
22
|
+
const normalized = nonBlank(value)?.toLowerCase();
|
|
23
|
+
if (!normalized || !GIT_PROVIDER_VALUES.has(normalized)) {
|
|
24
|
+
return undefined;
|
|
25
|
+
}
|
|
26
|
+
return normalized;
|
|
27
|
+
};
|
|
28
|
+
const parseFirstParentAncestors = (value) => {
|
|
29
|
+
const raw = nonBlank(value);
|
|
30
|
+
if (raw === undefined) {
|
|
31
|
+
return undefined;
|
|
32
|
+
}
|
|
33
|
+
return raw
|
|
34
|
+
.split(",")
|
|
35
|
+
.map((part) => part.trim())
|
|
36
|
+
.filter(Boolean);
|
|
37
|
+
};
|
|
38
|
+
const resolvePullRequestOverride = (ci) => {
|
|
39
|
+
const id = nonBlank(env.ALLURE_CI_PULL_REQUEST_ID) ?? nonBlank(ci.pullRequest?.id);
|
|
40
|
+
const url = nonBlank(env.ALLURE_CI_PULL_REQUEST_URL) ?? ci.pullRequest?.url;
|
|
41
|
+
const title = nonBlank(env.ALLURE_CI_PULL_REQUEST_TITLE) ?? ci.pullRequest?.title;
|
|
42
|
+
if (!id) {
|
|
43
|
+
return undefined;
|
|
44
|
+
}
|
|
45
|
+
return {
|
|
46
|
+
id,
|
|
47
|
+
url,
|
|
48
|
+
title,
|
|
49
|
+
};
|
|
50
|
+
};
|
|
51
|
+
const resolveRepositoryOverride = (ci, repositorySlugOverride, repositoryUrlOverride) => {
|
|
52
|
+
if (!repositorySlugOverride && !repositoryUrlOverride) {
|
|
53
|
+
return undefined;
|
|
54
|
+
}
|
|
55
|
+
const slug = repositorySlugOverride ?? nonBlank(ci.repository?.slug);
|
|
56
|
+
if (!slug) {
|
|
57
|
+
return undefined;
|
|
58
|
+
}
|
|
59
|
+
return {
|
|
60
|
+
slug,
|
|
61
|
+
url: repositoryUrlOverride ?? ci.repository?.url,
|
|
62
|
+
};
|
|
63
|
+
};
|
|
11
64
|
export const applyCiOverrides = (ci) => {
|
|
12
65
|
const overrides = {};
|
|
13
|
-
for (const [field, envVar] of
|
|
14
|
-
const value = env[envVar];
|
|
66
|
+
for (const [field, envVar] of OVERRIDABLE_STRING_FIELDS) {
|
|
67
|
+
const value = nonBlank(env[envVar]);
|
|
15
68
|
if (value) {
|
|
16
69
|
overrides[field] = value;
|
|
17
70
|
}
|
|
18
71
|
}
|
|
19
|
-
|
|
72
|
+
const repoNameOverride = nonBlank(env.ALLURE_CI_REPO_NAME);
|
|
73
|
+
const repositorySlugOverride = nonBlank(env.ALLURE_CI_REPOSITORY_SLUG);
|
|
74
|
+
const repositoryUrlOverride = nonBlank(env.ALLURE_CI_REPOSITORY_URL);
|
|
75
|
+
const providerOverride = parseGitProvider(env.ALLURE_CI_GIT_PROVIDER);
|
|
76
|
+
const repository = resolveRepositoryOverride(ci, repositorySlugOverride, repositoryUrlOverride);
|
|
77
|
+
const hasPullRequestEnv = Boolean(nonBlank(env.ALLURE_CI_PULL_REQUEST_ID) ||
|
|
78
|
+
nonBlank(env.ALLURE_CI_PULL_REQUEST_URL) ||
|
|
79
|
+
nonBlank(env.ALLURE_CI_PULL_REQUEST_TITLE));
|
|
80
|
+
const pullRequest = hasPullRequestEnv ? resolvePullRequestOverride(ci) : undefined;
|
|
81
|
+
const hasPullRequestObjectOverride = pullRequest !== undefined;
|
|
82
|
+
const hasRepoNameOverride = Boolean(repoNameOverride);
|
|
83
|
+
const hasRepositoryOverride = repository !== undefined;
|
|
84
|
+
const hasProviderOverride = providerOverride !== undefined;
|
|
85
|
+
if (Object.keys(overrides).length === 0 &&
|
|
86
|
+
!hasPullRequestObjectOverride &&
|
|
87
|
+
!hasRepoNameOverride &&
|
|
88
|
+
!hasRepositoryOverride &&
|
|
89
|
+
!hasProviderOverride) {
|
|
90
|
+
return ci;
|
|
91
|
+
}
|
|
92
|
+
return {
|
|
93
|
+
...ci,
|
|
94
|
+
...overrides,
|
|
95
|
+
...(hasRepoNameOverride ? { repoName: repoNameOverride } : {}),
|
|
96
|
+
...(hasRepositoryOverride ? { repository } : {}),
|
|
97
|
+
...(hasProviderOverride ? { provider: providerOverride } : {}),
|
|
98
|
+
...(hasPullRequestObjectOverride ? { pullRequest } : {}),
|
|
99
|
+
};
|
|
100
|
+
};
|
|
101
|
+
export const applyGitFactsOverrides = (facts) => {
|
|
102
|
+
const commitOverride = nonBlank(env.ALLURE_CI_COMMIT);
|
|
103
|
+
const ancestorsOverride = parseFirstParentAncestors(env.ALLURE_CI_FIRST_PARENT_ANCESTORS);
|
|
104
|
+
if (!commitOverride && ancestorsOverride === undefined) {
|
|
105
|
+
return facts;
|
|
106
|
+
}
|
|
107
|
+
if (commitOverride) {
|
|
108
|
+
if (!facts) {
|
|
109
|
+
return {
|
|
110
|
+
commit: commitOverride,
|
|
111
|
+
firstParentAncestors: ancestorsOverride ?? [],
|
|
112
|
+
branch: undefined,
|
|
113
|
+
};
|
|
114
|
+
}
|
|
115
|
+
const commitUnchanged = facts.commit === commitOverride;
|
|
116
|
+
return {
|
|
117
|
+
...facts,
|
|
118
|
+
commit: commitOverride,
|
|
119
|
+
firstParentAncestors: ancestorsOverride !== undefined ? ancestorsOverride : commitUnchanged ? facts.firstParentAncestors : [],
|
|
120
|
+
};
|
|
121
|
+
}
|
|
122
|
+
if (!facts?.commit) {
|
|
123
|
+
return facts;
|
|
124
|
+
}
|
|
125
|
+
return {
|
|
126
|
+
...facts,
|
|
127
|
+
firstParentAncestors: ancestorsOverride,
|
|
128
|
+
};
|
|
20
129
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@allurereport/plugin-testops",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.18.0",
|
|
4
4
|
"description": "Allure Plugin TestOps",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"allure",
|
|
@@ -32,14 +32,14 @@
|
|
|
32
32
|
"lint:fix": "oxlint --import-plugin --fix src test features stories"
|
|
33
33
|
},
|
|
34
34
|
"dependencies": {
|
|
35
|
-
"@allurereport/ci": "3.
|
|
36
|
-
"@allurereport/cli-commons": "3.
|
|
37
|
-
"@allurereport/core-api": "3.
|
|
38
|
-
"@allurereport/git": "3.
|
|
39
|
-
"@allurereport/plugin-api": "3.
|
|
40
|
-
"@allurereport/reader-api": "3.
|
|
41
|
-
"@allurereport/service": "3.
|
|
42
|
-
"axios": "^1.
|
|
35
|
+
"@allurereport/ci": "3.18.0",
|
|
36
|
+
"@allurereport/cli-commons": "3.18.0",
|
|
37
|
+
"@allurereport/core-api": "3.18.0",
|
|
38
|
+
"@allurereport/git": "3.18.0",
|
|
39
|
+
"@allurereport/plugin-api": "3.18.0",
|
|
40
|
+
"@allurereport/reader-api": "3.18.0",
|
|
41
|
+
"@allurereport/service": "3.18.0",
|
|
42
|
+
"axios": "^1.20.0",
|
|
43
43
|
"form-data": "^4.0.6",
|
|
44
44
|
"lodash-es": "^4.18.1",
|
|
45
45
|
"p-limit": "^7.3.0",
|