Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 28 additions & 0 deletions .github/workflows/mfe-runtime.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
name: MFE runtime
on:
pull_request:
paths:
- "datahub-web-react/devtools/mfe-fixture/**"
- "datahub-web-react/src/app/mfeframework/**"

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2: This job does not exercise src/app/mfeframework, even though the path filter runs it on changes there. The fixture's mount props are hand-written, so changes to the host contract can pass here. Either drive the real loader/container in this check or drop the path filter entry to avoid implying coverage.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. At .github/workflows/mfe-runtime.yml, line 6:

<comment>This job does not exercise `src/app/mfeframework`, even though the path filter runs it on changes there. The fixture's mount props are hand-written, so changes to the host contract can pass here. Either drive the real loader/container in this check or drop the path filter entry to avoid implying coverage.</comment>

<file context>
@@ -0,0 +1,28 @@
+  pull_request:
+    paths:
+      - "datahub-web-react/devtools/mfe-fixture/**"
+      - "datahub-web-react/src/app/mfeframework/**"
+      - "datahub-web-react/vite.config.ts"
+      - "datahub-web-react/package.json"
</file context>

- "datahub-web-react/vite.config.ts"
- "datahub-web-react/package.json"
- "datahub-web-react/yarn.lock"
- ".github/workflows/mfe-runtime.yml"
permissions:
contents: read
jobs:
browser:

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P3: The browser job has no timeout-minutes, so a stalled install or headless Chrome run holds the runner for the 6-hour default. Add a job-level timeout, matching other workflows in this repo.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. At .github/workflows/mfe-runtime.yml, line 14:

<comment>The `browser` job has no `timeout-minutes`, so a stalled install or headless Chrome run holds the runner for the 6-hour default. Add a job-level timeout, matching other workflows in this repo.</comment>

<file context>
@@ -0,0 +1,28 @@
+permissions:
+  contents: read
+jobs:
+  browser:
+    runs-on: ubuntu-24.04
+    defaults:
</file context>
Suggested change
browser:
browser:
timeout-minutes: 30

runs-on: ubuntu-24.04

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P3: Add timeout-minutes to the browser job so a hung install or build cannot run to the 6-hour default.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. At .github/workflows/mfe-runtime.yml, line 15:

<comment>Add `timeout-minutes` to the `browser` job so a hung install or build cannot run to the 6-hour default.</comment>

<file context>
@@ -0,0 +1,28 @@
+  contents: read
+jobs:
+  browser:
+    runs-on: ubuntu-24.04
+    defaults:
+      run:
</file context>
Suggested change
runs-on: ubuntu-24.04
runs-on: ubuntu-24.04
timeout-minutes: 30

