From 18ca46a3d66c5bdaa9de7db9739fcd22dc89a09e Mon Sep 17 00:00:00 2001 From: David Mann Date: Mon, 16 Nov 2026 00:05:21 +0100 Subject: [PATCH] ci: stop when the Windows cache target path cannot be computed (#15232) An empty path made rust-cache treat the checkout as its target directory. --- .github/workflows/ci.yml | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index be9cf42ee2..b8ff3e6e25 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -214,7 +214,15 @@ jobs: # cache found nothing to restore or save and every run built all dependencies from scratch. - name: Target directory for the dependency cache id: cache-target - run: echo "relative=$(realpath -m --relative-to="$(cygpath -u "$GITHUB_WORKSPACE")" "$(cygpath -u "$CARGO_TARGET_DIR")")" >> "$GITHUB_OUTPUT" + # An empty path would make rust-cache treat the checkout itself as the target directory, + # which its cleanup then prunes, so stop rather than write one. + run: | + relative=$(realpath -m --relative-to="$(cygpath -u "$GITHUB_WORKSPACE")" "$(cygpath -u "$CARGO_TARGET_DIR")") + if [ -z "$relative" ] || [ "$relative" = . ]; then + echo "::error::no target directory for rust-cache from CARGO_TARGET_DIR='$CARGO_TARGET_DIR'" + exit 1 + fi + echo "relative=$relative" >> "$GITHUB_OUTPUT" shell: bash # Only main saves caches; PRs restore main's, so the repo's 10 GB cache budget keeps main's.