forked from contourpy/contourpy
-
Notifications
You must be signed in to change notification settings - Fork 0
460 lines (409 loc) · 15.5 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
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
name: Test
on:
pull_request:
branches:
- main
push:
branches:
- main
workflow_dispatch:
schedule:
- cron: "42 01 * * SUN"
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
defaults:
run:
shell: bash
env:
PYTEST: python -m pytest -v -n auto --color=yes --log-image-diffs
jobs:
pre-commit:
name: pre-commit
if: github.event_name != 'schedule' || github.repository_owner == 'contourpy'
runs-on: ubuntu-latest
steps:
- name: Checkout source
uses: actions/checkout@v4
- name: Setup Python
uses: actions/setup-python@v5
with:
python-version: "3.12"
- name: Run pre-commit
uses: pre-commit/[email protected]
codebase:
name: codebase
if: github.event_name != 'schedule' || github.repository_owner == 'contourpy'
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.12"]
steps:
- name: Checkout source
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Setup Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Install contourpy
run: |
python -m pip install --upgrade pip
python -m pip install -v .[mypy,test]
- name: Install cppcheck
run: |
CPPCHECK_VERSION=2.13.0
CPPCHECK_TGZ=$CPPCHECK_VERSION.tar.gz
cd $RUNNER_TEMP
wget --no-verbose https://github.com/danmar/cppcheck/archive/refs/tags/$CPPCHECK_TGZ
tar xzf $CPPCHECK_TGZ
cd cppcheck-$CPPCHECK_VERSION
sudo make install MATCHCOMPILER=yes FILESDIR=/usr/share/cppcheck CXXFLAGS="-O2 -DNDEBUG" -j 2
- name: Smoke test
run: |
python -m pip list
python -c "from contourpy.util import build_config; from pprint import pprint; pprint(build_config())"
python -c "import contourpy as c; print('NDEBUG', c._contourpy.NDEBUG)"
- name: Run tests
run: |
${PYTEST} tests/test_codebase.py
test:
name: "${{ matrix.name }} ${{ matrix.python-version }} ${{ matrix.os }}"
if: github.event_name != 'schedule' || github.repository_owner == 'contourpy'
runs-on: ${{ matrix.os }}
env:
# Required version of chromium used for Bokeh image tests.
CHROME_VER: "118.0.5993.88"
CHROME_REV: "chromium_2670"
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-13, macos-14, windows-latest] # macos-14 is ARM
python-version: ["3.10", "3.11", "3.12", "3.13"]
name: ["Test"]
short-name: ["test"]
include:
# Debug build including Python and C++ coverage.
- os: ubuntu-latest
python-version: "3.12"
name: "Test debug with coverage"
short-name: "test-debug"
coverage-files: "coverage.lcov,coverage.cpp"
debug: true
# Bokeh and text tests with Python (not C++) coverage.
- os: ubuntu-latest
python-version: "3.12"
name: "Test bokeh and text tests with coverage"
short-name: "test-bokeh"
coverage-files: "coverage.lcov"
test-text: true
# Test against numpy debug build.
- os: ubuntu-latest
python-version: "3.12"
name: "Test numpy debug"
short-name: "test-numpy-debug"
build-numpy-debug: true
# Test against earliest supported numpy
- os: ubuntu-latest
python-version: "3.10"
name: "Test earliest numpy"
short-name: "test-earliest-numpy"
extra-install-args: "numpy==1.23"
# Compile using C++11.
- os: ubuntu-latest
python-version: "3.12"
name: "Test C++11"
short-name: "test-c++11"
extra-install-args: "-Csetup-args=-Dcpp_std=c++11"
# PyPy 3.10 only tested on ubuntu for speed, exclude big tests.
- os: ubuntu-latest
python-version: "pypy3.10"
name: "Test"
short-name: "test"
test-no-images: true
numpy-nightly: true
# Win32 test.
- os: windows-latest
python-version: "3.12"
name: "Win32"
short-name: "test-win32"
win32: true
test-no-images: true
# Test against matplotlib and numpy nightly wheels.
- os: ubuntu-latest
python-version: "3.12"
name: "Nightly wheels"
short-name: "test-nightlies"
nightly-wheels: true
- os: macos-13
python-version: "3.12"
name: "Nightly wheels"
short-name: "test-nightlies"
nightly-wheels: true
- os: windows-latest
python-version: "3.12"
name: "Nightly wheels"
short-name: "test-nightlies"
nightly-wheels: true
# Python 3.13 free-threading test.
- os: ubuntu-latest
python-version: "3.13t"
name: "Test"
short-name: "test"
steps:
- name: Checkout source
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Setup Python ${{ matrix.python-version }}
if: ${{ !matrix.win32 && matrix.python-version != '3.13t' }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Setup Python ${{ matrix.python-version }} win32
if: matrix.win32
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
architecture: x86
- name: Setup Python ${{ matrix.python-version }} using deadsnakes
if: matrix.python-version == '3.13t'
uses: deadsnakes/[email protected]
with:
python-version: '3.13'
nogil: true
- name: Setup MSVC (32-bit)
if: matrix.win32
uses: bus1/cabuild/action/msdevshell@v1
with:
architecture: 'x86'
- name: Fix PATH on win32
# Avoid this in GHA: "ERROR: Found GNU link.exe instead of MSVC link.exe"
if: matrix.win32
run: |
rm /c/Program\ Files/Git/usr/bin/link.EXE
- name: Install OS dependencies
if: matrix.debug
run: |
sudo apt update -yy
sudo apt install -yy lcov
- name: Install chromium for Bokeh tests
if: matrix.test-text
run: |
if [[ "$(chromium --version | cut -d' ' -f2)" = "$CHROME_VER" ]]; then
echo "Using pre-installed version of chromium"
else
URL=https://github.com/bokeh/chromium/raw/main/linux/$CHROME_VER
wget --no-verbose $URL/$CHROME_REV.assert
wget --no-verbose $URL/$CHROME_REV.snap
ls -l $CHROME_REV.*
sudo snap ack $CHROME_REV.assert
sudo snap install $CHROME_REV.snap
snap list chromium
snap info chromium
fi
which chromium
chromium --version
which chromedriver
chromedriver --version
- name: Build and install numpy from sdist
if: matrix.build-numpy
run: |
python -m pip install -v --no-binary=numpy numpy
- name: Build and install numpy from sdist with debug asserts enabled
if: matrix.build-numpy-debug
run: |
python -m pip install -v --no-binary=numpy numpy -Csetup-args=-Dbuildtype=debug
- name: Install numpy from nightly wheels
if: matrix.numpy-nightly
run: |
python -m pip install --only-binary=:all: --pre --extra-index-url https://pypi.anaconda.org/scientific-python-nightly-wheels/simple numpy
- name: Pre-install Python dependencies
run: |
python -m pip install --upgrade pip
if [[ "${{ matrix.debug }}" != "" ]] || [[ "${{ matrix.coverage-files }}" != "" ]]
then
# Install requirements when not using build isolation.
python -m pip install --only-binary=:all: -r build_requirements.txt ninja
fi
python -m pip list
- name: Install contourpy
run: |
if [[ "${{ matrix.debug }}" != "" ]]
then
echo "Install contourpy in debug editable mode with coverage"
python -m pip install -ve .[test] --no-build-isolation -Csetup-args=-Dbuildtype=debug -Csetup-args=-Db_coverage=true -Cbuilddir=build
elif [[ "${{ matrix.coverage-files }}" != "" ]]
then
echo "Install contourpy in editable mode with bokeh dependencies"
python -m pip install -ve .[bokeh,test] --no-build-isolation -Cbuilddir=build
elif [[ "${{ matrix.test-no-images }}" != "" ]]
then
echo "Install contourpy with non-image-generating test dependencies"
python -m pip install -v .[test-no-images]
else
echo "Install contourpy with standard test dependencies"
python -m pip install -v .[test] ${{ matrix.extra-install-args }}
fi
- name: Upgrade mpl and numpy nightly wheels
if: matrix.nightly-wheels
run: |
python -m pip install --only-binary=:all: --pre --upgrade --no-deps --extra-index-url https://pypi.anaconda.org/scientific-python-nightly-wheels/simple matplotlib numpy
- name: Smoke test
run: |
python -m pip list
python -c "from contourpy.util import build_config; from pprint import pprint; pprint(build_config())"
python -c "import contourpy as c; print('NDEBUG', c._contourpy.NDEBUG)"
- name: Run tests
run: |
if [[ "${{ matrix.debug }}" != "" ]]
then
echo "Run normal tests with coverage"
${PYTEST} tests/ --cov=lib --cov-report=lcov
elif [[ "${{ matrix.test-text }}" != "" ]]
then
echo "Run normal and text tests with coverage"
${PYTEST} -rP tests/test_bokeh_renderer.py tests/test_renderer.py --runtext --driver-path=/snap/bin/chromium.chromedriver --cov=lib --cov-report=lcov
elif [[ "${{ matrix.test-no-images }}" != "" ]]
then
echo "Run only tests that do not generate images"
${PYTEST} tests/ -k "not image"
elif [[ "${{ matrix.test-no-big }}" != "" ]]
then
echo "Run all tests except big ones"
${PYTEST} tests/ -k "not big"
else
echo "Run all tests"
${PYTEST} tests/
fi
- name: Collect C++ coverage
if: matrix.debug
run: |
lcov --output-file coverage.cpp --capture --directory build
lcov --output-file coverage.cpp --extract coverage.cpp $PWD/src/"*"
- name: Upload coverage
if: matrix.coverage-files
uses: codecov/codecov-action@v4
with:
files: ${{ matrix.coverage-files }}
token: ${{ secrets.CODECOV_TOKEN }}
verbose: true
- name: Upload test artifacts
if: always()
uses: actions/upload-artifact@v4
with:
name: ${{ matrix.short-name }}_${{ matrix.os }}_${{ matrix.python-version }}
path: result_images/
test-in-docker:
# In-docker tests are either emulated hardware or musllinux
name: In docker ${{ matrix.arch }} ${{ matrix.manylinux_version }}
if: github.event_name != 'schedule' || github.repository_owner == 'contourpy'
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
include:
# musllinux x86_64.
- arch: x86_64
manylinux_version: musllinux
image: musllinux_1_2_x86_64
venv: venv
test: test
# musllinux aarch64.
- arch: aarch64
manylinux_version: musllinux
image: musllinux_1_2_aarch64
venv: venv
test: test-no-images
# ppc64le and s390x: dependencies are conda packages.
- arch: ppc64le
manylinux_version: manylinux2014
image: manylinux2014_ppc64le
venv: conda
test: test
- arch: s390x
manylinux_version: manylinux2014
image: manylinux2014_s390x
venv: conda
test: test
steps:
- name: Checkout source
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set up QEMU
if: ${{ matrix.arch }} != "x86_64"
uses: docker/setup-qemu-action@v3
with:
platforms: all
- name: Run inside docker
uses: addnab/docker-run-action@v3
with:
image: quay.io/pypa/${{ matrix.image }}:latest
options: -v ${{ github.workspace }}:/work -e ARCH=${{ matrix.arch }} -e VENV=${{ matrix.venv}} -e TEST=${{ matrix.test }}
shell: bash
run: |
echo "-------------------- start --------------------"
set -eu
uname -a
cd /work
if [[ $VENV == "venv" ]]
then
echo "==> Create virtual environment"
/opt/python/cp312-cp312/bin/python -m venv venv
. venv/bin/activate
which python
python --version
else
echo "==> Install conda"
cd /tmp
curl -LO "http://repo.continuum.io/miniconda/Miniconda3-latest-Linux-$ARCH.sh"
bash Miniconda3-latest-Linux-$ARCH.sh -p /work/venv -b
rm Miniconda3-latest-Linux-$ARCH.sh
cd /work
echo "==> Activate conda in this shell"
. /work/venv/etc/profile.d/conda.sh
echo "==> Create and activate conda environment"
conda create -n my_env -q python=3.12
conda activate my_env
echo "==> Install conda dependencies"
conda install -q -c conda-forge -c nodefaults numpy matplotlib Pillow
conda list
fi
echo "==> Upgrade pip"
python -m pip install --upgrade pip
echo "==> Install contourpy with test dependencies"
python -m pip install -v .[$TEST] --only-binary=numpy
echo "==> Smoke test"
python -m pip list
python -c "from contourpy.util import build_config; from pprint import pprint; pprint(build_config())"
python -c "import contourpy as c; print('NDEBUG', c._contourpy.NDEBUG)"
PYTEST="python -m pytest -v -n auto --color=yes --log-image-diffs"
if [[ $TEST == "test-no-images" ]]
then
echo "==> Run non-image and non-big tests"
${PYTEST} tests/ -k "not (big or image)"
else
echo "==> Run tests except 'big' ones as on emulated hardware"
${PYTEST} tests/ -k "not big"
fi
echo "-------------------- end --------------------"
- name: Upload test artifacts
if: always()
uses: actions/upload-artifact@v4
with:
name: docker_${{ matrix.arch }}_${{ matrix.manylinux_version }}
path: result_images/
merge:
name: Merge test artifacts
if: github.event_name != 'schedule' || github.repository_owner == 'contourpy'
runs-on: ubuntu-latest
needs: [test, test-in-docker]
steps:
- name: Merge Artifacts
uses: actions/upload-artifact/merge@v4
with:
name: test-artifacts
separate-directories: true
delete-merged: true