forked from open-atmos/PyMPDATA
-
Notifications
You must be signed in to change notification settings - Fork 0
283 lines (254 loc) · 9.54 KB
/
tests+pypi.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
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
name: tests+pypi
defaults:
run:
shell: bash
on:
push:
branches: [ main ]
pull_request:
branches: [ main ]
schedule:
- cron: '0 13 * * 4'
release:
types: [published]
jobs:
precommit:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/[email protected]
with:
python-version: "3.10"
- run: |
pip install pre-commit
pre-commit clean
pre-commit autoupdate
pre-commit run --all-files
nojit_and_codecov:
runs-on: ubuntu-latest
env:
NUMBA_DISABLE_JIT: 1
steps:
- uses: actions/checkout@master
with:
submodules: recursive
fetch-depth: 0
- uses: actions/[email protected]
with:
python-version: 3.9
- name: Generate coverage report
run: |
pip install -e .[tests] -e ./examples
pip install pytest-cov
pytest --durations=10 -We tests/unit_tests --cov-report=xml --cov=PyMPDATA
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v4
with:
token: ${{ secrets.CODECOV_TOKEN }}
fail_ci_if_error: true
verbose: true
pylint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
with:
submodules: recursive
fetch-depth: 0
- name: Set up Python 3.9
uses: actions/[email protected]
with:
python-version: 3.9
- name: Install dependencies
run: |
python -m pip install --upgrade pip
# TODO #411 https://github.com/pylint-dev/pylint/issues/9099
pip install "pylint<3.0.0" nbqa
pip install -e .[tests] -e ./examples[tests]
- run: |
pylint --max-module-lines=500 --disable=fixme $(git ls-files '*.py' | grep -v ^examples)
- run: |
# TODO #299
pylint --disable=fixme --max-module-lines=200 \
--disable=too-many-locals,too-many-branches,duplicate-code,invalid-name,missing-function-docstring,missing-module-docstring,too-many-arguments,missing-class-docstring,too-many-instance-attributes $(git ls-files '*.py' | grep ^examples)
- run: |
# TODO #299
nbqa pylint --disable=fixme,trailing-whitespace,wrong-import-position,wrong-import-order,ungrouped-imports \
--disable=duplicate-code,invalid-name,missing-module-docstring,line-too-long,missing-function-docstring,redefined-outer-name,too-many-arguments,no-member,too-many-locals,cell-var-from-loop,missing-class-docstring $(git ls-files '*.ipynb')
pdoc:
strategy:
matrix:
platform: [ubuntu-latest, macos-latest, windows-latest]
runs-on: ${{ matrix.platform }}
steps:
- uses: actions/checkout@v2
with:
submodules: recursive
persist-credentials: false
- uses: actions/[email protected]
with:
python-version: 3.9
- env:
JUPYTER_PLATFORM_DIRS: 1
run: |
pip3 install pdoc nbformat
pip install -e . -e ./examples
python - <<EOF
import glob, nbformat
for notebook_path in glob.glob('examples/PyMPDATA_examples/*/*.ipynb'):
with open(notebook_path, encoding="utf8") as fin:
with open(notebook_path + ".badges.md", 'w') as fout:
fout.write(nbformat.read(fin, nbformat.NO_CONVERT).cells[0].source)
EOF
PDOC_ALLOW_EXEC=1 python -We -m pdoc -o html PyMPDATA examples/PyMPDATA_examples -t docs/templates --math
- if: ${{ github.ref == 'refs/heads/main' && matrix.platform == 'ubuntu-latest' }}
uses: JamesIves/[email protected]
with:
BRANCH: pdoc
FOLDER: html
CLEAN: true
zenodo_json:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: notiz-dev/github-action-json-property@release
with:
path: '.zenodo.json'
prop_path: 'creators'
tests:
timeout-minutes: 120
needs: [nojit_and_codecov, pylint, pdoc, precommit, zenodo_json]
strategy:
matrix:
platform: [ubuntu-latest, macos-13, macos-14, windows-latest]
python-version: ["3.9", "3.12"]
exclude:
- platform: macos-14
python-version: "3.9"
runs-on: ${{ matrix.platform }}
steps:
- uses: actions/checkout@v2
with:
submodules: recursive
fetch-depth: 0
- uses: actions/[email protected]
with:
python-version: ${{ matrix.python-version }}
- run: |
python -m pip install $PIP_INSTALL_ARGS -e . # to check if usable without test/example dependencies
python -We -c "import PyMPDATA"
python -m pip install $PIP_INSTALL_ARGS -e .[tests] ./examples
# https://github.com/numba/numba/issues/6350#issuecomment-728174860
- if: startsWith(matrix.platform, 'ubuntu-')
run: echo NUMBA_THREADING_LAYER=omp >> $GITHUB_ENV
- env:
NUMBA_OPT: 1
run: |
python -m pytest --durations=10 -p no:unraisableexception -We tests/unit_tests
python -m pytest --durations=10 -p no:unraisableexception -We -k "not test_timing_3d" tests/smoke_tests
- env:
NUMBA_OPT: 3
run: |
python -m pytest --durations=10 -p no:unraisableexception -We -k "test_timing_3d" tests/smoke_tests
examples:
needs: [pylint, precommit]
strategy:
matrix:
platform: [ubuntu-latest, macos-13, macos-14, windows-latest]
python-version: ["3.9", "3.12"]
fail-fast: false
runs-on: ${{ matrix.platform }}
steps:
- uses: actions/checkout@v2
with:
submodules: recursive
fetch-depth: 0
- uses: actions/[email protected]
with:
python-version: ${{ matrix.python-version }}
- run: python -m pip install $PIP_INSTALL_ARGS -e .[tests] ./examples
- run: python -m pip install $PIP_INSTALL_ARGS -r tests/devops_tests/requirements.txt
- if: matrix.platform == 'ubuntu-latest'
run: |
sudo apt-get install libblitz0-dev libboost-thread-dev libboost-date-time-dev libboost-system-dev libboost-iostreams-dev libboost-timer-dev libboost-filesystem-dev
git clone https://github.com/igfuw/libmpdataxx.git
cd libmpdataxx/libmpdata++
mkdir build
cd build
cmake ..
sudo make install
cd ../../../
rm -rf libmpdataxx
- uses: julia-actions/setup-julia@v2
- run: julia --version
# https://github.com/numba/numba/issues/6350#issuecomment-728174860
- if: matrix.platform == 'ubuntu-latest'
run: echo NUMBA_THREADING_LAYER=omp >> $GITHUB_ENV
- env:
NUMBA_OPT: 1
run: python -m pytest --durations=10 -p no:unraisableexception -We tests/devops_tests/test_notebooks.py
- if: ${{ matrix.platform == 'ubuntu-latest' && matrix.python-version == '3.12'}}
run: |
mkdir -p /home/runner/work/_temp/_github_home/figures
rm /tmp/pytest-of-runner/pytest-current/test_run_notebooks_examples_Pycurrent
mv /tmp/pytest-of-runner/pytest-current/test_run_notebooks_examples_*/fig_4.svg /home/runner/work/_temp/_github_home/figures
mv /tmp/pytest-of-runner/pytest-current/test_run_notebooks_examples_*/advection_diffusion.gif /home/runner/work/_temp/_github_home/figures
# - if: ${{ failure() }}
# uses: mxschmitt/action-tmate@v3
# with:
# limit-access-to-actor: true
- if: ${{ github.ref == 'refs/heads/main' && matrix.platform == 'ubuntu-latest' && matrix.python-version == '3.12'}}
uses: eine/tip@master
with:
token: ${{ secrets.GITHUB_TOKEN }}
files: |
/github/home/figures/*.svg
/github/home/figures/*.gif
devops:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
with:
submodules: recursive
fetch-depth: 0 # https://github.com/pypa/setuptools_scm/issues/480
- run: pip install -r tests/devops_tests/requirements.txt
- run: pip install -e . -e ./examples
- env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: pytest --durations=10 -v -s -We -p no:unraisableexception -k "not run_notebooks" tests/devops_tests
dist:
strategy:
matrix:
package-dir: [".", "examples"]
fail-fast: false
runs-on: ubuntu-latest
needs: [tests, examples, devops]
permissions:
id-token: write
steps:
- uses: actions/checkout@v2
with:
submodules: recursive
fetch-depth: 0 # https://github.com/pypa/setuptools_scm/issues/480
- uses: actions/[email protected]
with:
python-version: "3.10"
- run: pip install twine build
- run: |
unset CI
cd ${{ matrix.package-dir }}
python -m build 2>&1 | tee build.log
exit `fgrep -v "warning: no previously-included files matching" buid.log | fgrep -i warning | wc -l`
twine check --strict dist/*
exit `tar tzf dist/*.tar.gz | fgrep ".ipynb" | wc -l`
cd ..
- if: github.event_name == 'push' && github.ref == 'refs/heads/main'
uses: pypa/gh-action-pypi-publish@release/v1.12
with:
attestations: false
repository_url: https://test.pypi.org/legacy/
packages-dir: ${{ matrix.package-dir }}/dist
- if: startsWith(github.ref, 'refs/tags')
uses: pypa/gh-action-pypi-publish@release/v1.12
with:
attestations: false
packages-dir: ${{ matrix.package-dir }}/dist