Skip to content

Commit 883be41

Browse files
authored
Documentation: cover every module, map what lives where, and halve CI wall time (#5)
Five commits, 96 files, no library behaviour changes — every src/ edit is a doc comment. - CI split into parallel `test` and `Coverage` jobs; `test` 14m52s -> 6m46s, whole run ~15-19min -> 11m07s - Replaced a cache that never saved with Swatinem/rust-cache@v2 - 81 rustdoc warnings -> 0, and CI now builds docs under -D warnings - 63 modules had no //! summary, including lib.rs; all 296 source files now documented - docs/GUIDE.md: seven chapters, every code block a real example file run by CI - docs/MODULE_MAP.md: generated tree and per-module tables for all 295 modules - README rewritten against measured numbers, with the governing equations per domain - Six new CI gates, including two that nothing else catches
2 parents f221d18 + 9194eeb commit 883be41

96 files changed

Lines changed: 4022 additions & 191 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎.github/workflows/ci.yml‎

Lines changed: 85 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,22 @@
11
name: CI
22

3+
# Build, test and coverage. The deeper checks -- property tests, Kani,
4+
# Miri and the strict lint pass -- are in verify.yml.
5+
#
6+
# `test` and `coverage` are separate jobs on purpose. `cargo llvm-cov` is
7+
# not a reporting step that reads what `cargo test` already produced:
8+
# there is nothing to read. It compiles the crate with
9+
# `-C instrument-coverage` into its own target directory, runs the whole
10+
# suite again to emit .profraw files, and merges those into the summary.
11+
# Running the tests IS how it collects coverage.
12+
#
13+
# So the two do the same work twice no matter what, and the only question
14+
# is whether they do it in series or in parallel. As consecutive steps in
15+
# one job the wall time was their sum -- fifteen to nineteen minutes. As
16+
# separate jobs it is the slower of the two, and the plain `cargo test`
17+
# result comes back in a third of that instead of waiting behind the
18+
# instrumented rebuild.
19+
320
on:
421
push:
522
branches: [main]
@@ -11,30 +28,85 @@ env:
1128

1229
jobs:
1330
test:
31+
name: test
1432
runs-on: ubuntu-latest
1533
steps:
1634
- uses: actions/checkout@v4
1735

1836
- name: Install Rust
1937
uses: dtolnay/rust-toolchain@stable
20-
with:
21-
components: llvm-tools-preview
22-
23-
- name: Cache cargo
24-
uses: actions/cache@v4
25-
with:
26-
path: |
27-
~/.cargo/registry
28-
~/.cargo/git
29-
target
30-
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
3138

32-
- name: Build
33-
run: cargo build --verbose
39+
# Swatinem/rust-cache rather than a hand-rolled actions/cache, which
40+
# is what this job used to do and which cached nothing. The crate has
41+
# no dependencies -- Cargo.lock holds exactly one package, itself --
42+
# so ~/.cargo/registry and ~/.cargo/git are empty, and a key of
43+
# hashFiles('**/Cargo.lock') never changes, so after the first save
44+
# the cache was restored stale on every run and never written again.
45+
# This one keys on the compiler version and the job as well, and
46+
# saves each run.
47+
- uses: Swatinem/rust-cache@v2
3448

3549
- name: Test
3650
run: cargo test --verbose
3751

52+
# The README's Quick start section IS this example, so running it here
53+
# is what stops the front page of the repository from drifting out of
54+
# date. Its assertions are the check; the printed values are for a
55+
# human reading the log.
56+
- name: Check the README example
57+
run: cargo run --example readme_quickstart
58+
59+
# docs/GUIDE.md is written around these four files and quotes their
60+
# real output, so running them is what keeps the guide honest. Each
61+
# one asserts its own results; the printing is for a human reading
62+
# the log.
63+
- name: Check the guide examples
64+
run: |
65+
cargo run --example guide_02_orbit
66+
cargo run --example guide_03_signal
67+
cargo run --example guide_04_fem
68+
cargo run --example guide_05_correctness
69+
70+
# Rustdoc warnings are rendering bugs, not style. `[k]` in a formula
71+
# becomes a broken intra-doc link and `<counts>` becomes an unclosed
72+
# HTML tag that swallows the rest of the line, so the published docs
73+
# show something other than what the comment says. There were 81 of
74+
# these; denying them keeps the count at zero.
75+
- name: Documentation
76+
run: cargo doc --no-deps
77+
env:
78+
RUSTDOCFLAGS: "-D warnings"
79+
80+
# docs/MODULE_MAP.md is generated from the source tree, so it can go
81+
# stale the moment a module is added, renamed or resized. This
82+
# re-derives it and fails if the committed copy differs, which is the
83+
# only thing that keeps a generated file honest.
84+
- name: Module map is current
85+
run: python3 tools/gen_module_map.py --check
86+
87+
# Every module carries a //! summary, and the map is built from those
88+
# first sentences -- a module without one would appear in the map as a
89+
# blank row.
90+
- name: Every module is documented
91+
run: python3 tools/check_module_docs.py
92+
93+
coverage:
94+
name: Coverage
95+
runs-on: ubuntu-latest
96+
steps:
97+
- uses: actions/checkout@v4
98+
99+
- name: Install Rust
100+
uses: dtolnay/rust-toolchain@stable
101+
with:
102+
components: llvm-tools-preview
103+
104+
# A separate cache key from the `test` job, which is the point of
105+
# keying on the job: these artifacts are built with
106+
# -C instrument-coverage and cargo fingerprints them separately, so
107+
# sharing one cache between the two would thrash it.
108+
- uses: Swatinem/rust-cache@v2
109+
38110
- name: Install cargo-llvm-cov
39111
uses: taiki-e/install-action@cargo-llvm-cov
40112

‎.github/workflows/verify.yml‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,11 +91,11 @@ jobs:
9191
# core::, the interval and dual-number arithmetic where index and slice
9292
# reasoning is densest, rather than to the whole suite.
9393
#
94-
# Five tests in there carry #[cfg_attr(miri, ignore)]. Miri evaluates
94+
# Six tests in there carry #[cfg_attr(miri, ignore)]. Miri evaluates
9595
# sin, exp and powi with its own implementations rather than the host's,
9696
# and deliberately randomises the result within the slack the language
9797
# allows, so a test asserting an exact float value fails under Miri
98-
# whatever the code does. Those five are exactness assertions and are
98+
# whatever the code does. Those six are exactness assertions and are
9999
# skipped here; they run everywhere else.
100100
#
101101
# A libtest filter is a substring match, not a path prefix, so a bare

0 commit comments

Comments
 (0)