|
1 | 1 | name: CI |
2 | 2 |
|
| 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 | + |
3 | 20 | on: |
4 | 21 | push: |
5 | 22 | branches: [main] |
|
11 | 28 |
|
12 | 29 | jobs: |
13 | 30 | test: |
| 31 | + name: test |
14 | 32 | runs-on: ubuntu-latest |
15 | 33 | steps: |
16 | 34 | - uses: actions/checkout@v4 |
17 | 35 |
|
18 | 36 | - name: Install Rust |
19 | 37 | 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') }} |
31 | 38 |
|
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 |
34 | 48 |
|
35 | 49 | - name: Test |
36 | 50 | run: cargo test --verbose |
37 | 51 |
|
| 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 | + |
38 | 110 | - name: Install cargo-llvm-cov |
39 | 111 | uses: taiki-e/install-action@cargo-llvm-cov |
40 | 112 |
|
|
0 commit comments