-
Notifications
You must be signed in to change notification settings - Fork 259
240 lines (226 loc) · 7.16 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
name: Build and test
# This file tests the claimed support range of NiBabel including
#
# * Operating systems: Linux, Windows (x64 & x86), OSX
# * Dependencies: minimum requirements, optional requirements
# * Installation methods: setup.py, sdist, wheel, archive
on:
push:
branches:
- master
- maint/*
tags:
- "*"
pull_request:
branches:
- master
- maint/*
schedule:
- cron: '0 0 * * 1'
# Allow job to be triggered manually from GitHub interface
workflow_dispatch:
defaults:
run:
shell: bash
# Force tox and pytest to use color
env:
FORCE_COLOR: true
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
permissions:
contents: read
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: actions/setup-python@v5
with:
python-version: 3
- run: pip install --upgrade build twine
- name: Build sdist and wheel
run: python -m build
- run: twine check dist/*
- name: Build git archive
run: mkdir archive && git archive -v -o archive/nibabel-archive.tgz HEAD
- name: Upload sdist and wheel artifacts
uses: actions/upload-artifact@v4
with:
name: dist
path: dist/
- name: Upload git archive artifact
uses: actions/upload-artifact@v4
with:
name: archive
path: archive/
test-package:
runs-on: ubuntu-latest
needs: [build]
strategy:
matrix:
package: ['wheel', 'sdist', 'archive']
steps:
- name: Download sdist and wheel artifacts
if: matrix.package != 'archive'
uses: actions/download-artifact@v4
with:
name: dist
path: dist/
- name: Download git archive artifact
if: matrix.package == 'archive'
uses: actions/download-artifact@v4
with:
name: archive
path: archive/
- uses: actions/setup-python@v5
with:
python-version: 3
- name: Display Python version
run: python -c "import sys; print(sys.version)"
- name: Update pip
run: pip install --upgrade pip
- name: Install wheel
if: matrix.package == 'wheel'
run: pip install dist/nibabel-*.whl
- name: Install sdist
if: matrix.package == 'sdist'
run: pip install dist/nibabel-*.tar.gz
- name: Install archive
if: matrix.package == 'archive'
run: pip install archive/nibabel-archive.tgz
- run: python -c 'import nibabel; print(nibabel.__version__)'
- name: Install minimum test dependencies
run: pip install nibabel[test]
- name: Run tests
run: pytest --doctest-modules --doctest-plus -v --pyargs nibabel -n auto
test:
# Check each OS, all supported Python, minimum versions and latest releases
runs-on: ${{ matrix.os }}
continue-on-error: ${{ matrix.dependencies == 'pre' }}
strategy:
fail-fast: false
matrix:
os: ['ubuntu-latest', 'windows-latest', 'macos-13', 'macos-latest']
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"]
architecture: ['x64', 'x86', 'arm64']
dependencies: ['full', 'pre']
include:
# Basic dependencies only
- os: ubuntu-latest
python-version: 3.8
dependencies: 'none'
# Absolute minimum dependencies
- os: ubuntu-latest
python-version: 3.8
dependencies: 'min'
# NoGIL
- os: ubuntu-latest
python-version: '3.13-dev'
dependencies: 'dev'
exclude:
# x86 for Windows + Python<3.12
- os: ubuntu-latest
architecture: x86
- os: macos-13
architecture: x86
- os: macos-latest
architecture: x86
- python-version: '3.12'
architecture: x86
# arm64 is available for macos-14+
- os: ubuntu-latest
architecture: arm64
- os: windows-latest
architecture: arm64
- os: macos-13
architecture: arm64
# x64 is not available for macos-14+
- os: macos-latest
architecture: x64
# Drop pre tests for macos-13
- os: macos-13
dependencies: pre
# Drop pre tests for SPEC-0-unsupported Python versions
- python-version: '3.8'
dependencies: pre
- python-version: '3.9'
dependencies: pre
env:
DEPENDS: ${{ matrix.dependencies }}
ARCH: ${{ !contains(fromJSON('["none", "min"]'), matrix.dependencies) && matrix.architecture }}
steps:
- uses: actions/checkout@v4
with:
submodules: recursive
fetch-depth: 0
- name: Set up Python ${{ matrix.python-version }}
if: "!endsWith(matrix.python-version, '-dev')"
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
architecture: ${{ matrix.architecture }}
allow-prereleases: true
- name: Set up Python ${{ matrix.python-version }}
if: endsWith(matrix.python-version, '-dev')
uses: deadsnakes/[email protected]
with:
python-version: ${{ matrix.python-version }}
nogil: true
- name: Display Python version
run: python -c "import sys; print(sys.version)"
- name: Install tox
run: |
python -m pip install --upgrade pip
python -m pip install tox tox-gh-actions
- name: Show tox config
run: tox c
- name: Run tox
run: tox -vv --exit-and-dump-after 1200
- uses: codecov/codecov-action@v4
if: ${{ always() }}
with:
files: cov.xml
token: ${{ secrets.CODECOV_TOKEN }}
- name: Upload pytest test results
uses: actions/upload-artifact@v4
with:
name: pytest-results-${{ matrix.os }}-${{ matrix.python-version }}-${{ matrix.dependencies }}-${{ matrix.architecture }}
path: test-results.xml
if: ${{ always() }}
checks:
runs-on: 'ubuntu-latest'
continue-on-error: true
strategy:
matrix:
check: ['style', 'doctest', 'typecheck', 'spellcheck']
steps:
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: 3
- name: Display Python version
run: python -c "import sys; print(sys.version)"
- name: Show tox config
run: pipx run tox c
- name: Show tox config (this call)
run: pipx run tox c -e ${{ matrix.check }}
- name: Run check
run: pipx run tox -e ${{ matrix.check }}
publish:
runs-on: ubuntu-latest
environment: "Package deployment"
needs: [test, test-package]
permissions:
# Required for trusted publishing
id-token: write
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/')
steps:
- uses: actions/download-artifact@v4
with:
name: dist
path: dist/
- uses: pypa/gh-action-pypi-publish@release/v1