Create cache #9
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Create cache | |
on: | |
schedule: | |
- cron: 0 0 * * Sun # run on main every sunday at 00:00 | |
workflow_dispatch: | |
jobs: | |
clear-cache: | |
uses: ./.github/workflows/purge_cache.yml | |
test-cache: | |
needs: clear-cache | |
defaults: | |
run: | |
shell: bash -l {0} | |
strategy: | |
fail-fast: false | |
matrix: | |
os: [ubuntu-latest] | |
python-version: ['3.11'] | |
include: | |
- os: ubuntu-latest | |
label: linux-64 | |
prefix: /usr/share/miniconda3 | |
name: py ${{ matrix.python-version }} | |
runs-on: ${{ matrix.os }} | |
# note absence of cucurrency, this one should only be run one at a time | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v3 | |
- name: Setup Miniforge | |
uses: conda-incubator/setup-miniconda@v2 | |
with: | |
python-version: ${{ matrix.python-version }} | |
miniforge-variant: Miniforge3 | |
miniforge-version: latest | |
use-mamba: true | |
- name: Setup env | |
run: | | |
pip install tomli | |
python make_env.py test -p ${{ matrix.python-version}}.* | |
mamba env create -f environment.yml | |
mamba run -n wfs20_test pip install -e . | |
# mamba run -n wf20_test python .testdata/create_test_data.py | |
# run tests first so that we can also cache all of the artefacts | |
- name: Test | |
run: | | |
PYTHONPYCACHEPREFIX=~/pycache mamba run -n wfs20_test python -m pytest --verbose --cov --cov-report xml | |
- name: Upload cache | |
uses: actions/cache/save@v3 | |
if: always() | |
with: | |
path: | | |
/usr/share/miniconda3 | |
~/pycache | |
key: test-py${{ matrix.python-version }}-${{ hashFiles('environment.yml') }} | |
id: test-cache | |
docs-cache: | |
needs: clear-cache | |
defaults: | |
run: | |
shell: bash -l {0} | |
strategy: | |
fail-fast: false | |
matrix: | |
os: [ubuntu-latest] | |
python-version: ['3.11'] | |
include: | |
- os: ubuntu-latest | |
label: linux-64 | |
prefix: /usr/share/miniconda3 | |
runs-on: ${{ matrix.os }} | |
steps: | |
- name: checkout code | |
uses: actions/checkout@v3 | |
- name: Setup Miniforge3 | |
uses: conda-incubator/setup-miniconda@v2 | |
with: | |
python-version: ${{ matrix.python-version }} | |
miniforge-variant: Miniforge3 | |
miniforge-version: latest | |
use-mamba: true | |
- name: Setup env | |
run: | | |
pip install tomli | |
python make_env.py docs -p ${{ matrix.python-version}}.* | |
mamba env create -f environment.yml | |
mamba run -n wfs20_docs pip install -e . | |
# run tests first so that we can also cache all of the artefacts | |
# - name: Generate docs | |
# run: PYTHONPYCACHEPREFIX=~/pycache mamba run -n hydromt sphinx-build -M html ./docs ./docs/_build | |
- name: Upload cache | |
uses: actions/cache/save@v3 | |
if: always() | |
with: | |
path: | | |
/usr/share/miniconda3 | |
~/pycache | |
key: docs-${{ hashFiles('environment.yml') }} | |
id: docs-cache | |
min-cache: | |
needs: clear-cache | |
defaults: | |
run: | |
shell: bash -l {0} | |
strategy: | |
fail-fast: false | |
matrix: | |
os: [ubuntu-latest] | |
python-version: ['3.11'] | |
include: | |
- os: ubuntu-latest | |
label: linux-64 | |
prefix: /usr/share/miniconda3 | |
runs-on: ${{ matrix.os }} | |
steps: | |
- name: checkout code | |
uses: actions/checkout@v3 | |
- name: Setup Miniforge3 | |
uses: conda-incubator/setup-miniconda@v2 | |
with: | |
python-version: ${{ matrix.python-version }} | |
miniforge-variant: Miniforge3 | |
miniforge-version: latest | |
use-mamba: true | |
- name: Setup env | |
run: | | |
pip install tomli | |
python make_env.py min -p ${{ matrix.python-version}}.* | |
mamba env create -f environment.yml | |
- name: Upload cache | |
uses: actions/cache/save@v3 | |
if: always() | |
with: | |
path: | | |
/usr/share/miniconda3 | |
~/pycache | |
key: min-${{ hashFiles('environment.yml') }} | |
id: min-cache |