Skip to content

Commit 113af2f

Browse files
committed
fix(ci): preserve stdin through Docker heartbeat logging
1 parent 238c8bf commit 113af2f

2 files changed

Lines changed: 36 additions & 1 deletion

File tree

‎scripts/lib/docker-e2e-logs.sh‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ run_logged_print_heartbeat() {
153153
trap 'cleanup_heartbeat_command 130' INT
154154
trap 'cleanup_heartbeat_command 143' TERM
155155
trap 'cleanup_heartbeat_command 129' HUP
156-
"$@" >"$log_file" 2>&1 &
156+
"$@" <&0 >"$log_file" 2>&1 &
157157
command_pid=$!
158158
local started_at="$SECONDS"
159159
local next_heartbeat=$interval_seconds

‎test/scripts/docker-build-helper.test.ts‎

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2932,6 +2932,41 @@ output="$(docker_e2e_maybe_print_log_heartbeat plugins-run 1 1 "$TMPDIR/run.log"
29322932
execFileSync("bash", ["-lc", script], { encoding: "utf8" });
29332933
});
29342934

2935+
it("preserves heredoc stdin through Docker E2E heartbeat logging", () => {
2936+
const workDir = tempDirs.make("openclaw-docker-e2e-log-stdin-");
2937+
const script = repoShell(workDir)`
2938+
2939+
source "$ROOT_DIR/scripts/lib/docker-e2e-logs.sh"
2940+
2941+
run_logged_print_heartbeat plugins-run 30 bash -s <<'SH'
2942+
printf "first payload line\\nsecond payload line\\n"
2943+
SH
2944+
`;
2945+
2946+
expect(execFileSync("bash", ["-lc", script], { encoding: "utf8" })).toBe(
2947+
"first payload line\nsecond payload line\n",
2948+
);
2949+
});
2950+
2951+
it("preserves failing heredoc output and status through Docker E2E heartbeat logging", () => {
2952+
const workDir = tempDirs.make("openclaw-docker-e2e-log-failing-stdin-");
2953+
const script = repoShell(workDir)`
2954+
2955+
source "$ROOT_DIR/scripts/lib/docker-e2e-logs.sh"
2956+
2957+
run_logged_print_heartbeat plugins-run 30 bash -s <<'SH'
2958+
printf "captured failure output\\n"
2959+
exit 37
2960+
SH
2961+
`;
2962+
2963+
const result = spawnSync("bash", ["-lc", script], { encoding: "utf8" });
2964+
2965+
expect(result.status).toBe(37);
2966+
expect(result.stdout).toBe("captured failure output\n");
2967+
expect(result.stderr).toBe("");
2968+
});
2969+
29352970
it("cleans the heartbeat command when the wrapper is terminated", () => {
29362971
const workDir = tempDirs.make("openclaw-docker-e2e-log-term-cleanup-");
29372972
const script = repoShell(workDir)`

0 commit comments

Comments
 (0)