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
name: CI
on:
push:
branches:
# The benchmark job commits `benchmark.md` back; do not re-run the whole
# CI matrix for that commit.
paths-ignore:
- benchmark.md
pull_request:
env:
CARGO_TERM_COLOR: always
RUST_BACKTRACE: 1
permissions:
contents: read
jobs:
fmt:
name: Formatting
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4
- uses: dtolnay/rust-toolchain@4360b52568e2003a75bf9bc1d59f33a8e3fc893c # stable
with:
components: rustfmt
- name: Check formatting
run: cargo fmt --all -- --check
clippy:
name: Clippy (all features)
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4
- uses: dtolnay/rust-toolchain@4360b52568e2003a75bf9bc1d59f33a8e3fc893c # stable
with:
components: clippy
- uses: Swatinem/rust-cache@49a0bdc70d2e1b713ca9e2869b211fcce03d3c1c # v2
- name: Lint (warnings are errors)
run: cargo clippy --all-features --all-targets -- -D warnings
test:
name: Test (debug + release)
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4
- uses: dtolnay/rust-toolchain@4360b52568e2003a75bf9bc1d59f33a8e3fc893c # stable
- uses: Swatinem/rust-cache@49a0bdc70d2e1b713ca9e2869b211fcce03d3c1c # v2
- name: Test (debug)
run: cargo test --all-features
# Release mode runs without overflow checks; both modes must agree.
- name: Test (release)
run: cargo test --all-features --release
msrv:
name: Test (MSRV 1.81)
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4
- uses: dtolnay/rust-toolchain@a26bf97da1fe9e2cac5e215a0ff5761b0f27bd91 # 1.81.0
- uses: Swatinem/rust-cache@49a0bdc70d2e1b713ca9e2869b211fcce03d3c1c # v2
- name: Test at the declared MSRV
run: cargo test --all-features
features:
name: Feature matrix
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
features:
# `--no-default-features` is the allocator-free build: parsing,
# arithmetic, Display/FromStr and the write_* buffer APIs only.
- --no-default-features
- --no-default-features --features alloc
- --no-default-features --features std
- --no-default-features --features serde
- --no-default-features --features binary
steps:
- uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4
- uses: dtolnay/rust-toolchain@4360b52568e2003a75bf9bc1d59f33a8e3fc893c # stable
- uses: Swatinem/rust-cache@49a0bdc70d2e1b713ca9e2869b211fcce03d3c1c # v2
- name: Check every target with ${{ matrix.features }}
run: cargo check --all-targets ${{ matrix.features }}
- name: Unit tests with ${{ matrix.features }}
run: cargo test --lib ${{ matrix.features }}
doc:
name: Documentation
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4
- uses: dtolnay/rust-toolchain@4360b52568e2003a75bf9bc1d59f33a8e3fc893c # stable
- uses: Swatinem/rust-cache@49a0bdc70d2e1b713ca9e2869b211fcce03d3c1c # v2
- name: Build docs (warnings are errors)
run: cargo doc --all-features --no-deps
env:
RUSTDOCFLAGS: -D warnings
# docs.rs builds on nightly with `--cfg docsrs`; that combination can break
# in ways stable cannot see (removed `#![feature(...)]`, unstable API drift),
# so mirror it here instead of discovering it after a release.
docsrs:
name: Docs (docs.rs condition)
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4
- uses: dtolnay/rust-toolchain@7c8d7d138f5c09cef361f8214cf96882cd029cdb # nightly
- uses: Swatinem/rust-cache@49a0bdc70d2e1b713ca9e2869b211fcce03d3c1c # v2
- name: Build docs exactly like docs.rs
run: cargo doc --all-features --no-deps
env:
RUSTDOCFLAGS: --cfg docsrs
audit:
name: Security audit
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4
- uses: dtolnay/rust-toolchain@4360b52568e2003a75bf9bc1d59f33a8e3fc893c # stable
# `rustsec/audit-check` needs a Cargo.lock; generate one if the repo
# does not track it.
- name: Ensure a lockfile exists
run: cargo generate-lockfile
- name: Check dependencies against the RustSec advisory database
uses: rustsec/audit-check@69366f33c96575abad1ee0dba8212993eecbe998 # v2
with:
token: ${{ secrets.GITHUB_TOKEN }}