-
Notifications
You must be signed in to change notification settings - Fork 311
202 lines (183 loc) · 6.59 KB
/
build-test.yaml
File metadata and controls
202 lines (183 loc) · 6.59 KB
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
name: Build and Test
on:
push:
branches:
- main
pull_request:
workflow_dispatch:
defaults:
run:
shell: bash
permissions: {}
jobs:
check-lock-file:
# validate uv.lock against requirements
# a failure indicates that the lock file is out of sync
# with requirements and needs to be updated
# this is normally done using uv-pre-commit but yt's dependency
# graph is too big to run on pre-commit.ci
name: Check uv.lock
runs-on: ubuntu-latest
steps:
- name: Checkout repo
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
persist-credentials: false
- name: Set up uv
uses: astral-sh/setup-uv@681c641aba71e4a1c380be3ab5e12ad51f415867 # v7.1.6
with:
version: ">=0.9.11,<0.10.0" # pin uv to avoid the lock file format going out-of-sync
python-version: 3.14
cache-suffix: lockcheck
prune-cache: false
- run: uv lock --check
build:
name: "${{ matrix.tests-type }} tests: py${{ matrix.python-version }} on ${{ matrix.os }} (${{ matrix.test-runner }})"
needs: [check-lock-file]
strategy:
# run all tests even if e.g. image tests fail early
fail-fast: false
matrix:
os:
- ubuntu-latest
- macos-latest
python-version: ['3.13']
sync_args: [--extra=full]
tests-type: [unit]
test-runner: [pytest]
cache-suffix: [null]
include:
- os: windows-latest
python-version: '3.13'
sync_args: --extra=full
tests-type: unit
test-runner: pytest
cache-suffix: alldeps
- os: ubuntu-22.04
python-version: '3.10.4'
sync_args: --resolution=lowest
tests-type: unit
test-runner: pytest
cache-suffix: oldestdeps
- os: ubuntu-latest
# this job is necessary for non-answer, 'yield' based tests
# because pytest doesn't support such tests
python-version: '3.10'
sync_args: "--extra=full --group=nosetest"
tests-type: unit
test-runner: nose
cache-suffix: alldeps-nose
- os: ubuntu-latest
# answer tests use 'yield', so they require nose
# they are also attached to a specific, occasionally updated, Python version
# but it does *not* have to match the current minimal supported version
python-version: '3.10'
sync_args: "--extra=full --group=nosetest"
tests-type: answer
test-runner: nose
cache-suffix: alldeps-nose
- os: ubuntu-latest
# minimal tests with latest Python and no optional dependencies
python-version: '3.14'
sync_args: null
tests-type: unit
test-runner: pytest
cache-suffix: minimal
runs-on: ${{ matrix.os }}
concurrency:
# auto-cancel any in-progress job *on the same branch*
group: ${{ github.workflow }}-${{ github.ref }}-${{ matrix.tests-type }}-py${{ matrix.python-version }}-${{ matrix.os }}-${{ matrix.test-runner }}
cancel-in-progress: true
steps:
- name: Checkout repo
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
persist-credentials: false
submodules: ${{ matrix.tests-type == 'answer' }}
- name: Set up Python
uses: astral-sh/setup-uv@681c641aba71e4a1c380be3ab5e12ad51f415867 # v7.1.6
with:
python-version: ${{ matrix.python-version }}
cache-suffix: ${{ matrix.cache-suffix }}
prune-cache: false
- name: Install dependencies and yt
shell: bash
env:
sync_args: ${{ matrix.sync_args}}
run: source ./tests/ci_install.sh
- name: Patch nosetest
if: matrix.test-runner == 'nose'
# note: this could be handled with [tool.uv.sources]
run: |
find .venv/lib/python${{matrix.python-version}}/site-packages/nose -name '*.py' \
-exec sed -i -e s/collections.Callable/collections.abc.Callable/g '{}' ';'
- name: Run Unit Tests (pytest)
if: matrix.test-runner == 'pytest'
run: uv run --no-sync pytest yt --color=yes ${{ contains(matrix.sync_args , 'resolution=lowest' ) && '-Wdefault' || '' }}
env:
MPLCONFIGDIR: tests
- name: Run Tests (nose)
if: matrix.test-runner == 'nose'
run: |
cat nose_ignores | xargs uv run python -m nose -c nose_unit.cfg --traverse-namespace
env:
MPLCONFIGDIR: tests
image-tests:
name: Image tests
runs-on: ubuntu-latest
needs: [check-lock-file]
concurrency:
# auto-cancel any in-progress job *on the same branch*
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
steps:
- name: Checkout repo (with submodules)
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
submodules: true
persist-credentials: false
- name: Set up Python
uses: astral-sh/setup-uv@681c641aba71e4a1c380be3ab5e12ad51f415867 # v7.1.6
with:
python-version: '3.11'
enable-cache: false
- name: Install dependencies and yt
shell: bash
env:
sync_args: --group=mapping
run: source ./tests/ci_install.sh
- run: python -m pip list
- name: Run Image Tests
run: |
uv run --no-sync \
pytest yt --color=yes --mpl -m mpl_image_compare \
--mpl-generate-summary=html \
--mpl-results-path=pytest_mpl_results \
--mpl-baseline-path=tests/pytest_mpl_baseline \
-rxXs # show extra info on xfailed, xpassed, and skipped tests
env:
MPLCONFIGDIR: tests
- name: Generate new image baseline
if: failure()
run: |
uv run --no-sync \
pytest yt --color=yes --mpl -m mpl_image_compare \
--mpl-generate-path=pytest_mpl_new_baseline \
--last-failed
env:
MPLCONFIGDIR: tests
# always attempt to upload artifacts, even
# (and especially) in case of failure.
- name: Upload pytest-mpl report
if: always()
uses: actions/upload-artifact@bbbca2ddaa5d8feaa63e36b76fdaad77386f024f # v7.0.0
with:
name: yt_pytest_mpl_results
path: pytest_mpl_results/*
- name: Upload pytest-mpl baseline
if: always()
uses: actions/upload-artifact@bbbca2ddaa5d8feaa63e36b76fdaad77386f024f # v7.0.0
with:
name: yt_pytest_mpl_new_baseline
path: pytest_mpl_new_baseline/*
if-no-files-found: ignore