-
Notifications
You must be signed in to change notification settings - Fork 113
271 lines (260 loc) · 8.46 KB
/
ci.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
name: CI
on:
push:
branches:
- main
- release-*
pull_request:
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.sha }}
cancel-in-progress: true
jobs:
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
with:
components: rustfmt, clippy
- uses: Swatinem/rust-cache@v2
continue-on-error: true
- run: ./x.py check
test:
name: python${{ matrix.python-version }}-${{ matrix.platform.python-architecture }} ${{ matrix.platform.os }}
runs-on: ${{ matrix.platform.os }}
needs: [lint, check-msrv, examples]
strategy:
fail-fast: ${{ !contains(github.event.pull_request.labels.*.name, 'CI-no-fail-fast') }}
matrix:
python-version: ["3.7", "3.8", "3.9", "3.10", "3.11", "3.12"]
platform:
[
{
os: "ubuntu-latest",
python-architecture: "x64",
rust-target: "x86_64-unknown-linux-gnu",
},
{
os: "macOS-13",
python-architecture: "x64",
rust-target: "x86_64-apple-darwin",
},
{
os: "windows-latest",
python-architecture: "x64",
rust-target: "x86_64-pc-windows-msvc",
},
]
include:
# Older versions of CPython are not available for AArch64.
- python-version: 3.12
platform:
{
os: "macOS-latest",
python-architecture: "arm64",
rust-target: "aarch64-apple-darwin",
}
# NumPy does not provide pre-built wheels for PyPy on macOS and Windows
- python-version: pypy-3.7
platform:
{
os: "ubuntu-latest",
python-architecture: "x64",
rust-target: "x86_64-unknown-linux-gnu",
}
- python-version: pypy-3.8
platform:
{
os: "ubuntu-latest",
python-architecture: "x64",
rust-target: "x86_64-unknown-linux-gnu",
}
steps:
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
architecture: ${{ matrix.platform.python-architecture }}
- name: Install Rust
uses: dtolnay/rust-toolchain@stable
with:
targets: ${{ matrix.platform.rust-target }}
- name: Test
run: |
pip install "numpy" ml_dtypes
cargo test --all-features
# Not on PyPy, because no embedding API
if: ${{ !startsWith(matrix.python-version, 'pypy') }}
- name: Test example
run: |
pip install nox
nox -f examples/simple/noxfile.py
env:
CARGO_TERM_VERBOSE: true
CARGO_BUILD_TARGET: ${{ matrix.platform.rust-target }}
RUST_BACKTRACE: 1
test-numpy1:
name: python${{ matrix.python-version }}-${{ matrix.platform.python-architecture }} ${{ matrix.platform.os }} numpy1
runs-on: ${{ matrix.platform.os }}
needs: [lint, check-msrv, examples]
strategy:
fail-fast: ${{ !contains(github.event.pull_request.labels.*.name, 'CI-no-fail-fast') }}
matrix:
python-version: ["3.7", "3.8", "3.9", "3.10", "3.11", "3.12"]
platform:
[
{
os: "ubuntu-latest",
python-architecture: "x64",
rust-target: "x86_64-unknown-linux-gnu",
},
{
os: "macOS-13",
python-architecture: "x64",
rust-target: "x86_64-apple-darwin",
},
{
os: "windows-latest",
python-architecture: "x64",
rust-target: "x86_64-pc-windows-msvc",
},
]
steps:
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
architecture: ${{ matrix.platform.python-architecture }}
- name: Install Rust
uses: dtolnay/rust-toolchain@stable
with:
targets: ${{ matrix.platform.rust-target }}
- name: Test
run: |
pip install "numpy<2" ml_dtypes
cargo test --all-features
- name: Test example
run: |
pip install nox
nox -f examples/simple/noxfile.py
env:
CARGO_TERM_VERBOSE: true
RUST_BACKTRACE: 1
cross-build:
runs-on: ubuntu-latest
needs: [lint, check-msrv, examples]
steps:
- uses: actions/checkout@v4
- uses: messense/maturin-action@v1
with:
target: aarch64
manylinux: auto
args: --manifest-path examples/simple/Cargo.toml
valgrind:
runs-on: ubuntu-latest
needs: [lint, check-msrv, examples]
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
- uses: Swatinem/rust-cache@v2
continue-on-error: true
- uses: taiki-e/install-action@valgrind
- run: |
pip install "numpy" ml_dtypes
cargo test --all-features --release
env:
CARGO_TARGET_X86_64_UNKNOWN_LINUX_GNU_RUNNER: valgrind --leak-check=no --error-exitcode=1
careful:
runs-on: ubuntu-latest
needs: [lint, check-msrv, examples]
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@nightly
- uses: Swatinem/rust-cache@v2
continue-on-error: true
- uses: taiki-e/install-action@cargo-careful
- run: |
pip install "numpy" ml_dtypes
cargo careful test --all-features
check-msrv:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: 3.8
- name: Install Rust
uses: dtolnay/rust-toolchain@1.63
- uses: Swatinem/rust-cache@v2
with:
workspaces: examples/simple
continue-on-error: true
- name: Install toml
run: pip install toml
- name: Edit Cargo.toml
run: |
import toml
cargo_toml = toml.load("Cargo.toml")
cargo_toml["dependencies"]["ndarray"] = "0.15.6"
with open("Cargo.toml", "w") as f:
toml.dump(cargo_toml, f)
working-directory: examples/simple
shell: python
- name: Generate lockfile
run: cargo generate-lockfile
working-directory: examples/simple
- name: Unify dependencies to MSRV-compatible versions
run: |
import toml
import subprocess
cargo_lock = toml.load("Cargo.lock")
for pkg in cargo_lock["package"]:
pkg_id = pkg["name"] + ":" + pkg["version"]
if pkg["name"] == "ndarray" and pkg["version"] != "0.15.6":
subprocess.run(["cargo", "update", "--package", pkg_id, "--precise", "0.15.6"], check=True)
working-directory: examples/simple
shell: python
- name: Test example
run: |
pip install nox
nox -f examples/simple/noxfile.py
examples:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install OpenBLAS
run: sudo apt install --yes libopenblas-dev
- name: Install Rust
uses: dtolnay/rust-toolchain@stable
- uses: Swatinem/rust-cache@v2
continue-on-error: true
- name: Test examples
run: |
pip install nox
nox -f examples/linalg/noxfile.py
nox -f examples/parallel/noxfile.py
coverage:
runs-on: ubuntu-latest
needs: [lint, check-msrv, examples]
steps:
- uses: actions/checkout@v4
- name: Install numpy
run: pip install "numpy" ml_dtypes
- uses: Swatinem/rust-cache@v2
continue-on-error: true
- uses: dtolnay/rust-toolchain@stable
with:
components: llvm-tools-preview
- name: Install cargo-llvm-cov
uses: taiki-e/install-action@cargo-llvm-cov
- name: Generate code coverage
run: cargo llvm-cov --all-features --codecov --output-path coverage.json
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v4
with:
file: coverage.json
token: ${{ secrets.CODECOV_TOKEN }}
fail_ci_if_error: true