mirror of
https://github.com/openclaw/openclaw.git
synced 2026-04-12 09:41:11 +00:00
fix(qa): default docker artifacts from repo root
This commit is contained in:
committed by
Peter Steinberger
parent
76bde3d42b
commit
daeff2fa89
@@ -122,6 +122,40 @@ describe("runQaDockerUp", () => {
|
||||
}
|
||||
});
|
||||
|
||||
it("uses a repo-root-relative default output dir when none is provided", async () => {
|
||||
const calls: string[] = [];
|
||||
const repoRoot = await mkdtemp(path.join(os.tmpdir(), "qa-docker-root-"));
|
||||
|
||||
try {
|
||||
const result = await runQaDockerUp(
|
||||
{
|
||||
repoRoot,
|
||||
usePrebuiltImage: true,
|
||||
skipUiBuild: true,
|
||||
},
|
||||
{
|
||||
async runCommand(command, args, cwd) {
|
||||
calls.push([command, ...args, `@${cwd}`].join(" "));
|
||||
return { stdout: "", stderr: "" };
|
||||
},
|
||||
fetchImpl: vi.fn(async () => ({ ok: true })),
|
||||
sleepImpl: vi.fn(async () => {}),
|
||||
},
|
||||
);
|
||||
|
||||
expect(result.outputDir).toBe(path.join(repoRoot, ".artifacts/qa-docker"));
|
||||
expect(result.composeFile).toBe(
|
||||
path.join(repoRoot, ".artifacts/qa-docker/docker-compose.qa.yml"),
|
||||
);
|
||||
expect(calls).toEqual([
|
||||
`docker compose -f ${path.join(repoRoot, ".artifacts/qa-docker/docker-compose.qa.yml")} down --remove-orphans @${repoRoot}`,
|
||||
`docker compose -f ${path.join(repoRoot, ".artifacts/qa-docker/docker-compose.qa.yml")} up -d @${repoRoot}`,
|
||||
]);
|
||||
} finally {
|
||||
await rm(repoRoot, { recursive: true, force: true });
|
||||
}
|
||||
});
|
||||
|
||||
it("falls back to free host ports when defaults are already occupied", async () => {
|
||||
const outputDir = await mkdtemp(path.join(os.tmpdir(), "qa-docker-up-"));
|
||||
const gatewayPort = 18789;
|
||||
|
||||
@@ -20,7 +20,9 @@ type RunCommand = (
|
||||
|
||||
type FetchLike = (input: string) => Promise<{ ok: boolean }>;
|
||||
|
||||
const DEFAULT_QA_DOCKER_DIR = path.resolve(process.cwd(), ".artifacts/qa-docker");
|
||||
function resolveDefaultQaDockerDir(repoRoot: string) {
|
||||
return path.resolve(repoRoot, ".artifacts/qa-docker");
|
||||
}
|
||||
|
||||
function describeError(error: unknown) {
|
||||
if (error instanceof Error) {
|
||||
@@ -258,8 +260,8 @@ export async function runQaDockerUp(
|
||||
},
|
||||
): Promise<QaDockerUpResult> {
|
||||
const repoRoot = path.resolve(params.repoRoot ?? process.cwd());
|
||||
const outputDir = path.resolve(params.outputDir ?? DEFAULT_QA_DOCKER_DIR);
|
||||
const resolveHostPortImpl = deps?.resolveHostPortImpl ?? resolveHostPort;
|
||||
const outputDir = path.resolve(params.outputDir ?? resolveDefaultQaDockerDir(repoRoot));
|
||||
const gatewayPort = await resolveHostPortImpl(
|
||||
params.gatewayPort ?? 18789,
|
||||
params.gatewayPort != null,
|
||||
|
||||
Reference in New Issue
Block a user