fix: use shell hashing instead of hashFiles() which returns empty on Gitea Actions
This commit is contained in:
@@ -16,6 +16,17 @@ outputs:
|
||||
runs:
|
||||
using: composite
|
||||
steps:
|
||||
# Gitea Actions does not have Cargo.lock by default (cargo generates it on first build),
|
||||
# and hashFiles() globs don't work reliably here. Use shell hashing instead.
|
||||
- name: Compute cache key
|
||||
id: cache-key
|
||||
shell: bash
|
||||
run: |
|
||||
# Hash both files; if Cargo.lock doesn't exist yet, only Cargo.toml is hashed
|
||||
HASH=$(cat Cargo.toml Cargo.lock 2>/dev/null | sha256sum | cut -d' ' -f1)
|
||||
echo "hash=$HASH" >> $GITHUB_OUTPUT
|
||||
echo "fingerprint=$HASH" >> $GITHUB_ENV
|
||||
|
||||
- name: Cache cargo + rustup
|
||||
id: cache
|
||||
uses: https://gitea.com/actions/cache@v3
|
||||
@@ -26,10 +37,8 @@ runs:
|
||||
~/.rustup/toolchains
|
||||
~/.rustup/settings.toml
|
||||
target
|
||||
key: rust-linux-${{ hashFiles('**/Cargo.lock') }}-${{ hashFiles('**/Cargo.toml') }}
|
||||
restore-keys: |
|
||||
rust-linux-${{ hashFiles('**/Cargo.lock') }}-
|
||||
rust-linux-
|
||||
key: rust-linux-${{ steps.cache-key.outputs.hash }}
|
||||
restore-keys: rust-linux-
|
||||
|
||||
- name: Setup Rust
|
||||
shell: bash
|
||||
|
||||
Reference in New Issue
Block a user