ci: fix SCCACHE_DIR expansion and use OS-specific default; cache the correct dir; guard mkdir; avoid literal /Users/zemaj in env

This commit is contained in:
James Peter
2025-08-24 06:58:38 +10:00
parent de54dbe217
commit 0a5960074d
+21 -4
View File
@@ -143,11 +143,28 @@ jobs:
core.exportVariable('ACTIONS_CACHE_URL', process.env.ACTIONS_CACHE_URL || '');
core.exportVariable('ACTIONS_RUNTIME_TOKEN', process.env.ACTIONS_RUNTIME_TOKEN || '');
# Compute a writable sccache directory per-OS and export to env
- name: Set sccache dir
shell: bash
run: |
case "${{ runner.os }}" in
macOS)
echo "SCCACHE_DIR=$HOME/Library/Caches/Mozilla.sccache" >> "$GITHUB_ENV"
;;
Linux)
echo "SCCACHE_DIR=$HOME/.cache/sccache" >> "$GITHUB_ENV"
;;
*)
# Use sccache default on Windows; no override
;;
esac
# Persist local sccache directory as a fallback/shared cache
- name: Cache sccache directory (fallback)
uses: actions/cache@v4
if: runner.os != 'Windows'
with:
path: ~/.cache/sccache
path: ${{ env.SCCACHE_DIR }}
key: sccache-${{ runner.os }}-${{ matrix.target }}-rust-1.89.0-${{ hashFiles('codex-rs/Cargo.lock') }}
restore-keys: |
sccache-${{ runner.os }}-${{ matrix.target }}-rust-1.89.0-
@@ -215,8 +232,6 @@ jobs:
SCCACHE_GHA_ENABLED: 'true'
# Avoid hard-fail if sccache server has IO error; prefer fallback
SCCACHE_IGNORE_SERVER_IO_ERROR: '1'
# Use a consistent local cache directory across OSes for fallback and caching
SCCACHE_DIR: $HOME/.cache/sccache
# Show more detail on failures
RUST_BACKTRACE: "1"
run: |
@@ -230,7 +245,9 @@ jobs:
if ! sccache --start-server; then
echo "sccache GHA backend failed to start; falling back to local disk cache"
unset SCCACHE_GHA_ENABLED
mkdir -p "$SCCACHE_DIR"
if [ -n "${SCCACHE_DIR:-}" ]; then
mkdir -p "$SCCACHE_DIR"
fi
if ! sccache --start-server; then
echo "sccache local cache also failed; disabling sccache"
unset RUSTC_WRAPPER