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
name: CI
on:
push:
branches:
pull_request:
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: ${{ github.event_name == 'pull_request' }}
env:
CARGO_TERM_COLOR: always
CARGO_INCREMENTAL: 0
RUST_BACKTRACE: 1
jobs:
fmt:
name: rustfmt
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v7
- uses: dtolnay/rust-toolchain@stable
with:
components: rustfmt
- run: cargo fmt --all --check
clippy:
name: clippy
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v7
- uses: dtolnay/rust-toolchain@stable
with:
components: clippy
- uses: Swatinem/rust-cache@v2
- run: cargo clippy --locked --all-features --all-targets -- -D warnings
test:
name: test (${{ matrix.toolchain }})
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
# Stable plus the MSRV declared in Cargo.toml.
toolchain:
steps:
- uses: actions/checkout@v7
- uses: dtolnay/rust-toolchain@master
with:
toolchain: ${{ matrix.toolchain }}
- uses: Swatinem/rust-cache@v2
# --locked throughout: Cargo.lock is committed so that the MSRV job
# tests a resolution that is known to build on 1.90. Without it a
# dependency raising its own MSRV turns this job red for reasons
# unrelated to the change under test.
- run: cargo test --locked --all-features --all-targets
# Doctests are not covered by --all-targets.
- run: cargo test --locked --all-features --doc
# The committed lockfile pins one resolution; this proves the declared
# version requirements still work when dependencies float, so the lock
# is never quietly load-bearing.
test-unlocked:
name: test (updated dependencies)
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v7
- uses: dtolnay/rust-toolchain@stable
- uses: Swatinem/rust-cache@v2
- run: cargo update
- run: cargo test --all-features --all-targets
test-non-utc:
name: test (non-UTC timezone)
runs-on: ubuntu-latest
env:
# The library has no clock and no timezone handling, so results
# must be identical in any environment timezone. Keep it honest
# with a timezone that is ahead of UTC and observes DST.
TZ: Pacific/Auckland
steps:
- uses: actions/checkout@v7
- uses: dtolnay/rust-toolchain@stable
- uses: Swatinem/rust-cache@v2
- run: cargo test --locked --all-features --all-targets
no-std:
name: no_std build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v7
- uses: dtolnay/rust-toolchain@stable
with:
targets: thumbv7em-none-eabihf
- uses: Swatinem/rust-cache@v2
# A bare-metal target has no std at all, so this proves the
# #![no_std] claim for both feature sets.
- run: cargo check --locked --target thumbv7em-none-eabihf --no-default-features
- run: cargo check --locked --target thumbv7em-none-eabihf --all-features
doc:
name: doc
runs-on: ubuntu-latest
env:
RUSTDOCFLAGS: -D warnings
steps:
- uses: actions/checkout@v7
- uses: dtolnay/rust-toolchain@stable
- uses: Swatinem/rust-cache@v2
- run: cargo doc --locked --all-features --no-deps
deny:
name: cargo-deny
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v7
- uses: taiki-e/install-action@cargo-deny
- run: cargo deny check
# Proves the crate is publishable from a clean checkout: that the
# packaged file list compiles on its own, and that LICENSE-APACHE,
# LICENSE-MIT and THIRD-PARTY-NOTICES are actually inside the .crate
# rather than only in the repository.
package:
name: package
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v7
- uses: dtolnay/rust-toolchain@stable
- uses: Swatinem/rust-cache@v2
- run: cargo package --locked
- name: License and notice files are in the package
run: |
set -euo pipefail
list=$(cargo package --locked --list)
for f in LICENSE-APACHE LICENSE-MIT THIRD-PARTY-NOTICES; do
echo "$list" | grep -qx "$f" || { echo "::error::$f missing from packaged crate"; exit 1; }
done