frame-alloc 0.1.0

A no_std, dependency-free, const-constructible physical frame allocator for kernels
Documentation
name: CI

on:
  push:
  pull_request:

env:
  CARGO_TERM_COLOR: always

jobs:
  # Style + lint gate: formatting and clippy.
  lint:
    name: fmt + clippy
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - uses: dtolnay/rust-toolchain@stable
        with:
          components: rustfmt, clippy
      - uses: Swatinem/rust-cache@v2
      - run: cargo fmt --all --check
      - run: cargo clippy --all-targets --features stats -- -D warnings

  # Functional correctness: sequential + threaded stress tests.
  test:
    name: tests (stable)
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - uses: dtolnay/rust-toolchain@stable
      - uses: Swatinem/rust-cache@v2
      - run: cargo test --features stats

  # Proof that library builds without any feature.
  default-build:
    name: default build (lean)
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - uses: dtolnay/rust-toolchain@stable
      - uses: Swatinem/rust-cache@v2
      - run: cargo build
      - run: cargo test --no-run

  # Data-race detection. Requires nightly + rust-src for -Zbuild-std.
  thread-sanitizer:
    name: ThreadSanitizer (real code)
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - uses: dtolnay/rust-toolchain@nightly
        with:
          components: rust-src
      - uses: Swatinem/rust-cache@v2
      - name: cargo test under TSan
        run: |
          TARGET=$(rustc -vV | sed -n 's/host: //p')
          cargo test -Zbuild-std --target "$TARGET" --features stats \
            --lib --test conformance -- concurrent mutual_exclusion_under_contention
        env:
          RUSTFLAGS: "-Zsanitizer=thread"

  # Undefined-behaviour / provenance check: the only layer
  # that validates reinterpreting pool bytes as atomics, the Provenance int<->ptr
  # casts, and bounds/alignment of every base.add(idx). Curated subset — Miri is
  # too slow to run the full suite as a routine gate. -Zmiri-permissive-provenance
  # is required because the test harness fakes physical memory via exposed provenance.
  miri:
    name: Miri (UB / provenance)
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - uses: dtolnay/rust-toolchain@nightly
        with:
          components: miri
      - uses: Swatinem/rust-cache@v2
      - name: cargo miri test (curated subset)
        # Keep this filter list in sync with MIRI_TESTS in scripts/verify.sh. A
        # name that matches nothing does not fail — it silently runs fewer tests.
        run: |
          cargo miri test --lib --features stats -- \
            managed_frames_not_written \
            bitmap_hosted_past_span_start_hole \
            free_stats_split_and_merge \
            phantom_prefix_reserved_for_unaligned_phys_base \
            multi_frame_count_rounds_up_to_order \
            frees_overflow_into_depot_and_other_cpu_reuses \
            single_frame_oom_steals_from_sibling_magazine \
            default_selector_alloc_dealloc \
            add_usable_routes_to_owning_region
        env:
          MIRIFLAGS: "-Zmiri-permissive-provenance"

  # Weak-memory emulation over 16 scheduler seeds — the only layer that can
  # surface an insufficient atomic ordering. TSan flags unsynchronised accesses
  # but not synchronised-but-wrong protocols, and the x86 runners' TSO model
  # hides acquire/release mistakes at runtime. cfg(miri) shrinks iteration
  # counts to keep this tractable; it is still the slowest job here.
  miri-concurrent:
    name: Miri (concurrent / weak memory)
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - uses: dtolnay/rust-toolchain@nightly
        with:
          components: miri
      - uses: Swatinem/rust-cache@v2
      - name: cargo miri test (threaded, 16 seeds)
        run: |
          cargo miri test --features stats --lib --test conformance \
            -- concurrent mutual_exclusion_under_contention
        env:
          MIRIFLAGS: "-Zmiri-permissive-provenance -Zmiri-many-seeds=0..16"

  # Per-op structural-invariant check. Audit-incompatible tests are gated in code.
  audit:
    name: audit (per-op invariants)
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - uses: dtolnay/rust-toolchain@stable
      - uses: Swatinem/rust-cache@v2
      - run: cargo test --features stats
        env:
          RUSTFLAGS: "--cfg audit"