@@ -38,26 +38,26 @@ format_bytes() {
3838 fi
3939}
4040
41- # Build a ref in a temporary worktree, print byte count to stdout.
41+ # Build a ref in a worktree placed inside the repo root so that Cargo's
42+ # path-based fingerprints are stable across runs (no /tmp/tmp.xxx/ variance).
4243build_ref () {
4344 local ref=" $1 "
4445 local label=" $2 "
45- local worktree
46- worktree=" $( mktemp -d) "
46+ local short
47+ short=" $( git -C " $REPO_ROOT " rev-parse --short " $ref " ) "
48+ local worktree=" $REPO_ROOT /.worktree-size-$label "
4749
48- echo " Building $label ($( git -C " $REPO_ROOT " rev-parse -- short " $ref " ) )…" >&2
50+ echo " Building $label ($short )…" >&2
4951
5052 git -C " $REPO_ROOT " worktree add --detach " $worktree " " $ref " 2>&1 | sed ' s/^/ /' >&2
5153
5254 # cargo writes to stderr; wc -c is the only stdout line.
5355 # Always use the script from the current checkout (base may not have it).
54- # Override WORKSPACE_ROOT so the script builds the worktree, not itself.
55- # Point CARGO_TARGET_DIR at the main worktree so both builds share the cache.
56- # Redirect build stderr → our stderr so CI logs show progress.
56+ # Override WORKSPACE_ROOT so the script builds the worktree's sources.
57+ # CARGO_TARGET_DIR is fixed so both refs share the same build cache.
5758 CARGO_TARGET_DIR=" $REPO_ROOT /target" \
5859 WORKSPACE_ROOT=" $worktree " \
5960 bash " $BUILD_SCRIPT " 2>&3
60- # (stdout = byte count, captured by the caller via $())
6161
6262 git -C " $REPO_ROOT " worktree remove --force " $worktree " 2> /dev/null || true
6363 rm -rf " $worktree "
0 commit comments