Files
openclaw/test/e2e/qa-lab/runtime/docker-e2e-lane.fixture.ts
Peter Steinberger fe261b0f59 chore(tooling): typecheck root test/** with a dedicated tsgo lane (#104475)
* chore(types): add declaration files for scripts/lib and scripts/e2e modules

* chore(types): add declaration files for top-level script modules (a-m)

* chore(types): add declaration files for top-level script modules (n-z)

* test: use a non-secret-shaped gateway token fixture

* test: type ci workflow guard helpers for the root test lane

* chore(tooling): typecheck root test/** with a dedicated tsgo lane

- test/tsconfig/tsconfig.test.root.json: root-test program (strict unused checks,
  fixtures excluded; two Docker E2E clients that import built dist/** stay out,
  same rationale as the scripts/e2e exclusion in tsconfig.scripts.json)
- tsgo:test:root wired into tsgo:test, check:test-types, scripts/check.mjs, and
  the ci.yml test-types shard, mirroring the tsgo:scripts lane (#104348)
- changed-lane routing: test/**/*.ts (excluding fixtures) and the lane tsconfig
  now trigger 'typecheck test root' in check:changed; previously test/ paths ran
  lint only, so harness type errors surfaced first in CI (#104287 envDir case)
- burn down all 1071 latent type errors in the program: precise param/local
  types across test/scripts, test/vitest, test/e2e, and transitive scripts/e2e
  program members; 205 sibling .d.mts declaration files for imported .mjs
  modules (committed separately); zero any, zero ts-expect-error
- resolve the pre-existing testing star-export ambiguity in
  scripts/e2e/parallels/common.ts with an explicit re-export

Closes #104388

* chore(types): correct declaration fidelity per structured review

- re-derive 51 .d.mts files from implementation data flow instead of
  initializers: fix a wrong never return (runTestProjectsDelegation returns
  the child), add encoding-sensitive exec/spawn overloads (plain-gh), restore
  the full release profile union, make parsed paths string | null, add missing
  parseArgs fields via help/non-help unions, add a missing sibling declaration
  (budget-number-args), drop 15 unused lint directives
- precise install-record/tuple typing removes the type-aware oxlint
  regressions the first declarations caused in scripts/e2e implementations
- route .mts declaration edits under test/ to the testRoot lane and reference
  the test-root project from tsconfig.projects.json so tsgo:all covers it
  (closes both review findings against the lane wiring)

* chore(scripts): keep telegram runner dist typing structural for the boundary guard

* chore(types): declare runtime pack and gateway readiness exports added on main

* test: pin the importTargetPlan form of the plugin-contract plan import

The guard expectation still referenced the raw await import( form that
7ae5996bb3 (#103975) replaced with the importTargetPlan fallback helper;
the assertion fails on current main.
2026-07-11 06:15:41 -07:00

170 lines
4.9 KiB
TypeScript

// Shared QA Lab fixture for dispatching existing Docker E2E lanes.
import { spawnSync } from "node:child_process";
export type QaDockerE2eLaneDefinition = {
env?: (env: NodeJS.ProcessEnv) => Record<string, string>;
script: string;
};
type QaDockerE2eLaneRunResult = {
error?: Error;
signal: NodeJS.Signals | null;
status: number | null;
};
type SpawnQaDockerE2eLane = (
command: string,
args: string[],
options: { env: NodeJS.ProcessEnv; stdio: "inherit" },
) => QaDockerE2eLaneRunResult;
export const QA_DOCKER_E2E_LANES = {
"agent-bundle-mcp-tools": {
script: "scripts/e2e/agent-bundle-mcp-tools-docker.sh",
},
"agents-delete-shared-workspace": {
script: "scripts/e2e/agents-delete-shared-workspace-docker.sh",
},
"bundled-plugin-install-uninstall": {
script: "scripts/e2e/bundled-plugin-install-uninstall-docker.sh",
},
"crestodian-first-run": {
script: "scripts/e2e/crestodian-first-run-docker.sh",
},
"docker-build-image": {
script: "scripts/e2e/build-image.sh",
},
"gateway-network": {
script: "scripts/e2e/gateway-network-docker.sh",
},
"npm-onboard-channel-agent": {
script: "scripts/e2e/npm-onboard-channel-agent-docker.sh",
},
"openai-chat-tools": {
script: "scripts/e2e/openai-chat-tools-docker.sh",
},
"openai-web-search-minimal": {
script: "scripts/e2e/openai-web-search-minimal-docker.sh",
},
openwebui: {
script: "scripts/e2e/openwebui-docker.sh",
},
"plugin-lifecycle-matrix": {
script: "scripts/e2e/plugin-lifecycle-matrix-docker.sh",
},
"release-plugin-marketplace": {
script: "scripts/e2e/release-plugin-marketplace-docker.sh",
},
"release-upgrade-user-journey": {
script: "scripts/e2e/release-upgrade-user-journey-docker.sh",
},
"release-user-journey": {
script: "scripts/e2e/release-user-journey-docker.sh",
},
"update-channel-switch": {
script: "scripts/e2e/update-channel-switch-docker.sh",
},
"update-migration": {
env: (env) => ({
OPENCLAW_UPGRADE_SURVIVOR_BASELINE_SPEC:
env.OPENCLAW_UPGRADE_SURVIVOR_BASELINE_SPEC ?? "openclaw@2026.4.23",
OPENCLAW_UPGRADE_SURVIVOR_PUBLISHED_BASELINE: "1",
OPENCLAW_UPGRADE_SURVIVOR_SCENARIO:
env.OPENCLAW_UPGRADE_SURVIVOR_SCENARIO ?? "plugin-deps-cleanup",
}),
script: "scripts/e2e/upgrade-survivor-docker.sh",
},
"update-restart-auth": {
env: (env) => ({
OPENCLAW_UPGRADE_SURVIVOR_DOCKER_RUN_TIMEOUT:
env.OPENCLAW_UPGRADE_SURVIVOR_DOCKER_RUN_TIMEOUT ?? "1500s",
OPENCLAW_UPGRADE_SURVIVOR_UPDATE_RESTART_MODE: "auto-auth",
}),
script: "scripts/e2e/upgrade-survivor-docker.sh",
},
"upgrade-survivor": {
script: "scripts/e2e/upgrade-survivor-docker.sh",
},
} satisfies Record<string, QaDockerE2eLaneDefinition>;
export type QaDockerE2eLaneName = keyof typeof QA_DOCKER_E2E_LANES;
export type QaDockerE2eLaneArgs =
| { kind: "help" }
| { kind: "list" }
| { kind: "run"; laneName: string };
export type ResolvedQaDockerE2eLane = {
env: NodeJS.ProcessEnv;
name: QaDockerE2eLaneName;
script: string;
};
export function listQaDockerE2eLaneNames(): QaDockerE2eLaneName[] {
return Object.keys(QA_DOCKER_E2E_LANES).toSorted() as QaDockerE2eLaneName[];
}
export function formatQaDockerE2eLaneUsage(
entrypoint = "node --import tsx test/e2e/qa-lab/runtime/docker-e2e-lane.ts",
): string {
return [
`Usage: ${entrypoint} --lane <name>`,
"",
"Known lanes:",
...listQaDockerE2eLaneNames().map((lane) => ` - ${lane}`),
"",
].join("\n");
}
export function parseQaDockerE2eLaneArgs(argv: string[]): QaDockerE2eLaneArgs {
if (argv.includes("--help") || argv.includes("-h")) {
return { kind: "help" };
}
if (argv.includes("--list")) {
return { kind: "list" };
}
const index = argv.indexOf("--lane");
if (index === -1) {
throw new Error("--lane is required");
}
const laneName = argv[index + 1];
if (!laneName || laneName.startsWith("-")) {
throw new Error("--lane requires a value");
}
return { kind: "run", laneName };
}
export function resolveQaDockerE2eLane(
laneName: string,
env: NodeJS.ProcessEnv = process.env,
): ResolvedQaDockerE2eLane {
if (!isQaDockerE2eLaneName(laneName)) {
throw new Error(`unknown Docker E2E lane: ${laneName}\n\n${formatQaDockerE2eLaneUsage()}`);
}
const lane = QA_DOCKER_E2E_LANES[laneName];
return {
env: { ...env, ...("env" in lane ? lane.env?.(env) : undefined) },
name: laneName,
script: lane.script,
};
}
export function runQaDockerE2eLane(
laneName: string,
deps: {
env?: NodeJS.ProcessEnv;
spawn?: SpawnQaDockerE2eLane;
} = {},
): QaDockerE2eLaneRunResult {
const lane = resolveQaDockerE2eLane(laneName, deps.env);
const spawn = deps.spawn ?? spawnSync;
return spawn("bash", [lane.script], {
env: lane.env,
stdio: "inherit",
});
}
function isQaDockerE2eLaneName(laneName: string): laneName is QaDockerE2eLaneName {
return Object.hasOwn(QA_DOCKER_E2E_LANES, laneName);
}