Skip to content

Commit

Permalink
Add env path to cache key (#36)
Browse files Browse the repository at this point in the history
  • Loading branch information
pavelzw authored Nov 14, 2023
1 parent 69d3422 commit ccc5c07
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 3 deletions.
7 changes: 6 additions & 1 deletion dist/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -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": {
Expand Down
9 changes: 8 additions & 1 deletion src/cache.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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}`)
})
Expand Down

0 comments on commit ccc5c07

Please sign in to comment.