mirror of
https://github.com/Swatinem/rust-cache
synced 2026-02-07 11:32:15 +00:00
fix: cache key dependency on installed packages
Add the installed packages to the environment element of the cache key so that CI tooling is considered. This ensures that rust CI tooling is cached correctly when changes occur. Prior to this a manual key change or cache expiry would need to occur before CI tools were correctly cached.
This commit is contained in:
parent
127a0e9568
commit
535f5f8f1c
4 changed files with 28 additions and 0 deletions
8
dist/restore/index.js
vendored
8
dist/restore/index.js
vendored
|
|
@ -60055,6 +60055,9 @@ class CacheConfig {
|
|||
}
|
||||
}
|
||||
self.keyEnvs = keyEnvs;
|
||||
// Installed packages and their versions are also considered for the key.
|
||||
const packages = await getPackages();
|
||||
hasher.update(packages);
|
||||
key += `-${hasher.digest("hex")}`;
|
||||
self.restoreKey = key;
|
||||
// Construct the lockfiles portion of the key:
|
||||
|
|
@ -60146,6 +60149,11 @@ async function getRustVersion() {
|
|||
.filter((s) => s.length === 2);
|
||||
return Object.fromEntries(splits);
|
||||
}
|
||||
async function getPackages() {
|
||||
let stdout = await getCmdOutput("cargo", ["install", "--list"]);
|
||||
// Make OS independent.
|
||||
return stdout.split(/[\n\r]+/).join("\n");
|
||||
}
|
||||
async function globFiles(pattern) {
|
||||
const globber = await glob.create(pattern, {
|
||||
followSymbolicLinks: false,
|
||||
|
|
|
|||
8
dist/save/index.js
vendored
8
dist/save/index.js
vendored
|
|
@ -60055,6 +60055,9 @@ class CacheConfig {
|
|||
}
|
||||
}
|
||||
self.keyEnvs = keyEnvs;
|
||||
// Installed packages and their versions are also considered for the key.
|
||||
const packages = await getPackages();
|
||||
hasher.update(packages);
|
||||
key += `-${hasher.digest("hex")}`;
|
||||
self.restoreKey = key;
|
||||
// Construct the lockfiles portion of the key:
|
||||
|
|
@ -60146,6 +60149,11 @@ async function getRustVersion() {
|
|||
.filter((s) => s.length === 2);
|
||||
return Object.fromEntries(splits);
|
||||
}
|
||||
async function getPackages() {
|
||||
let stdout = await getCmdOutput("cargo", ["install", "--list"]);
|
||||
// Make OS independent.
|
||||
return stdout.split(/[\n\r]+/).join("\n");
|
||||
}
|
||||
async function globFiles(pattern) {
|
||||
const globber = await glob.create(pattern, {
|
||||
followSymbolicLinks: false,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue