Skip to content

Commit

Permalink
added caches
Browse files Browse the repository at this point in the history
  • Loading branch information
ESadek-MO committed Apr 15, 2024
1 parent 0455fcc commit 5b4c271
Show file tree
Hide file tree
Showing 5 changed files with 150 additions and 0 deletions.
41 changes: 41 additions & 0 deletions .github/workflows/composite/cartopy-cache/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
name: "cartopy-cache"
description: "create and cache cartopy assets"

#
# Assumes the environment contains the following variables:
# - CONDA
#
inputs:
cache_build:
description: "conda environment cache build number"
required: false
default: "0"
cache_period:
description: "conda environment cache timestamp"
required: true
env_name:
description: "environment name"
required: true

runs:
using: "composite"
steps:
- uses: actions/cache@v3
id: cartopy-cache
with:
path: ~/.local/share/cartopy
key: ${{ runner.os }}-cartopy-${{ inputs.env_name }}-p${{ inputs.cache_period }}-b${{ inputs.cache_build }}

- if: steps.cartopy-cache.outputs.cache-hit != 'true'
env:
CARTOPY_SHARE_DIR: ~/.local/share/cartopy
CARTOPY_FEATURE: https://raw.githubusercontent.com/SciTools/cartopy/v0.20.0/tools/cartopy_feature_download.py
shell: bash
run: |
# Require to explicitly activate the environment within the composite action.
source ${{ env.CONDA }}/etc/profile.d/conda.sh >/dev/null 2>&1
conda activate ${{ inputs.env_name }}
wget --quiet ${CARTOPY_FEATURE}
mkdir -p ${CARTOPY_SHARE_DIR}
# Requires a pre-installed version of cartopy within the environment.
python cartopy_feature_download.py physical --output ${CARTOPY_SHARE_DIR} --no-warn
35 changes: 35 additions & 0 deletions .github/workflows/composite/conda-env-cache/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
name: "conda-env-cache"
description: "create and cache the conda environment"

#
# Assumes the environment contains the following variables:
# - CONDA
#
inputs:
cache_build:
description: "conda environment cache build number"
required: false
default: "0"
cache_period:
description: "conda environment cache timestamp"
required: true
env_name:
description: "environment name"
required: true
install_packages:
description: "conda packages to install into environment"
required: true

runs:
using: "composite"
steps:
- uses: actions/cache@v3
id: conda-env-cache
with:
path: ${{ env.CONDA }}/envs/${{ inputs.env_name }}
key: ${{ runner.os }}-conda-env-${{ inputs.env_name }}-p${{ inputs.cache_period }}-b${{ inputs.cache_build }}

- if: steps.conda-env-cache.outputs.cache-hit != 'true'
shell: bash
run: |
conda install --quiet --name ${{ inputs.env_name }} ${{ inputs.install_packages }}
22 changes: 22 additions & 0 deletions .github/workflows/composite/conda-pkg-cache/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
name: "conda-pkg-cache"
description: "cache the conda environment packages"

inputs:
cache_build:
description: "conda environment cache build number"
required: false
default: "0"
cache_period:
description: "conda environment cache timestamp"
required: true
env_name:
description: "environment name"
required: true

runs:
using: "composite"
steps:
- uses: actions/cache@v3
with:
path: ~/conda_pkgs_dir
key: ${{ runner.os }}-conda-pkgs-${{ inputs.env_name }}-p${{ inputs.cache_period }}-b${{ inputs.cache_build }}
30 changes: 30 additions & 0 deletions .github/workflows/composite/iris-data-cache/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
name: "iris-data-cache"
description: "create and cache the iris test data"

inputs:
cache_build:
description: "data cache build number"
required: false
default: "0"
env_name:
description: "environment name"
required: true
version:
description: "iris test data version"
required: true

runs:
using: "composite"
steps:
- uses: actions/cache@v3
id: data-cache
with:
path: ~/iris-test-data
key: ${{ runner.os }}-iris-test-data-${{ inputs.env_name }}-v${{ inputs.version }}-b${{ inputs.cache_build }}

- if: steps.data-cache.outputs.cache-hit != 'true'
shell: bash
run: |
wget --quiet https://github.com/SciTools/iris-test-data/archive/v${{ inputs.version }}.zip -O iris-test-data.zip
unzip -q iris-test-data.zip
mv iris-test-data-${{ inputs.version }} ~/iris-test-data
22 changes: 22 additions & 0 deletions .github/workflows/composite/nox-cache/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
name: "nox cache"
description: "cache the nox test environments"

inputs:
cache_build:
description: "nox cache build number"
required: false
default: "0"
env_name:
description: "environment name"
required: true
lock_file:
description: "conda-lock environment requirements filename"
required: true

runs:
using: "composite"
steps:
- uses: actions/cache@v3
with:
path: ${{ github.workspace }}/.nox
key: ${{ runner.os }}-nox-${{ inputs.env_name }}-py${{ matrix.python-version }}-b${{ inputs.cache_build }}-${{ hashFiles(inputs.lock_file) }}

0 comments on commit 5b4c271

Please sign in to comment.