Skip to content

Commit 2a3d1d9

Browse files
committed
feat: setup-micromamba-and-uv
1 parent 909f553 commit 2a3d1d9

3 files changed

Lines changed: 71 additions & 15 deletions

File tree

README.md

Lines changed: 45 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -257,7 +257,11 @@ jobs:
257257
uses: deargen/workflows/actions/run-doctest@master
258258
```
259259

260-
### Setup conda with cache and run pytest
260+
### Setup micromamba with cache and run pytest and doctest
261+
262+
> [!NOTE]
263+
> In CI, use micromamba to speed up the conda environment setup.
264+
> run `micromamba install ...` instead of `conda install ...`.
261265

262266
```yaml
263267
name: Tests
@@ -278,29 +282,57 @@ jobs:
278282
runs-on: ubuntu-latest
279283
defaults:
280284
run:
281-
shell: bash -el {0} # setup-miniconda requires bash
285+
shell: bash -leo pipefail {0} # required by setup-micromamba
282286
steps:
283287
- uses: actions/checkout@v4
284-
- name: Setup conda
285-
uses: deargen/workflows/actions/setup-conda-and-uv@master
286-
- name: Cache Conda environment
287-
id: cache-conda
288+
- name: Setup micromamba and uv
289+
uses: deargen/workflows/actions/setup-micromamba-and-uv@master
290+
- name: Cache Micromamba environment
291+
id: cache-micromamba
288292
uses: actions/cache@v4
289293
env:
290-
cache-name: cache-conda
294+
cache-name: cache-micromamba
291295
with:
292-
path: ~/miniconda3/envs/test
293-
key: ${{ runner.os }}-conda-${{ env.cache-name }}-${{ hashFiles('deps/lock/x86_64-manylinux_2_28/requirements_dev.txt') }}
294-
- if: steps.cache-conda.outputs.cache-hit == 'true'
295-
run: echo 'conda cache hit!'
296+
path: ~/micromamba/envs/test
297+
key: ${{ runner.os }}-micromamba-${{ env.cache-name }}-${{ hashFiles('deps/lock/x86_64-manylinux_2_28/requirements_dev.txt') }}-${{ hashFiles('.github/workflows/tests.yml') }}
298+
- if: steps.cache-micromamba.outputs.cache-hit == 'true'
299+
run: echo 'micromamba cache hit!'
296300
- name: Install dependencies
297-
if: steps.cache-conda.outputs.cache-hit != 'true'
301+
if: steps.cache-micromamba.outputs.cache-hit != 'true'
298302
run: |
303+
bash scripts/install_binaries.sh
299304
uv pip install -r deps/lock/x86_64-manylinux_2_28/requirements_dev.txt
300305
uv pip install -e .
301-
bash scripts/install_binaries.sh
302306
- name: Run pytest
303307
uses: deargen/workflows/actions/run-pytest@master
308+
309+
doctest:
310+
runs-on: ubuntu-latest
311+
defaults:
312+
run:
313+
shell: bash -leo pipefail {0} # required by setup-micromamba
314+
steps:
315+
- uses: actions/checkout@v4
316+
- name: Setup micromamba and uv
317+
uses: deargen/workflows/actions/setup-micromamba-and-uv@master
318+
- name: Cache Micromamba environment
319+
id: cache-micromamba
320+
uses: actions/cache@v4
321+
env:
322+
cache-name: cache-micromamba
323+
with:
324+
path: ~/micromamba/envs/test
325+
key: ${{ runner.os }}-micromamba-${{ env.cache-name }}-${{ hashFiles('deps/lock/x86_64-manylinux_2_28/requirements_dev.txt') }}-${{ hashFiles('.github/workflows/tests.yml') }}
326+
- if: steps.cache-micromamba.outputs.cache-hit == 'true'
327+
run: echo 'micromamba cache hit!'
328+
- name: Install dependencies
329+
if: steps.cache-micromamba.outputs.cache-hit != 'true'
330+
run: |
331+
bash scripts/install_binaries.sh
332+
uv pip install -r deps/lock/x86_64-manylinux_2_28/requirements_dev.txt
333+
uv pip install -e .
334+
- name: Run doctest
335+
uses: deargen/workflows/actions/run-doctest@master
304336
```
305337

306338
## Deploying a new version

actions/setup-conda-and-uv/action.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
name: Setup conda with the minimum python version, and install uv
2-
description: It will be installed at ~/miniconda3/envs/test
1+
name: (Deprecated!) Setup conda with the minimum python version, and install uv
2+
description: Deprecated! Use setup-micromamba-and-uv instead.
33
author: Kiyoon Kim
44

55
inputs:
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
name: Setup conda with the minimum python version, and install uv
2+
description: It will be installed at ~/micromamba/envs/test
3+
author: Kiyoon Kim
4+
5+
inputs:
6+
pyproject-toml-file:
7+
description: Path to pyproject.toml to infer the minimum python version
8+
required: true
9+
default: pyproject.toml
10+
11+
runs:
12+
using: 'composite'
13+
steps:
14+
- shell: bash
15+
run: |
16+
echo "python_version=$(python3 ${{ github.action_path }}/../../scripts/get_min_python_version.py ${{ inputs.pyproject-toml-file }})" >> "$GITHUB_OUTPUT"
17+
pip3 install --user uv
18+
id: get-python-version
19+
- name: Setup micromamba
20+
uses: mamba-org/setup-micromamba@v1
21+
with:
22+
environment-name: test
23+
create-args: >-
24+
python=${{ steps.get-python-version.outputs.python_version }}

0 commit comments

Comments
 (0)