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.
This commit is contained in:
David Mann
2026-11-16 00:05:21 +01:00
parent c55c24aa47
commit 18ca46a3d6
+9 -1
View File
@@ -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.