rhdh-e2e-test-utils 1.1.8 → 1.1.10
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.
|
@@ -7,8 +7,8 @@ import { resolve } from "path";
|
|
|
7
7
|
export const baseConfig = {
|
|
8
8
|
testDir: "./tests",
|
|
9
9
|
forbidOnly: !!process.env.CI,
|
|
10
|
-
retries: process.env.
|
|
11
|
-
workers: "50%",
|
|
10
|
+
retries: Number(process.env.PLAYWRIGHT_RETRIES ?? 0),
|
|
11
|
+
workers: process.env.PLAYWRIGHT_WORKERS || "50%",
|
|
12
12
|
outputDir: "node_modules/.cache/e2e-test-results",
|
|
13
13
|
timeout: 90_000,
|
|
14
14
|
reporter: [
|
|
@@ -22,8 +22,8 @@ export const baseConfig = {
|
|
|
22
22
|
screenshot: "only-on-failure",
|
|
23
23
|
viewport: { width: 1920, height: 1080 },
|
|
24
24
|
video: {
|
|
25
|
-
mode: "on",
|
|
26
|
-
size: { width:
|
|
25
|
+
mode: "retain-on-failure",
|
|
26
|
+
size: { width: 1280, height: 720 },
|
|
27
27
|
},
|
|
28
28
|
actionTimeout: 10_000,
|
|
29
29
|
navigationTimeout: 50_000,
|
|
@@ -52,7 +52,7 @@ export declare function getMetadataDirectory(metadataPath?: string): string | nu
|
|
|
52
52
|
* @param filePath Path to the metadata YAML file
|
|
53
53
|
* @returns PluginMetadata if valid, null otherwise
|
|
54
54
|
*/
|
|
55
|
-
export declare function parseMetadataFile(filePath: string): Promise<PluginMetadata
|
|
55
|
+
export declare function parseMetadataFile(filePath: string): Promise<PluginMetadata>;
|
|
56
56
|
/**
|
|
57
57
|
* Parses all metadata files in a directory and builds a map of plugin name to config.
|
|
58
58
|
* The plugin name is extracted from the dynamicArtifact path for flexible matching.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plugin-metadata.d.ts","sourceRoot":"","sources":["../../src/utils/plugin-metadata.ts"],"names":[],"mappings":"
|
|
1
|
+
{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AE,MAAM,GAAG,OAAO,CAAC;CACxB;AA4CD;;;;;;;;;;;GAWG;AACH,wBAAgB,oBAAoB,CAClC,oBAAoB,EAAE,oBAAoB,EAC1C,WAAW,EAAE,GAAG,CAAC,MAAM,EAAE,cAAc,CAAC,GACvC,oBAAoB,CAsCtB;AAED;;;;;;;;;;GAUG;AACH,wBAAsB,wCAAwC,CAC5D,YAAY,GAAE,MAA8B,GAC3C,OAAO,CAAC,oBAAoB,CAAC,CAsD/B;AAED;;;;;;;;GAQG;AACH,wBAAsB,2BAA2B,CAC/C,oBAAoB,EAAE,oBAAoB,EAC1C,YAAY,GAAE,MAA8B,GAC3C,OAAO,CAAC,oBAAoB,CAAC,CAuC/B"}
|
|
@@ -32,13 +32,13 @@ async function getOCIUrlsForPR(workspacePath, prNumber) {
|
|
|
32
32
|
throw new Error(`[PluginMetadata] Failed to parse GitHub repo from source.json: ${repo}`);
|
|
33
33
|
}
|
|
34
34
|
const ownerRepo = match[1];
|
|
35
|
-
//
|
|
36
|
-
const
|
|
37
|
-
const
|
|
38
|
-
|
|
39
|
-
.
|
|
40
|
-
|
|
41
|
-
|
|
35
|
+
// Parse plugins-list.yaml as YAML and extract keys (plugin paths)
|
|
36
|
+
const pluginsListContent = await fs.readFile(pluginsListPath, "utf-8");
|
|
37
|
+
const pluginsListData = yaml.load(pluginsListContent);
|
|
38
|
+
if (!pluginsListData || typeof pluginsListData !== "object") {
|
|
39
|
+
throw new Error(`[PluginMetadata] plugins-list.yaml is empty or invalid: ${pluginsListPath}`);
|
|
40
|
+
}
|
|
41
|
+
const pluginPaths = Object.keys(pluginsListData);
|
|
42
42
|
const workspaceName = path.basename(workspacePath);
|
|
43
43
|
console.log(`[PluginMetadata] Fetching versions for ${pluginPaths.length} plugins from source...`);
|
|
44
44
|
for (const pluginPath of pluginPaths) {
|
|
@@ -142,28 +142,23 @@ export function getMetadataDirectory(metadataPath = DEFAULT_METADATA_PATH) {
|
|
|
142
142
|
* @returns PluginMetadata if valid, null otherwise
|
|
143
143
|
*/
|
|
144
144
|
export async function parseMetadataFile(filePath) {
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
console.log(`[PluginMetadata] Skipping ${filePath}: no spec.dynamicArtifact`);
|
|
153
|
-
return null;
|
|
154
|
-
}
|
|
155
|
-
console.log(`[PluginMetadata] Loaded metadata for: ${packagePath}`);
|
|
156
|
-
return {
|
|
157
|
-
packagePath,
|
|
158
|
-
pluginConfig: pluginConfig || {},
|
|
159
|
-
packageName: packageName || "",
|
|
160
|
-
sourceFile: filePath,
|
|
161
|
-
};
|
|
145
|
+
const content = await fs.readFile(filePath, "utf8");
|
|
146
|
+
const parsed = yaml.load(content);
|
|
147
|
+
const packagePath = parsed?.spec?.dynamicArtifact;
|
|
148
|
+
const packageName = parsed?.spec?.packageName;
|
|
149
|
+
const pluginConfig = parsed?.spec?.appConfigExamples?.[0]?.content;
|
|
150
|
+
if (!packagePath) {
|
|
151
|
+
throw new Error(`[PluginMetadata] Missing required field spec.dynamicArtifact in ${filePath}`);
|
|
162
152
|
}
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
return null;
|
|
153
|
+
if (!packageName) {
|
|
154
|
+
throw new Error(`[PluginMetadata] Missing required field spec.packageName in ${filePath}`);
|
|
166
155
|
}
|
|
156
|
+
return {
|
|
157
|
+
packagePath,
|
|
158
|
+
pluginConfig: pluginConfig || {},
|
|
159
|
+
packageName,
|
|
160
|
+
sourceFile: filePath,
|
|
161
|
+
};
|
|
167
162
|
}
|
|
168
163
|
/**
|
|
169
164
|
* Parses all metadata files in a directory and builds a map of plugin name to config.
|
|
@@ -179,16 +174,46 @@ export async function parseAllMetadataFiles(metadataDir) {
|
|
|
179
174
|
const metadataMap = new Map();
|
|
180
175
|
for (const file of files) {
|
|
181
176
|
const metadata = await parseMetadataFile(file);
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
metadataMap.set(pluginName, metadata);
|
|
186
|
-
console.log(`[PluginMetadata] Mapped plugin: ${pluginName} <- ${metadata.packagePath}`);
|
|
187
|
-
}
|
|
177
|
+
const pluginName = extractPluginName(metadata.packagePath);
|
|
178
|
+
metadataMap.set(pluginName, metadata);
|
|
179
|
+
console.log(`[PluginMetadata] Mapped plugin: ${pluginName} <- ${metadata.packagePath}`);
|
|
188
180
|
}
|
|
189
181
|
console.log(`[PluginMetadata] Successfully parsed ${metadataMap.size} plugin metadata entries`);
|
|
190
182
|
return metadataMap;
|
|
191
183
|
}
|
|
184
|
+
/**
|
|
185
|
+
* Replaces local package paths with OCI URLs for plugins that have matching metadata.
|
|
186
|
+
* Only applies to plugins with metadata (workspace plugins). Plugins without metadata
|
|
187
|
+
* (e.g., keycloak, bulk-import from auth defaults) keep their original paths.
|
|
188
|
+
*
|
|
189
|
+
* @param plugins The plugin entries to process
|
|
190
|
+
* @param metadataMap Map of plugin names to plugin metadata
|
|
191
|
+
* @param metadataPath Path to the metadata directory (used to resolve workspace root)
|
|
192
|
+
* @returns Plugin entries with OCI URLs replaced where applicable
|
|
193
|
+
*/
|
|
194
|
+
async function replaceWithOCIUrls(plugins, metadataMap, metadataPath) {
|
|
195
|
+
const prNumber = process.env.GIT_PR_NUMBER;
|
|
196
|
+
if (!prNumber) {
|
|
197
|
+
return plugins;
|
|
198
|
+
}
|
|
199
|
+
console.log(`[PluginMetadata] PR build detected (PR #${prNumber}), fetching OCI URLs...`);
|
|
200
|
+
const workspacePath = path.resolve(metadataPath, "..");
|
|
201
|
+
const ociUrls = await getOCIUrlsForPR(workspacePath, prNumber);
|
|
202
|
+
return plugins.map((plugin) => {
|
|
203
|
+
const pluginName = extractPluginName(plugin.package);
|
|
204
|
+
const metadata = metadataMap.get(pluginName);
|
|
205
|
+
if (!metadata?.packageName)
|
|
206
|
+
return plugin;
|
|
207
|
+
const displayName = metadata.packageName
|
|
208
|
+
.replace(/^@/, "")
|
|
209
|
+
.replace(/\//g, "-");
|
|
210
|
+
const ociUrl = ociUrls.get(displayName);
|
|
211
|
+
if (!ociUrl)
|
|
212
|
+
return plugin;
|
|
213
|
+
console.log(`[PluginMetadata] Replacing ${plugin.package} with ${ociUrl}`);
|
|
214
|
+
return { ...plugin, package: ociUrl };
|
|
215
|
+
});
|
|
216
|
+
}
|
|
192
217
|
/**
|
|
193
218
|
* Injects plugin configurations from metadata into a dynamic plugins config.
|
|
194
219
|
* Metadata config serves as the base, user-provided pluginConfig overrides it.
|
|
@@ -255,43 +280,18 @@ export async function generateDynamicPluginsConfigFromMetadata(metadataPath = DE
|
|
|
255
280
|
if (metadataMap.size === 0) {
|
|
256
281
|
throw new Error(`[PluginMetadata] Cannot generate dynamic-plugins config: no valid metadata files found in ${metadataDir}`);
|
|
257
282
|
}
|
|
258
|
-
// If PR number is set, fetch OCI URLs
|
|
259
|
-
const prNumber = process.env.GIT_PR_NUMBER;
|
|
260
|
-
let ociUrls = null;
|
|
261
|
-
if (prNumber) {
|
|
262
|
-
console.log(`[PluginMetadata] PR build detected (PR #${prNumber}), fetching OCI URLs...`);
|
|
263
|
-
const workspacePath = path.resolve(metadataPath, "..");
|
|
264
|
-
ociUrls = await getOCIUrlsForPR(workspacePath, prNumber);
|
|
265
|
-
}
|
|
266
283
|
// Build plugin entries from metadata
|
|
267
|
-
|
|
284
|
+
let plugins = [];
|
|
268
285
|
for (const [pluginName, metadata] of metadataMap) {
|
|
269
|
-
|
|
270
|
-
// Replace with OCI URL if available (required for PR builds)
|
|
271
|
-
if (ociUrls) {
|
|
272
|
-
if (!metadata.packageName) {
|
|
273
|
-
throw new Error(`[PluginMetadata] PR build requires packageName in metadata but not found for: ${pluginName}\n` +
|
|
274
|
-
` Source file: ${metadata.sourceFile}`);
|
|
275
|
-
}
|
|
276
|
-
const displayName = metadata.packageName
|
|
277
|
-
.replace(/^@/, "")
|
|
278
|
-
.replace(/\//g, "-");
|
|
279
|
-
const ociUrl = ociUrls.get(displayName);
|
|
280
|
-
if (!ociUrl) {
|
|
281
|
-
throw new Error(`[PluginMetadata] PR build requires OCI URL but not found for: ${displayName}\n` +
|
|
282
|
-
` Package name: ${metadata.packageName}\n` +
|
|
283
|
-
` Source file: ${metadata.sourceFile}`);
|
|
284
|
-
}
|
|
285
|
-
console.log(`[PluginMetadata] Replacing ${packageRef} with ${ociUrl}`);
|
|
286
|
-
packageRef = ociUrl;
|
|
287
|
-
}
|
|
288
|
-
console.log(`[PluginMetadata] Adding plugin: ${pluginName} (${packageRef})`);
|
|
286
|
+
console.log(`[PluginMetadata] Adding plugin: ${pluginName} (${metadata.packagePath})`);
|
|
289
287
|
plugins.push({
|
|
290
|
-
package:
|
|
288
|
+
package: metadata.packagePath,
|
|
291
289
|
disabled: false,
|
|
292
290
|
pluginConfig: metadata.pluginConfig,
|
|
293
291
|
});
|
|
294
292
|
}
|
|
293
|
+
// Replace local paths with OCI URLs for PR builds
|
|
294
|
+
plugins = await replaceWithOCIUrls(plugins, metadataMap, metadataPath);
|
|
295
295
|
console.log(`[PluginMetadata] Generated dynamic-plugins config with ${plugins.length} plugins`);
|
|
296
296
|
return { plugins };
|
|
297
297
|
}
|
|
@@ -321,5 +321,10 @@ export async function loadAndInjectPluginMetadata(dynamicPluginsConfig, metadata
|
|
|
321
321
|
throw new Error(`[PluginMetadata] PR build requires plugin metadata but no valid metadata files found in ${metadataDir}`);
|
|
322
322
|
}
|
|
323
323
|
// Inject metadata configs into the dynamic plugins config
|
|
324
|
-
|
|
324
|
+
const result = injectMetadataConfig(dynamicPluginsConfig, metadataMap);
|
|
325
|
+
// Replace local paths with OCI URLs for PR builds
|
|
326
|
+
if (result.plugins) {
|
|
327
|
+
result.plugins = await replaceWithOCIUrls(result.plugins, metadataMap, metadataPath);
|
|
328
|
+
}
|
|
329
|
+
return result;
|
|
325
330
|
}
|