defaults:
run:
working-directory: datahub-web-react
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
- uses: actions/setup-node@820762786026740c76f36085b0efc47a31fe5020 # v7.0.0
with:
node-version: "22"
cache: yarn
cache-dependency-path: datahub-web-react/yarn.lock
- run: yarn install --frozen-lockfile
- run: npm ci --prefix devtools/mfe-fixture/remote --ignore-scripts
- run: node devtools/mfe-fixture/build.mjs && python3 devtools/mfe-fixture/verify.py
1 change: 1 addition & 0 deletions .github/workflows/post-workflow-actions.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ on:
- "metadata model generate"
- "Metadata Models Custom CI"
- "metadata-io"
- "MFE runtime"
- "Nightly Docker Test"
- "OAuth Smoke Test"
- "PR Title Check"
Expand Down
5 changes: 5 additions & 0 deletions datahub-web-react/.eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -333,6 +333,11 @@ module.exports = {
},
},
overrides: [
{
files: ['devtools/mfe-fixture/host/main.js'],

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P3: This override never takes effect in CI: yarn lint runs eslint . --ext .ts,.tsx, which skips .js files, and devtools is type-checked with tsc instead. Either drop the override or add a lint step that actually covers devtools/mfe-fixture/host/main.js. Also note that replacing the import/no-unresolved options drops airbnb's commonjs: true and caseSensitive: true for this file.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. At datahub-web-react/.eslintrc.js, line 337:

<comment>This override never takes effect in CI: `yarn lint` runs `eslint . --ext .ts,.tsx`, which skips `.js` files, and devtools is type-checked with `tsc` instead. Either drop the override or add a lint step that actually covers `devtools/mfe-fixture/host/main.js`. Also note that replacing the `import/no-unresolved` options drops airbnb's `commonjs: true` and `caseSensitive: true` for this file.</comment>

<file context>
@@ -333,6 +333,11 @@ module.exports = {
     },
     overrides: [
+        {
+            files: ['devtools/mfe-fixture/host/main.js'],
+            env: { browser: true },
+            rules: { 'import/no-unresolved': ['error', { ignore: ['^virtual:__federation__$'] }] },
</file context>

env: { browser: true },
rules: { 'import/no-unresolved': ['error', { ignore: ['^virtual:__federation__$'] }] },
},
{
files: ['src/app/searchV2/**/*.tsx', 'src/app/entityV2/**/*.tsx'],
rules: { 'import/no-cycle': 'off' },
Expand Down
2 changes: 2 additions & 0 deletions datahub-web-react/devtools/mfe-fixture/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
build/
remote/node_modules/
34 changes: 34 additions & 0 deletions datahub-web-react/devtools/mfe-fixture/build.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import federation from '@originjs/vite-plugin-federation';
import { execFileSync } from 'node:child_process';
import path from 'node:path';
import { fileURLToPath } from 'node:url';
import { build } from 'vite';

const fixture = path.dirname(fileURLToPath(import.meta.url));
const name = process.argv[2];
if (!name) {
// The federation plugin keeps its Rollup file references in module-level state.
for (const target of ['host', 'remote']) {
execFileSync(process.execPath, [fileURLToPath(import.meta.url), target], { stdio: 'inherit' });
}
} else {
const root = path.join(fixture, name);
const remote = name === 'remote';
await build({
configFile: false,
root,
base: name === 'host' ? '/' : `/${name}/`,
build: {
target: 'esnext',
outDir: path.join(fixture, 'build', name === 'host' ? '.' : name),

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2: The host build writes to build/ with emptyOutDir: true, which also wipes build/remote. The no-argument run works only because host runs first. Running the host target alone deletes the remote bundle, so give the host its own subdirectory or document that the target order is required.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. At datahub-web-react/devtools/mfe-fixture/build.mjs, line 23:

<comment>The host build writes to `build/` with `emptyOutDir: true`, which also wipes `build/remote`. The no-argument run works only because host runs first. Running the host target alone deletes the remote bundle, so give the host its own subdirectory or document that the target order is required.</comment>

<file context>
@@ -0,0 +1,34 @@
+        base: name === 'host' ? '/' : `/${name}/`,
+        build: {
+            target: 'esnext',
+            outDir: path.join(fixture, 'build', name === 'host' ? '.' : name),
+            emptyOutDir: true,
+            rollupOptions: { input: path.join(root, 'index.html') },
</file context>
Suggested change
outDir: path.join(fixture, 'build', name === 'host' ? '.' : name),
outDir: path.join(fixture, 'build', name),

emptyOutDir: true,
rollupOptions: { input: path.join(root, 'index.html') },
},
plugins: [
federation({
name,
...(remote ? { exposes: { './mount': path.join(root, 'mount.jsx') } } : { remotes: { fixture: '' } }),
}),
],
});
}
2 changes: 2 additions & 0 deletions datahub-web-react/devtools/mfe-fixture/host/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
<div id="root"></div>
<script type="module" src="./main.js"></script>
45 changes: 45 additions & 0 deletions datahub-web-react/devtools/mfe-fixture/host/main.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
import React from 'react';
import {
__federation_method_getRemote as getRemote,
__federation_method_setRemote as setRemote,
} from 'virtual:__federation__';

async function verify() {
setRemote('fixture', { format: 'esm', from: 'vite', url: '/remote/assets/remoteEntry.js' });
const remote = await getRemote('fixture', './mount');
if (!React.version.startsWith('17.') || !remote.reactVersion.startsWith('19.')) {
throw Error('Expected a React 17 host and an independent React 19 remote');
}
let listener;
const element = document.getElementById('root');
const cleanup = remote.mount(element, {
contractVersion: 1,
slot: 'nav.page',
area: 'app',
basePath: '/fixture',
theme: { id: 'light', colors: { textBrand: '#123456' }, styles: {} },
subscribeTheme(cb) {
listener = cb;
return () => {
listener = undefined;
};
},
navigate() {},

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2: Custom agent: Enforce Pragmatic Test Coverage

This fixture passes a no-op navigate and never observes datahub:mfe-location, leaving the new host location-event contract untested. Add a test that changes host history and asserts the event payload.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. At datahub-web-react/devtools/mfe-fixture/host/main.js, line 27:

<comment>This fixture passes a no-op `navigate` and never observes `datahub:mfe-location`, leaving the new host location-event contract untested. Add a test that changes host history and asserts the event payload.</comment>

<file context>
@@ -0,0 +1,45 @@
+                listener = undefined;
+            };
+        },
+        navigate() {},
+    });
+    const label = element.firstElementChild;
</file context>

});
const label = element.firstElementChild;
if (label.textContent !== 'light' || getComputedStyle(label).color !== 'rgb(18, 52, 86)')
throw Error('Initial theme mismatch');
listener({ id: 'themeV2Dark', colors: { textBrand: '#abcdef' }, styles: {} });
if (
label !== element.firstElementChild ||
label.textContent !== 'themeV2Dark' ||
getComputedStyle(label).color !== 'rgb(171, 205, 239)'
)
throw Error('Live switch failed');
cleanup();
if (listener || element.childElementCount) throw Error('Cleanup failed');
document.body.dataset.fixture = 'passed';
}
verify().catch((error) => {
document.body.textContent = String(error);
});
1 change: 1 addition & 0 deletions datahub-web-react/devtools/mfe-fixture/remote/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<main></main>
24 changes: 24 additions & 0 deletions datahub-web-react/devtools/mfe-fixture/remote/mount.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import React, { useState } from 'react';
import { flushSync } from 'react-dom';
import { createRoot } from 'react-dom/client';

export const reactVersion = React.version;

export function mount(element, props) {
if (
props.contractVersion !== 1 ||
props.slot !== 'nav.page' ||
props.area !== 'app' ||
props.basePath !== '/fixture'
) {
throw Error('Expected the app page mount context');
}
const root = createRoot(element);
function Label() {
const [theme, setTheme] = useState(props.theme);
React.useLayoutEffect(() => props.subscribeTheme((value) => flushSync(() => setTheme(value))), []);
return <span style={{ color: theme.colors.textBrand }}>{theme.id}</span>;
}
flushSync(() => root.render(<Label />));
return () => root.unmount();
}
41 changes: 41 additions & 0 deletions datahub-web-react/devtools/mfe-fixture/remote/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions datahub-web-react/devtools/mfe-fixture/remote/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"name": "datahub-mfe-test-remote",
"private": true,
"dependencies": {
"react": "19.2.4",
"react-dom": "19.2.4"
}
}
19 changes: 19 additions & 0 deletions datahub-web-react/devtools/mfe-fixture/verify.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
"""Serve both production builds on one origin and check the browser result."""
import functools
import http.server
import os
from pathlib import Path
import subprocess
import threading

root = Path(__file__).resolve().parent / "build"
handler = functools.partial(http.server.SimpleHTTPRequestHandler, directory=root)
with http.server.ThreadingHTTPServer(("127.0.0.1", 0), handler) as server:
threading.Thread(target=server.serve_forever, daemon=True).start()
page = subprocess.check_output([
os.environ.get("CHROME_BIN", "google-chrome"), "--headless", "--no-sandbox",
"--disable-dev-shm-usage", "--dump-dom", "--virtual-time-budget=15000",
f"http://127.0.0.1:{server.server_port}/",
], timeout=60, text=True)
if 'data-fixture="passed"' not in page:
raise SystemExit(page)
Loading
Loading