Skip to content

[pre-commit.ci] pre-commit autoupdate #2336

[pre-commit.ci] pre-commit autoupdate

[pre-commit.ci] pre-commit autoupdate #2336

name: CI # based on https://github.com/pydata/xarray/blob/master/.github/workflows/ci.yaml
on:
pull_request:
schedule:
- cron: "0 23 * * 0" # Sun 23:00 UTC
workflow_dispatch: # allows you to trigger the workflow run manually
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
detect-ci-trigger:
name: detect ci trigger
runs-on: ubuntu-latest
if: github.event_name == 'push' || github.event_name == 'pull_request'
outputs:
triggered: ${{ steps.detect-trigger.outputs.trigger-found }}
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 2
- uses: xarray-contrib/[email protected]
id: detect-trigger
with:
keyword: "[skip-ci]"
minimum-test: # Runs testing suite with minimal dependencies
name: Test minimum dependencies, Python${{ matrix.python-version }}
runs-on: ubuntu-latest
needs: detect-ci-trigger
if: needs.detect-ci-trigger.outputs.triggered == 'false'
defaults:
run:
shell: bash -l {0}
strategy:
matrix:
python-version: ["3.9", "3.12"]
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0 # Fetch all history for all branches and tags.
- name: Set up conda (micromamba)
uses: mamba-org/setup-micromamba@v1
with:
environment-file: ci/requirements/minimum-tests.yml
environment-name: climpred-minimum-tests
cache-environment: true
create-args: >-
python=${{ matrix.python-version }}
conda
- name: Install climpred
run: |
python -m pip install -e .
python -m pip uninstall netcdf4 -y
- name: Conda info
run: |
conda info
- name: Conda list
run: |
conda list
- name: Cache datasets # pytest-xdist fails otherwise
run: |
python -c "import climpred; climpred.tutorial._cache_all()"
- name: Run tests
run: |
pytest -n 4 --durations=20
maximum-test: # Runs testing suite with all optional dependencies
name: Test optional dependencies, Python${{ matrix.python-version }}
runs-on: ubuntu-latest
needs: detect-ci-trigger
if: needs.detect-ci-trigger.outputs.triggered == 'false'
defaults:
run:
shell: bash -l {0}
strategy:
fail-fast: false
matrix:
include:
- env: "climpred-maximum-tests"
python-version: "3.9"
extras: "esmpy=*=mpi*" # Ensures MPI works with version of esmpy.
os: ubuntu-latest
- env: "climpred-maximum-tests"
python-version: "3.10"
extras: "esmpy=*=mpi*" # Ensures MPI works with version of esmpy.
os: ubuntu-latest
- env: "climpred-maximum-tests-upstream"
python-version: "3.11"
extras: "esmpy=*=mpi*" # Ensures MPI works with version of esmpy.
os: ubuntu-latest
- env: "climpred-maximum-tests"
python-version: "3.12"
extras: "esmpy" # MPI is not supported in lastest esmpy conda packages for Python3.12
os: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0 # Fetch all history for all branches and tags.
- name: Setup conda (micromamba)
uses: mamba-org/setup-micromamba@v1
with:
environment-file: ci/requirements/maximum-tests.yml
environment-name: climpred-maximum-tests
cache-environment: true
cache-environment-key: "${{ runner.os }}-${{ runner.arch }}-py${{ matrix.python-version }}-${{ env.TODAY }}-${{ hashFiles(env.CONDA_ENV_FILE) }}"
create-args: >-
conda
python=${{ matrix.python-version }}
${{ matrix.extras }}
- name: Install climpred[complete]
run: |
python -m pip install -e .[complete]
python -m pip uninstall netcdf4 -y
- name: Install bleeding edge
if: matrix.env == 'climpred-maximum-tests-upstream'
run: |
python -m pip install -r requirements_upstream.txt
- name: Conda info
run: |
conda info
- name: Conda list
run: |
conda list
- name: Cache datasets # pytest-xdist fails otherwise
run: |
python -c "import climpred; climpred.tutorial._cache_all()"
- name: Run tests
run: |
pytest -n 4 --durations=20 --cov=climpred --cov-report=xml
- name: Upload coverage to codecov
uses: codecov/codecov-action@v4
with:
token: ${{ secrets.CODECOV_TOKEN }}
file: ./coverage.xml
fail_ci_if_error: false
doctest: # tests all docstrings
name: Doctests, Python${{ matrix.python-version }}
runs-on: ubuntu-latest
defaults:
run:
shell: bash -l {0}
strategy:
matrix:
python-version: ["3.9"]
steps:
- uses: actions/checkout@v4
- name: Setup conda (micromamba)
uses: mamba-org/setup-micromamba@v1
with:
environment-file: ci/requirements/maximum-tests.yml
environment-name: climpred-maximum-tests
cache-environment: true
create-args: >-
python=${{ matrix.python-version }}
conda
- name: Install climpred[complete]
run: |
python -m pip install -e .[complete]
python -m pip install 'xarray<2024.2.0'
- name: Conda info
run: |
conda info
- name: Conda list
run: |
conda list
- name: Run doctests
run: |
python -m pytest --doctest-modules src/climpred --ignore src/climpred/tests
notebooks: # Checks that pre-compiled notebooks in docs still work.
name: Notebooks, Python${{ matrix.python-version }}
runs-on: ubuntu-latest
defaults:
run:
shell: bash -l {0}
strategy:
matrix:
python-version: ["3.9"]
steps:
- uses: actions/checkout@v4
- name: Set up conda (micromamba)
uses: mamba-org/setup-micromamba@v1
with:
environment-file: ci/requirements/docs.yml
environment-name: climpred-docs
cache-environment: true
create-args: >-
python=${{ matrix.python-version }}
conda
- name: Install climpred
run: |
python -m pip install -e .
- name: Conda info
run: |
conda info
- name: Conda list
run: |
conda list
- name: Test notebooks in docs
run: |
pushd docs
nbstripout source/*.ipynb source/examples/decadal/*.ipynb source/examples/monseas/*.ipynb examples/subseasonal/*ly-subx-example.html
make -j4 html
popd