|
| 1 | +// Runs an existing Docker E2E lane through the QA Lab script scenario contract. |
| 2 | +import { spawnSync } from "node:child_process"; |
| 3 | + |
| 4 | +type Lane = { |
| 5 | + env?: Record<string, string>; |
| 6 | + script: string; |
| 7 | +}; |
| 8 | + |
| 9 | +const lanes: Record<string, Lane> = { |
| 10 | + "release-upgrade-user-journey": { |
| 11 | + script: "scripts/e2e/release-upgrade-user-journey-docker.sh", |
| 12 | + }, |
| 13 | + "release-user-journey": { |
| 14 | + script: "scripts/e2e/release-user-journey-docker.sh", |
| 15 | + }, |
| 16 | + "update-channel-switch": { |
| 17 | + script: "scripts/e2e/update-channel-switch-docker.sh", |
| 18 | + }, |
| 19 | + "update-migration": { |
| 20 | + env: { |
| 21 | + OPENCLAW_UPGRADE_SURVIVOR_PUBLISHED_BASELINE: "1", |
| 22 | + OPENCLAW_UPGRADE_SURVIVOR_BASELINE_SPEC: |
| 23 | + process.env.OPENCLAW_UPGRADE_SURVIVOR_BASELINE_SPEC ?? "[email protected]", |
| 24 | + OPENCLAW_UPGRADE_SURVIVOR_SCENARIO: |
| 25 | + process.env.OPENCLAW_UPGRADE_SURVIVOR_SCENARIO ?? "plugin-deps-cleanup", |
| 26 | + }, |
| 27 | + script: "scripts/e2e/upgrade-survivor-docker.sh", |
| 28 | + }, |
| 29 | + "update-restart-auth": { |
| 30 | + env: { |
| 31 | + OPENCLAW_UPGRADE_SURVIVOR_UPDATE_RESTART_MODE: "auto-auth", |
| 32 | + OPENCLAW_UPGRADE_SURVIVOR_DOCKER_RUN_TIMEOUT: |
| 33 | + process.env.OPENCLAW_UPGRADE_SURVIVOR_DOCKER_RUN_TIMEOUT ?? "1500s", |
| 34 | + }, |
| 35 | + script: "scripts/e2e/upgrade-survivor-docker.sh", |
| 36 | + }, |
| 37 | + "upgrade-survivor": { |
| 38 | + script: "scripts/e2e/upgrade-survivor-docker.sh", |
| 39 | + }, |
| 40 | +}; |
| 41 | + |
| 42 | +function laneArg(argv: string[]) { |
| 43 | + const index = argv.indexOf("--lane"); |
| 44 | + if (index === -1) { |
| 45 | + throw new Error("--lane is required"); |
| 46 | + } |
| 47 | + const lane = argv[index + 1]; |
| 48 | + if (!lane || lane.startsWith("-")) { |
| 49 | + throw new Error("--lane requires a value"); |
| 50 | + } |
| 51 | + return lane; |
| 52 | +} |
| 53 | + |
| 54 | +const laneName = laneArg(process.argv.slice(2)); |
| 55 | +const lane = lanes[laneName]; |
| 56 | +if (!lane) { |
| 57 | + throw new Error(`unknown Docker E2E lane: ${laneName}`); |
| 58 | +} |
| 59 | + |
| 60 | +const result = spawnSync("bash", [lane.script], { |
| 61 | + env: { ...process.env, ...lane.env }, |
| 62 | + stdio: "inherit", |
| 63 | +}); |
| 64 | + |
| 65 | +if (result.error) { |
| 66 | + console.error(result.error); |
| 67 | + process.exit(1); |
| 68 | +} |
| 69 | +if (result.signal) { |
| 70 | + process.kill(process.pid, result.signal); |
| 71 | +} |
| 72 | +process.exit(result.status ?? 1); |
0 commit comments