Skip to content

Commit

Permalink
use micromamba (#427)
Browse files Browse the repository at this point in the history
* use micromamba

* modify other actions
  • Loading branch information
d-chambers authored Aug 27, 2024
1 parent f4f6947 commit 2e911d1
Show file tree
Hide file tree
Showing 3 changed files with 60 additions and 61 deletions.
23 changes: 15 additions & 8 deletions .github/workflows/get_coverage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,23 @@ jobs:
run: |
git fetch --tags --force # Retrieve annotated tags.
- name: Setup conda
uses: conda-incubator/setup-miniconda@v3
- uses: mamba-org/setup-micromamba@v1
with:
mamba-version: "*"
channels: conda-forge,defaults
channel-priority: true
python-version: "3.11"
activate-environment: dascore
micromamba-version: '1.5.8-0' # versions: https://github.com/mamba-org/micromamba-releases
environment-file: environment.yml
condarc-file: .github/test_condarc.yml
init-shell: >-
bash
powershell
cache-environment: true
post-cleanup: 'all'

# Not sure why this is needed but it appears to be the case
- name: fix env
shell: bash -l {0}
run: |
micromamba shell init --shell bash --root-prefix=~/micromamba
eval "$(micromamba shell hook --shell bash)"
micromamba activate dascore
- name: install dascore
shell: bash -l {0}
Expand Down
29 changes: 17 additions & 12 deletions .github/workflows/run_min_dep_tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,6 @@ jobs:
if: github.event_name == 'push' || !contains(github.event.pull_request.labels.*.name, 'no_ci')

env:
# set path of test environment for caching
prefix: ${{ startsWith(matrix.os, 'ubuntu') && '/usr/share/miniconda3/envs/dascore'
|| startsWith(matrix.os, 'macos') && '/Users/runner/miniconda3/envs/dascore'
|| startsWith(matrix.os, 'windows') && 'C:\Miniconda3\envs\dascore' }}
# set individual cache key (only the start of it)
cache_key: ${{ matrix.os }}-py${{ matrix.python-version }}
# set conda environment file with dependencies
env_file: "environment.yml"

Expand All @@ -57,18 +51,29 @@ jobs:
git fetch --tags --force # Retrieve annotated tags.
# Have to use conda to install hdf5 so mac (I guess m1/2) runners work.
- uses: conda-incubator/setup-miniconda@v3
- uses: mamba-org/setup-micromamba@v1
with:
mamba-version: "*"
channels: conda-forge,defaults
channel-priority: true
python-version: ${{ matrix.python-version }}
micromamba-version: '1.5.8-0' # versions: https://github.com/mamba-org/micromamba-releases
environment-file: environment.yml
init-shell: >-
bash
powershell
cache-environment: true
post-cleanup: 'all'

# Not sure why this is needed but it appears to be the case
- name: fix env
shell: bash -l {0}
run: |
micromamba shell init --shell bash --root-prefix=~/micromamba
eval "$(micromamba shell hook --shell bash)"
micromamba activate dascore
- name: install hdf5
if: matrix.os=='macos-latest'
shell: bash -l {0}
run: |
conda install pytables
micromamba install pytables
- name: install dascore
shell: bash -l {0}
Expand Down
69 changes: 28 additions & 41 deletions .github/workflows/runtests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,6 @@ jobs:
if: github.event_name == 'push' || !contains(github.event.pull_request.labels.*.name, 'no_ci')

env:
# set path of test environment for caching
prefix: ${{ startsWith(matrix.os, 'ubuntu') && '/usr/share/miniconda3/envs/dascore'
|| startsWith(matrix.os, 'macos') && '/Users/runner/miniconda3/envs/dascore'
|| startsWith(matrix.os, 'windows') && 'C:\Miniconda3\envs\dascore' }}
# set individual cache key (only the start of it)
cache_key: ${{ matrix.os }}-py${{ matrix.python-version }}
# set conda environment file with dependencies
env_file: "environment.yml"

Expand All @@ -52,41 +46,31 @@ jobs:
run: |
git fetch --tags --force # Retrieve annotated tags.
- name: Get year week
id: date
run: echo "date=$(date +'%Y:%U')" >> $GITHUB_STATE

- name: setup conda env
uses: conda-incubator/setup-miniconda@v3
- uses: mamba-org/setup-micromamba@v1
with:
mamba-version: "*"
channels: conda-forge,defaults
micromamba-version: '1.5.8-0' # versions: https://github.com/mamba-org/micromamba-releases
environment-file: environment.yml
channel-priority: true
miniforge-variant: Mambaforge
miniforge-version: latest
activate-environment: dascore
use-mamba: true
python-version: ${{ matrix.python-version }}

- name: Cache conda env
uses: actions/cache@v3
with:
path: ${{ env.prefix }}
key: ${{ env.cache_key }}-${{ runner.arch }}-hash${{ hashFiles(env.env_file) }}-${{ steps.date.outputs.date }}-${{ env.CACHE_NUMBER }}
id: cache

- name: Update environment
run: mamba env update -n dascore -f ${{ env.env_file }}
if: steps.cache.outputs.cache-hit != 'true'
init-shell: >-
bash
powershell
cache-environment: true
post-cleanup: 'all'

# Not sure why this is needed but it appears to be the case
- name: fix env
shell: bash -l {0}
run: |
micromamba shell init --shell bash --root-prefix=~/micromamba
eval "$(micromamba shell hook --shell bash)"
micromamba activate dascore
- name: install dascore
shell: bash -l {0}
shell: bash -el {0}
run: |
python -m pip install -e .[test,all]
- name: set data cache path
shell: bash -l {0}
shell: bash -el {0}
run: |
echo "DATA_CACHE_PATH=$(python -c "import pooch; print(pooch.os_cache('dascore'))")" >> $GITHUB_ENV
Expand All @@ -97,29 +81,32 @@ jobs:
path: ${{ env.DATA_CACHE_PATH }}
key: DATA_${{ env.CACHE_NUMBER }}

# Print out the package info for current environment
- name: print package info
shell: bash -l {0}
shell: bash -el {0}
run: |
conda info -a
conda list
micromamba info
micromamba list
# Runs test suite and calculates coverage
- name: run test suite
shell: bash -l {0}
shell: bash -el {0}
run: ./.github/test_code.sh

# Runs examples in docstrings
- name: test docstrings
shell: bash -l {0}
shell: bash -el {0}
run: ./.github/test_code.sh doctest

# Upload coverage files
- uses: codecov/codecov-action@v4
with:
fail_ci_if_error: false
files: ./coverage.xml
flags: unittests # optional
name: PR_tests # optional
token: ${{ secrets.CODECOV_TOKEN }} # required
flags: unittests
name: PR_tests
token: ${{ secrets.CODECOV_TOKEN }}


# This is a very useful step for debugging, it allows you to ssh into the CI
# machine (https://github.com/marketplace/actions/debugging-with-tmate).
Expand Down

0 comments on commit 2e911d1

Please sign in to comment.