Skip to content

merge in work from earlier this week #77

merge in work from earlier this week

merge in work from earlier this week #77

Workflow file for this run

name: pre-commit
on:
push:
branches: [ main ]
pull_request:
branches: [ main ]
jobs:
lint:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.13'
cache: 'pip'
- name: Install Poetry
run: |
python -m pip install --upgrade pip
python -m pip install pipx
pipx install poetry
poetry --version
- name: Enable in-project venv for better caching
run: poetry config virtualenvs.in-project true
- name: Cache virtualenv
uses: actions/cache@v4
with:
path: .venv
key: venv-${{ runner.os }}-py${{ hashFiles('**/poetry.lock') }}
restore-keys: |
venv-${{ runner.os }}-
- name: Install deps (incl. dev)
run: poetry install --no-interaction --no-ansi
- name: Run pre-commit on all files
run: poetry run pre-commit run --all-files
tests:
name: pytest
runs-on: ubuntu-latest
needs: lint
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: '3.13'
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: Pin esmpy to ESMF tag
run: |
set -euo pipefail
MK="$HOME/ESMF/lib/esmf.mk"
VER=$(awk -F= '/^ESMF_VERSION_STRING[[:space:]]*=/{gsub(/[[:space:]]*/,"",$2); print $2}' "$MK")
# Normalize to plain semver if needed (drop anything after first non-semver char)
VER_CLEAN=$(python - "$VER" <<'PY'
import re, sys

Check failure on line 70 in .github/workflows/pylint.yml

View workflow run for this annotation

GitHub Actions / .github/workflows/pylint.yml

Invalid workflow file

You have an error in your yaml syntax on line 70
v=sys.argv[1]
m=re.match(r'^(\d+\.\d+\.\d+)', v)
print(m.group(1) if m else v)
PY
)
TAG="v${VER_CLEAN}"
echo "Detected ESMF ${VER} -> using ESMPy tag ${TAG}"
# remove any existing esmpy dep and add the exact git subdir tag
poetry remove esmpy || true
poetry add --lock --no-interaction \
"esmpy@git+https://github.com/esmf-org/esmf.git@${TAG}#subdirectory=src/addon/esmpy"
- 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
poetry run python -c "import esmpy; print('ESMPy:', esmpy.__version__)"
- name: Cache virtualenv
uses: actions/cache@v4
with:
path: .venv
key: venv-${{ runner.os }}-py${{ matrix.python-version }}-${{ hashFiles('**/poetry.lock') }}
restore-keys: |
venv-${{ runner.os }}-py${{ matrix.python-version }}-
venv-${{ runner.os }}-
- name: Run pytest
env:
ESMFMKFILE: ${{ env.ESMFMKFILE }}
LD_LIBRARY_PATH: ${{ env.ESMF_INSTALL_PREFIX }}/lib:${{ env.LD_LIBRARY_PATH }}
run: poetry run pytest -q
# the following can be used by developers to login to the github server in case of errors
# see https://github.com/marketplace/actions/debugging-with-tmate for further details
# - name: Setup tmate session
# if: ${{ failure() }}
# uses: mxschmitt/action-tmate@v3