apsis-rs/.github/workflows/ci.yml

73 lines
3.0 KiB
YAML

name: CI
on:
push:
pull_request:
env:
CARGO_TERM_COLOR: always
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
with:
components: rustfmt, clippy
- name: Format
run: cargo fmt --all --check
- name: Check
# --all-features matters: the facade crate enables nothing by default,
# so without it almost all of its code, and every example, is skipped.
run: cargo check --workspace --all-targets --all-features
- name: Clippy
run: cargo clippy --workspace --all-targets --all-features -- -D warnings
- name: Test
run: cargo test --workspace --all-features
- name: Integration checks
# The cross-layer checks are examples rather than tests, because they
# are also meant to be read and run by hand. `cargo test` does not run
# them, so without this step a change that breaks one layer's
# assumptions about another would pass CI silently.
run: |
cargo run -p apsis-rs --features network --example integrate_network
cargo run -p apsis-rs --features ops --example integrate_ops
cargo run -p apsis-rs --features sim --example integrate_sim
- name: Build the benchmarks
# The benchmarks are not run in CI, because their timings are only
# meaningful on a quiet machine, but they must still compile so that
# they do not rot.
run: |
cargo build -p apsis-rs --features full --example bench
cargo build -p apsis-rs --features full --example bench_scale
cargo build -p apsis-rs --features full --example bench_parallel
- name: Documentation
# Catches a doc link that no longer resolves, which is how a doc
# comment drifts away from the code it describes.
env:
RUSTDOCFLAGS: -D warnings
run: cargo doc --workspace --all-features --no-deps
- name: Check the layer rule
# README.md states that a crate may only depend on layers to its
# left. Nothing else in the build enforces that, so a reverse
# dependency would otherwise pass CI silently.
run: bash scripts/check-layers.sh
- name: Verify dependency freedom
run: |
# Every package in the graph must be a workspace crate. `--prefix
# none` prints bare `name version` lines, one per package, which the
# box drawing prefix of the default format would otherwise hide.
external=$(cargo tree --workspace --all-features \
--edges normal,build,dev --prefix none 2>/dev/null \
| sed -E 's/ \(\*\)$//; s/ \([^)]*\)$//' \
| awk 'NF {print $1}' \
| sort -u \
| grep -v '^apsis' || true)
if [ -n "$external" ]; then
echo "unexpected external dependency detected:" >&2
echo "$external" >&2
exit 1
fi
echo "dependency check passed: workspace crates only"