Skip to content

Commit 9b428a3

Browse files
authored
Add default package hash to cache key (#5821)
Without this there would be cache collisions of different default-packages. i.e. the symptom I was seeing was the cache would restore my conda environment but without the packages. I tested it here with torchcodec meta-pytorch/torchcodec#298 https://github.com/pytorch/torchcodec/actions/runs/11523232397/job/32081186451?pr=298 And it seems to be working fine. Example the cache key contains the package hashes: <img width="1193" alt="image" src="https://github.com/user-attachments/assets/f04d6ac9-ff72-4f07-b5ef-831b6d3fd09f">
1 parent aa4554a commit 9b428a3

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

.github/actions/setup-miniconda/action.yml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,13 +40,14 @@ runs:
4040
shell: bash
4141
run: |
4242
echo "today=$(/bin/date -u '+%Y%m%d')d" >> "${GITHUB_OUTPUT}"
43+
echo "default_packages_checksum=$(echo -n ${{ inputs.default-packages }} | md5sum | awk '{print $1}' )" >> "${GITHUB_OUTPUT}"
4344
4445
- name: Setup miniconda cache
4546
id: miniconda-cache
4647
uses: actions/cache@v3
4748
with:
4849
path: ${{ runner.temp }}/miniconda
49-
key: miniconda-${{ inputs.miniconda-version }}-${{ runner.os }}-${{ runner.arch }}-${{ inputs.python-version }}-${{ steps.get-date.outputs.today }}
50+
key: miniconda-${{ inputs.miniconda-version }}-${{ runner.os }}-${{ runner.arch }}-${{ inputs.python-version }}-${{ steps.get-date.outputs.default_packages_checksum }}-${{ steps.get-date.outputs.today }}
5051

5152
- name: Install miniconda (${{ inputs.miniconda-version }})
5253
if: steps.miniconda-cache.outputs.cache-hit != 'true'
@@ -104,7 +105,7 @@ runs:
104105
uses: actions/cache@v3
105106
with:
106107
path: ${{ runner.temp }}/conda-python-${{ inputs.python-version }}
107-
key: miniconda-env-${{ runner.os }}-${{ runner.arch }}-${{ inputs.python-version }}-${{ steps.get-date.outputs.today }}-${{ hashFiles(inputs.environment-file) }}-${{ hashFiles(inputs.pip-requirements-file) }}
108+
key: miniconda-env-${{ runner.os }}-${{ runner.arch }}-${{ inputs.python-version }}-${{ steps.get-date.outputs.default_packages_checksum }}-${{ steps.get-date.outputs.today }}-${{ hashFiles(inputs.environment-file) }}-${{ hashFiles(inputs.pip-requirements-file) }}
108109

109110
- name: Setup conda environment with python (v${{ inputs.python-version }})
110111
if: steps.miniconda-env-cache.outcome == 'success' && steps.miniconda-env-cache.outputs.cache-hit != 'true'

0 commit comments

Comments
 (0)