Add env path to cache key (#36)

This commit is contained in:
Pavel Zwerschke
2023-11-14 20:11:14 +01:00
committed by GitHub
parent 69d34221c7
commit ccc5c07ed9
3 changed files with 15 additions and 3 deletions
Generated Vendored
+6 -1
View File
@@ -61228,7 +61228,12 @@ var import_promises = __toESM(require("fs/promises"));
var import_path2 = __toESM(require("path"));
var core3 = __toESM(require_core());
var cache = __toESM(require_cache());
var generateCacheKey = async (cacheKeyPrefix) => import_promises.default.readFile(options.pixiLockFile, "utf-8").then((content) => `${cacheKeyPrefix}${getCondaArch()}-${sha256(content)}`).catch((err) => {
var generateCacheKey = async (cacheKeyPrefix) => import_promises.default.readFile(options.pixiLockFile, "utf-8").then((content) => {
const contentsSha = sha256(content);
const lockFileSha = sha256(options.pixiLockFile);
const sha = sha256(contentsSha + lockFileSha);
return `${cacheKeyPrefix}${getCondaArch()}-${sha}`;
}).catch((err) => {
throw new Error(`Failed to generate cache key: ${err}`);
});
var cachePath = import_path2.default.join(import_path2.default.dirname(options.pixiLockFile), ".pixi");
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "setup-pixi",
"version": "0.4.0",
"version": "0.4.1",
"private": true,
"description": "Action to set up the pixi package manager.",
"scripts": {
+8 -1
View File
@@ -8,7 +8,14 @@ import { getCondaArch, sha256 } from './util'
export const generateCacheKey = async (cacheKeyPrefix: string) =>
fs
.readFile(options.pixiLockFile, 'utf-8')
.then((content) => `${cacheKeyPrefix}${getCondaArch()}-${sha256(content)}`)
.then((content) => {
const contentsSha = sha256(content)
// the path to the lock file decides where the pixi env is created (../.pixi/env)
// since conda envs are not relocatable, we need to include the path in the cache key
const lockFileSha = sha256(options.pixiLockFile)
const sha = sha256(contentsSha + lockFileSha)
return `${cacheKeyPrefix}${getCondaArch()}-${sha}`
})
.catch((err) => {
throw new Error(`Failed to generate cache key: ${err}`)
})