mirror of
https://github.com/moonrepo/setup-rust.git
synced 2025-04-29 13:30:03 +00:00
Improve cache key.
This commit is contained in:
parent
8a603fb6f3
commit
dfc6a0d9ae
1 changed files with 15 additions and 1 deletions
16
src/cache.ts
16
src/cache.ts
|
@ -47,12 +47,26 @@ export async function getPrimaryCacheKey() {
|
||||||
core.debug(`Hashing target profile = ${cacheTarget}`);
|
core.debug(`Hashing target profile = ${cacheTarget}`);
|
||||||
hasher.update(cacheTarget);
|
hasher.update(cacheTarget);
|
||||||
|
|
||||||
|
// When warming up, loosen the cache key to allow for more cache hits
|
||||||
if (core.getInput('cache-base')) {
|
if (core.getInput('cache-base')) {
|
||||||
core.debug('Using warmup strategy, not hashing Cargo.lock, GITHUB_WORKFLOW, or GITHUB_JOB');
|
core.debug('Using warmup strategy, not hashing Cargo.lock, GITHUB_WORKFLOW, or GITHUB_JOB');
|
||||||
hasher.update('warmup');
|
hasher.update('warmup');
|
||||||
|
|
||||||
|
const baseRef = process.env.GITHUB_BASE_REF ?? '';
|
||||||
|
|
||||||
|
if (
|
||||||
|
baseRef === 'master' ||
|
||||||
|
baseRef === 'main' ||
|
||||||
|
baseRef === 'trunk' ||
|
||||||
|
baseRef.startsWith('develop') ||
|
||||||
|
baseRef.startsWith('release')
|
||||||
|
) {
|
||||||
|
core.debug(`Hashing GITHUB_BASE_REF = ${baseRef}`);
|
||||||
|
hasher.update(baseRef);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// When warming up, these add far too much granularity to the cache key
|
// Otherwise, these add far too much granularity to the cache key
|
||||||
else {
|
else {
|
||||||
const lockHash = await glob.hashFiles('Cargo.lock');
|
const lockHash = await glob.hashFiles('Cargo.lock');
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue