Skip to content

Commit

Permalink
Add root prefix to cache key (#158)
Browse files Browse the repository at this point in the history
  • Loading branch information
pavelzw committed Oct 11, 2023
1 parent 01bedba commit dde38e2
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 2 deletions.
40 changes: 40 additions & 0 deletions .github/workflows/test-cache.yml
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,46 @@ jobs:
python -c "import os; env = os.path.basename(os.environ['CONDA_PREFIX']); assert env == 'env-name'"
test-env-changing-root-path1:
name: Test env cache with changing root path 1/2
timeout-minutes: 10
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [windows-latest, ubuntu-latest, macos-latest]
steps:
- uses: actions/checkout@v4
- uses: ./
with:
environment-file: test/environment.yml
cache-environment-key: env-root-path-key-${{ github.sha }}-${{ github.run_attempt }}
micromamba-root-path: ~/micromamba
- name: test environment name
run: |
python -c "import os; env = os.path.basename(os.environ['CONDA_PREFIX']); assert env == 'env-name'"
test-env-changing-root-path2:
name: Test env cache with changing root path 2/2
timeout-minutes: 10
needs: test-env-changing-root-path1
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [windows-latest, ubuntu-latest, macos-latest]
steps:
- uses: actions/checkout@v4
- uses: ./
with:
environment-file: test/environment.yml
cache-environment-key: env-root-path-key-${{ github.sha }}-${{ github.run_attempt }}
micromamba-root-path: ~/micromamba2
- name: test environment name
run: |
python -c "import os; env = os.path.basename(os.environ['CONDA_PREFIX']); assert env == 'env-name'"
test-env-then-download1:
name: Test env then download 1/2
timeout-minutes: 10
Expand Down
3 changes: 2 additions & 1 deletion dist/index.js

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

3 changes: 2 additions & 1 deletion src/cache.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,8 @@ const generateEnvironmentKey = (prefix: string) => {
const arch = `-${getCondaArch()}`
const envName = options.environmentName ? `-${options.environmentName}` : ''
const createArgs = options.createArgs ? `-args-${sha256Short(JSON.stringify(options.createArgs))}` : ''
const key = `${prefix}${arch}${envName}${createArgs}`
const rootPrefix = `-root-${sha256Short(options.micromambaRootPath)}`
const key = `${prefix}${arch}${envName}${createArgs}${rootPrefix}`
if (options.environmentFile) {
return fs.readFile(options.environmentFile, 'utf-8').then((content) => {
const keyWithFileSha = `${key}-file-${sha256(content)}`
Expand Down

0 comments on commit dde38e2

Please sign in to comment.