Skip to content

Refactor

Refactor #18

Workflow file for this run

name: pytest
on:
push:
branches: [ main ]
pull_request:
branches: [ main ]
jobs:
tests:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.12'
cache: 'pip'
- name: Install NetCDF
run: sudo apt-get update && sudo apt-get install -y libnetcdf-dev libnetcdff-dev
- name: Install ESMF
uses: esmf-org/install-esmf-action@v1
env:
ESMF_NETCDF: nc-config
ESMF_INSTALL_PREFIX: $HOME/ESMF
with:
version: latest
esmpy: false
- name: Install Poetry
run: |
python -m pip install --upgrade pip pipx
pipx install poetry
poetry --version
poetry config virtualenvs.in-project true
poetry env use "$(python -c 'import sys; print(sys.executable)')"
poetry install --no-interaction --no-ansi
- name: Pin esmpy to ESMF tag
run: |
set -euo pipefail
echo "using ESMPy tag ${ESMF_VERSION}"
# remove any existing esmpy dep and add the exact git subdir tag
poetry remove esmpy || true
poetry add --lock --no-interaction --directory=$ESMF_DIR/src/addon/esmpy esmpy
poetry run python -c "import esmpy; print('ESMPy:', esmpy.__version__)"
- name: Cache virtualenv
uses: actions/cache@v4
with:
path: |
.venv
$HOME/ESMF
key: esmf-esmpy-venv-${{ runner.os }}-py${{ steps.setup-python.outputs.python-version }}-${{ hashFiles('**/poetry.lock') }}
restore-keys: |
esmf-esmpy-venv-${{ runner.os }}-py${{ steps.setup-python.outputs.python-version }}-
- name: Run pytest
env:
ESMFMKFILE: ${{ env.ESMFMKFILE }}
LD_LIBRARY_PATH: ${{ env.ESMF_INSTALL_PREFIX }}/lib:${{ env.LD_LIBRARY_PATH }}
run: poetry run pytest -q