-
Notifications
You must be signed in to change notification settings - Fork 113
209 lines (198 loc) · 7.21 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
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-latest", python-architecture: "x64", rust-target: "x86_64-apple-darwin" },
{ os: "windows-latest", python-architecture: "x64", rust-target: "x86_64-pc-windows-msvc" },
{ os: "windows-latest", python-architecture: "x86", rust-target: "i686-pc-windows-msvc" },
]
include:
# 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@v4
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: Install toml
run: pip install toml
- name: Edit Cargo.toml and enable new resolver
run: |
import toml
cargo_toml = toml.load("Cargo.toml")
cargo_toml["package"]["resolver"] = "2"
with open("Cargo.toml", "w") as f:
toml.dump(cargo_toml, f)
shell: python
- 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
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@v4
with:
python-version: 3.8
- name: Install Rust
uses: dtolnay/[email protected]
- 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.13.1"
cargo_toml["dependencies"]["parking_lot"] = "0.11.2"
cargo_toml["dependencies"]["num-complex"] = "0.2.4"
cargo_toml["dependencies"]["once_cell"] = "1.14.0"
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.13.1":
subprocess.run(["cargo", "update", "--package", pkg_id, "--precise", "0.13.1"], check=True)
elif pkg["name"] == "parking_lot" and pkg["version"] != "0.11.2":
subprocess.run(["cargo", "update", "--package", pkg_id, "--precise", "0.11.2"], check=True)
elif pkg["name"] == "once_cell" and pkg["version"] != "1.14.0":
subprocess.run(["cargo", "update", "--package", pkg_id, "--precise", "1.14.0"], 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@v3
with:
file: coverage.json
fail_ci_if_error: true