-
Notifications
You must be signed in to change notification settings - Fork 279
183 lines (162 loc) · 5.38 KB
/
build-test.yaml
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
name: Build and Test
on:
push:
branches:
- main
pull_request:
workflow_dispatch:
defaults:
run:
shell: bash
env:
HOMEBREW_NO_AUTO_UPDATE: 1
jobs:
build:
name: "${{ matrix.tests-type }} tests: py${{ matrix.python-version }} on ${{ matrix.os }} (${{ matrix.test-runner }})"
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']
dependencies: [full]
tests-type: [unit]
test-runner: [pytest]
venv-loc: [bin]
include:
- os: windows-latest
python-version: '3.13'
dependencies: full
tests-type: unit
test-runner: pytest
venv-loc: Scripts
- os: ubuntu-20.04
python-version: '3.10.3'
dependencies: minimal
tests-type: unit
test-runner: pytest
venv-loc: bin
- os: ubuntu-latest
# this job is necessary for non-answer, 'yield' based tests
# because pytest doesn't support such tests
python-version: '3.10'
dependencies: full
tests-type: unit
test-runner: nose
venv-loc: bin
- 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'
dependencies: full
tests-type: answer
test-runner: nose
venv-loc: bin
- os: ubuntu-latest
# minimal tests with latest Python and no optional dependencies
python-version: '3.x'
dependencies: ''
tests-type: unit
test-runner: pytest
venv-loc: bin
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: Set up Python
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Checkout repo (bare)
if: matrix.tests-type != 'answer'
uses: actions/checkout@v4
- name: Checkout repo (with submodules)
if: matrix.tests-type == 'answer'
uses: actions/checkout@v4
with:
submodules: true
- name: Install dependencies and yt
shell: bash
env:
dependencies: ${{ matrix.dependencies }}
run: |
python -m venv .venv
source .venv/${{matrix.venv-loc}}/activate
source ./tests/ci_install.sh
- name: Install and patch nosetest
if: matrix.test-runner == 'nose'
run: |
source .venv/${{matrix.venv-loc}}/activate
python -m pip install -r nose_requirements.txt
find .venv/lib/python${{matrix.python-version}}/site-packages/nose -name '*.py' \
-exec sed -i -e s/collections.Callable/collections.abc.Callable/g '{}' ';'
- name: Show final env
run: |
source .venv/${{matrix.venv-loc}}/activate
python -m pip list
- name: Run Unit Tests (pytest)
if: matrix.test-runner == 'pytest'
run: |
source .venv/${{matrix.venv-loc}}/activate
pytest --color=yes
- name: Run Tests (nose)
if: matrix.test-runner == 'nose'
run: |
source .venv/${{matrix.venv-loc}}/activate
cat nose_ignores.txt | xargs python -m nose -c nose_unit.cfg --traverse-namespace
image-tests:
name: Image tests
runs-on: ubuntu-latest
concurrency:
# auto-cancel any in-progress job *on the same branch*
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
steps:
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.11'
- name: Checkout repo (with submodules)
uses: actions/checkout@v4
with:
submodules: true
- name: Install dependencies and yt
shell: bash
env:
dependencies: 'cartopy'
run: |
source ./tests/ci_install.sh
- run: python -m pip list
- name: Run Image Tests
run: |
pytest --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
- name: Generate new image baseline
if: failure()
run: |
pytest --color=yes --mpl -m mpl_image_compare \
--mpl-generate-path=pytest_mpl_new_baseline \
--last-failed
# always attempt to upload artifacts, even
# (and especially) in case of failure.
- name: Upload pytest-mpl report
if: always()
uses: actions/upload-artifact@v4
with:
name: yt_pytest_mpl_results
path: pytest_mpl_results/*
- name: Upload pytest-mpl baseline
if: always()
uses: actions/upload-artifact@v4
with:
name: yt_pytest_mpl_new_baseline
path: pytest_mpl_new_baseline/*
if-no-files-found: ignore