Skip to content

Commit 1a6b55c

Browse files
jezdezkenodegardjaimergp
authored
Make conda’s package directories configurable (#328)
Co-authored-by: Ken Odegard <[email protected]> Co-authored-by: jaimergp <[email protected]>
1 parent 6225267 commit 1a6b55c

File tree

13 files changed

+2901
-104
lines changed

13 files changed

+2901
-104
lines changed

.github/workflows/caching-example.yml

Lines changed: 33 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,12 @@ concurrency:
1919
cancel-in-progress: true
2020

2121
jobs:
22-
caching-example:
22+
caching-ubuntu:
2323
# prevent cronjobs from running on forks
2424
if:
2525
(github.event_name == 'schedule' && github.repository ==
2626
'conda-incubator/setup-miniconda') || (github.event_name != 'schedule')
27-
name: Caching
27+
name: Caching on Ubuntu
2828
runs-on: "ubuntu-latest"
2929
timeout-minutes: 30
3030
steps:
@@ -35,6 +35,8 @@ jobs:
3535
# Increase this value to reset cache if etc/example-environment.yml has not changed
3636
CACHE_NUMBER: 2
3737
with:
38+
# Use faster GNU tar
39+
enableCrossOsArchive: true
3840
path: ~/conda_pkgs_dir
3941
key:
4042
${{ runner.os }}-conda-${{ env.CACHE_NUMBER }}-${{
@@ -45,3 +47,32 @@ jobs:
4547
channel-priority: strict
4648
environment-file: etc/example-environment-caching.yml
4749
use-only-tar-bz2: true
50+
caching-windows:
51+
# prevent cronjobs from running on forks
52+
if:
53+
(github.event_name == 'schedule' && github.repository ==
54+
'conda-incubator/setup-miniconda') || (github.event_name != 'schedule')
55+
name: Caching on Windows
56+
runs-on: "windows-latest"
57+
timeout-minutes: 30
58+
steps:
59+
- uses: actions/checkout@v4
60+
- name: Cache conda
61+
uses: actions/cache@v3
62+
env:
63+
# Increase this value to reset cache if etc/example-environment.yml has not changed
64+
CACHE_NUMBER: 2
65+
with:
66+
# Use faster GNU tar
67+
enableCrossOsArchive: true
68+
path: D:\conda_pkgs_dir
69+
key:
70+
${{ runner.os }}-conda-${{ env.CACHE_NUMBER }}-${{
71+
hashFiles('etc/example-environment.yml') }}
72+
- uses: ./
73+
with:
74+
activate-environment: anaconda-client-env
75+
channel-priority: strict
76+
environment-file: etc/example-environment-caching.yml
77+
pkgs-dirs: D:\conda_pkgs_dir
78+
- run: conda info

README.md

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -676,6 +676,45 @@ jobs:
676676
use-only-tar-bz2: true # IMPORTANT: This needs to be set for caching to work properly!
677677
```
678678

679+
You may also set conda's package directories (`pkgs_dirs`) config value, if you
680+
want to change setup-miniconda's default of `~/conda_pkgs_dir` with the
681+
`pkgs-dirs` config option. This is a comma-separated string like the channels
682+
config option:
683+
684+
```yaml
685+
jobs:
686+
caching-example:
687+
name: Caching
688+
runs-on: "windows-latest"
689+
steps:
690+
- uses: actions/checkout@v4
691+
- name: Cache conda
692+
uses: actions/cache@v3
693+
env:
694+
# Increase this value to reset cache if etc/example-environment.yml has not changed
695+
CACHE_NUMBER: 0
696+
with:
697+
# Use faster GNU tar
698+
enableCrossOsArchive: true
699+
path: D:\conda_pkgs_dir
700+
key:
701+
${{ runner.os }}-conda-${{ env.CACHE_NUMBER }}-${{
702+
hashFiles('etc/example-environment.yml') }}
703+
- uses: conda-incubator/setup-miniconda@v3
704+
with:
705+
activate-environment: anaconda-client-env
706+
channel-priority: strict
707+
environment-file: etc/example-environment.yml
708+
pkgs-dirs: D:\conda_pkgs_dir
709+
```
710+
711+
> [!NOTE]
712+
>
713+
> - GitHub hosted Windows runners are currently faster during cache
714+
> decompression when configuring the package directories on the `D:` drive as
715+
> shown above. Make sure to use the `enableCrossOsArchive` cache config option
716+
> as well.
717+
679718
If you are using pip to resolve any dependencies in your conda environment then
680719
you may want to
681720
[cache those dependencies separately](https://docs.github.com/en/actions/language-and-framework-guides/using-python-with-github-actions#caching-dependencies),

action.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -213,6 +213,14 @@ inputs:
213213
for more information.'
214214
required: false
215215
default: ""
216+
pkgs-dirs:
217+
description:
218+
'Conda configuration. Comma separated list of package directories
219+
("pkgs_dirs") to configure conda. See
220+
https://docs.conda.io/projects/conda/en/stable/user-guide/configuration/use-condarc.html#specify-pkg-directories
221+
for more information.'
222+
required: false
223+
default: ""
216224
use-only-tar-bz2:
217225
description:
218226
'Conda configuration. Conda 4.7 introduced a new .conda package file

0 commit comments

Comments
 (0)