|
| 1 | +name: CI |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: [main] |
| 6 | + pull_request: |
| 7 | + # A new advisory against a static lockfile arrives without anyone pushing, and |
| 8 | + # `dtolnay/rust-toolchain@stable` moves under us between releases. Note GitHub |
| 9 | + # disables cron on a repo with 60 days of no activity (it emails first), so |
| 10 | + # this buys bounded, not unbounded, coverage. |
| 11 | + schedule: |
| 12 | + - cron: "0 6 * * 1" |
| 13 | + |
| 14 | +env: |
| 15 | + CARGO_TERM_COLOR: always |
| 16 | + RUSTFLAGS: -D warnings |
| 17 | + |
| 18 | +jobs: |
| 19 | + test: |
| 20 | + strategy: |
| 21 | + fail-fast: false |
| 22 | + matrix: |
| 23 | + os: [ubuntu-latest, windows-latest] |
| 24 | + runs-on: ${{ matrix.os }} |
| 25 | + steps: |
| 26 | + - uses: actions/checkout@v4 |
| 27 | + - uses: dtolnay/rust-toolchain@stable |
| 28 | + with: |
| 29 | + components: rustfmt, clippy |
| 30 | + - uses: Swatinem/rust-cache@v2 |
| 31 | + |
| 32 | + - name: Format |
| 33 | + run: cargo fmt --all --check |
| 34 | + |
| 35 | + - name: Clippy |
| 36 | + run: cargo clippy --workspace --all-targets |
| 37 | + |
| 38 | + # The ubuntu leg is the load-bearing half of the purity contract: goz-core |
| 39 | + # is 9.8k of the workspace's 14.3k lines and green here means none of it |
| 40 | + # *calls* a Windows API. (Only *calls*: an unused platform dep would still |
| 41 | + # link. The declared-dep half is the allowlist below.) |
| 42 | + - name: Test |
| 43 | + run: cargo test --workspace |
| 44 | + |
| 45 | + # The architecture doc comments in lib.rs are the design record, and |
| 46 | + # RUSTFLAGS above does not reach rustdoc, so their intra-doc links rot |
| 47 | + # unchecked. --document-private-items because these are internal docs. |
| 48 | + - name: Docs |
| 49 | + env: |
| 50 | + RUSTDOCFLAGS: -D warnings |
| 51 | + run: cargo doc --workspace --no-deps --document-private-items |
| 52 | + |
| 53 | + # goz-core's direct deps are a closed set, so assert the set itself: an |
| 54 | + # allowlist fails on anything unforeseen, where the denylist this replaces |
| 55 | + # named four crates and would have waved through `windows`, `winapi`, |
| 56 | + # `libc` and `nix`. `--target all` so the ubuntu leg still sees a |
| 57 | + # cfg(windows)-gated entry; `set -euo pipefail` so a cargo failure fails |
| 58 | + # the step rather than matching nothing and passing. |
| 59 | + # |
| 60 | + # The other direction (goz-winfs must not depend on goz-core) is a |
| 61 | + # `wrappers` ban in deny.toml, enforced by the `deny` job below. |
| 62 | + - name: "goz-core purity: direct deps are the allowed set" |
| 63 | + shell: bash |
| 64 | + run: | |
| 65 | + set -euo pipefail |
| 66 | + expected="hashbrown memchr rayon rustc-hash serde serde_json smallvec thiserror unicode-normalization zerocopy" |
| 67 | + actual="$(cargo tree -p goz-core --edges normal --target all --depth 1 --prefix none \ |
| 68 | + | awk 'NF && $1 != "goz-core" { print $1 }' \ |
| 69 | + | sort -u | tr '\n' ' ' | sed 's/ $//')" |
| 70 | + if [ "$actual" != "$expected" ]; then |
| 71 | + echo "::error::goz-core direct dependencies changed; keep goz-core pure or update this allowlist deliberately" |
| 72 | + echo "expected: $expected" |
| 73 | + echo "actual: $actual" |
| 74 | + exit 1 |
| 75 | + fi |
| 76 | +
|
| 77 | + # MSRV gate: `rust-version` in Cargo.toml is a promise, so pin exactly that |
| 78 | + # toolchain and build. The main `test` job floats on stable, which would let |
| 79 | + # the real minimum drift above the advertised one unnoticed. `cargo check` |
| 80 | + # (not test) because dev-dependencies need not honor the MSRV. |
| 81 | + msrv: |
| 82 | + runs-on: windows-latest |
| 83 | + steps: |
| 84 | + - uses: actions/checkout@v4 |
| 85 | + - uses: dtolnay/rust-toolchain@1.94.0 |
| 86 | + - uses: Swatinem/rust-cache@v2 |
| 87 | + - run: cargo check --workspace |
| 88 | + |
| 89 | + # Supply-chain gate: enforce the deny.toml policy (licenses, yanked crates, |
| 90 | + # advisories, unknown sources). cargo-deny is graph-wide and deny.toml has no |
| 91 | + # [targets] filter, so ubuntu covers the Windows-gated deps too. |
| 92 | + deny: |
| 93 | + runs-on: ubuntu-latest |
| 94 | + steps: |
| 95 | + - uses: actions/checkout@v4 |
| 96 | + - uses: EmbarkStudios/cargo-deny-action@v2 |
| 97 | + with: |
| 98 | + command: check advisories bans licenses sources |
0 commit comments