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
name: CI
on:
push:
branches:
pull_request:
branches:
env:
CARGO_TERM_COLOR: always
RUSTFLAGS: "-D warnings"
# Run every JS action on Node.js 24 ahead of GitHub's forced migration,
# silencing "Node.js 20 actions are deprecated" runner warnings.
FORCE_JAVASCRIPT_ACTIONS_TO_NODE24: "true"
jobs:
test:
name: Test (${{ matrix.os }} / ${{ matrix.rust }})
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
# x86_64 and aarch64 on every OS: macos-latest is aarch64 only, so
# macos-15-intel covers x86_64 macOS (dev/PLAN.md, D-009).
os:
- ubuntu-latest
- ubuntu-24.04-arm
- macos-latest
- macos-15-intel
- windows-latest
- windows-11-arm
rust:
steps:
- uses: actions/checkout@v5
- uses: dtolnay/rust-toolchain@master
with:
toolchain: ${{ matrix.rust }}
components: clippy, rustfmt
- uses: Swatinem/rust-cache@v2
- name: Format
run: cargo fmt --all -- --check
- name: Clippy (default features)
run: cargo clippy --all-targets -- -D warnings
- name: Clippy (all features)
run: cargo clippy --all-targets --all-features -- -D warnings
- name: Clippy (no default features)
run: cargo clippy --all-targets --no-default-features -- -D warnings
- name: Test (default features)
run: cargo test
- name: Test (all features)
run: cargo test --all-features
- name: Test (no default features)
run: cargo test --no-default-features
# A crash in a test thread loses its output: one at a time, uncaptured,
# the log names the test that stopped the run.
- name: Name the crashing test
if: failure()
run: cargo test --lib --all-features -- --test-threads=1 --nocapture
# A trap inside CoreFoundation or IOKit prints nothing: lldb prints where.
- name: Backtrace of the crash (macOS)
if: failure() && runner.os == 'macOS'
run: |
exe=$(cargo test --lib --all-features --no-run --message-format=json | jq -r 'select(.profile.test == true and .target.kind[0] == "lib") | .executable' | head -1)
lldb --batch -o run -k "thread backtrace" -k quit -- "$exe" --test-threads=1 --nocapture
- name: Build examples
run: cargo build --examples
# Both modes: a doc link to a feature-gated item breaks only when that
# feature is off (dev/PLAN.md, D-010).
- name: Doc (default features)
run: cargo doc --no-deps
env:
RUSTDOCFLAGS: "-D warnings"
- name: Doc (all features)
run: cargo doc --no-deps --all-features
env:
RUSTDOCFLAGS: "-D warnings"
cross:
name: Check (${{ matrix.target }} / ${{ matrix.rust }})
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
target:
- x86_64-unknown-linux-musl
- i686-pc-windows-msvc
- aarch64-linux-android
- aarch64-apple-ios
rust:
env:
# blake3 (feature device-id) would build C and assembly for the target,
# and these jobs have no compiler for it. Its Rust code checks the same.
CARGO_FEATURE_PURE: "1"
steps:
- uses: actions/checkout@v5
- uses: dtolnay/rust-toolchain@master
with:
toolchain: ${{ matrix.rust }}
targets: ${{ matrix.target }}
components: clippy
- uses: Swatinem/rust-cache@v2
with:
key: ${{ matrix.target }}
- name: Check (default features)
run: cargo check --target ${{ matrix.target }}
- name: Check (all features)
run: cargo check --target ${{ matrix.target }} --all-features
- name: Check (no default features)
run: cargo check --target ${{ matrix.target }} --no-default-features
# --all-targets compiles the unit tests too, and with them the layout
# oracles in src/sys/<platform>/ffi.rs (dev/PLAN.md, D-012): every OS
# struct is checked against libc or windows-sys for this target.
- name: Clippy and layout oracles (all features)
run: cargo clippy --target ${{ matrix.target }} --all-targets --all-features -- -D warnings
- name: Clippy and layout oracles (no default features)
run: cargo clippy --target ${{ matrix.target }} --all-targets --no-default-features -- -D warnings
container:
name: Container limits (cgroup v2)
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@v5
- uses: dtolnay/rust-toolchain@stable
- uses: Swatinem/rust-cache@v2
# Built on the runner, run inside a container with real limits: the test
# asserts sys-lib reports the container's memory and CPUs, not the host's.
- name: Build the container test
id: build
shell: bash
run: |
set -euo pipefail
exe=$(cargo test --test container --no-run --message-format=json \
| jq -r 'select(.executable != null and .target.name == "container") | .executable')
echo "exe=$exe" >> "$GITHUB_OUTPUT"
- name: Run it under --memory=256m --cpus=1.5 --cpuset-cpus=0-1
shell: bash
run: |
docker run --rm --memory=256m --cpus=1.5 --cpuset-cpus=0-1 \
-e SYS_LIB_EXPECT_MEMORY=268435456 -e SYS_LIB_EXPECT_CPUS=2 \
-v "${{ steps.build.outputs.exe }}:/test:ro" ubuntu:24.04 /test --nocapture
miri:
name: Miri (parsers and units)
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v5
- uses: dtolnay/rust-toolchain@nightly
with:
components: miri
- uses: Swatinem/rust-cache@v2
# Every parser runs over OS data; Miri checks them for undefined behaviour
# on every push (dev/PLAN.md section 19.1). Isolation is off only so
# proptest can look for its regression files; the code under test does
# no I/O.
- name: Miri
run: "cargo miri test --lib -- parse:: units:: fmt::"
env:
MIRIFLAGS: "-Zmiri-disable-isolation"
PROPTEST_CASES: "16"
# A DLL in the import table that a stripped-down Windows lacks stops the whole
# program before `main`, so a real binary runs where the fewest DLLs exist.
nanoserver:
name: Nano Server
runs-on: windows-2022
steps:
- uses: actions/checkout@v5
- uses: dtolnay/rust-toolchain@stable
- name: Build a static binary
env:
RUSTFLAGS: -Ctarget-feature=+crt-static
run: cargo build --example summary --features device-id
- name: Run it on Nano Server
shell: bash
run: |
mkdir nano && cp target/debug/examples/summary.exe nano/
docker run --rm -v "$(cygpath -w "$PWD/nano"):C:\\app" mcr.microsoft.com/windows/nanoserver:ltsc2022 'C:\app\summary.exe'
fuzz-smoke:
name: Fuzz (smoke, 20 s per target)
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v5
- uses: dtolnay/rust-toolchain@nightly
- uses: Swatinem/rust-cache@v2
with:
workspaces: fuzz
- name: Install cargo-fuzz
uses: taiki-e/install-action@v2
with:
tool: cargo-fuzz
# install-action's cargo-fuzz is a musl build, and cargo-fuzz defaults to
# its own target, where AddressSanitizer cannot run: name the target.
- name: Run every target
shell: bash
run: |
set -euo pipefail
for target in $(cargo fuzz list); do
mkdir -p "$RUNNER_TEMP/corpus/$target"
cargo fuzz run --target x86_64-unknown-linux-gnu "$target" "$RUNNER_TEMP/corpus/$target" tests/fixtures -- -max_total_time=20
done
no-subprocess:
name: No subprocess at run time
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v5
- name: Only the build helper may start a program
shell: bash
run: |
set -euo pipefail
# 1. std::process::Command anywhere in src/ outside the build helper
# (src/build.rs, src/build/).
std_hits=$(grep -rnE 'Command::new|process::Command|process::\{[^}]*\bCommand\b' src --include='*.rs' \
| grep -vE '^src/build(\.rs|/)' || true)
# 2. Process-creation calls declared or called in the OS modules.
# Names followed by `(` (a declaration or a call), bare or through
# `ffi::` or `libc::`, so a method such as `Root::system()` does not
# match; comment lines are skipped so prose such as "a system call"
# does not either.
ffi_hits=$(grep -rnE '\b(CreateProcess(A|W|AsUserW)?|ShellExecute(Ex)?W|WinExec)\b|(^|[^:[:alnum:]_]|ffi::|libc::)(posix_spawnp?|execv[pe]?|execl[pe]?|popen|v?fork|system)[[:space:]]*\(' src/sys --include='*.rs' 2>/dev/null \
| grep -vE '^[^:]+:[0-9]+:[[:space:]]*//' || true)
if [ -n "$std_hits$ffi_hits" ]; then
echo "sys-lib never runs a program at run time (dev/PLAN.md, D-004)."
echo "$std_hits"
echo "$ffi_hits"
exit 1
fi
echo "No subprocess found outside the build helper."
package:
name: Package
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v5
- uses: dtolnay/rust-toolchain@stable
- uses: Swatinem/rust-cache@v2
- name: Package
run: cargo package
security:
name: Security (audit + deny)
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v5
- uses: dtolnay/rust-toolchain@stable
- uses: Swatinem/rust-cache@v2
- name: Install cargo-audit and cargo-deny
uses: taiki-e/install-action@v2
with:
tool: cargo-audit,cargo-deny
- name: Generate lockfile
run: cargo generate-lockfile
- name: Audit
run: cargo audit
- name: Deny
run: cargo deny check