-
Notifications
You must be signed in to change notification settings - Fork 6
560 lines (459 loc) · 18.2 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
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
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
# There are two kinds of continuous integration jobs in this project:
#
# - Every code submission or master push passes continuous integration on the
# minimal supported Rust version and the current stable Rust version.
# - Two times a month, a scheduled job makes sure that the code remains
# compatible and lint-free on upcoming Rust toolchains (beta and nightly).
name: Continuous Integration
on:
push:
pull_request:
schedule:
- cron: '0 0 6/15 * *'
# Cancel existing jobs on new pushes to the same branch
concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
cancel-in-progress: true
env:
CARGO_INCREMENTAL: 0
RUSTFLAGS: '-D warnings'
RUSTDOCFLAGS: '-D warnings'
RUST_LOG: 'info'
MINIMAL_RUST: '1.75.0' # Minimal Supported Rust Version
HWLOC_VERSION: '2.10.0'
HWLOC_VERSION_SHORT: '2.10' # Used in URL to official tarball/binaries
HWLOC_DEBUG_VERBOSE: 0 # Set to 1 when debugging issues inside of hwloc
HWLOC_HIDE_ERRORS: 0 # Remove if this proves too chatty
jobs:
# Workaround for github CI dropping env var expansion in matrix strategy
matrix_vars:
# Don't run CI twice when a PR is created from a branch internal to the repo
if: github.event_name == 'push' || github.event_name == 'schedule' || github.event.pull_request.head.repo.full_name != github.repository
runs-on: ubuntu-latest
outputs:
MINIMAL_RUST: ${{ env.MINIMAL_RUST }}
steps:
- name: Forward env var to output
run: echo "MINIMAL_RUST=${{ env.MINIMAL_RUST }}" >> $GITHUB_OUTPUT
# Formatter output and dependency checking don't depend on cargo features, and
# only need to be tested on the latest supported release of each CI run.
#
# We don't care about warnings on the minimum supported Rust version, only
# about building and running correctly.
format-machete:
# Don't run CI twice when a PR is created from a branch internal to the repo
if: github.event_name == 'push' || github.event_name == 'schedule' || github.event.pull_request.head.repo.full_name != github.repository
runs-on: ubuntu-latest
steps:
- name: Checkout sources
uses: actions/checkout@v4
- name: Set up stable toolchain
if: github.event_name != 'schedule'
uses: actions-rust-lang/setup-rust-toolchain@v1
with:
components: rustfmt
- name: Set up nightly toolchain
if: github.event_name == 'schedule'
uses: actions-rust-lang/setup-rust-toolchain@v1
with:
toolchain: nightly
components: rustfmt
- name: Check format
run: cargo fmt --all --check
- name: Set up cargo-binstall
run: curl -L --proto '=https' --tlsv1.2 -sSf https://raw.githubusercontent.com/cargo-bins/cargo-binstall/main/install-from-binstall-release.sh | bash
- name: Look for unused dependencies with cargo-machete
run: |
# FIXME: --force used as a workaround for https://github.com/Swatinem/rust-cache/issues/204
cargo binstall -y --force cargo-machete
cargo machete
# Clippy and rustc lints depend on cfg(), of which we currently use "feature"
# and "target_os". So far, hwlocality has Linux- and Windows-specific code,
# but nothing macOS-specific, so we can cover all configurations by testing on
# Linux and Windows.
#
# We don't care about warnings on the minimum supported Rust version, only
# about building and running correctly.
lints:
# Don't run CI twice when a PR is created from a branch internal to the repo
if: github.event_name == 'push' || github.event_name == 'schedule' || github.event.pull_request.head.repo.full_name != github.repository
runs-on: ${{ matrix.os }}
strategy:
matrix:
os:
- ubuntu-latest
- windows-latest
features:
- '""'
- 'hwloc-2_0_4'
- 'hwloc-2_1_0'
- 'hwloc-2_2_0'
- 'hwloc-2_3_0'
- 'hwloc-2_4_0'
- 'hwloc-2_5_0'
- 'hwloc-2_8_0'
- 'hwloc-2_10_0'
# Remember to also update scheduled-semver-checks matrix
- 'hwloc-latest,vendored'
- 'hwloc-latest,proptest'
env:
JOB_FLAGS: '--workspace --features=${{ matrix.features }}'
steps:
- name: Checkout sources
uses: actions/checkout@v4
- name: Set up stable toolchain
if: github.event_name != 'schedule'
uses: actions-rust-lang/setup-rust-toolchain@v1
with:
components: clippy
- name: Set up nightly toolchain
if: github.event_name == 'schedule'
uses: actions-rust-lang/setup-rust-toolchain@v1
with:
toolchain: nightly
components: clippy
- name: Set up hwloc
uses: ./.github/actions/setup-hwloc-dependencies
with:
hwloc-version: ${{ env.HWLOC_VERSION }}
hwloc-version-short: ${{ env.HWLOC_VERSION_SHORT }}
if: contains(matrix.features, 'vendored') == false
- name: Check clippy lints
run: cargo clippy ${{ env.JOB_FLAGS }} --all-targets -- -D warnings
- name: Build docs
run: cargo doc ${{ env.JOB_FLAGS }}
- name: Check semver compliance (push/PR version)
# Not guaranteed to run on nightly, so we use the separate job below
if: github.event_name != 'schedule'
uses: obi1kenobi/cargo-semver-checks-action@v2
with:
feature-group: default-features
features: ${{ matrix.features }}
rust-toolchain: manual
# Workaround for cargo-semver-checks not guaranteeing nightly support
scheduled-semver-checks:
if: github.event_name == 'schedule'
runs-on: ${{ matrix.os }}
strategy:
matrix:
os:
- ubuntu-latest
- windows-latest
features:
- '""'
- 'hwloc-2_0_4'
- 'hwloc-2_1_0'
- 'hwloc-2_2_0'
- 'hwloc-2_3_0'
- 'hwloc-2_4_0'
- 'hwloc-2_5_0'
- 'hwloc-2_8_0'
- 'hwloc-2_10_0'
# Remember to also update lints matrix
- 'hwloc-latest,vendored'
- 'hwloc-latest,proptest'
steps:
- name: Checkout sources
uses: actions/checkout@v4
- name: Set up stable toolchain
uses: actions-rust-lang/setup-rust-toolchain@v1
with:
components: rustfmt,clippy
- name: Set up hwloc
uses: ./.github/actions/setup-hwloc-dependencies
with:
hwloc-version: ${{ env.HWLOC_VERSION }}
hwloc-version-short: ${{ env.HWLOC_VERSION_SHORT }}
if: contains(matrix.features, 'vendored') == false
- name: Check semver compliance (scheduled version)
uses: obi1kenobi/cargo-semver-checks-action@v2
with:
feature-group: default-features
features: ${{ matrix.features }}
rust-toolchain: manual
# Run the tests and examples on all supported OSes and Rust versions (main CI)
#
# FIXME: In an ideal world, it would be enough to test on the first and last
# version of each major hwloc series, as within each series versions
# are additive and almost solely (*cough cough* add_distances *cough
# cough*) add new features to test without removing any.
#
# Unfortunately, `cargo check` does not currently check doctests
# (see https://github.com/rust-lang/cargo/issues/6424 ), so we need to
# test each version individually to make sure that doctests for a
# feature coming from one hwloc version do not use features from newer
# hwloc versions (which would force people to needlessly up their hwloc
# version requirements if they want to follow the doc examples).
test-contrib-debug:
# Don't run CI twice when a PR is created from a branch internal to the repo
# Don't run in scheduled jobs, that's what test-scheduled is for
if: github.event_name == 'push' || github.event.pull_request.head.repo.full_name != github.repository
runs-on: ${{ matrix.os }}
needs: matrix_vars
strategy:
matrix:
os:
- ubuntu-latest
- macos-latest
- windows-latest
rust:
- stable
- ${{ needs.matrix_vars.outputs.MINIMAL_RUST }}
features:
- '""'
- 'hwloc-2_0_4'
- 'hwloc-2_1_0'
- 'hwloc-2_2_0'
- 'hwloc-2_3_0'
- 'hwloc-2_4_0'
- 'hwloc-2_5_0'
- 'hwloc-2_8_0'
- 'hwloc-2_10_0'
- 'hwloc-latest,vendored'
- 'hwloc-latest,proptest'
env:
FEATURES_FLAG: '--features=${{ matrix.features }}'
steps:
- name: Checkout sources
uses: actions/checkout@v4
- name: Set up toolchain
uses: actions-rust-lang/setup-rust-toolchain@v1
with:
toolchain: ${{ matrix.rust }}
- name: Set up hwloc
uses: ./.github/actions/setup-hwloc-dependencies
with:
hwloc-version: ${{ env.HWLOC_VERSION }}
hwloc-version-short: ${{ env.HWLOC_VERSION_SHORT }}
if: contains(matrix.features, 'vendored') == false
- name: Set up hwloc build dependencies (macOS)
run: brew install automake libtool
if: contains(matrix.features, 'vendored') && startsWith(matrix.os, 'macos')
- name: Collect system information
uses: ./.github/actions/system-information
if: contains(matrix.features, 'vendored') == false
- name: Run tests
run: cargo test --workspace ${{ env.FEATURES_FLAG }}
- name: Install cargo-examples
uses: baptiste0928/cargo-install@v3
with:
crate: cargo-examples
- name: Run all examples
run: cargo examples ${{ env.FEATURES_FLAG }}
# Run the tests and examples on all supported OSes and Rust versions,
# in release mode
#
# Some things like UB or arithmetic overflow differ between debug and release
# builds, so it's a good idea to run the tests in release mode too.
#
# We do not do this in the test-contrib-debug job because switching between
# debug and release builds trashes the cargo cache.
#
# We restrict this to the latest supported hwloc release because the
# test-contrib-debug job is already testing for basic consistency, so our only
# goal here is to run as many tests as possible, and running on the latest
# hwloc release (for all supported compilers and OSes) gives us that.
test-contrib-release:
# Don't run CI twice when a PR is created from a branch internal to the repo
# Don't run in scheduled jobs, that's what test-scheduled is for
if: github.event_name == 'push' || github.event.pull_request.head.repo.full_name != github.repository
runs-on: ${{ matrix.os }}
needs: matrix_vars
strategy:
matrix:
os:
- ubuntu-latest
- macos-latest
- windows-latest
rust:
- stable
- ${{ needs.matrix_vars.outputs.MINIMAL_RUST }}
steps:
- name: Checkout sources
uses: actions/checkout@v4
- name: Set up toolchain
uses: actions-rust-lang/setup-rust-toolchain@v1
with:
toolchain: ${{ matrix.rust }}
- name: Set up hwloc
uses: ./.github/actions/setup-hwloc-dependencies
with:
hwloc-version: ${{ env.HWLOC_VERSION }}
hwloc-version-short: ${{ env.HWLOC_VERSION_SHORT }}
- name: Collect system information
uses: ./.github/actions/system-information
- name: Run unit and doc tests
run: cargo test --workspace --release --features=hwloc-latest
- name: Install cargo-examples
uses: baptiste0928/cargo-install@v3
with:
crate: cargo-examples
- name: Run all examples
run: cargo examples --features=hwloc-latest -- --release
# Run the tests with extra stdlib checks and the ASAN sanitizer
#
# Here, our goal is only code coverage. We noticeably don't need...
#
# - Full version coverage (there's test-contrib-debug for that)
# - Release build coverage (it shouldn't change stdlib usage or turn code with
# valid memory accesses into code with invalid ones)
# - Full OS coverage (we don't test what happens inside of hwloc, so as with
# lints, only testing OSes that have specific Rust code associated with them
# in the bindings is fine)
#
# Also, as a cargo-careful constraint we can only test nightly.
test-careful:
# Don't run CI twice when a PR is created from a branch internal to the repo
if: github.event_name == 'push' || github.event_name == 'schedule' || github.event.pull_request.head.repo.full_name != github.repository
runs-on: ${{ matrix.os }}
strategy:
matrix:
os:
- ubuntu-latest
- windows-latest
env:
JOB_FLAGS: '--workspace --features=hwloc-latest'
# cargo-careful uses the nightly compiler, but runs in the stable CI, so
# we must disable warnings-as-error to avoid breaking submitted PRs when
# a new lint gets added to nightly rustc
RUSTFLAGS: ''
steps:
- name: Checkout sources
uses: actions/checkout@v4
- name: Set up toolchain
uses: actions-rust-lang/setup-rust-toolchain@v1
with:
toolchain: nightly
components: rust-src
- name: Set up hwloc
uses: ./.github/actions/setup-hwloc-dependencies
with:
hwloc-version: ${{ env.HWLOC_VERSION }}
hwloc-version-short: ${{ env.HWLOC_VERSION_SHORT }}
- name: Collect system information
uses: ./.github/actions/system-information
- name: Install cargo-careful
uses: baptiste0928/cargo-install@v3
with:
crate: cargo-careful
- name: Run unit and doc tests under cargo careful, with ASAN (Unices)
run: |
# By default, cargo-careful disables LeakChecker, but I actually like it
export ASAN_OPTIONS=''
cargo careful test -Zcareful-sanitizer=address ${{ env.JOB_FLAGS }}
if: runner.os != 'Windows'
- name: Run unit and doc tests under cargo careful, w/o ASAN (Windows)
run: cargo careful test ${{ env.JOB_FLAGS }}
if: runner.os == 'Windows'
# Test current code coverage
#
# It is okay to measure coverage for the latest hwloc release only: it is the
# one with the most features to test, as no hwloc release has removed
# significant features so far. However, we must test both linux and windows as
# they each have os-specific code.
test-coverage:
# Don't run CI twice when a PR is created from a branch internal to the repo
# Don't run in scheduled jobs, coverage doesn't change on its own
if: github.event_name == 'push' || github.event.pull_request.head.repo.full_name != github.repository
runs-on: ${{ matrix.os }}
strategy:
matrix:
os:
- ubuntu-latest
- windows-latest
steps:
- name: Checkout sources
uses: actions/checkout@v4
- name: Set up toolchain
uses: actions-rust-lang/setup-rust-toolchain@v1
with:
toolchain: stable
- name: Set up hwloc
uses: ./.github/actions/setup-hwloc-dependencies
with:
hwloc-version: ${{ env.HWLOC_VERSION }}
hwloc-version-short: ${{ env.HWLOC_VERSION_SHORT }}
- name: Collect system information
uses: ./.github/actions/system-information
- name: Install cargo-tarpaulin
uses: baptiste0928/cargo-install@v3
with:
crate: cargo-tarpaulin
- name: Measure code coverage
run: cargo tarpaulin --verbose --timeout 120 --out xml
- name: Upload to codecov.io
uses: codecov/codecov-action@v4
with:
token: ${{ secrets.CODECOV_TOKEN }}
env_vars: OS
flags: ${{ matrix.os }}
fail_ci_if_error: true
verbose: true
# Check compatibility with newer Rust/deps versions (scheduled CI)
#
# We aren't concerned about trashing the cargo cache here since these jobs
# only run occasionally, so the extra convenience and maintainability of
# grouping debug and release tests trumps other considerations.
#
# FIXME: There should be a way to use conditional build matrices without
# duplicating the whole job recipe...
#
test-scheduled:
if: github.event_name == 'schedule'
runs-on: ${{ matrix.os }}
needs: matrix_vars
strategy:
matrix:
os:
- ubuntu-latest
- macos-latest
- windows-latest
rust:
- beta
- nightly
- ${{ needs.matrix_vars.outputs.MINIMAL_RUST }}
features:
- '""'
- 'hwloc-2_0_4'
- 'hwloc-2_1_0'
- 'hwloc-2_2_0'
- 'hwloc-2_3_0'
- 'hwloc-2_4_0'
- 'hwloc-2_5_0'
- 'hwloc-2_8_0'
- 'hwloc-2_10_0'
- 'hwloc-latest,vendored'
- 'hwloc-latest,proptest'
env:
FEATURES_FLAG: '--features=${{ matrix.features }}'
steps:
- name: Checkout sources
uses: actions/checkout@v4
- name: Set up toolchain
uses: actions-rust-lang/setup-rust-toolchain@v1
with:
toolchain: ${{ matrix.rust }}
- name: Set up hwloc
uses: ./.github/actions/setup-hwloc-dependencies
with:
hwloc-version: ${{ env.HWLOC_VERSION }}
hwloc-version-short: ${{ env.HWLOC_VERSION_SHORT }}
if: contains(matrix.features, 'vendored') == false
- name: Set up hwloc build dependencies (macOS)
run: brew install automake libtool
if: contains(matrix.features, 'vendored') && startsWith(matrix.os, 'macos')
- name: Collect system information
uses: ./.github/actions/system-information
if: contains(matrix.features, 'vendored') == false
- name: Install cargo-examples
uses: baptiste0928/cargo-install@v3
with:
crate: cargo-examples
- name: Run basic tests (debug build)
run: cargo test --workspace ${{ env.FEATURES_FLAG }}
- name: Run all examples (debug build)
run: cargo examples ${{ env.FEATURES_FLAG }}
- name: Run all examples (release build)
run: cargo examples ${{ env.FEATURES_FLAG }} -- --release
- name: Run basic tests (release build)
run: cargo test --workspace --release ${{ env.FEATURES_FLAG }}