Skip to content

Commit f190cd1

Browse files
authored
Fix caching of conda environment (#794)
1 parent 025ede7 commit f190cd1

File tree

2 files changed

+42
-27
lines changed

2 files changed

+42
-27
lines changed

.github/workflows/ci.yml

Lines changed: 28 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -43,25 +43,30 @@ jobs:
4343
with:
4444
fetch-depth: 0
4545

46-
- name: Restore conda environment cache
47-
id: conda-cache
48-
uses: actions/cache@v4
49-
with:
50-
path: ${{ env.CONDA_INSTALL_DIR }}
51-
key: conda-${{ runner.os }}-py${{ matrix.python }}-${{ hashFiles('environment-dev.yml') }}
52-
53-
- name: Create Helios dev environment
46+
- name: Setup Miniconda
5447
uses: conda-incubator/setup-miniconda@v3
5548
with:
5649
installation-dir: ${{ env.CONDA_INSTALL_DIR }}
5750
auto-update-conda: true
5851
conda-remove-defaults: true
52+
channels: conda-forge
5953
auto-activate: false
6054
activate-environment: helios-dev
61-
environment-file: environment-dev.yml
6255
python-version: ${{ matrix.python }}
6356
miniconda-version: "latest"
6457

58+
- name: Restore conda environment cache
59+
id: conda-cache
60+
uses: actions/cache@v4
61+
with:
62+
path: ${{ env.CONDA_INSTALL_DIR }}/envs/helios-dev
63+
key: conda-env-v2-${{ runner.os }}-py${{ matrix.python }}-${{ hashFiles('environment-dev.yml') }}
64+
65+
- name: Create Helios dev environment
66+
if: steps.conda-cache.outputs.cache-hit != 'true'
67+
run: |
68+
conda env update -n helios-dev -f environment-dev.yml --prune || conda env create -n helios-dev -f environment-dev.yml
69+
6570
- name: Install Conda GCC
6671
if: runner.os == 'Linux'
6772
run: |
@@ -110,25 +115,30 @@ jobs:
110115
with:
111116
fetch-depth: 0
112117

113-
- name: Restore conda environment cache
114-
id: conda-cache
115-
uses: actions/cache@v4
116-
with:
117-
path: ${{ env.CONDA_INSTALL_DIR }}
118-
key: conda-${{ runner.os }}-py3.10-${{ hashFiles('environment-dev.yml') }}
119-
120-
- name: Create Helios dev environment
118+
- name: Setup Miniconda
121119
uses: conda-incubator/setup-miniconda@v3
122120
with:
123121
installation-dir: ${{ env.CONDA_INSTALL_DIR }}
124122
auto-update-conda: true
125123
conda-remove-defaults: true
124+
channels: conda-forge
126125
auto-activate: false
127126
activate-environment: helios-dev
128-
environment-file: environment-dev.yml
129127
python-version: "3.10"
130128
miniconda-version: "latest"
131129

130+
- name: Restore conda environment cache
131+
id: conda-cache
132+
uses: actions/cache@v4
133+
with:
134+
path: ${{ env.CONDA_INSTALL_DIR }}/envs/helios-dev
135+
key: conda-env-v2-${{ runner.os }}-py3.10-${{ hashFiles('environment-dev.yml') }}
136+
137+
- name: Create Helios dev environment
138+
if: steps.conda-cache.outputs.cache-hit != 'true'
139+
run: |
140+
conda env update -n helios-dev -f environment-dev.yml --prune || conda env create -n helios-dev -f environment-dev.yml
141+
132142
- name: Install Conda GCC
133143
run: |
134144
conda install -y -c conda-forge gcc gxx

.github/workflows/coverage.yml

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -29,25 +29,30 @@ jobs:
2929
with:
3030
fetch-depth: 0
3131

32-
- name: Restore conda environment cache
33-
id: conda-cache
34-
uses: actions/cache@v4
35-
with:
36-
path: ${{ env.CONDA_INSTALL_DIR }}
37-
key: conda-${{ runner.os }}-py3.14-${{ hashFiles('environment-dev.yml') }}
38-
39-
- name: Create Helios dev environment
32+
- name: Setup Miniconda
4033
uses: conda-incubator/setup-miniconda@v3
4134
with:
4235
installation-dir: ${{ env.CONDA_INSTALL_DIR }}
4336
auto-update-conda: true
4437
conda-remove-defaults: true
38+
channels: conda-forge
4539
auto-activate: false
4640
activate-environment: helios-dev
47-
environment-file: environment-dev.yml
4841
python-version: "3.14"
4942
miniconda-version: "latest"
5043

44+
- name: Restore conda environment cache
45+
id: conda-cache
46+
uses: actions/cache@v4
47+
with:
48+
path: ${{ env.CONDA_INSTALL_DIR }}/envs/helios-dev
49+
key: conda-env-v2-${{ runner.os }}-py3.14-${{ hashFiles('environment-dev.yml') }}
50+
51+
- name: Create Helios dev environment
52+
if: steps.conda-cache.outputs.cache-hit != 'true'
53+
run: |
54+
conda env update -n helios-dev -f environment-dev.yml --prune || conda env create -n helios-dev -f environment-dev.yml
55+
5156
- name: Install Conda GCC
5257
run: |
5358
conda install -y -c conda-forge gcc gxx

0 commit comments

Comments
 (0)