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
name: CI
on:
push:
branches:
pull_request:
env:
CARGO_TERM_COLOR: always
# Every feature except `permissions`, which is Unix-only (§9.6) — its
# `nix` dependency doesn't exist for non-Unix targets.
WINDOWS_FEATURES: operations,analyze,checksum,watch,compress,sync,diagnostics
# `fmt` and `clippy` are pinned rather than tracking `stable`, because
# both gate on tool *output* that legitimately changes between Rust
# releases: clippy adds lints and rustfmt adjusts its layout rules, so
# a floating toolchain turns every release into a spontaneously red CI
# run on code nobody touched (which is exactly how this pin came to be
# — a batch of style lints landed on an untouched crate). `test` and
# `feature-matrix` deliberately stay on `stable`: they gate on the code
# compiling and behaving, which is precisely what should be re-checked
# against each new release. Bump this deliberately, in its own commit.
LINT_TOOLCHAIN: "1.96"
jobs:
fmt:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@master
with:
toolchain: ${{ env.LINT_TOOLCHAIN }}
components: rustfmt
- run: cargo fmt --all -- --check
clippy:
strategy:
fail-fast: false
matrix:
os:
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@master
with:
toolchain: ${{ env.LINT_TOOLCHAIN }}
components: clippy
- name: clippy (all features valid for this OS)
shell: bash
run: |
if [ "${{ runner.os }}" = "Windows" ]; then
cargo clippy --no-default-features --features "$WINDOWS_FEATURES" --all-targets -- -D warnings
else
cargo clippy --all-features --all-targets -- -D warnings
fi
test:
strategy:
fail-fast: false
matrix:
os:
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
- name: test (default features)
run: cargo test
- name: test (all features valid for this OS)
shell: bash
run: |
if [ "${{ runner.os }}" = "Windows" ]; then
cargo test --no-default-features --features "$WINDOWS_FEATURES"
else
cargo test --all-features
fi
# Every single feature and every pair (`cargo hack --feature-powerset
# --depth 2`) — catches a bad `#[cfg(feature = ...)]` in an untested
# combination without paying for the full 2^8 powerset. Runs on Ubuntu
# only: it's a compile-correctness sweep across feature *combinations*,
# not a cross-platform check (that's `test`'s job) — `permissions` is
# exercised here since Ubuntu is Unix.
feature-matrix:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
- uses: taiki-e/install-action@cargo-hack
- run: cargo hack check --feature-powerset --depth 2 --no-dev-deps
# Pinned to the floor declared in Cargo.toml's `rust-version` (§9.4).
# Catches the case where a `cargo update` bumps a transitive dependency's
# own MSRV past what we declare, without anyone touching this crate's
# Cargo.toml.
msrv:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@1.88
- run: cargo check --all-features