Skip to content

Cache conda environment instead of just packages #11

Cache conda environment instead of just packages

Cache conda environment instead of just packages #11

Workflow file for this run

name: test
on: [push]
jobs:
build-linux:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.7", "3.9", "3.12"]
fail-fast: false
defaults:
run:
# these makes it so all steps automatically have our conda environment activated
shell: bash -el {0}
steps:
- name: Checkout
uses: actions/checkout@v4
# only cache environments with the same date because otherwise we might be using out of date packages
- name: Get Date
id: get-date
run: echo "today=$(/bin/date -u '+%Y%m%d')" >> $GITHUB_OUTPUT
shell: bash
- name: Cache conda environment
id: cache
uses: actions/cache@v4
with:
path: ${{ env.CONDA }}/envs
key:
${{ runner.os }}-conda-python${{ matrix.python-version }}-${{ steps.get-date.outputs.today }}-${{ hashFiles('environment.yml') }}
- name: Set up Conda (Python ${{ matrix.python-version }})
uses: conda-incubator/setup-miniconda@v3
with:
activate-environment: df3d
auto-update-conda: true
python-version: ${{ matrix.python-version }}
use-only-tar-bz2: true
- name: Update environment
run: |
conda env update -n df3d -f environment.yml
if: steps.cache.outputs.cache-hit != 'true'
- name: Install ffmpeg
run: |
sudo apt install ffmpeg -y
- name: Conda info
run: |
conda info
conda list
- name: Run Tests
run: |
conda activate df3d
python -m unittest