Skip to content

Commit cc460d3

Browse files
test(e2e): add Playwright global setup/teardown to kill ports and force clean exit; run React consumers via build+serve; batch port cleanup (Linux/macOS)\n\n- federated-css: kill ports before/after tests (globalSetup/globalTeardown)\n- federated-css-react-ssr: kill SSR ports before/after tests\n- start-all: switch React consumers to static build+serve; Next apps build+start\n- port cleanup: single kill-port CLI + multi-port lsof/fuser fallback (Linux focus)\n\nNote: Windows cleanup path dropped per scope — Linux/CI only.
1 parent 17315ee commit cc460d3

File tree

15 files changed

+335
-87
lines changed

15 files changed

+335
-87
lines changed
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
import { execSync } from 'node:child_process';
2+
3+
function killPorts(ports: number[]) {
4+
const unique = Array.from(new Set(ports));
5+
for (const port of unique) {
6+
try {
7+
// macOS/Linux via lsof; ignore if nothing found
8+
execSync(`lsof -ti:${port} | xargs kill -9`, { stdio: 'ignore' });
9+
} catch {}
10+
try {
11+
// Linux alternative via fuser
12+
execSync(`fuser -k ${port}/tcp`, { stdio: 'ignore' });
13+
} catch {}
14+
}
15+
}
16+
17+
export default async function globalSetup() {
18+
// SSR uses exposes on 3001-3007 and shells on 4000-4005
19+
const ports = [3001,3002,3003,3004,3005,3006,3007, 4000,4001,4002,4003,4004,4005];
20+
try {
21+
killPorts(ports);
22+
} catch {}
23+
}
24+
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import { execSync } from 'node:child_process';
2+
3+
export default async function globalTeardown() {
4+
const ports = [3001,3002,3003,3004,3005,3006,3007, 4000,4001,4002,4003,4004,4005];
5+
for (const port of ports) {
6+
try { execSync(`lsof -ti:${port} | xargs kill -9`, { stdio: 'ignore' }); } catch {}
7+
try { execSync(`fuser -k ${port}/tcp`, { stdio: 'ignore' }); } catch {}
8+
}
9+
await new Promise((r) => setTimeout(r, 200));
10+
const code = typeof process.exitCode === 'number' ? process.exitCode : 0;
11+
// eslint-disable-next-line no-process-exit
12+
process.exit(code);
13+
}

federated-css-react-ssr/playwright.config.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@ export default defineConfig({
2929
use: { ...devices['Desktop Chrome'] },
3030
},
3131
],
32+
globalSetup: './e2e/global-setup.ts',
33+
globalTeardown: './e2e/global-teardown.ts',
3234
webServer: [
3335
{
3436
command: 'node scripts/start-exposes.cjs',

federated-css-react-ssr/scripts/start-exposes.cjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ async function main() {
6363
`http://localhost:${port}/client/remoteEntry.js`,
6464
],
6565
timeout: 480000,
66-
validateStatus: s => s >= 200 && s < 500,
66+
validateStatus: s => s >= 200 && s < 400,
6767
});
6868
console.log(`[exposes] ${dir} ready on ${port}.`);
6969
}

federated-css-react-ssr/scripts/start-shells.cjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ async function main() {
6161
await waitOn({
6262
resources: [`http://localhost:${port}`],
6363
timeout: 480000,
64-
validateStatus: s => s >= 200 && s < 500,
64+
validateStatus: s => s >= 200 && s < 400,
6565
});
6666
console.log(`[shells] ${dir} is up on ${port}.`);
6767
}

federated-css/consumers-nextjs/combination-of-4/next.config.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,4 +19,8 @@ module.exports = {
1919
},
2020
// your original next.config.js export
2121
reactStrictMode: true,
22+
eslint: {
23+
// Skip linting during CI builds/start to avoid legacy options failure and speed up startup
24+
ignoreDuringBuilds: true,
25+
},
2226
};

federated-css/consumers-nextjs/jss-and-tailwind-global/next.config.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,4 +19,7 @@ module.exports = {
1919
},
2020
// your original next.config.js export
2121
reactStrictMode: true,
22+
eslint: {
23+
ignoreDuringBuilds: true,
24+
},
2225
};

federated-css/consumers-nextjs/jss-css-and-tailwind-module/next.config.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,4 +19,7 @@ module.exports = {
1919
},
2020
// your original next.config.js export
2121
reactStrictMode: true,
22+
eslint: {
23+
ignoreDuringBuilds: true,
24+
},
2225
};

federated-css/consumers-nextjs/less-and-styled-component/next.config.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,4 +19,7 @@ module.exports = {
1919
},
2020
// your original next.config.js export
2121
reactStrictMode: true,
22+
eslint: {
23+
ignoreDuringBuilds: true,
24+
},
2225
};

federated-css/e2e/global-setup.ts

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
import { execFileSync } from 'node:child_process';
2+
import { resolve } from 'node:path';
3+
4+
async function killAll() {
5+
const killer = resolve(__dirname, '../scripts/kill-all-ports.cjs');
6+
execFileSync(process.execPath, [killer], { stdio: 'inherit' });
7+
}
8+
9+
export default async function globalSetup() {
10+
try {
11+
await killAll();
12+
} catch (e) {
13+
// ignore; CI will retry inside start scripts
14+
}
15+
}
16+

0 commit comments

Comments
 (0)