-
Notifications
You must be signed in to change notification settings - Fork 0
355 lines (335 loc) · 13.7 KB
/
ci.yaml
File metadata and controls
355 lines (335 loc) · 13.7 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
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
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
on:
pull_request:
paths-ignore:
- '.github/workflows/latest-deps.yaml'
merge_group:
push:
branches:
- master
- main
name: Continuous integration
env:
CARGO_TERM_COLOR: always
HOST: x86_64-unknown-linux-gnu
FEATURES: "approx,serde,rayon"
# `-C target-cpu=x86-64-v3` was removed from the global env. It conflicts
# with the cross_test matrix (`i686-unknown-linux-gnu` is 32-bit, `s390x`
# isn't even x86) and contradicts the design intent recorded in
# `.cargo/config.toml`: per-function `#[target_feature]` + runtime
# `LazyLock<Tier>` detection means one binary, all ISAs. Jobs that
# specifically need a higher target-cpu can opt in via per-job env.
RUSTFLAGS: "-D warnings"
MSRV: 1.95.0
BLAS_MSRV: 1.95.0
jobs:
pass-msrv:
runs-on: ubuntu-latest
name: Pass MSRV values to other jobs
outputs:
MSRV: ${{ env.MSRV }}
BLAS_MSRV: ${{ env.BLAS_MSRV }}
steps:
- name: Pass MSRV
run: |
echo "MSRV=${{ env.MSRV }}" >> $GITHUB_OUTPUT
echo "BLAS_MSRV=${{ env.BLAS_MSRV }}" >> $GITHUB_OUTPUT
clippy:
runs-on: ubuntu-latest
strategy:
matrix:
# Pinned to 1.95.0 to match `rust-toolchain.toml`. The workspace
# bumped from 1.94.1 → 1.95.0 in commit
# https://github.com/AdaWorldAPI/ndarray (this PR) to align with
# bevy (edition 2024 → 1.95 MSRV) and lance-graph. 1.95 added the
# `clippy::manual_checked_ops` lint which fires on
# `impl_owned_array.rs::into_scalar` — fixed in this same PR.
rust:
- "1.95.0"
name: clippy/${{ matrix.rust }}
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@1.95.0
with:
components: clippy
- uses: Swatinem/rust-cache@v2
- run: cargo clippy --features approx,serde,rayon -- -D warnings
- run: cargo clippy --features native -- -D warnings
format:
runs-on: ubuntu-latest
name: format/stable
# Blocking — no continue-on-error. `rustfmt.toml` was stripped of all
# nightly-only directives in PR #133 (`7ca1cf3d chore(fmt): strip
# unstable rustfmt options, keep stable-only config` + `ed59b3b1
# style: normalize codebase to stable rustfmt 1.94.1`) and the
# codebase normalized — so stable rustfmt enforces the project's
# style losslessly. The previous `continue-on-error: true` +
# `dtolnay/rust-toolchain@nightly` setup was a stale band-aid from
# when `brace_style = AlwaysNextLine`, `imports_granularity =
# Preserve`, `unstable_features = true` still lived in rustfmt.toml.
# That state no longer exists; the band-aid is removed in this PR.
steps:
- uses: actions/checkout@v4
# Stable rustfmt 1.95.0 — pinned in `rust-toolchain.toml`. No
# nightly dependency since rustfmt.toml is stable-clean post-PR
# #133.
- uses: dtolnay/rust-toolchain@1.95.0
with:
components: rustfmt
- run: cargo fmt --all --check
nostd:
runs-on: ubuntu-latest
continue-on-error: ${{ matrix.experimental }}
strategy:
matrix:
include:
- rust: stable
experimental: false
target: thumbv6m-none-eabi
name: nostd/${{ matrix.target }}/${{ matrix.rust }}
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
with:
toolchain: ${{ matrix.rust }}
targets: ${{ matrix.target }}
# rust-toolchain.toml pins 1.95.0 — install the cross-compile target
# for that toolchain too, since dtolnay/rust-toolchain only installs
# for the matrix value which may differ from the pinned version.
- run: rustup target add ${{ matrix.target }}
- name: Tests
run: |
# Scope to `-p ndarray` so workspace dev-deps (criterion → serde_core
# → getrandom) don't get evaluated against the no_std target. The
# library itself builds cleanly under no_std + portable-atomic-
# critical-section; only its dev-dependency tree pulls std-requiring
# crates that have no business existing in the nostd build.
cargo rustc -p ndarray "--target=${{ matrix.target }}" --no-default-features --features portable-atomic-critical-section
tests:
runs-on: ubuntu-latest
needs: pass-msrv
strategy:
matrix:
rust:
- stable
- beta
- ${{ needs.pass-msrv.outputs.MSRV }}
name: tests/${{ matrix.rust }}
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@master
with:
toolchain: ${{ matrix.rust }}
- uses: rui314/setup-mold@v1
- uses: Swatinem/rust-cache@v2
- uses: taiki-e/install-action@nextest
- name: Install openblas
run: sudo apt-get install libopenblas-dev gfortran
- run: ./scripts/all-tests.sh "$FEATURES" ${{ matrix.rust }}
native-backend:
runs-on: ubuntu-latest
name: native-backend/stable
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
- uses: Swatinem/rust-cache@v2
- uses: taiki-e/install-action@nextest
- name: Build native backend
run: cargo build --features native
- name: Test native backend
run: cargo nextest run -p ndarray --features native
- name: Test native + approx
run: cargo nextest run -p ndarray --features native,approx
hpc-stream-parallel:
# D-CSV-17 (sprint-13 W-I4): rayon par_* variants for hpc::stream.
# This job co-ships with the par_* implementation so the rayon feature
# gate is always exercised alongside the code it guards — prevents
# silent-dead-code drift (spec §0 + worker-template-v2 §5 CI ownership).
runs-on: ubuntu-latest
name: hpc-stream-parallel/rayon
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@1.95.0
- uses: Swatinem/rust-cache@v2
- uses: taiki-e/install-action@nextest
- name: cargo check (no rayon — scalar path unchanged)
run: cargo check -p ndarray
- name: cargo check --features rayon
run: cargo check -p ndarray --features rayon
- name: par_* stream tests (--features rayon, hpc::stream filter)
run: cargo nextest run -p ndarray --features rayon -E 'test(hpc::stream)'
- name: clippy --features rayon
run: cargo clippy -p ndarray --features rayon --lib -- -D warnings
tier4-avx512-check:
# Phase 6 of the SIMD integration plan (.claude/knowledge/
# simd-dispatch-architecture.md). Exercises the AVX-512 dispatch
# arm (`#[cfg(target_feature = "avx512f")]` in `src/simd.rs`) so it
# doesn't bit-rot under the v3-default cargo config.
#
# `cargo check` rather than `cargo test`: GH-hosted `ubuntu-latest`
# runners may not have AVX-512 silicon (intermittent across SKUs),
# so a v4-baked binary would SIGILL at run time. `check` compiles
# the AVX-512 code path through the type checker + borrow checker
# + monomorphization without producing a runnable artifact —
# catches type mismatches and dispatch-arm holes that the v3
# default never touches.
#
# # Why `CARGO_TARGET_<triple>_RUSTFLAGS` instead of plain `RUSTFLAGS`:
#
# The first iteration used `env: RUSTFLAGS: "-Ctarget-cpu=x86-64-v4"`
# and failed in ~23 s — RUSTFLAGS env applies to BOTH the target
# compilation AND host build scripts (`build.rs` artifacts that
# cargo runs natively). On a GH runner without AVX-512 silicon,
# those v4-baked build scripts SIGILL during the dep build.
#
# `CARGO_TARGET_X86_64_UNKNOWN_LINUX_GNU_RUSTFLAGS` is documented to
# apply only when cargo is producing artifacts for that triple, NOT
# to host build scripts. Combined with explicit `--target` (so cargo
# distinguishes host from target even when they're the same triple),
# this gives us "v4 for our crate, baseline for build scripts."
runs-on: ubuntu-latest
name: tier4-avx512-check
env:
CARGO_TARGET_X86_64_UNKNOWN_LINUX_GNU_RUSTFLAGS: "-D warnings -Ctarget-cpu=x86-64-v4"
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
- uses: Swatinem/rust-cache@v2
- name: cargo check (v4 / AVX-512 dispatch arm)
run: cargo check --target=x86_64-unknown-linux-gnu -p ndarray --features approx,serde,rayon
- name: cargo check (v4 / AVX-512 + hpc-extras)
run: cargo check --target=x86_64-unknown-linux-gnu -p ndarray --features approx,serde,rayon,hpc-extras
nightly-simd-polyfill:
# TD-SIMD-9 from .claude/knowledge/simd-dispatch-architecture.md.
# Exercises the `feature = "nightly-simd"` dispatch arm in
# `src/simd.rs` (added in Phase 2 / PR #173) so the portable
# `core::simd::*` backend doesn't bit-rot between PRs.
#
# Why nightly: `src/simd_nightly/*` uses `#![feature(portable_simd)]`
# which only compiles on nightly rustc. The stable `cargo check`
# paths in tests/clippy never reach this arm.
#
# `cargo check` rather than full build/test — pure type/borrow/cfg
# verification. Catches arm shadowing bugs and the kind of API-break
# codex flagged on PR #173 (lowercase aliases dropped).
#
# Runs only on merge_group + push (not every PR) to keep nightly
# toolchain pulls out of the per-PR critical path. Mirrors the
# `miri` job's gating strategy.
if: github.event_name == 'merge_group' || github.event_name == 'push'
runs-on: ubuntu-latest
name: nightly-simd-polyfill
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@nightly
- uses: Swatinem/rust-cache@v2
- name: cargo check (nightly + nightly-simd feature)
run: cargo check -p ndarray --features approx,serde,rayon,nightly-simd
- name: cargo check (nightly + nightly-simd + hpc-extras)
run: cargo check -p ndarray --features approx,serde,rayon,nightly-simd,hpc-extras
blas-msrv:
runs-on: ubuntu-latest
name: blas-msrv
needs: pass-msrv
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@master
with:
toolchain: ${{ needs.pass-msrv.outputs.BLAS_MSRV }}
- uses: rui314/setup-mold@v1
- uses: Swatinem/rust-cache@v2
- uses: taiki-e/install-action@nextest
- name: Install openblas
run: sudo apt-get install libopenblas-dev gfortran
- run: ./scripts/blas-integ-tests.sh $BLAS_MSRV
miri:
# Nightly-only. Cannot run SIMD intrinsics or FFI.
# Only runs on merge queue / push to main — never blocks PR checks.
if: github.event_name == 'merge_group' || github.event_name == 'push'
runs-on: ubuntu-latest
name: miri
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@nightly
with:
components: miri
- uses: Swatinem/rust-cache@v2
- uses: taiki-e/install-action@nextest
- run: ./scripts/miri-tests.sh
cross_test:
# Gated on merge_group only — cross-compile via docker (cross-rs) for
# s390x / i686 is slow, flaky on the s390x docker image's toolchain
# resolution (rust-toolchain.toml's 1.94.1 pin doesn't resolve cleanly
# inside the s390x cross container), and reliably caught by the
# `tests/{stable,beta,1.94.0}` jobs on every PR push. Reserve cross
# validation for the merge queue where it can fail loudly without
# gating individual PRs on infra flakiness. The commented `if:` was
# the original intent (per the pre-existing comment) — uncommenting
# per the PR #143 codex thread that surfaced this consistently.
if: ${{ github.event_name == 'merge_group' }}
runs-on: ubuntu-latest
strategy:
matrix:
include:
- rust: stable
target: s390x-unknown-linux-gnu
- rust: stable
target: i686-unknown-linux-gnu
name: cross_test/${{ matrix.target }}/${{ matrix.rust }}
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@master
with:
toolchain: ${{ matrix.rust }}
targets: ${{ matrix.target }}
- uses: rui314/setup-mold@v1
- uses: Swatinem/rust-cache@v2
- name: Install cross
run: cargo install cross
- run: ./scripts/cross-tests.sh "approx,serde,rayon" ${{ matrix.rust }} ${{ matrix.target }}
cargo-careful:
# Nightly-only. Only runs on merge queue / push — never blocks PR checks.
if: github.event_name == 'merge_group' || github.event_name == 'push'
runs-on: ubuntu-latest
name: cargo-careful
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@nightly
- uses: Swatinem/rust-cache@v2
- uses: taiki-e/install-action@nextest
- name: Install cargo-careful
run: cargo install cargo-careful
- run: cargo careful nextest run -Zcareful-sanitizer --features="$FEATURES"
docs:
# Nightly needed for --cfg docsrs. Only on merge queue / push.
if: github.event_name == 'merge_group' || github.event_name == 'push'
runs-on: ubuntu-latest
name: docs/nightly
env:
RUSTDOCFLAGS: "-Dwarnings --cfg docsrs"
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@nightly
- run: cargo doc --no-deps --all-features
conclusion:
needs:
- clippy
- format
- nostd
- tests
- native-backend
- hpc-stream-parallel
- tier4-avx512-check
- nightly-simd-polyfill
- miri
- cross_test
- cargo-careful
- docs
runs-on: ubuntu-latest
steps:
- name: Result
run: |
jq -C <<< "${needs}"
# Check if all needs were successful or skipped.
"$(jq -r 'all(.result as $result | (["success", "skipped"] | contains([$result])))' <<< "${needs}")"
env:
needs: ${{ toJson(needs) }}