Skip to content

Commit f823238

Browse files
chore(ci-local): enforce 7-minute max timeout in local e2e scripts; on timeout, kill sub-app ports and exit; add SSR kill-all-ports script
1 parent 3207f54 commit f823238

File tree

3 files changed

+66
-36
lines changed

3 files changed

+66
-36
lines changed
Lines changed: 14 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,18 @@
1-
const kill = require('kill-port');
1+
const { execSync } = require('node:child_process');
22

3-
async function killAllPorts() {
4-
const exposePorts = [3001, 3002, 3003, 3004, 3005, 3006, 3007];
5-
const shellPorts = [4000, 4001, 4002, 4003, 4004, 4005];
6-
7-
const allPorts = [...exposePorts, ...shellPorts];
8-
9-
console.log('[kill-all-ports] Killing all ports...');
10-
11-
for (const port of allPorts) {
12-
try {
13-
await kill(port, 'tcp');
14-
console.log(`[kill-all-ports] Killed port ${port}`);
15-
} catch (e) {
16-
// Port might not be in use, ignore
17-
}
3+
function killPorts(ports) {
4+
const unique = [...new Set(ports)];
5+
for (const port of unique) {
6+
try { execSync(`lsof -ti:${port} | xargs kill -9`, { stdio: 'ignore' }); } catch {}
7+
try { execSync(`fuser -k ${port}/tcp`, { stdio: 'ignore' }); } catch {}
188
}
19-
20-
console.log('[kill-all-ports] All ports killed.');
219
}
2210

23-
killAllPorts().catch(err => {
24-
console.error('[kill-all-ports] Error:', err);
25-
process.exit(1);
26-
});
11+
(async () => {
12+
const exposePorts = [3001,3002,3003,3004,3005,3006,3007];
13+
const shellPorts = [4000,4001,4002,4003,4004,4005];
14+
const all = [...exposePorts, ...shellPorts];
15+
console.log('[kill-ports:ssr] killing', all.join(', '));
16+
killPorts(all);
17+
})();
18+

scripts/ci-local/run-federated-css-ssr.sh

Lines changed: 26 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,32 @@ node federated-css-react-ssr/scripts/kill-all-ports.cjs || true 2>/dev/null || t
1010
echo "[local-ci] Sockets before run:"
1111
ss -ltnp || true
1212

13-
echo "[local-ci] Running federated-css-react-ssr Playwright tests with 12-minute timeout…"
14-
if command -v timeout >/dev/null 2>&1; then
15-
timeout 12m pnpm --dir federated-css-react-ssr exec playwright test --reporter=list || STATUS=$?
16-
else
17-
pnpm --dir federated-css-react-ssr exec playwright test --reporter=list || STATUS=$?
18-
fi
13+
MAX_SECS=$((7*60))
14+
echo "[local-ci] Running federated-css-react-ssr Playwright tests with ${MAX_SECS}s max timeout…"
15+
16+
run_with_timeout() {
17+
set +e
18+
( pnpm --dir federated-css-react-ssr exec playwright test --reporter=list ) &
19+
PW_PID=$!
20+
(
21+
sleep "$MAX_SECS"
22+
if kill -0 "$PW_PID" 2>/dev/null; then
23+
echo "[local-ci] TIMEOUT reached (${MAX_SECS}s). Killing SSR ports and Playwright (pid=$PW_PID)…"
24+
node federated-css-react-ssr/scripts/kill-all-ports.cjs || true
25+
kill -TERM "$PW_PID" 2>/dev/null || true
26+
sleep 2
27+
kill -KILL "$PW_PID" 2>/dev/null || true
28+
exit 124
29+
fi
30+
) & WATCHDOG=$!
31+
wait "$PW_PID"; STATUS=$?
32+
kill -TERM "$WATCHDOG" 2>/dev/null || true
33+
wait "$WATCHDOG" 2>/dev/null || true
34+
set -e
35+
return $STATUS
36+
}
37+
38+
run_with_timeout || STATUS=$?
1939

2040
echo "[local-ci] Sockets after run:"
2141
ss -ltnp || true
@@ -24,4 +44,3 @@ echo "[local-ci] Killing SSR ports after run…"
2444
node federated-css-react-ssr/scripts/kill-all-ports.cjs || true 2>/dev/null || true
2545

2646
exit ${STATUS:-0}
27-

scripts/ci-local/run-federated-css.sh

Lines changed: 26 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,32 @@ node federated-css/scripts/kill-all-ports.cjs || true
1010
echo "[local-ci] Snapshot of listening sockets before run:"
1111
ss -ltnp || true
1212

13-
echo "[local-ci] Running federated-css Playwright tests with 9-minute timeout…"
14-
if command -v timeout >/dev/null 2>&1; then
15-
timeout 9m pnpm --dir federated-css exec playwright test --reporter=list || STATUS=$?
16-
else
17-
pnpm --dir federated-css exec playwright test --reporter=list || STATUS=$?
18-
fi
13+
MAX_SECS=$((7*60))
14+
echo "[local-ci] Running federated-css Playwright tests with ${MAX_SECS}s max timeout…"
15+
16+
run_with_timeout() {
17+
set +e
18+
( pnpm --dir federated-css exec playwright test --reporter=list ) &
19+
PW_PID=$!
20+
(
21+
sleep "$MAX_SECS"
22+
if kill -0 "$PW_PID" 2>/dev/null; then
23+
echo "[local-ci] TIMEOUT reached (${MAX_SECS}s). Killing sub-app ports and Playwright (pid=$PW_PID)…"
24+
node federated-css/scripts/kill-all-ports.cjs || true
25+
kill -TERM "$PW_PID" 2>/dev/null || true
26+
sleep 2
27+
kill -KILL "$PW_PID" 2>/dev/null || true
28+
exit 124
29+
fi
30+
) & WATCHDOG=$!
31+
wait "$PW_PID"; STATUS=$?
32+
kill -TERM "$WATCHDOG" 2>/dev/null || true
33+
wait "$WATCHDOG" 2>/dev/null || true
34+
set -e
35+
return $STATUS
36+
}
37+
38+
run_with_timeout || STATUS=$?
1939

2040
echo "[local-ci] Snapshot of listening sockets after run:"
2141
ss -ltnp || true
@@ -24,4 +44,3 @@ echo "[local-ci] Killing ports after run…"
2444
node federated-css/scripts/kill-all-ports.cjs || true
2545

2646
exit ${STATUS:-0}
27-

0 commit comments

Comments
 (0)