Skip to content
Merged
208 changes: 53 additions & 155 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,167 +6,65 @@ on:
pull_request:
branches: [main]

env:
CARGO_TERM_COLOR: always
RUSTFLAGS: -D warnings
permissions:
contents: read

jobs:
fmt:
name: Format
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- uses: dtolnay/rust-toolchain@stable
with:
components: rustfmt
- run: cargo fmt --check

clippy:
name: Clippy
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- uses: dtolnay/rust-toolchain@stable
with:
components: clippy
- uses: Swatinem/rust-cache@9bdad043e88c75890e36ad3bbc8d27f0090dd609 # v2.7.8
- run: cargo clippy --all-targets -- -D warnings

test:
name: Test (${{ matrix.os }})
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- uses: dtolnay/rust-toolchain@stable
- uses: Swatinem/rust-cache@9bdad043e88c75890e36ad3bbc8d27f0090dd609 # v2.7.8
- run: cargo test

msrv:
name: MSRV (1.85)
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- uses: dtolnay/rust-toolchain@1.85
- uses: Swatinem/rust-cache@9bdad043e88c75890e36ad3bbc8d27f0090dd609 # v2.7.8
- run: cargo build

coverage:
name: Coverage (100% lines)
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- uses: dtolnay/rust-toolchain@stable
with:
components: llvm-tools-preview
- uses: Swatinem/rust-cache@9bdad043e88c75890e36ad3bbc8d27f0090dd609 # v2.7.8
- uses: taiki-e/install-action@59012be0884e296ca2da49b530610e72c49039ad # v2.81.6
with:
tool: cargo-llvm-cov
# The library's I/O is generic over the reader, so each error closure is
# monomorphized per reader type — making cargo-llvm-cov's region/function
# metrics structurally < 100%. The meaningful, monomorphization-robust
# invariant is that every executable source line is hit at least once.
#
# Exception — panic-free defence in depth: a line carrying a
# `// cov:unreachable` marker is a defensive guard (a `let-else { continue }`,
# a bounds-checked `.get()` fallback, etc.) that is provably unreachable
# under a dominating invariant, kept deliberately to stay panic-free if that
# invariant is ever broken by a future change. Such lines cannot be exercised
# by any test and are exempt. The gate fails on any OTHER zero-hit line.
- name: Generate lcov
run: cargo llvm-cov --lcov --output-path lcov.info --ignore-filename-regex '(^|/)src/(main\.rs|bin/)'
- name: Enforce line coverage (unreachable defensive arms must carry // cov:unreachable)
shell: bash
run: |
fail=0
while IFS= read -r line; do
if [[ "$line" == SF:* ]]; then
f="${line#SF:}"
elif [[ "$line" =~ ^DA:([0-9]+),0$ ]]; then
n="${BASH_REMATCH[1]}"
src="$(sed -n "${n}p" "$f")"
if [[ "$src" == *cov:unreachable* ]]; then
echo "exempt (// cov:unreachable): $f:$n"
else
echo "::error::Uncovered line $f:$n:$src"
fail=1
fi
fi
done < lcov.info
if [[ "$fail" -ne 0 ]]; then exit 1; fi
echo "All executable lines covered, or annotated // cov:unreachable."

deny:
name: cargo-deny
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- uses: EmbarkStudios/cargo-deny-action@bb137d7af7e4fb67e5f82a49c4fce4fad40782fe # v2.0.20
with:
command: check

vet:
name: Cargo Vet (supply-chain)
runs-on: ubuntu-latest
# Complements `deny` (known-bad advisories/licenses) with the supply-chain-
# injection layer: every dependency version must be human-source-reviewed or
# covered by an imported aggregate audit set (Google/Mozilla/Bytecode-Alliance/
# Embark). Config in supply-chain/{config,audits,imports}.toml.
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- uses: dtolnay/rust-toolchain@stable
- name: Install cargo-vet
uses: taiki-e/install-action@59012be0884e296ca2da49b530610e72c49039ad # v2.81.6
with:
tool: cargo-vet
- name: Fetch dependencies
run: cargo fetch
- name: Check supply chain
run: cargo vet --locked

secrets:
name: Secret Scan (gitleaks)
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
with:
fetch-depth: 0
- name: Install gitleaks
run: |
VERSION=$(curl -s https://api.github.com/repos/gitleaks/gitleaks/releases/latest | jq -r '.tag_name[1:]')
curl -sSfL "https://github.com/gitleaks/gitleaks/releases/download/v${VERSION}/gitleaks_${VERSION}_linux_x64.tar.gz" \
| tar xz -C /tmp gitleaks
- name: Run gitleaks
run: /tmp/gitleaks detect --source .

fuzz:
name: Fuzz targets (nightly)
runs-on: ubuntu-latest
# cargo-fuzz builds with the host nightly; warnings in its own deps must not
# fail the install, so this job does not deny warnings.
env:
RUSTFLAGS: ""
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- uses: dtolnay/rust-toolchain@nightly
- uses: Swatinem/rust-cache@9bdad043e88c75890e36ad3bbc8d27f0090dd609 # v2.7.8
- run: cargo install cargo-fuzz
- name: Build all fuzz targets
run: cargo +nightly fuzz check
- name: Smoke-fuzz each target (30s)
run: |
for t in boot record attributes runlist index_buffer attribute_list; do
cargo +nightly fuzz run "$t" -- -max_total_time=30 -rss_limit_mb=4096
done
# fmt · clippy · test (3 OS) · MSRV · cargo-deny · cargo-vet · secret scan ·
# fuzz build-check · per-line coverage gate.
#
# No overrides: MSRV derives from rust-version (1.85) and the root fuzz/ crate
# is discovered automatically.
#
# COVERAGE — deliberately `floor`, not the fleet-standard `strict`. This is
# migration debt with a named end state, recorded here rather than hidden.
#
# Adopting fleet-ci widens the coverage SCOPE. The workflow being replaced ran
# `cargo llvm-cov --lib` with no features, so core/src/vfs.rs — the whole `vfs`
# feature adapter — was never compiled during coverage and therefore never
# measured. The old job was named "Coverage (100% lines)"; that number was true
# of what it looked at and silent about a feature-gated module.
#
# At the fleet scope vfs.rs started at 37 uncovered lines. Tests for the
# adapter's refusal and degradation paths took that to 27 (94.18% for the file,
# 99.27% workspace-wide).
#
# The remaining 27 are NOT unreachable, and are not annotated
# `// cov:unreachable` for that reason — that annotation asserts a proven
# invariant, and writing one where the truth is "untested" would be a false
# statement that survives review by looking rigorous. They are reachable error
# branches that need fixtures this repo does not have:
#
# volume_label degradation — needs a volume whose $Volume record or
# $VOLUME_NAME attribute is absent
# .map_err(map_err) arms in — needs records crafted to make read_record or
# read_dir/extents/lookup/ directory_entries fail part-way through a walk
# meta/read_at on an otherwise-mountable volume
# build_meta $SI branches — needs a record with a malformed
# $STANDARD_INFORMATION
#
# `coverage-ignore-regex: 'core/src/vfs\.rs'` was considered and rejected: it
# would disable the gate for all 443 lines of the file to excuse 27, so a later
# regression in the 416 that ARE covered would go unreported. The floor keeps
# every line measured and still fails on a real drop.
#
# 99 is set just below the current 99.27%, so this holds the line rather than
# granting slack. REMOVE WHEN: the fixtures above exist — then drop these two
# inputs and inherit the fleet `strict` gate.
ci:
uses: SecurityRonin/fleet-ci/.github/workflows/rust-ci.yml@f49dff5ddb19b17f69926210abb70f78c14c29e2
with:
coverage-gate: floor
coverage-floor: 99

# Repo-specific, so it stays here rather than moving into the shared workflow.
docs:
name: Docs
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- uses: dtolnay/rust-toolchain@stable
- uses: Swatinem/rust-cache@9bdad043e88c75890e36ad3bbc8d27f0090dd609 # v2.7.8
- uses: dtolnay/rust-toolchain@2c7215f132e9ebf062739d9130488b56d53c060c # master
with:
toolchain: stable
- uses: Swatinem/rust-cache@9d47c6ad4b02e050fd481d890b2ea34778fd09d6 # v2.7.8
- run: RUSTDOCFLAGS="-D warnings" cargo doc --no-deps
Loading
Loading