Cache keys need the lockfile hash, and a restore-key without it
Key a cache only on the OS and it never updates. Key it on the lockfile hash and one changed dependency means a complete miss. You want both.
- uses: actions/cache@v4
with:
path: ~/.local/share/pnpm/store
key: pnpm-${{ runner.os }}-${{ hashFiles('pnpm-lock.yaml') }}
restore-keys: pnpm-${{ runner.os }}-An exact hit costs nothing. On a miss it restores the latest cache for that OS, so the install only has to fetch what changed.
ci