forked from landlab/landlab
-
Notifications
You must be signed in to change notification settings - Fork 0
369 lines (315 loc) · 10.2 KB
/
test.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
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
name: Test
on:
- push
- pull_request
concurrency:
group: ${{ github.ref }}-${{ github.workflow }}
cancel-in-progress: true
jobs:
check-tag:
# Run on external PRs, but not on internal PRs, to avoid duplicate runs
if: |
github.event_name == 'push' ||
github.event.pull_request.head.repo.full_name != github.repository
runs-on: ubuntu-latest
outputs:
publish_url: ${{ steps.check-publish.outputs.publish_url }}
steps:
- name: Check if this is a release/prerelease
id: check-publish
run: |
tag_name="${GITHUB_REF#refs/tags/}"
if [[ "$tag_name" =~ ^v[0-9]+\.[0-9]+\.[0-9]+[ab][0-9]+$ ]]; then
publish_url="https://test.pypi.org/legacy/"
elif [[ "$tag_name" =~ ^v[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
publish_url="https://upload.pypi.org/legacy/"
else
publish_url="none"
fi
echo "publish_url=$publish_url" >> "$GITHUB_OUTPUT"
echo "tag_name=$tag_name"
echo "publish_url=$publish_url"
build-sdist:
name: Build source distribution
needs: check-tag
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Build sdist
run: pipx run build --sdist
- uses: actions/upload-artifact@v4
with:
name: build-sdist
path: ${{ github.workspace }}/dist/*.tar.gz
# Until GA has native aarch64 runners, this step is extremely
# slow so we run it as a separate job and hope if finishes
# around the same time as everything else.
build-aarch64:
needs: check-tag
name: Build aarch64 wheels on ${{ matrix.cibw-only }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
include:
- cibw-only: "cp310-manylinux_aarch64"
os: "ubuntu-latest"
- cibw-only: "cp311-manylinux_aarch64"
os: "ubuntu-latest"
- cibw-only: "cp312-manylinux_aarch64"
os: "ubuntu-latest"
steps:
- uses: actions/checkout@v4
- name: Use Python 3.12
uses: actions/setup-python@v5
with:
python-version: '3.12'
# Needed to build aarch64 wheels
- name: Set up QEMU
if: runner.os == 'Linux'
uses: docker/setup-qemu-action@v3
with:
platforms: all
- name: Print build identifiers
run: |
python -m pip install cibuildwheel
python -m cibuildwheel --only ${{ matrix.cibw-only }} --print-build-identifiers
- name: Build wheels
if: ${{ startsWith(needs.check-tag.outputs.publish_url, 'http') }}
uses: pypa/[email protected]
with:
only: ${{ matrix.cibw-only }}
- uses: actions/upload-artifact@v4
with:
name: build-wheels-${{ matrix.os }}-${{ matrix.cibw-only }}
path: ${{ github.workspace }}/wheelhouse/*.whl
if-no-files-found: ignore
build-wheels:
name: Build wheels on ${{ matrix.cibw-only }}
needs: check-tag
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
include:
# Linux x86_64
- cibw-only: "cp310-manylinux_x86_64"
os: "ubuntu-latest"
- cibw-only: "cp311-manylinux_x86_64"
os: "ubuntu-latest"
- cibw-only: "cp312-manylinux_x86_64"
os: "ubuntu-latest"
# Mac x86_64
- cibw-only: "cp310-macosx_x86_64"
os: "macos-13"
- cibw-only: "cp311-macosx_x86_64"
os: "macos-13"
- cibw-only: "cp312-macosx_x86_64"
os: "macos-13"
# Mac arm64
- cibw-only: "cp310-macosx_arm64"
os: "macos-14"
- cibw-only: "cp311-macosx_arm64"
os: "macos-14"
- cibw-only: "cp312-macosx_arm64"
os: "macos-14"
# Windows 64bit
- cibw-only: "cp310-win_amd64"
os: "windows-latest"
- cibw-only: "cp311-win_amd64"
os: "windows-latest"
- cibw-only: "cp312-win_amd64"
os: "windows-latest"
steps:
- uses: actions/checkout@v4
- name: Use Python 3.12
uses: actions/setup-python@v5
with:
python-version: '3.12'
- name: Print build identifiers
run: |
python -m pip install cibuildwheel
python -m cibuildwheel --only ${{ matrix.cibw-only }} --print-build-identifiers
- name: Install openmp
if: runner.os == 'macOS'
run: |
curl -O https://mac.r-project.org/openmp/openmp-13.0.0-darwin21-Release.tar.gz
sudo tar fvxz openmp-13.0.0-darwin21-Release.tar.gz -C /
- name: Build wheels
uses: pypa/[email protected]
with:
only: ${{ matrix.cibw-only }}
- uses: actions/upload-artifact@v4
with:
name: build-wheels-${{ matrix.os }}-${{ matrix.cibw-only }}
path: ${{ github.workspace }}/wheelhouse/*.whl
test-landlab:
needs: build-wheels
name: Run the tests
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
python-version: ["3.10", "3.11", "3.12"]
pytest-marker: ["slow", "not slow"]
runs-on: ${{ matrix.os }}
defaults:
run:
shell: bash -l {0}
steps:
- uses: actions/checkout@v4
- uses: conda-incubator/setup-miniconda@v3
with:
python-version: ${{ matrix.python-version }}
miniforge-variant: Miniforge3
miniforge-version: latest
auto-update-conda: true
- uses: actions/download-artifact@v4
name: Download build artifacts
with:
pattern: "build-*"
merge-multiple: true
path: ${{ github.workspace }}/dist
- name: Test
env:
HYPOTHESIS_PROFILE: "ci"
MPLBACKEND: "Agg"
run: |
pip install nox
nox --verbose -s test \
--force-pythons=${{ matrix.python-version }} \
-- -m '${{ matrix.pytest-marker }}' --path=dist
- name: Coveralls
if: ${{ matrix.os == 'ubuntu-latest' }}
uses: AndreMiras/coveralls-python-action@develop
with:
parallel: true
flag-name: py${{ matrix.python-version }}-${{ matrix.os }}-${{ matrix.pytest-marker }}
debug: true
test-notebooks:
needs: build-wheels
name: Run the notebook tests
strategy:
fail-fast: false
matrix:
os: [macos-latest, windows-latest]
python-version: ["3.12"]
pytest-marker: ["slow", "not slow"]
runs-on: ${{ matrix.os }}
defaults:
run:
shell: bash -l {0}
steps:
- uses: actions/checkout@v4
- uses: conda-incubator/setup-miniconda@v3
with:
python-version: ${{ matrix.python-version }}
miniforge-variant: Miniforge3
miniforge-version: latest
auto-update-conda: true
- uses: actions/download-artifact@v4
name: Download build artifacts
with:
pattern: "build-*"
merge-multiple: true
path: ${{ github.workspace }}/dist
- name: Test
env:
OPENTOPOGRAPHY_API_KEY: ${{ secrets.OPENTOPOGRAPHY_API_KEY }}
MPLBACKEND: "module://matplotlib_inline.backend_inline"
PYTEST_ADDOPTS: "--overwrite"
run: |
pip install matplotlib_inline
pip install nox
nox --verbose -s test-notebooks \
--force-pythons=${{ matrix.python-version }} \
-- -m '${{ matrix.pytest-marker }}' --path=dist
- name: Find executed notebooks
run: |
for f in $(git diff --name-only); do
mkdir -p executed/$(dirname $f);
cp $f executed/$(dirname $f);
done
ls -R executed/
- name: Upload executed notebooks
if: ${{ matrix.os == 'macos-latest' }}
uses: actions/upload-artifact@v4
with:
name: notebooks-${{ matrix.os }}-${{ matrix.python-version }}-${{ matrix.pytest-marker }}
path: executed/
overwrite: true
docs:
needs: test-notebooks
strategy:
matrix:
os: [macos-latest]
python-version: ["3.12"]
runs-on: ${{ matrix.os }}
defaults:
run:
shell: bash -l {0}
steps:
- uses: actions/checkout@v4
- uses: conda-incubator/setup-miniconda@v3
with:
python-version: ${{ matrix.python-version }}
miniforge-variant: Miniforge3
miniforge-version: latest
auto-update-conda: true
- uses: actions/download-artifact@v4
name: Download build artifact
with:
pattern: notebooks-*
merge-multiple: true
- name: Display structure of downloaded files
run: ls -R
- name: install and check pandoc
run: |
conda install pandoc -c conda-forge
pandoc --help
pandoc --version
- name: Build documentation
run: |
pip install nox
pip install -r requirements/docs.txt
nox -s docs-build --no-venv
- name: Create zip
run: zip -r docs.zip build/html
- name: Upload docs
uses: actions/upload-artifact@v4
with:
name: docs-${{ matrix.os }}-${{ matrix.python-version }}
path: docs.zip
coveralls_finish:
needs: test-landlab
runs-on: ubuntu-latest
steps:
- name: Coveralls Finished
uses: AndreMiras/coveralls-python-action@develop
with:
parallel-finished: true
debug: true
publish:
needs:
- check-tag
- test-landlab
- test-notebooks
- build-sdist
- build-aarch64
name: "Publish to PyPI/TestPyPI"
runs-on: ubuntu-latest
permissions:
id-token: write
steps:
- uses: actions/download-artifact@v4
with:
pattern: "build-*"
merge-multiple: true
path: ${{ github.workspace }}/dist
- uses: pypa/gh-action-pypi-publish@release/v1
if: ${{ startsWith(needs.check-tag.outputs.publish_url, 'http') }}
with:
repository-url: ${{ needs.check-tag.outputs.publish_url }}
skip-existing: true
print-hash: true
verify-metadata: false