fix(perf): keep build_ref_binary stdout clean and fail fast on missing baseline (#4683)

git worktree add prints 'HEAD is now at …' on stdout, which polluted the
path captured from build_ref_binary and made the rig exec a two-line
string as the baseline binary (dispatch run 29087503110 died 1s after
spawn with 'No such file or directory'). Route command output to stderr,
verify the baseline binary exists before returning (exempt in dry-run),
and fix the 'mis-reports' typo flagged by the Typos check.
This commit is contained in:
Zhengchao An
2026-07-10 21:58:00 +08:00
committed by GitHub
parent 13f8768e7f
commit f13e98eb81
+9 -4
View File
@@ -186,10 +186,15 @@ build_ref_binary() {
local ref="$1" dest="$OUT_DIR/rustfs-baseline"
if [[ -n "$BASELINE_BIN" ]]; then echo "$BASELINE_BIN"; return; fi
local wt="$OUT_DIR/baseline-worktree"
run git worktree add --detach "$wt" "$ref"
run bash -c "cd '$wt' && cargo build --release --bin rustfs"
run cp "$wt/target/release/rustfs" "$dest" 2>/dev/null || true
run git worktree remove --force "$wt" 2>/dev/null || true
# This function returns the binary path on stdout, so every command's
# stdout must be routed to stderr: `git worktree add` prints "HEAD is now
# at …" on stdout, which polluted the captured path and made the rig exec
# a two-line string as the binary (2026-07-10 dispatch run failure).
run git worktree add --detach "$wt" "$ref" >&2
run bash -c "cd '$wt' && cargo build --release --bin rustfs" >&2
run cp "$wt/target/release/rustfs" "$dest" 2>/dev/null >&2 || true
run git worktree remove --force "$wt" 2>/dev/null >&2 || true
[[ "$DRY_RUN" == "true" || -x "$dest" ]] || { echo "error: baseline binary missing at $dest (baseline build failed?)" >&2; return 1; }
echo "$dest"
}