This commit is contained in:
@@ -38,22 +38,36 @@ jobs:
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Generate dependency hash
|
||||
id: deps_hash
|
||||
run: |
|
||||
# Create a hash of dependencies only (excludes package version)
|
||||
# This prevents cache invalidation on version bumps
|
||||
{
|
||||
# Get all dependencies from Cargo.toml (skip package.version)
|
||||
grep -A 9999 '^\[dependencies' Cargo.toml 2>/dev/null || true
|
||||
grep -A 9999 '^\[dev-dependencies' Cargo.toml 2>/dev/null || true
|
||||
grep -A 9999 '^\[build-dependencies' Cargo.toml 2>/dev/null || true
|
||||
# Include Cargo.lock for exact dependency versions
|
||||
cat Cargo.lock 2>/dev/null || true
|
||||
} | sha256sum | cut -d' ' -f1 > /tmp/deps_hash.txt
|
||||
echo "hash=$(cat /tmp/deps_hash.txt)" >> $GITHUB_OUTPUT
|
||||
|
||||
- name: Cache Cargo Dependencies
|
||||
uses: actions/cache@v3
|
||||
uses: https://gitea.com/actions/cache@v3
|
||||
with:
|
||||
# Path to cache: The 'target' directory contains all compiled libraries
|
||||
path: |
|
||||
~/.cargo/bin/
|
||||
~/.cargo/registry/
|
||||
~/.cargo/registry/index/
|
||||
~/.cargo/registry/cache/
|
||||
~/.cargo/git/db/
|
||||
target/
|
||||
# Key: Changes if OS, Rust toolchain, or dependencies change
|
||||
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}-${{ matrix.target }}
|
||||
# Restore Keys: Use for finding a cache from a slightly older lock file
|
||||
# Key: Changes only when dependencies change, not when version changes
|
||||
key: ${{ runner.os }}-cargo-${{ steps.deps_hash.outputs.hash }}-${{ matrix.target }}
|
||||
# Restore Keys: Fallback to any cache for this target
|
||||
restore-keys: |
|
||||
${{ runner.os }}-cargo-${{ matrix.target }}-
|
||||
${{ runner.os }}-cargo-${{ steps.deps_hash.outputs.hash }}-
|
||||
${{ runner.os }}-cargo-
|
||||
env:
|
||||
GHA_TAR_PATH: /usr/bin/tar
|
||||
|
||||
- name: Setup cross-compilation tools
|
||||
if: matrix.setup_cmd != ''
|
||||
|
||||
Reference in New Issue
Block a user