whichdisk 0.5.0

Cross-platform disk/volume resolver — given a path, tells you which disk it's on, its mount point, relative path, disk usage, and per-volume capabilities (case-sensitivity, filesystem type)
Documentation
name: CI

on:
  push:
    branches:
      - main
    paths-ignore:
      - 'README'
      - 'COPYRIGHT'
      - 'LICENSE-*'
      - '**.md'
      - '**.txt'
  pull_request:
    paths-ignore:
      - 'README'
      - 'COPYRIGHT'
      - 'LICENSE-*'
      - '**.md'
      - '**.txt'
  workflow_dispatch:
  schedule: [cron: "0 1 */30 * *"]

env:
  CARGO_TERM_COLOR: always
  RUSTFLAGS: -Dwarnings
  RUST_BACKTRACE: 1

jobs:
  # Check formatting (platform-independent, one OS is enough)
  rustfmt:
    name: rustfmt
    runs-on: ubuntu-latest
    steps:
    - uses: actions/checkout@v7
    - name: Install Rust
      run: rustup update stable && rustup default stable && rustup component add rustfmt
    - name: Check formatting
      run: cargo fmt --all -- --check

  # Apply clippy lints
  clippy:
    name: clippy
    strategy:
      matrix:
        os:
          - ubuntu-latest
          - macos-latest
          - windows-latest
    runs-on: ${{ matrix.os }}
    steps:
    - uses: actions/checkout@v7
    - name: Install Rust
      # --no-self-update is necessary because the windows environment cannot self-update rustup.exe.
      run: rustup update stable --no-self-update && rustup default stable && rustup component add clippy
    - name: Install cargo-hack
      run: cargo install cargo-hack
    - name: Apply clippy lints
      run: cargo hack clippy --each-feature

  build:
    name: build
    strategy:
      matrix:
        os:
          - ubuntu-latest
          - macos-latest
          - windows-latest
    runs-on: ${{ matrix.os }}
    steps:
    - uses: actions/checkout@v7
    - name: Cache cargo build and registry
      uses: actions/cache@v6
      with:
        path: |
          ~/.cargo/registry
          ~/.cargo/git
          target
        key: ${{ runner.os }}-build-${{ hashFiles('**/Cargo.lock') }}
        restore-keys: |
          ${{ runner.os }}-build-
    - name: Install Rust
      # --no-self-update is necessary because the windows environment cannot self-update rustup.exe.
      run: rustup update stable --no-self-update && rustup default stable
    - name: Install cargo-hack
      run: cargo install cargo-hack
    - name: Run build
      run: cargo hack build --feature-powerset

  test:
    name: test
    strategy:
      matrix:
        os:
          - ubuntu-latest
          - macos-latest
          - windows-latest
    runs-on: ${{ matrix.os }}
    steps:
    - uses: actions/checkout@v7
    - name: Cache cargo build and registry
      uses: actions/cache@v6
      with:
        path: |
          ~/.cargo/registry
          ~/.cargo/git
          target
        key: ${{ runner.os }}-test-${{ hashFiles('**/Cargo.lock') }}
        restore-keys: |
          ${{ runner.os }}-test-
    - name: Install Rust
      # --no-self-update is necessary because the windows environment cannot self-update rustup.exe.
      run: rustup update stable --no-self-update && rustup default stable
    - name: Install cargo-hack
      run: cargo install cargo-hack
    - name: Run test
      run: cargo hack test --feature-powerset

  # Run the suite inside real BSD VMs via https://github.com/vmactions.
  # The ubuntu/macos/windows matrix above never exercises the FreeBSD /
  # OpenBSD / DragonFly code paths (statfs / getmntinfo FFI, device-prefix
  # ejectable detection, fs-type capability mapping); these jobs run them at
  # runtime, catching struct-layout / FFI bugs that compile checks miss.
  test-freebsd:
    name: test (freebsd)
    runs-on: ubuntu-latest
    timeout-minutes: 45
    steps:
    - uses: actions/checkout@v6
    - name: Test on FreeBSD
      uses: vmactions/freebsd-vm@v1
      with:
        usesh: true
        copyback: false
        prepare: |
          pkg install -y rust
        run: |
          cargo build --all-features
          cargo test --all-features -- --nocapture

  test-openbsd:
    name: test (openbsd)
    runs-on: ubuntu-latest
    timeout-minutes: 45
    steps:
    - uses: actions/checkout@v6
    - name: Test on OpenBSD
      uses: vmactions/openbsd-vm@v1
      with:
        usesh: true
        copyback: false
        prepare: |
          pkg_add -I rust
        run: |
          cargo build --all-features
          cargo test --all-features -- --nocapture

  # DragonFly's pkg Rust can lag (1.85.x). Lib tests only; --ignore-rust-version
  # lets a dev-dep that *declares* a newer rust-version than the pkg Rust still
  # build (whichdisk's own MSRV is 1.85).
  test-dragonflybsd:
    name: test (dragonflybsd)
    runs-on: ubuntu-latest
    timeout-minutes: 45
    steps:
    - uses: actions/checkout@v6
    - name: Test on DragonFlyBSD
      uses: vmactions/dragonflybsd-vm@v1
      with:
        usesh: true
        copyback: false
        prepare: |
          pkg install -y rust
        run: |
          cargo build --all-features --ignore-rust-version
          cargo test --all-features --lib --ignore-rust-version -- --nocapture

  # NetBSD: statvfs path (src/netbsd.rs); lib tests only (VM env). Same
  # --ignore-rust-version guard for the pkgsrc Rust version.
  test-netbsd:
    name: test (netbsd)
    runs-on: ubuntu-latest
    timeout-minutes: 45
    steps:
    - uses: actions/checkout@v6
    - name: Test on NetBSD
      uses: vmactions/netbsd-vm@v1
      with:
        usesh: true
        copyback: false
        prepare: |
          /usr/sbin/pkg_add rust
        run: |
          cargo build --all-features --ignore-rust-version
          cargo test --all-features --lib --ignore-rust-version -- --nocapture