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
name: CI
on:
push:
branches:
pull_request:
branches:
workflow_dispatch:
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
env:
CARGO_TERM_COLOR: always
RUST_BACKTRACE: 1
# `rust-toolchain.toml` pins the MSRV. RUSTUP_TOOLCHAIN takes precedence over
# that file, so each job below selects its own toolchain explicitly.
RUSTUP_TOOLCHAIN: stable
jobs:
fmt:
name: ๐จ rustfmt
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
with:
components: rustfmt
- run: cargo fmt --all -- --check
clippy:
name: ๐ clippy
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
with:
components: clippy
- uses: Swatinem/rust-cache@v2
- name: clippy (default features)
run: cargo clippy --all-targets -- -D warnings
- name: clippy (all features)
run: cargo clippy --all-targets --all-features -- -D warnings
purity:
name: ๐ง purity
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
# The crate guarantees equal inputs give equal outputs: no clock read, no
# I/O, no unsafe outside comments. Cheap to check, easy to regress.
- name: no ambient state in src/
run: |
hits="$(grep -rn --include='*.rs' -E \
'now_utc|SystemTime::now|Instant::now|std::(fs|env|net|process)|\bunsafe\b' \
src/ | grep -vE ':[[:space:]]*(///|//!|//)' || true)"
if [ -n "$hits" ]; then
echo "::error::ambient state or unsafe reached the source"
echo "$hits"
exit 1
fi
echo "pure: no clock, no I/O, no unsafe"
test:
name: ๐งช test (${{ matrix.os }})
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os:
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
- uses: Swatinem/rust-cache@v2
- name: test (default features)
run: cargo test --all-targets
- name: test (all features)
run: cargo test --all-features --all-targets
- name: doctests (all features)
run: cargo test --all-features --doc
# The example asserts its own invariants, so running it is a test.
- name: examples
run: cargo run --all-features --example pipeline
features:
name: ๐๏ธ feature matrix
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
- uses: Swatinem/rust-cache@v2
- name: build (no default features)
run: cargo build --no-default-features
- name: build (serde)
run: cargo build --no-default-features --features serde
msrv:
name: ๐ฆ MSRV 1.94
runs-on: ubuntu-latest
env:
RUSTUP_TOOLCHAIN: "1.94"
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@master
with:
toolchain: "1.94"
- uses: Swatinem/rust-cache@v2
# Keep in sync with `rust-version` in Cargo.toml and `rust-toolchain.toml`.
- run: cargo check --all-features --all-targets
docs:
name: ๐ rustdoc
runs-on: ubuntu-latest
env:
RUSTDOCFLAGS: -D warnings
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
- uses: Swatinem/rust-cache@v2
- run: cargo doc --no-deps --all-features
package:
name: ๐ฆ package
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
- uses: Swatinem/rust-cache@v2
# Catches missing files / bad metadata before a release tag is cut.
- run: cargo publish --dry-run --all-features
audit:
name: ๐ก๏ธ audit
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
- uses: Swatinem/rust-cache@v2
- uses: taiki-e/install-action@cargo-audit
# Run cargo-audit directly rather than via rustsec/audit-check: that action
# reports through the Checks API, which needs `checks: write` and is
# read-only for pull requests from forks, so it fails the job on the
# permission rather than on any finding. The exit code is the signal.
- run: cargo audit --deny warnings