-
Notifications
You must be signed in to change notification settings - Fork 48
208 lines (201 loc) · 6.75 KB
/
climpred_testing.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
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