Skip to content

Commit 6aa8337

Browse files
committed
fix(scripts): pin Docker preflight platform
1 parent 59950f7 commit 6aa8337

2 files changed

Lines changed: 24 additions & 2 deletions

File tree

scripts/test-docker-all.mjs

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -542,6 +542,15 @@ export function dockerPreflightContainerNames(raw) {
542542
);
543543
}
544544

545+
export function resolveDockerPreflightPlatform(arch = process.arch) {
546+
return arch === "arm64" ? "linux/arm64" : "linux/amd64";
547+
}
548+
549+
export function dockerPreflightSmokeCommand(arch = process.arch) {
550+
const platform = resolveDockerPreflightPlatform(arch);
551+
return `docker run --rm --platform ${shellQuote(platform)} alpine:3.20 true`;
552+
}
553+
545554
export function runShellCommand({ command, env, label, logFile, timeoutMs, noOutputTimeoutMs }) {
546555
return new Promise((resolve) => {
547556
const pipeOutput = Boolean(logFile || noOutputTimeoutMs > 0);
@@ -873,15 +882,15 @@ async function runDockerPreflight(baseEnv, options) {
873882

874883
const startedAt = Date.now();
875884
const run = await runShellCommand({
876-
command: "docker run --rm alpine:3.20 true",
885+
command: dockerPreflightSmokeCommand(),
877886
env: baseEnv,
878887
label: "docker-run-smoke",
879888
timeoutMs: options.runTimeoutMs,
880889
});
881890
const elapsedSeconds = Math.round((Date.now() - startedAt) / 1000);
882891
if (run.status !== 0) {
883892
throw new Error(
884-
`Docker preflight failed: docker run alpine:3.20 true status=${run.status} elapsed=${elapsedSeconds}s`,
893+
`Docker preflight failed: ${dockerPreflightSmokeCommand()} status=${run.status} elapsed=${elapsedSeconds}s`,
885894
);
886895
}
887896
console.log(`==> Docker preflight run: ${elapsedSeconds}s`);

test/scripts/docker-all-scheduler.test.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,10 @@ import {
1111
canStartSchedulerLane,
1212
describeDockerSchedulerLimits,
1313
dockerPreflightContainerNames,
14+
dockerPreflightSmokeCommand,
1415
LOG_TAIL_MAX_BYTES,
1516
parseDockerAllCliArgs,
17+
resolveDockerPreflightPlatform,
1618
runShellCommand,
1719
SHELL_CAPTURE_MAX_CHARS,
1820
tailFile,
@@ -417,6 +419,17 @@ postgres Created
417419
]);
418420
});
419421

422+
it("pins Docker preflight smoke to the native platform", () => {
423+
expect(resolveDockerPreflightPlatform("x64")).toBe("linux/amd64");
424+
expect(resolveDockerPreflightPlatform("arm64")).toBe("linux/arm64");
425+
expect(dockerPreflightSmokeCommand("x64")).toBe(
426+
"docker run --rm --platform 'linux/amd64' alpine:3.20 true",
427+
);
428+
expect(dockerPreflightSmokeCommand("arm64")).toBe(
429+
"docker run --rm --platform 'linux/arm64' alpine:3.20 true",
430+
);
431+
});
432+
420433
it("bounds captured preflight command output while keeping the newest tail", () => {
421434
const first = appendBoundedShellCapture("abc", "def", 8);
422435
expect(first).toEqual({ text: "abcdef", truncated: false });

0 commit comments

Comments
 (0)