Skip to content

Commit 1306801

Browse files
committed
rust-cache-save: dodge manifest templating, resolve the target against the workspace
The save input's description quoted a literal expression, which the runner template-evaluates while loading the manifest — no github context exists there, so every consumer failed to load the action. The prune script now resolves the workspace-relative target directory against GITHUB_WORKSPACE instead of its working directory, which may sit in a nested crate for cargo metadata.
1 parent 9f4c2a9 commit 1306801

2 files changed

Lines changed: 8 additions & 1 deletion

File tree

‎.github/actions/rust-cache-save/action.yml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ description: >-
1111
inputs:
1212
save:
1313
description: >-
14-
Upload the pruned target. Pass `${{ github.ref == 'refs/heads/main' }}` for the
14+
Upload the pruned target. Pass the expression "github.ref == 'refs/heads/main'" for the
1515
restore-everywhere/save-on-main pattern.
1616
required: false
1717
default: "true"

‎.github/actions/rust-cache-save/prune-target.sh‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,14 @@
77
# DRY_RUN=1 prints what would go instead of removing it, for local runs.
88
set -euo pipefail
99

10+
# RUST_CI_TARGET_DIR is workspace-relative (the same string the cache paths
11+
# use), while this script may run in a nested working-directory for cargo
12+
# metadata — resolve against the workspace, not the cwd.
1013
target="${RUST_CI_TARGET_DIR:?rust-cache did not export RUST_CI_TARGET_DIR}"
14+
case "$target" in
15+
/*) ;;
16+
*) target="${GITHUB_WORKSPACE:-$PWD}/$target" ;;
17+
esac
1118
if [ ! -d "$target" ]; then
1219
echo "no $target directory; nothing to prune"
1320
exit 0

0 commit comments

Comments
 (0)