mirror of
https://github.com/Swatinem/rust-cache.git
synced 2025-08-15 05:05:09 +00:00
Include env vars in the generated cache key
This commit is contained in:
parent
f8f67b7515
commit
5f6b32160d
10
dist/restore/index.js
vendored
10
dist/restore/index.js
vendored
@ -59564,6 +59564,7 @@ async function getCacheConfig() {
|
|||||||
key += `${job}-`;
|
key += `${job}-`;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
key += `${getEnvKey()}-`;
|
||||||
key += await getRustKey();
|
key += await getRustKey();
|
||||||
return {
|
return {
|
||||||
paths: [
|
paths: [
|
||||||
@ -59594,6 +59595,15 @@ async function getCargoBins() {
|
|||||||
return new Set();
|
return new Set();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
function getEnvKey() {
|
||||||
|
const hasher = external_crypto_default().createHash("sha1");
|
||||||
|
for (const [key, value] of Object.entries(process.env)) {
|
||||||
|
if (value) {
|
||||||
|
hasher.update(`${key}=${value}`);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return hasher.digest("hex").slice(0, 20);
|
||||||
|
}
|
||||||
async function getRustKey() {
|
async function getRustKey() {
|
||||||
const rustc = await getRustVersion();
|
const rustc = await getRustVersion();
|
||||||
return `${rustc.release}-${rustc.host}-${rustc["commit-hash"].slice(0, 12)}`;
|
return `${rustc.release}-${rustc.host}-${rustc["commit-hash"].slice(0, 12)}`;
|
||||||
|
10
dist/save/index.js
vendored
10
dist/save/index.js
vendored
@ -59564,6 +59564,7 @@ async function getCacheConfig() {
|
|||||||
key += `${job}-`;
|
key += `${job}-`;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
key += `${getEnvKey()}-`;
|
||||||
key += await getRustKey();
|
key += await getRustKey();
|
||||||
return {
|
return {
|
||||||
paths: [
|
paths: [
|
||||||
@ -59594,6 +59595,15 @@ async function getCargoBins() {
|
|||||||
return new Set();
|
return new Set();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
function getEnvKey() {
|
||||||
|
const hasher = external_crypto_default().createHash("sha1");
|
||||||
|
for (const [key, value] of Object.entries(process.env)) {
|
||||||
|
if (value) {
|
||||||
|
hasher.update(`${key}=${value}`);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return hasher.digest("hex").slice(0, 20);
|
||||||
|
}
|
||||||
async function getRustKey() {
|
async function getRustKey() {
|
||||||
const rustc = await getRustVersion();
|
const rustc = await getRustVersion();
|
||||||
return `${rustc.release}-${rustc.host}-${rustc["commit-hash"].slice(0, 12)}`;
|
return `${rustc.release}-${rustc.host}-${rustc["commit-hash"].slice(0, 12)}`;
|
||||||
|
1
package-lock.json
generated
1
package-lock.json
generated
@ -5,6 +5,7 @@
|
|||||||
"requires": true,
|
"requires": true,
|
||||||
"packages": {
|
"packages": {
|
||||||
"": {
|
"": {
|
||||||
|
"name": "rust-cache",
|
||||||
"version": "1.2.0",
|
"version": "1.2.0",
|
||||||
"license": "LGPL-3.0",
|
"license": "LGPL-3.0",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
|
@ -71,6 +71,7 @@ export async function getCacheConfig(): Promise<CacheConfig> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
key += `${getEnvKey()}-`;
|
||||||
key += await getRustKey();
|
key += await getRustKey();
|
||||||
|
|
||||||
return {
|
return {
|
||||||
@ -105,6 +106,17 @@ export async function getCargoBins(): Promise<Set<string>> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function getEnvKey(): string {
|
||||||
|
const hasher = crypto.createHash("sha1");
|
||||||
|
for (const [key, value] of Object.entries(process.env)) {
|
||||||
|
if (value) {
|
||||||
|
hasher.update(`${key}=${value}`);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return hasher.digest("hex").slice(0, 20);
|
||||||
|
}
|
||||||
|
|
||||||
async function getRustKey(): Promise<string> {
|
async function getRustKey(): Promise<string> {
|
||||||
const rustc = await getRustVersion();
|
const rustc = await getRustVersion();
|
||||||
return `${rustc.release}-${rustc.host}-${rustc["commit-hash"].slice(0, 12)}`;
|
return `${rustc.release}-${rustc.host}-${rustc["commit-hash"].slice(0, 12)}`;
|
||||||
@ -249,5 +261,5 @@ export async function rm(parent: string, dirent: fs.Dirent) {
|
|||||||
} else if (dirent.isDirectory()) {
|
} else if (dirent.isDirectory()) {
|
||||||
await io.rmRF(fileName);
|
await io.rmRF(fileName);
|
||||||
}
|
}
|
||||||
} catch {}
|
} catch { }
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user