Skip to content

Commit

Permalink
Fix caching bug (1.4.1) (#69)
Browse files Browse the repository at this point in the history
  • Loading branch information
pavelzw authored May 13, 2023
1 parent 5f6b0b4 commit 5d5dbeb
Show file tree
Hide file tree
Showing 5 changed files with 56 additions and 5 deletions.
3 changes: 1 addition & 2 deletions .github/workflows/label.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ jobs:
repo-token: "${{ secrets.GITHUB_TOKEN }}"
- uses: mheap/github-action-required-labels@v4
with:
labels: |
"bug, enhancement, ci, documentation, dependencies, ignore-for-release"
labels: bug,enhancement,ci,documentation,dependencies,ignore-for-release
mode: minimum
count: 1
46 changes: 44 additions & 2 deletions .github/workflows/test-cache.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ jobs:
test-download2:
name: Test download cache 2/2
timeout-minutes: 10
needs: [test-download1]
needs: test-download1
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
Expand Down Expand Up @@ -69,7 +69,7 @@ jobs:
test-env2:
name: Test env cache 2/2
timeout-minutes: 10
needs: [test-env1]
needs: test-env1
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
Expand All @@ -85,3 +85,45 @@ jobs:
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
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [windows-latest, ubuntu-latest, macos-latest]
steps:
- uses: actions/checkout@v3
- uses: ./
with:
environment-file: test/environment.yml
cache-environment-key: env-then-download-env-${{ github.sha }}-${{ github.run_attempt }}
- name: test environment name
run: |
python -c "import os; env = os.path.basename(os.environ['CONDA_PREFIX']); assert env == 'env-name'"
test-env-then-download2:
name: Test env then download 2/2
timeout-minutes: 10
needs: test-env-then-download1
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [windows-latest, ubuntu-latest, macos-latest]
steps:
- uses: actions/checkout@v3
- uses: ./
with:
# Since the environment is cached, there will be no downloaded packages in $MAMBA_ROOT_PREFIX/pkgs.
# The caching should not fail because of this.
environment-file: test/environment.yml
cache-environment-key: env-then-download-env-${{ github.sha }}-${{ github.run_attempt }}
cache-downloads-key: env-then-download-download-${{ github.sha }}-${{ github.run_attempt }}
- name: test environment name
run: |
python -c "import os; env = os.path.basename(os.environ['CONDA_PREFIX']); assert env == 'env-name'"
test -d $MAMBA_ROOT_PREFIX
! test -d $MAMBA_ROOT_PREFIX/pkgs
5 changes: 5 additions & 0 deletions dist/post.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-micromamba",
"version": "1.4.0",
"version": "1.4.1",
"private": true,
"description": "Action to setup micromamba",
"scripts": {
Expand Down
5 changes: 5 additions & 0 deletions src/cache.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import path from 'path'
import * as fs from 'fs/promises'
import { existsSync } from 'fs'
import * as cache from '@actions/cache'
import * as coreDefault from '@actions/core'
import { coreMocked } from './mocking'
Expand Down Expand Up @@ -117,6 +118,10 @@ export const saveCacheDownloads = () => {
}
const cachePath = path.join(options.micromambaRootPath, 'pkgs')
const cacheDownloadsKey = generateDownloadsKey(options.cacheDownloadsKey)
if (!existsSync(cachePath)) {
core.debug(`Cache folder \`${cachePath}\` doesn't exist, skipping cache saving.`)
return Promise.resolve()
}
return trimPkgsCacheFolder(cachePath)
.then(() => {
core.startGroup(`Saving cache for \`${cachePath}\` ...`)
Expand Down

0 comments on commit 5d5dbeb

Please sign in to comment.