Repository navigation
215 lines (196 loc) · 10.3 KB
/
Copy pathci.yml
File metadata and controls
215 lines (196 loc) · 10.3 KB
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
name: CI
on:
push:
branches: [main]
pull_request:
env:
CARGO_TERM_COLOR: always
# A failing build should say why once, not scroll.
RUST_BACKTRACE: 1
concurrency:
group: ci-${{ github.ref }}
cancel-in-progress: true
jobs:
check:
name: Format, lints and tests
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
with:
components: rustfmt, clippy
- uses: Swatinem/rust-cache@v2
# `#[derive(RustEmbed)]` fails the whole crate's build if `web-panel/dist/` doesn't exist at
# all — `build.rs` covers that case with an empty fallback directory, but an empty panel is
# not what should ship or what the panel's own integration test expects to find. Build it
# for real before Rust ever touches it.
- uses: oven-sh/setup-bun@v2
with:
bun-version: latest
- name: Build the web panel frontend
working-directory: crates/terrustia/web-panel
run: |
bun install --frozen-lockfile
bun run build
# `update.rs`'s own tests shell out to a real `cosign` binary to sign and verify a fixture
# release end to end — the same verifier `terrustia update` and the boot-time check run in
# production, just with a locally generated key instead of a live OIDC token (see that
# module's own doc comment for why keyless signing itself cannot be minted in a test). Tests
# that need it skip themselves when it is missing rather than failing the build, but this
# makes "present" the real answer here, the same way `release.yml`/`docker.yml` already
# install it to *use* cosign rather than merely test around its absence.
- uses: sigstore/cosign-installer@v3
- name: Formatting
run: cargo fmt --all --check
# `[workspace.lints]` already denies warnings, so this needs no `-D` of its own.
- name: Lints
run: cargo clippy --workspace --all-targets
# `embed-web` is default-on (`crates/terrustia/Cargo.toml`), so the step above never compiles
# the panel's disk-serving static-asset branch: `panel/mod.rs::load_static_asset`'s
# `#[cfg(not(feature = "embed-web"))]` arm, the one with the `..` traversal guard against a
# request path escaping `web-panel/dist`. Unbuilt code is unchecked code, guard included; this
# step is what actually compiles and lints it. No frontend build needed first: unlike the
# `embed-web` arm, this one reads `web-panel/dist` from disk at runtime rather than embedding
# it via `rust_embed::RustEmbed` at compile time, so there is nothing here for a missing
# `dist/` to fail on the way the step above needs `bun run build` to have already run.
- name: Lints (embed-web off, exercises the disk-serving panel branch)
run: cargo clippy -p terrustia --all-targets --no-default-features
- name: Tests
run: cargo test --workspace
# Every release target, on every push. This project was developed entirely on macOS and had a
# Windows compile error sitting in it for months — `clock_gettime` does not exist there — which
# nothing would have caught until somebody tried to build a release.
targets:
name: ${{ matrix.target }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
include:
# `host: true` means the runner's own architecture *is* this target, so the test suite can
# actually execute rather than only compile. Everything else here is a cross-compile and
# stays compile-only, which is all a cross-check can honestly claim. Until this existed,
# `cargo test` had never run on Windows or macOS at all, while `release.yml` shipped real
# binaries for both: every test this project has ever passed, it passed on Linux.
- { target: x86_64-unknown-linux-musl, os: ubuntu-latest }
- { target: aarch64-unknown-linux-musl, os: ubuntu-latest }
- { target: x86_64-apple-darwin, os: macos-latest }
- { target: aarch64-apple-darwin, os: macos-latest, host: true }
- { target: x86_64-pc-windows-msvc, os: windows-latest, host: true }
# Windows ARM64 checks on GitHub's native arm64 runner, so this is a real host-native
# compile rather than a cross-check. It is an official release target.
- { target: aarch64-pc-windows-msvc, os: windows-11-arm, host: true }
# riscv64 is compile-only by decision: it must keep building, but it is not a release
# or qualification target yet.
- { target: riscv64gc-unknown-linux-gnu, os: ubuntu-latest }
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
with:
targets: ${{ matrix.target }}
- uses: Swatinem/rust-cache@v2
with:
key: ${{ matrix.target }}
# `ring` (pulled in transitively through `rustls`, via `ureq`'s HTTPS client for the update
# checker) runs real C compiler-family detection in its build script — a linker alone is not
# enough for it, unlike everything else in this dependency graph. This installs an actual
# C cross-toolchain (and points CC/AR/the linker at it) for the cross-compiled targets: both
# musl targets, and the riscv64 compile-only check.
- uses: taiki-e/setup-cross-toolchain-action@v1
if: endsWith(matrix.target, '-musl') || startsWith(matrix.target, 'riscv64')
with:
target: ${{ matrix.target }}
- run: cargo check --workspace --target ${{ matrix.target }}
# The host-native runs below test `--no-default-features`, which serves the panel from
# `web-panel/dist/` on disk instead of embedding it, so the frontend has to exist for real.
# That is the point rather than a chore: the disk-serving branch is the one carrying the
# `..`-traversal guard, and a path guard is exactly the code that behaves differently where
# `\` is a separator. Windows is where it most wants running, and until now it had never run
# there at all.
- uses: oven-sh/setup-bun@v2
if: matrix.host
with:
bun-version: latest
- name: Build the web panel frontend
if: matrix.host
working-directory: crates/terrustia/web-panel
run: |
bun install --frozen-lockfile
bun run build
# `update.rs`'s signature tests skip themselves where `cosign` is absent rather than failing,
# so they are simply not part of what this proves.
- name: Tests (host-native targets only)
if: matrix.host
run: cargo test --workspace --no-default-features --target ${{ matrix.target }}
supply-chain:
name: Licences and advisories
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: EmbarkStudios/cargo-deny-action@v2
with:
command: check
# Every message id must stay classified, and the classification must match the code.
# docs/packet-ids.tsv is the source of truth; packet_audit.py re-derives the dispatched and
# encoded id sets from server.rs and the proto crate and fails naming the id on any mismatch,
# so a handler added without a table row (or a row claiming code that is not there) goes red
# here instead of drifting the way the old prose doc did.
packet-audit:
name: Packet id classification
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- run: python3 tools/packet_audit.py
# A bounded replay, not an open-ended campaign — this is a CI gate confirming the decoder still
# survives everything the committed corpus already knows how to break it with, plus 60 seconds
# of genuinely new exploration per target. `regression_oom_oversized_header` in
# fuzz/corpus/section_stream is not a hypothetical: fuzzing found a real out-of-memory abort
# within the first 90 seconds this target ever ran, on a fresh checkout, before any CI job had
# ever exercised it. 60s/target was chosen because that is what was actually run and measured
# locally before this job was written (2.4-2.7 million executions per target in that window) —
# not a number assumed to be enough.
fuzz:
name: Fuzz the decoder
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@nightly
- uses: Swatinem/rust-cache@v2
with:
workspaces: fuzz -> target
- name: Install cargo-fuzz
run: cargo install cargo-fuzz --locked
# `rust-toolchain.toml` pins the workspace to a specific stable-ish release, and that pin
# wins over whatever `dtolnay/rust-toolchain@nightly` just installed for any cargo invocation
# run from inside this checkout — the exact same class of bug AUDIT.md already documents once
# for the release targets. `+nightly` here is not decoration, it is the fix: without it this
# job silently builds and "fuzzes" with the pinned stable toolchain, which cargo-fuzz's own
# sanitizer flags fail on immediately, before a single input runs.
- name: Fuzz section_stream
run: cargo +nightly fuzz run section_stream -- -max_total_time=60
- name: Fuzz packet_decoders
run: cargo +nightly fuzz run packet_decoders -- -max_total_time=60
# The job most likely to earn its keep. Unit tests are self-consistent by construction: this
# server once sent 18,165 door packets in five minutes — 48% of all its traffic — behind a
# completely green suite, and it was found months later by a person watching a log. A minute of
# a real server with real clients catches that class of bug on the commit that introduces it.
soak:
name: Sixty-second soak
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
- uses: Swatinem/rust-cache@v2
- uses: oven-sh/setup-bun@v2
with:
bun-version: latest
- name: Build the web panel frontend
working-directory: crates/terrustia/web-panel
run: |
bun install --frozen-lockfile
bun run build
# `--bins` as well as `--examples`: `--examples` alone builds the examples and *not* the
# server, so the soak would have failed on its first run looking for a binary nobody made.
- run: cargo build --release --workspace --bins --examples
- name: Soak
run: ./tools/soak_ci.sh