ci(release): fix sccache caching - use SCCACHE_GHA_VERSION instead of non-existent variables

The SCCACHE_GHA_CACHE_TO and SCCACHE_GHA_CACHE_FROM environment variables don't exist in sccache v0.10.0.
They were mentioned in a PR but never implemented. The correct variable is SCCACHE_GHA_VERSION which
creates unique cache namespaces by being SHA256 hashed along with the sccache version string.

This should finally enable proper cache hits across workflow runs.
This commit is contained in:
James Peter
2025-08-24 11:54:57 +10:00
parent 5518dd5731
commit 43e4c058ee
2 changed files with 9 additions and 17 deletions
+5 -4
View File
@@ -124,9 +124,9 @@ jobs:
- name: Configure sccache cache keys
shell: bash
run: |
# Use stable cache keys that persist across runs
echo "SCCACHE_GHA_CACHE_TO=sccache-${{ matrix.target }}-rust-1.89-v3" >> "$GITHUB_ENV"
echo "SCCACHE_GHA_CACHE_FROM=sccache-${{ matrix.target }}-rust-1.89-v3,sccache-${{ matrix.target }}-rust-1.89-v2" >> "$GITHUB_ENV"
# SCCACHE_GHA_VERSION creates a unique namespace for the cache
# This gets SHA256 hashed to create the cache "name" field
echo "SCCACHE_GHA_VERSION=${{ matrix.target }}-rust-1.89-v3" >> "$GITHUB_ENV"
# ✅ Current sccache action (GHAC support). Do not hand-edit ACTIONS_* envs.
- name: Setup sccache (GHA backend)
@@ -251,7 +251,8 @@ jobs:
echo "=== Initial sccache stats ==="
if command -v sccache >/dev/null 2>&1; then
sccache --show-stats || true
echo "Cache keys: TO=${SCCACHE_GHA_CACHE_TO:-not set}, FROM=${SCCACHE_GHA_CACHE_FROM:-not set}"
echo "Cache version: ${SCCACHE_GHA_VERSION:-not set}"
echo "Expected cache name hash: $(echo -n "sccache-v0.10.0-${SCCACHE_GHA_VERSION}" | shasum -a 256 | cut -d' ' -f1)"
fi
# Calculate parallel jobs
+4 -13
View File
@@ -238,7 +238,8 @@ ${USE_CARGO} build ${USE_LOCKED} --profile "${PROFILE}" --bin code --bin code-tu
# Check if build succeeded
if [ $? -eq 0 ]; then
echo "✅ Build successful!"
echo "Binary location: ${BIN_PATH}"
echo "Binary location: ./codex-rs/target/${PROFILE}/code"
echo ""
# Keep old symlink locations working for compatibility
# Create symlink in target/release for npm wrapper expectations
@@ -264,8 +265,6 @@ if [ $? -eq 0 ]; then
ln -sf "../../codex-rs/target/${PROFILE}/code" "$DEST"
done
echo "✅ Symlinks updated"
echo ""
# Optional post-link step for deterministic builds: re-link executables
# with -no_uuid only on macOS. Apply per-bin via `cargo rustc` so
# dependencies/proc-macro dylibs are not affected.
@@ -297,18 +296,10 @@ if [ $? -eq 0 ]; then
ln -sf "../${PROFILE}/code" "./target/dev-fast/code"
fi
echo "You can run the CLI directly:"
if [ -n "$BIN_SHA" ]; then
echo " ${ABS_BIN_PATH} (sha256: ${BIN_SHA})"
echo "Binary Hash: ${BIN_SHA} ($(du -sh "${ABS_BIN_PATH}" | awk '{print $1}'))"
else
echo " ${ABS_BIN_PATH}"
fi
echo "Binary size: $(du -h "${ABS_BIN_PATH}" | cut -f1)"
echo ""
echo "Build profile: ${PROFILE}"
if [ "$PROFILE" = "dev-fast" ]; then
echo " → Optimized for fast iteration (incremental builds enabled)"
echo " → For production build, use: PROFILE=release-prod ./build-fast.sh"
echo "Binary Size: $(du -h "${ABS_BIN_PATH}" | cut -f1)"
fi
if [ "${TRACE_BUILD:-}" = "1" ] && [ -n "$BIN_SHA" ]; then